Browse Source

售后上传图片接口修改

master
杜叶春 2 years ago
parent
commit
0a591521f6
  1. 71
      pages/aftersales/apply.js
  2. 4
      pages/aftersales/apply.wxml
  3. 3
      utils/server.js

71
pages/aftersales/apply.js

@ -17,6 +17,7 @@ Page({
remark: '',
return_suess: false,
order: {},
imgIndex: 0,
},
/**
@ -80,20 +81,43 @@ Page({
} else {
images = tempFiles;
}
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: images,
srcList: resList,
});
}
})
}
}
})
},
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,7 +134,14 @@ Page({
},
confirmAct() {
var that = this
if (that.data.srcList.length == 0) {
if (!that.data.errordesc) {
wx.showToast({
title: '请输入退款说明',
icon: 'none',
duration: 2000
});
return;
}
WXAPI.returnData({
accessId: app.globalData.accessId,
storeId: 239,
@ -120,6 +151,7 @@ Page({
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
@ -129,39 +161,6 @@ Page({
});
}
})
} 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);
}
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成

4
pages/aftersales/apply.wxml

@ -64,7 +64,7 @@
<view>上传凭证:</view>
</view>
<view class="evaluat_view" wx:for="{{srcList}}" wx:key="index">
<image class="evaluat_image" src="{{item.tempFilePath}}" bindtap="touchstartAct" />
<image class="evaluat_image" src="{{item}}" bindtap="touchstartAct" />
<image class="image_dele" src="/images/delete.png" data-index="{{index}}" bindtap="deleteAct" />
</view>
<view class="uploadImage" bindtap="chooseImage" data-index="{{index}}" wx:if="{{srcList.length < 3 ? true : false}}">
@ -116,7 +116,7 @@
<view class="end_lef">上传凭证:</view>
<view class="flex">
<view class="re_photo" wx:for="{{srcList}}" wx:key='index'>
<image src="{{item.tempFilePath}}" mode="" />
<image src="{{item}}" mode="" />
</view>
</view>
</view>

3
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)
},
}
Loading…
Cancel
Save