269 lines
6.1 KiB
JavaScript
269 lines
6.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: '',
|
|
textRefund: '',
|
|
total: 0,
|
|
logistics: null,
|
|
isAllRefund: false,
|
|
refundPackageGoods: []
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
orderId: options.id,
|
|
})
|
|
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) {
|
|
const goods = res.data.value;
|
|
this.setData({
|
|
goods: goods,
|
|
logistics: goods.logistics ? JSON.parse(goods.logistics) : null,
|
|
isAllRefund: !!!(goods.logistics ? JSON.parse(goods.logistics) : []).find(el => el.afterSalesStatus),
|
|
refundPackage: (goods.logistics ? JSON.parse(goods.logistics) : []).find(el => el.afterSalesStatus) ?? []
|
|
})
|
|
} 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'
|
|
})
|
|
}
|
|
},
|
|
// 物流名称
|
|
textRefund(e) {
|
|
this.setData({
|
|
textRefund: e.detail.value,
|
|
})
|
|
},
|
|
// 物流单号
|
|
textarea: function (e) {
|
|
this.setData({
|
|
textarea: e.detail.value,
|
|
})
|
|
},
|
|
textarea1: function (e) {
|
|
this.setData({
|
|
textarea1: e.detail.value,
|
|
})
|
|
},
|
|
//提交
|
|
submitBut: function () {
|
|
var photos = this.data.photo.join(",")
|
|
var reg = new RegExp('^[A-Za-z0-9]+$');
|
|
console.log(this.data.photo)
|
|
console.log(photos)
|
|
if (this.data.textarea1 == "") {
|
|
wx.showToast({
|
|
title: '请填写换货说明',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
console.log(this.data.textarea)
|
|
if (!reg.test(this.data.textarea)) {
|
|
wx.showToast({
|
|
title: '请填写正确的物流单号',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.data.textRefund == "") {
|
|
wx.showToast({
|
|
title: '请填写物流名称',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
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/submitSales',
|
|
method: 'POST',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
orderRefundNumber: this.data.textarea,
|
|
orderRefundInstructions: this.data.textarea1,
|
|
orderId: parseInt(this.data.orderId),
|
|
orderRefundImage: photos,
|
|
orderRefundName: this.data.textRefund
|
|
},
|
|
success: res => {
|
|
console.log(res)
|
|
wx.hideLoading()
|
|
if (res.data.code == 1) {
|
|
wx.showToast({
|
|
title: '提交成功',
|
|
icon: 'success',
|
|
success() {
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 2
|
|
})
|
|
}, 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 () {
|
|
|
|
},
|
|
}) |