From 0a591521f6fff7f820462a9535daf716ab83745c Mon Sep 17 00:00:00 2001 From: initwithout Date: Wed, 17 May 2023 15:12:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=94=AE=E5=90=8E=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/aftersales/apply.js | 109 ++++++++++++++++++------------------ pages/aftersales/apply.wxml | 4 +- utils/server.js | 3 + 3 files changed, 59 insertions(+), 57 deletions(-) diff --git a/pages/aftersales/apply.js b/pages/aftersales/apply.js index d5163fd..b79a4ce 100644 --- a/pages/aftersales/apply.js +++ b/pages/aftersales/apply.js @@ -17,6 +17,7 @@ Page({ remark: '', return_suess: false, order: {}, + imgIndex: 0, }, /** @@ -80,9 +81,31 @@ Page({ } else { images = tempFiles; } - that.setData({ - srcList: images, - }); + wx.uploadFile({ + url: 'https://mall.gylservice.com/gw?api=resources.file.uploadFiles', + filePath: images[that.data.imgIndex].tempFilePath, + name: 'image', + header: { + 'content-type': 'multipart/form-data' + }, // 设置请求的 header + formData: { + accessId: app.globalData.accessId, + storeId: 239, + storeType: 1, + uploadType: 2, + }, // HTTP 请求中其他额外的 form data + success: function (res) { + that.data.imgIndex++ + console.log(that.data.imgIndex) + var data = JSON.parse(res.data) + // console.log(data) + var resList = that.data.srcList + resList.push(data.data.imgUrls[0]) + that.setData({ + srcList: resList, + }); + } + }) } } }) @@ -90,10 +113,11 @@ Page({ deleteAct: function (e) { var index = e.currentTarget.dataset.index; var that = this; + that.data.imgIndex-- if (that.data.srcList.length > 0) { that.data.srcList.splice(index, 1) that.setData({ - srcList: that.data.srcList + srcList: that.data.srcList, }); } else { return; @@ -110,58 +134,33 @@ Page({ }, confirmAct() { var that = this - if (that.data.srcList.length == 0) { - WXAPI.returnData({ - accessId: app.globalData.accessId, - storeId: 239, - storeType: 1, - order_details_id: that.data.orderId, - refund_amount: that.data.refund_price, - explain: that.data.remark, - type: that.data.refund_type, - refund_apply_money: that.data.re_price, - }).then(res => { - if (res.code == 200) { - var data = res.data - that.setData({ - return_suess: true, - order: data - }); - } - }) - } else { - wx.uploadFile({ - url: 'https://mall.gylservice.com/gw?api=app.order.ReturnData', - filePath: that.data.srcList[0].tempFilePath, - name: 'file', - header: { - 'content-type': 'multipart/form-data' - }, // 设置请求的 header - formData: { - accessId: app.globalData.accessId, - storeId: 239, - storeType: 1, - order_details_id: that.data.orderId, - refund_amount: that.data.refund_price, - explain: that.data.remark, - type: that.data.refund_type, - upload_z_num: 1, - upload_num: 0, - refund_apply_money: that.data.re_price, - }, // HTTP 请求中其他额外的 form data - success: function (res) { - var data = JSON.parse(res.data) - console.log(that.data.srcList); - that.setData({ - return_suess: true, - order: data.data, - }); - }, - fail: function (res) { - console.log(res); - } - }) + if (!that.data.errordesc) { + wx.showToast({ + title: '请输入退款说明', + icon: 'none', + duration: 2000 + }); + return; } + WXAPI.returnData({ + accessId: app.globalData.accessId, + storeId: 239, + storeType: 1, + order_details_id: that.data.orderId, + refund_amount: that.data.refund_price, + explain: that.data.remark, + type: that.data.refund_type, + refund_apply_money: that.data.re_price, + images: that.data.srcList + }).then(res => { + if (res.code == 200) { + var data = res.data + that.setData({ + return_suess: true, + order: data + }); + } + }) }, /** * 生命周期函数--监听页面初次渲染完成 diff --git a/pages/aftersales/apply.wxml b/pages/aftersales/apply.wxml index a7b17c6..6bf3848 100644 --- a/pages/aftersales/apply.wxml +++ b/pages/aftersales/apply.wxml @@ -64,7 +64,7 @@ 上传凭证: - + @@ -116,7 +116,7 @@ 上传凭证: - + diff --git a/utils/server.js b/utils/server.js index 9595120..4b426bf 100644 --- a/utils/server.js +++ b/utils/server.js @@ -232,4 +232,7 @@ module.exports = { similarList: (data) => { //找相似 return requestServer('app.addFavorites.similar', 'post', data) }, + uploadFiles: (data) => { //上传图片 + return requestServer('resources.file.uploadFiles', 'post', data) + }, } \ No newline at end of file