Files
sgy-web/pages/order/refundForm/refundForm.js

152 lines
3.5 KiB
JavaScript

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
reasonArr : [],
reasonIndex: 0,
orderNo : '',
albumArr : [], //我的相册
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options)
this.setData({
orderNo: options.order_no
})
// 获取退款原因
this.reasonInfo(options.order_no)
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 退款原因
*/
reasonInfo(order_no) {
wx.$api.order.reason(order_no).then(res => {
this.setData({
reasonArr: res.data.title
})
}).catch(err => {})
},
/**
* 选择退款原因
*/
reasonChange(e) {
this.setData({
reasonIndex: e.detail.value
})
},
/**
* 上传图片
*/
addAlbum() {
wx.chooseImage({
count : 9,
success : path => {
// 上传图片
if (path.tempFilePaths){
let pathArr = path.tempFilePaths
for (let i = 0; i < pathArr.length; i++){
wx.$api.file.uploadImg(pathArr[i], {}).then(res=>{
wx.showLoading({
title: '上传中',
})
let albumArr = this.data.albumArr
albumArr.push({
path: res.path,
showpath: res.url
})
this.setData({
albumArr
})
wx.hideLoading()
})
if (i == pathArr.length - 1) {
wx.hideLoading()
}
}
}else{
wx.showToast({
title: '上传图片失败',
icon : 'none'
})
}
}
})
},
/**
* 删除图片
*/
removeAlbum(e){
wx.showLoading({
title: '加载中'
})
let index = e.currentTarget.dataset.index,
atalbum = this.data.albumArr
wx.showToast({
title: '删除成功',
icon : 'none'
})
atalbum.splice(index,1)
this.setData({
albumArr : atalbum
})
},
/**
* 提交表单
*/
siteform(e) {
let paths = []
for (let paht of this.data.albumArr){
paths.push(paht.path)
}
let value = e.detail.value
let data = {
remark : value.remark,
title : this.data.reasonIndex,
pictures : paths
}
this.setData({
disabled: true
})
wx.$api.order.refundPost(this.data.orderNo, data).then(() => {
wx.showToast({
title: '提交成功',
icon : 'none'
})
setTimeout(()=>{
wx.redirectTo({
url: '/pages/order/refund/refund',
})
},3000)
}).catch(() =>{
this.setData({
disabled: false
})
})
}
})