|
@@ -1,33 +1,107 @@
|
|
// pages/append/append.js
|
|
// pages/append/append.js
|
|
|
|
+const { getCategoryAPI, upLoadGoods } = require('../../API/appraise')
|
|
|
|
+const { upLoad, chooseImage } = require('../../utils/util')
|
|
|
|
+const baseURL = "http://192.168.31.30:8084";
|
|
|
|
+
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
- fileList: [],
|
|
|
|
latitude: 0,
|
|
latitude: 0,
|
|
longtitude: 0,
|
|
longtitude: 0,
|
|
- mapName: ""
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- moveLocation() {
|
|
|
|
- let _this = this;
|
|
|
|
- wx.chooseLocation({
|
|
|
|
- success: function(res) {
|
|
|
|
- console.log(res.name);
|
|
|
|
- _this.setData({
|
|
|
|
- mapName: res.name
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- fail: function() {
|
|
|
|
- console.log(err);
|
|
|
|
- }
|
|
|
|
|
|
+ mapName: "",
|
|
|
|
+ columns: [],
|
|
|
|
+ id: [],
|
|
|
|
+ popShow: false,
|
|
|
|
+ clssify: [],
|
|
|
|
+ valueKeyName: "",
|
|
|
|
+ index: 0,
|
|
|
|
+ // 页面数据们
|
|
|
|
+ title: "",
|
|
|
|
+ desc: "",
|
|
|
|
+ price: Number,
|
|
|
|
+ address: "",
|
|
|
|
+ fileList: [],
|
|
|
|
+ maxgoodsURL: 6
|
|
|
|
+ // clssify: Number
|
|
|
|
+ },
|
|
|
|
+ popChange() {
|
|
|
|
+ this.setData({
|
|
|
|
+ popShow: true
|
|
|
|
+ })
|
|
|
|
+ this.getClassifyList()
|
|
|
|
+ },
|
|
|
|
+ onConfirm(e) {
|
|
|
|
+ const { value, index} = e.detail;
|
|
|
|
+ this.setData({
|
|
|
|
+ popShow: false,
|
|
|
|
+ valueKeyName: value,
|
|
|
|
+ index: index
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ onCancel() {
|
|
|
|
+ this.setData({
|
|
|
|
+ popShow: false,
|
|
|
|
+ valueKeyName: ""
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ titleInput(e) {
|
|
|
|
+ const {value, cursor, keyCode} = e.detail;
|
|
|
|
+ this.setData({
|
|
|
|
+ title: value
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ describeInput(e) {
|
|
|
|
+ const {value, cursor, keyCode} = e.detail;
|
|
|
|
+ this.setData({
|
|
|
|
+ desc: value
|
|
})
|
|
})
|
|
},
|
|
},
|
|
numInput(e){
|
|
numInput(e){
|
|
const {value, cursor, keyCode} = e.detail;
|
|
const {value, cursor, keyCode} = e.detail;
|
|
- console.log(value);
|
|
|
|
|
|
+ this.setData({
|
|
|
|
+ price: value
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ adressInput(e) {
|
|
|
|
+ const { value, cursor, keyCode} = e.detail;
|
|
|
|
+ this.setData({
|
|
|
|
+ address: value
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ upData(){
|
|
|
|
+ // const price = this.data.price;
|
|
|
|
+ // const address = this.data.address;
|
|
|
|
+ // const classify = this.data.id[this.data.index];
|
|
|
|
+ // upLoadGoods(this.data).then((res) => {
|
|
|
|
+ // console.log(res);
|
|
|
|
+ // }).catch((err) => {
|
|
|
|
+ // console.log(err);
|
|
|
|
+ // })
|
|
|
|
+ wx.request({
|
|
|
|
+ url: baseURL + '/goods/create',
|
|
|
|
+ method: "POST",
|
|
|
|
+ header: {
|
|
|
|
+ "content-type": "application/x-www-form-urlencoded"
|
|
|
|
+ },
|
|
|
|
+ data: {
|
|
|
|
+ "categories": [
|
|
|
|
+ this.data.id[this.data.index]
|
|
|
|
+ ],
|
|
|
|
+ "desc": this.data.desc,
|
|
|
|
+ "ownerId": 0,
|
|
|
|
+ "pic": this.data.fileList,
|
|
|
|
+ "place": this.data.address,
|
|
|
|
+ "price": this.data.price,
|
|
|
|
+ "state": 0,
|
|
|
|
+ "title": this.data.title
|
|
|
|
+ },
|
|
|
|
+ success: function(res) {
|
|
|
|
+ console.log(res);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
@@ -35,7 +109,23 @@ Page({
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
|
|
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+ getClassifyList() {
|
|
|
|
+ getCategoryAPI(this.data)
|
|
|
|
+ .then((res) => {
|
|
|
|
+ const { code, data, mesage } = res.data;
|
|
|
|
+ const name = [];
|
|
|
|
+ const id = [];
|
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
|
+ name[i] = data[i].Name;
|
|
|
|
+ id[i] = data[i].Id;
|
|
|
|
+ }
|
|
|
|
+ console.log(id);
|
|
|
|
+ this.setData({
|
|
|
|
+ columns: name,
|
|
|
|
+ id: id
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|
|
@@ -83,5 +173,16 @@ Page({
|
|
*/
|
|
*/
|
|
onShareAppMessage() {
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ afterRead(e) {
|
|
|
|
+ const { file } = e.detail;
|
|
|
|
+ upLoad(file.url).then((res) => {
|
|
|
|
+ const { fileList = [] } = this.data;
|
|
|
|
+ fileList.push({ ...file, url: res.data });
|
|
|
|
+ this.setData({
|
|
|
|
+ fileList,
|
|
|
|
+ })
|
|
|
|
+ console.log(this.data.fileList);
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})
|
|
})
|