Files
coupon/pages/orderdetail/orderdetail.js
2023-04-29 15:34:25 +08:00

350 lines
6.9 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();
// pages/peihu.js
Page({
/**
* 页面的初始数据
*/
data: {
dingdan_msg: false,
ewm_msg: false,
mengceng: false,
order_id: 0,
goods_id: '',
btn1: '',
qrcode: '',
id: '',
item: {},
url: app.globalData.url,
refund: '',
charge_phone: '',
refund_box: false,
list: [{
text: '不喜欢/不想要',
},
{
text: '商品信息与描述不符'
},
{
text: '买多/买错/计划有变'
},
{
text: '更换其他项目、购买了其他项目'
},
{
text: '没有时间/个人原因'
},
{
text: '其他原因'
}
],
show: false,
height: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (e) {
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
this.setData({
statusBarHeight: statusBarHeight,
height: 46 + statusBarHeight,
});
//条目点击进入详情页
// this.setData({
// order_id: e.id
// })
//条目点击进入详情页,调取接口获取详情页数据,除外都是通过列表传参的方式展示详情页数据。
if (e.type = 3) {
this.getOrderDetail();
}
var that = this;
let item = JSON.parse(e.item);
that.setData({
item: item,
charge_phone: 18133233292,
order_id: item.orderId
});
console.log("进入订单详情的status==" + that.data.item.status)
console.log("进入订单详情的orderId==" + that.data.item.orderId)
console.log("进入订单详情的orderNumber==" + that.data.item.orderNumber)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
onClickLeft() {
wx.navigateBack()
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
//订单详情
getOrderDetail: function () {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/getInfo',
header: app.getRequestHeader(),
method: 'get',
data: {
orderId: this.data.order_id
},
success: function (res) {
var resp = res.data;
if (res.data.code == 200) {
that.setData({
item: res.data.data
});
}
}
});
},
/**
* 订单状态0待接单 1已接单 时候的取消订单
*/
cancelOrder() {
this.setData({
dingdan_msg: true,
mengceng: true
})
},
/**
* 订单状态2待服务 时候的取消订单
*/
cancelOrderdfw() {
this.setData({
dingdan_msg: true,
mengceng: true
})
},
/**
* 订单状态3服务中 时候的取消订单
*/
cancelOrderfwz() {
console.log('点击了取消订单')
this.setData({
dingdan_msgfwz: true,
mengceng: true
})
},
okcancel() {
console.log('点击了联系客服取消订单')
var that = this;
this.setData({
dingdan_msgfwz: false,
mengceng: false
})
},
/**
* 待接单/已接单时被坚持取消订单
*/
cancelok() {
var that = this;
wx.request({
url: app.globalData.url + '/system/order/concelOrder/' + this.data.order_id,
header: app.getRequestHeader(),
method: 'GET',
data: {
// id: this.data.item.orderId,
},
success: (res) => {
if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
icon: 'none'
});
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
}
}
});
this.setData({
dingdan_msg: false,
mengceng: false
})
},
mengceng() {
this.setData({
dingdan_msg: false,
ewm_msg: false,
mengceng: false,
refund_box: false
})
},
mengcengfwz() {
this.setData({
dingdan_msgfwz: false,
mengcengfwz: false,
refund_box: false
})
},
//确认开始服务
startService() {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/startServiceWithOrder',
header: app.getRequestHeader(),
method: 'post',
data: {
orderId: that.data.order_id
},
success: function (res) {
var resp = res.data;
if (res.data.code == 200) {
wx.showToast({
title: res.data.msg,
})
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
}
}
});
},
/**
* 待服务时被坚持取消订单
*/
cancelokdfw() {
//关闭服务人员正在赶来弹框
this.setData({
dingdan_msg: false,
mengceng: false
})
//打开退款原因弹框
this.setData({
refund_box: true,
mengceng: true
})
},
/**
* 填写原因开始退款
*/
isok() {
this.refund()
},
/**
* 退款
*/
refund() {
var that = this;
wx.request({
url: app.globalData.url + '/system/order/refundOrder/' + this.data.order_id,
header: app.getRequestHeader(),
method: 'GET',
data: {
// id: this.data.item.orderId,
},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
wx.showToast({
title: '退款申请成功',
})
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
}
}
});
this.setData({
refund_box: false,
mengceng: false
})
},
nocancel() {
this.setData({
dingdan_msg: false,
dingdan_msgfwz: false,
mengceng: false
})
},
gang() {
this.setData({
refund_box: false,
mengceng: false
})
},
/**
* 拨打电话
*/
callphone() {
wx.makePhoneCall({
phoneNumber: this.data.charge_phone,
})
},
//订单详情
getOrderDetail: function () {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/getInfo',
header: app.getRequestHeader(),
method: 'get',
data: {
orderId: this.data.order_id
},
success: function (res) {
var resp = res.data;
if (res.data.code == 200) {
that.setData({
item: res.data.data
});
}
}
});
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})