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