|
@@ -1,7 +1,8 @@
|
|
|
// pages/append/append.js
|
|
|
const { getCategoryAPI, upLoadGoods } = require('../../API/appraise')
|
|
|
const { upLoad, chooseImage } = require('../../utils/util')
|
|
|
-const baseURL = "http://192.168.31.30:8084";
|
|
|
+const baseURL = "http://192.168.31.27:8084";
|
|
|
+import Toast from '@vant/weapp/toast/toast'
|
|
|
|
|
|
Page({
|
|
|
|
|
@@ -18,14 +19,15 @@ Page({
|
|
|
clssify: [],
|
|
|
valueKeyName: "",
|
|
|
index: 0,
|
|
|
+ fileImg: [],
|
|
|
// 页面数据们
|
|
|
title: "",
|
|
|
desc: "",
|
|
|
- price: Number,
|
|
|
+ price: 0,
|
|
|
address: "",
|
|
|
fileList: [],
|
|
|
+ gid: Number,
|
|
|
maxgoodsURL: 6
|
|
|
- // clssify: Number
|
|
|
},
|
|
|
popChange() {
|
|
|
this.setData({
|
|
@@ -62,7 +64,7 @@ Page({
|
|
|
numInput(e){
|
|
|
const {value, cursor, keyCode} = e.detail;
|
|
|
this.setData({
|
|
|
- price: value
|
|
|
+ price: parseInt(value)
|
|
|
})
|
|
|
},
|
|
|
adressInput(e) {
|
|
@@ -72,36 +74,18 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
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);
|
|
|
- }
|
|
|
+ this.setData({
|
|
|
+ gid: this.data.id[this.data.index]
|
|
|
+ })
|
|
|
+ upLoadGoods(this.data).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ Toast({
|
|
|
+ message: '发布商品成功!'
|
|
|
+ })
|
|
|
+ }).catch((err) => {
|
|
|
+ console.log(err);
|
|
|
})
|
|
|
+ console.log(this.data);
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
@@ -177,10 +161,12 @@ Page({
|
|
|
afterRead(e) {
|
|
|
const { file } = e.detail;
|
|
|
upLoad(file.url).then((res) => {
|
|
|
- const { fileList = [] } = this.data;
|
|
|
- fileList.push({ ...file, url: res.data });
|
|
|
+ const { fileList = [], fileImg = [] } = this.data;
|
|
|
+ fileImg.push({ ...file, url: res.data });
|
|
|
+ fileList.push(file.url)
|
|
|
this.setData({
|
|
|
fileList,
|
|
|
+ fileImg
|
|
|
})
|
|
|
console.log(this.data.fileList);
|
|
|
})
|