Files
coupon/pages/reforderdetail/reforderdetail.js
2023-02-18 16:24:17 +08:00

455 lines
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//获取应用实例
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
resp:{
"erro": 0,
"infro": {
"address": "陕西省西安市雁塔区长延居底商2层",
"charge_phone": "13772530001",
"goods_name": "【十亿补贴】【水光补水】嗨体水光【水光套餐】5ml 抗衰美白 嫩肤补水",
"id": "19fdf93c85c2f9f393a59bb8d64c3948",
"index_img": "https://www.zoowoo.net/uploadnv/2022/02/09/164437226246602.png",
"mechanism_name": "西安蜜芽购科技有限公司",
"num": "1",
"order_id": "2022021514543285003305",
"total_money": "0.01",
"wechat_logo": "https://www.zoowoo.net/uploadnv/2022/02/08/164430729380625.png"
},
"msg": "查询成功",
"refund": {}
},
dingdan_msg:false,
goods_id:'',
type:'',
fileListtwo: [],
reason:[],
id:'',
refund_remark:'',
voucher_img:'',
mengceng:false,
refund_box:false,
refund_id:'',
refund_name:'请选择',
goods_img:[],
list:[
{
text:'不喜欢/不想要',
},
{
text:'商品信息与描述不符'
},
{
text:'买多/买错/计划有变'
},
{
text:'更换其他项目、购买了其他项目'
},
{
text:'没有时间/个人原因'
},
{
text:'其他原因'
}
]
},
afterReadtwo(event) {
var that = this;
const { file } = event.detail;
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
wx.uploadFile({
url: app.buildUrl("/app/Goddesswechat/uploadImg"),
filePath: file.url,
name: 'file',
formData: {
uid:app.getCache('uid'),
token:app.getCache('token'),
file:file.url
},
success: (res)=> {
var resp = res.data;
var rstObj = JSON.parse(resp); //字符串转为对象
if(rstObj.erro==0){
app.console(rstObj.file_path+'cccccccc')
// 上传完成需要更新 fileList
const { fileListtwo = [] } = that.data;
fileListtwo.push({ ...file, url: rstObj.file_path ,name:rstObj.file_name});
that.setData({
fileListtwo,
voucher_img:rstObj.file_path
});
}else{
wx.showToast({ title: rstObj.msg, icon: 'none' });
return;
}
},
});
},
deletetwo(event){
app.console(event.detail.index+"================="+222),
this.data.fileListtwo.splice([event.detail.index],1)
this.setData({fileListtwo:this.data.fileListtwo});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options.type)
console.log(options.id)
//详情显示
if(options.type==2){
this.setData({
id:options.id,
type:2
})
this.refundOderInfor()
}
//退款编辑
if(options.type==3){
this.setData({
id:options.id,
type:3
})
this.refundOderInfor()
}
//退款驳回
if(options.type==1){
this.setData({
id:options.id,
type:1
})
this.refundOderInfor()
}
//待退款
if(options.type==4){
this.setData({
id:options.id,
type:4
})
this.refundOderInfor()
}
this.getRefundReason()
},
select(){
this.setData({
refund_box:true,
mengceng:true
})
},
mengceng(){
this.isok()
},
isok(){
this.setData({
refund_box:false,
mengceng:false
})
},
commit(){
//假逻辑
setTimeout(function () {
//要延时执行的代码
wx.switchTab({
url: '/pages/order/order',
});
}, 2000) //延迟时间 这里是2秒
var that = this;
that.data.fileListtwo.forEach(item => {
app.console('长度=item================'+item)
const { goods_img = [] } = that.data;
goods_img.push(item.url);
that.setData({ goods_img });
}),
wx.request({
url: app.buildUrl("/app/Goddesswechat/submitRefund"),
header: app.getRequestHeader(),
method:'POST',
data: {
version_number: app.globalData.version_number,
uid:wx.getStorageSync('uid'),
token:wx.getStorageSync('token'),
id:this.data.id,
refund_id:this.data.refund_id,
refund_remark:this.data.refund_remark,
voucher_img:that.data.goods_img,
},
success: function (res) {
var resp = res.data;
console.log(resp+"=================dddddddddddddddddddddddddddddddddddddddddddd")
if(resp.erro==0){
wx.showToast({ title: resp.msg, icon: 'none' });
setTimeout(function () {
//要延时执行的代码
wx.switchTab({
url: '/pages/order/order',
});
}, 2000) //延迟时间 这里是2秒
}else{
wx.showToast({ title: resp.msg, icon: 'none' });
}
}
});
},
onClickLeft() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
// this.refundOderInfor();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//退款订单详情
refundOderInfor: function () {
var that = this;
wx.request({
url: app.buildUrl("/app/Goddesswechat/refundOderInfor"),
header: app.getRequestHeader(),
method:'POST',
data: {
version_number: this.data.version_number,
uid:wx.getStorageSync('uid'),
token:wx.getStorageSync('token'),
id:this.data.id
},
success: function (res) {
var resp = res.data;
console.log(resp+"=================dddddddddddddddddddddddddddddddddddddddddddd")
console.log(resp.erro+"=================dddddddddddddddddddddddddddddddddddddddddddd")
if(resp.erro==0){
that.setData({
infro:resp.infro
});
}
}
});
},
radioChange(e) {
console.log('radio发生change事件携带value值为', e.detail.value)
this.setData({
refund_id:e.detail.value
})
const reason = this.data.reason
for (let i = 0, len = reason.length; i < len; ++i) {
reason[i].checked = reason[i].value === e.detail.value
}
this.setData({
reason
})
this.data.reason.forEach(item => {
if(this.data.refund_id==item.id){
this.setData({ refund_name:item.reason });
}
})
console.log('radio发生change事件携带value值为', this.data.refund_name)
this.isok()
},
//后台设置的退款原因
getRefundReason: function () {
var that = this;
//假数据
var resp = {
"erro": 0,
"msg": "查询成功",
"reason": [
{
"id": "2",
"reason": "预约不到"
},
{
"id": "4",
"reason": "商品信息与描述不符"
},
{
"id": "6",
"reason": "以各种理由拒绝服务"
},
{
"id": "8",
"reason": "服务态度差,不友好"
},
{
"id": "9",
"reason": "没有时间"
},
{
"id": "10",
"reason": "买多/买错/计划有变"
},
{
"id": "12",
"reason": "更换其他项目/购买了其他项目"
},
{
"id": "13",
"reason": "其他原因"
}
]
};
console.log(resp+"=================dddddddddddddddddddddddddddddddddddddddddddd")
if(resp.erro==0){
that.setData({
reason:resp.reason
});
}
// wx.request({
// url: app.buildUrl("/app/Goddesswechat/getRefundReason"),
// header: app.getRequestHeader(),
// method:'POST',
// data: {
// version_number: app.globalData.version_number,
// uid:wx.getStorageSync('uid'),
// token:wx.getStorageSync('token'),
// },
// success: function (res) {
// var resp = res.data;
// console.log(resp+"=================dddddddddddddddddddddddddddddddddddddddddddd")
// if(resp.erro==0){
// that.setData({
// reason:resp.reason
// });
// }
// }
// });
},
//退款订单信息
refundOderInfor: function () {
var that = this;
if(this.data.resp.erro==0){
if(that.data.type==3){
that.setData({
infro:this.data.resp.infro,
});
}else{
that.setData({
infro:this.data.resp.infro,
refund:this.data.resp.refund,
refund_remark:this.data.resp.refund.refund_remark,
goods_img:this.data.resp.refund.voucher_img,
refund_id:this.data.resp.refund.refund_id
});
}
that.data.reason.forEach(item => {
if(that.data.refund_id==item.id){
that.setData({ refund_name:item.reason });
}
})
if(that.data.goods_img.length>0){
that.data.goods_img.forEach(item => {
app.console('长度=item================'+item)
const { fileListtwo = [] } = that.data;
fileListtwo.push({ url: item });
that.setData({ fileListtwo });
})
that.setData({
goods_img:[]
})
}
}
// wx.request({
// url: app.buildUrl("/app/Goddesswechat/refundOderInfor"),
// header: app.getRequestHeader(),
// method:'POST',
// data: {
// version_number: app.globalData.version_number,
// uid:wx.getStorageSync('uid'),
// token:wx.getStorageSync('token'),
// id:this.data.id
// },
// success: function (res) {
// var resp = res.data;
// if(resp.erro==0){
// if(that.data.type==3){
// that.setData({
// infro:resp.infro,
// });
// }else{
// that.setData({
// infro:resp.infro,
// refund:resp.refund,
// refund_remark:resp.refund.refund_remark,
// goods_img:resp.refund.voucher_img,
// refund_id:resp.refund.refund_id
// });
// }
// that.data.reason.forEach(item => {
// if(that.data.refund_id==item.id){
// that.setData({ refund_name:item.reason });
// }
// })
// if(that.data.goods_img.length>0){
// that.data.goods_img.forEach(item => {
// app.console('长度=item================'+item)
// const { fileListtwo = [] } = that.data;
// fileListtwo.push({ url: item });
// that.setData({ fileListtwo });
// })
// that.setData({
// goods_img:[]
// })
// }
// }
// }
// });
},
})