You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

222 lines
5.1 KiB

// pages/aftersales/apply.js
var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({
/**
* 页面的初始数据
*/
data: {
refund_type: '', // 区分退款方式1退货退款,2仅退款, 3换货
order: "",
r_status: '', // 商品当前状态
content: '',
orderId: '',
srcList: [],
re_price: '',
remark: '',
return_suess: false,
order: {},
imgIndex: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options)
this.setData({
refund_type: options.refund_type,
orderId:options.orderId
});
this.loadData(options.orderId);
},
loadData: function (orderId) {
var that = this;
WXAPI.returnMethod({
accessId: app.globalData.accessId,
storeId: 239,
storeType: 1,
order_details_id: orderId,
}).then(res => {
if (res.code == 200) {
var data = res.data
that.setData({
re_price: data.refund_price,
refund_price: data.refund_price,
order: data.list,
status: data.status,
refund_only_status: data.refund_only_status,
return_refund_status: data.return_refund_status,
exchange_goods_status: data.exchange_goods_status,
orderType: data.orderType
});
}
})
},
refundPriceInput: function(e) {
this.setData({
re_price: e.detail.value
})
},
chooseImage: function (e) {
var that = this;
// 选择图片
wx.chooseMedia({
count: 3, // 默认9
sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var tempFiles = res.tempFiles;
var images = that.data.srcList;
if (images.length > 2) {
wx.showToast({
title: '亲!最多上传3张哦!',
icon: 'none',
duration: 2000
});
} else {
if (images) {
images = images.concat(tempFiles);
} else {
images = tempFiles;
}
wx.showLoading({
title: '上传中...',
mask: true,
})
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) {
wx.hideLoading();
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,
});
}
})
}
}
})
},
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,
});
} else {
return;
}
},
remarkInput: function(e) {
var remark = e.detail.value
if (remark.length > 100) {
return;
}
this.setData({
remark: remark
})
},
confirmAct() {
var that = this
if (!that.data.remark) {
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
});
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
if (this.data.return_suess == true) {
wx.navigateBack({
delta: 1
})
}
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})