236 lines
5.1 KiB
JavaScript
236 lines
5.1 KiB
JavaScript
![]() |
// pages/my/applyAfter_sales/applyAfter_sales.js
|
||
|
const app = getApp();
|
||
|
const IP = app.globalData.ip;
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
photo: [],
|
||
|
ipUrl: app.globalData.ipUrl,
|
||
|
textarea: '',
|
||
|
total: 0,
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.setData({
|
||
|
orderId: options.id,
|
||
|
num: options.num,
|
||
|
sq: options.sq,
|
||
|
})
|
||
|
if (options.sq == 1) {
|
||
|
wx.setNavigationBarTitle({
|
||
|
title: '退货申请'
|
||
|
})
|
||
|
} else {
|
||
|
wx.setNavigationBarTitle({
|
||
|
title: '换货申请'
|
||
|
})
|
||
|
}
|
||
|
wx.showLoading({
|
||
|
title: '加载中..',
|
||
|
})
|
||
|
wx.request({
|
||
|
url: app.globalData.ip + '/wisdommining/api/order/getOrderDetail',
|
||
|
method: 'GET',
|
||
|
header: {
|
||
|
"content-type": "application/x-www-form-urlencoded",
|
||
|
},
|
||
|
data: {
|
||
|
userId: app.globalData.userId,
|
||
|
orderNumber: options.num,
|
||
|
},
|
||
|
success: res => {
|
||
|
console.log(res)
|
||
|
wx.hideLoading()
|
||
|
if (res.data.code == 1) {
|
||
|
let goods = res.data.value;
|
||
|
this.setData({
|
||
|
goods: goods,
|
||
|
})
|
||
|
} else {
|
||
|
wx.showModal({
|
||
|
title: '提示!',
|
||
|
content: res.data.message,
|
||
|
showCancel: false,
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
|
||
|
//选择图片
|
||
|
revise_img: function (e) {
|
||
|
if (this.data.photo.length < 4) {
|
||
|
var a = 4 - this.data.photo.length
|
||
|
console.log(a)
|
||
|
wx.chooseImage({
|
||
|
count: a,
|
||
|
sizeType: ['original', 'compressed'],
|
||
|
sourceType: ['album', 'camera'],
|
||
|
success: res => {
|
||
|
console.log(res)
|
||
|
for (var i = 0; i < res.tempFilePaths.length; i++) {
|
||
|
wx.uploadFile({
|
||
|
url: IP + '/wisdommining/api/user/img',
|
||
|
filePath: res.tempFilePaths[i],
|
||
|
name: 'file',
|
||
|
success: ress => {
|
||
|
console.log(ress)
|
||
|
var photo = this.data.photo;
|
||
|
var data = JSON.parse(ress.data);
|
||
|
photo.push(data.src);
|
||
|
this.setData({
|
||
|
photo: photo
|
||
|
})
|
||
|
console.log(this.data.photo)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '超过上传上限',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
|
||
|
textarea: function (e) {
|
||
|
this.setData({
|
||
|
textarea: e.detail.value,
|
||
|
})
|
||
|
},
|
||
|
//提交
|
||
|
submitBut: function () {
|
||
|
var photos = this.data.photo.join(",")
|
||
|
console.log(this.data.photo)
|
||
|
console.log(photos)
|
||
|
if (this.data.textarea == "") {
|
||
|
wx.showToast({
|
||
|
title: '请说明原因',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
if (this.data.photo.length == 0) {
|
||
|
wx.showToast({
|
||
|
title: '请上传凭证',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '确认提交申请?',
|
||
|
success: s => {
|
||
|
if (s.confirm) {
|
||
|
wx.showLoading({
|
||
|
title: '提交中',
|
||
|
})
|
||
|
wx.request({
|
||
|
url: IP + '/wisdommining/api/order/afterSales',
|
||
|
method: 'POST',
|
||
|
header: {
|
||
|
"content-type": "application/x-www-form-urlencoded",
|
||
|
},
|
||
|
data: {
|
||
|
orderRefund: this.data.textarea,
|
||
|
orderId: parseInt(this.data.orderId),
|
||
|
orderRefundImg: photos,
|
||
|
status: this.data.sq == 1 ? 62 : 61
|
||
|
},
|
||
|
success: res => {
|
||
|
console.log(res)
|
||
|
wx.hideLoading()
|
||
|
if (res.data.code == 1) {
|
||
|
wx.showToast({
|
||
|
title: '提交成功',
|
||
|
icon: 'success',
|
||
|
success() {
|
||
|
setTimeout(() => {
|
||
|
wx.navigateBack()
|
||
|
}, 1000);
|
||
|
}
|
||
|
})
|
||
|
} else {
|
||
|
wx.showModal({
|
||
|
title: '获取数据失败!',
|
||
|
content: res.data.message,
|
||
|
showCancel: false,
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
|
||
|
//长按删除
|
||
|
delimg(e) {
|
||
|
let index = e.currentTarget.dataset.index;
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '是否删除?',
|
||
|
showCancel: true,
|
||
|
success: res => {
|
||
|
if (res.confirm) {
|
||
|
let photo = this.data.photo;
|
||
|
photo.splice(index, 1);
|
||
|
this.setData({
|
||
|
photo: photo
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
})
|