Files
coupon/pages/orderdetail/orderdetail.js

437 lines
9.3 KiB
JavaScript
Raw Normal View History

2023-02-18 16:24:17 +08:00
//获取应用实例
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
2023-03-12 21:05:54 +08:00
dingdan_msg: false,
ewm_msg: false,
mengceng: false,
order_id: 0,
goods_id: '',
btn1: '',
qrcode: '',
id: '',
2023-02-18 16:24:17 +08:00
item: {},
url: app.globalData.url,
2023-03-12 21:05:54 +08:00
refund: '',
charge_phone: '',
refund_box: false,
list: [{
text: '不喜欢/不想要',
2023-02-18 16:24:17 +08:00
},
{
2023-03-12 21:05:54 +08:00
text: '商品信息与描述不符'
2023-02-18 16:24:17 +08:00
},
{
2023-03-12 21:05:54 +08:00
text: '买多/买错/计划有变'
2023-02-18 16:24:17 +08:00
},
{
2023-03-12 21:05:54 +08:00
text: '更换其他项目、购买了其他项目'
2023-02-18 16:24:17 +08:00
},
{
2023-03-12 21:05:54 +08:00
text: '没有时间/个人原因'
2023-02-18 16:24:17 +08:00
},
{
2023-03-12 21:05:54 +08:00
text: '其他原因'
2023-02-18 16:24:17 +08:00
}
],
show: false,
statusType: ["拼团"],
2023-03-12 21:05:54 +08:00
status: ["0"],
2023-02-18 16:24:17 +08:00
currentType: 0,
2023-03-12 21:05:54 +08:00
nav_type: 0,
is_ok_click: false,
height: ''
2023-02-18 16:24:17 +08:00
},
2023-04-25 23:33:40 +08:00
2023-02-18 16:24:17 +08:00
onClickShow() {
2023-03-12 21:05:54 +08:00
this.setData({
show: true
});
2023-02-18 16:24:17 +08:00
},
onClickHide() {
2023-03-12 21:05:54 +08:00
this.setData({
show: false
});
2023-02-18 16:24:17 +08:00
},
2023-04-25 23:33:40 +08:00
2023-02-18 16:24:17 +08:00
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (e) {
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
this.setData({
2023-03-12 21:05:54 +08:00
statusBarHeight: statusBarHeight,
height: 46 + statusBarHeight,
2023-02-18 16:24:17 +08:00
});
//条目点击进入详情页
this.setData({
2023-03-12 21:05:54 +08:00
order_id: e.id
})
2023-04-25 23:33:40 +08:00
//条目点击进入详情页,调取接口获取详情页数据,除外都是通过列表传参的方式展示详情页数据。
2023-04-26 23:14:18 +08:00
if(e.type=3){
this.getOrderDetail();
}
2023-02-18 16:24:17 +08:00
2023-03-12 21:05:54 +08:00
var that = this;
let item = JSON.parse(e.item);
that.setData({
item: item,
2023-03-29 00:00:43 +08:00
charge_phone: 18133233292,
order_id: item.orderId
2023-03-12 21:05:54 +08:00
});
2023-03-29 00:00:43 +08:00
app.console("order_id=================" + this.data.order_id)
2023-02-18 16:24:17 +08:00
},
2023-03-12 21:05:54 +08:00
mengceng() {
2023-02-18 16:24:17 +08:00
this.setData({
2023-03-12 21:05:54 +08:00
dingdan_msg: false,
ewm_msg: false,
mengceng: false,
refund_box: false
2023-02-18 16:24:17 +08:00
})
},
2023-04-06 22:57:57 +08:00
mengcengfwz() {
this.setData({
dingdan_msgfwz: false,
ewm_msg: false,
mengcengfwz: false,
refund_box: false
})
},
2023-03-29 00:00:43 +08:00
//确认开始服务
2023-04-25 23:33:40 +08:00
startService() {
2023-03-29 00:00:43 +08:00
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) {
2023-04-25 23:33:40 +08:00
// that.setData({
// item : res.data.data
// });
2023-03-29 00:00:43 +08:00
}
}
});
},
2023-02-18 16:24:17 +08:00
2023-03-12 21:05:54 +08:00
cancelOrder() {
2023-02-18 16:24:17 +08:00
console.log('点击了取消订单')
this.setData({
2023-03-12 21:05:54 +08:00
dingdan_msg: true,
mengceng: true
2023-02-18 16:24:17 +08:00
})
},
2023-04-06 22:57:57 +08:00
cancelOrderfwz() {
console.log('点击了取消订单')
this.setData({
dingdan_msgfwz: true,
mengcengfwz: true
})
},
2023-03-12 21:05:54 +08:00
okcancel() {
2023-02-18 16:24:17 +08:00
var that = this;
wx.request({
2023-04-25 23:33:40 +08:00
// url: app.globalData.url + '/system/order/concelOrder/' + this.data.item.orderId,
url: app.globalData.url + '/system/order/refundOrder/' + this.data.item.orderId,
2023-03-12 21:05:54 +08:00
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: res.data.msg,
icon: 'none'
});
2023-04-06 22:57:57 +08:00
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
2023-02-18 16:24:17 +08:00
}
2023-03-12 21:05:54 +08:00
}
2023-02-18 16:24:17 +08:00
});
console.log('点击了坚持取消');
// var _this=this;
// wx.request({
// url: app.globalData.url + '/app/Goddesswechat/cancelOrder',
// data: {
// version_number: app.globalData.version_number,
// uid: wx.getStorageSync('uid'),
// token:wx.getStorageSync('token'),
// order_id:this.data.order_id
// },
// method: 'POST',
// header: { 'content-type': 'application/x-www-form-urlencoded' },
// success(res) {
// console.log(1111111)
// console.log(res)
// if (res.data.erro == 0) {
// wx.showToast({ title: res.data.msg, icon: 'none' });
// }else{
2023-03-12 21:05:54 +08:00
2023-02-18 16:24:17 +08:00
// }
// }
// }
2023-03-12 21:05:54 +08:00
// )
2023-02-18 16:24:17 +08:00
this.setData({
2023-03-12 21:05:54 +08:00
dingdan_msg: false,
mengceng: false
2023-02-18 16:24:17 +08:00
})
},
2023-03-12 21:05:54 +08:00
nocancel() {
2023-02-18 16:24:17 +08:00
this.setData({
2023-03-12 21:05:54 +08:00
dingdan_msg: false,
mengceng: false
2023-02-18 16:24:17 +08:00
})
},
/**
* 拨打电话
*/
2023-03-12 21:05:54 +08:00
callphone() {
2023-02-18 16:24:17 +08:00
wx.makePhoneCall({
phoneNumber: this.data.charge_phone,
})
},
/**
* 发起拼团
*/
2023-03-12 21:05:54 +08:00
pintuan() {
this.setData({
show: true
});
2023-02-18 16:24:17 +08:00
},
2023-03-12 21:05:54 +08:00
tiaoguo() {
this.setData({
show: false
});
2023-02-18 16:24:17 +08:00
},
2023-03-12 21:05:54 +08:00
/**
2023-02-18 16:24:17 +08:00
* 同意发起
*/
2023-03-12 21:05:54 +08:00
tongyifaqi() {
2023-02-18 16:24:17 +08:00
this.confirmCollage()
2023-03-12 21:05:54 +08:00
},
2023-04-25 23:33:40 +08:00
refund() {
2023-03-12 21:05:54 +08:00
var that = this;
wx.request({
2023-04-25 23:33:40 +08:00
// url: app.globalData.url + '/system/order/concelOrder/' + this.data.item.orderId,
url: app.globalData.url + '/system/order/refundOrder/' + this.data.item.orderId,
2023-03-12 21:05:54 +08:00
header: app.getRequestHeader(),
2023-04-25 23:33:40 +08:00
method: 'GET',
2023-03-12 21:05:54 +08:00
data: {
2023-04-25 23:33:40 +08:00
// id: this.data.item.orderId,
2023-03-12 21:05:54 +08:00
},
2023-04-25 23:33:40 +08:00
success: (res) => {
2023-03-12 21:05:54 +08:00
var resp = res.data;
2023-04-25 23:33:40 +08:00
if (res.data.code == 200) {
2023-03-12 21:05:54 +08:00
wx.showToast({
2023-04-25 23:33:40 +08:00
title: res.data.msg,
2023-03-12 21:05:54 +08:00
icon: 'none'
});
2023-04-25 23:33:40 +08:00
setTimeout(function () {
//要延时执行的代码
wx.navigateBack()
}, 2000) //延迟时间 这里是2秒
2023-03-12 21:05:54 +08:00
}
}
});
2023-04-25 23:33:40 +08:00
2023-03-12 21:05:54 +08:00
if (this.data.refund == 0) {
app.tip({
content: '该订单不支持退款'
2023-02-18 16:24:17 +08:00
});
return
}
wx.navigateTo({
2023-03-12 21:05:54 +08:00
url: '/pages/reforderdetail/reforderdetail?' + "type=" + '3' + '&id=' + this.data.id,
2023-02-18 16:24:17 +08:00
})
// this.setData({
// refund_box:true,
// mengceng:true
// })
},
2023-03-12 21:05:54 +08:00
gang() {
2023-02-18 16:24:17 +08:00
this.setData({
2023-03-12 21:05:54 +08:00
refund_box: false,
mengceng: false
2023-02-18 16:24:17 +08:00
})
},
// 确认支付
2023-03-12 21:05:54 +08:00
confirm_pay: async function () {
2023-02-18 16:24:17 +08:00
var that = this;
2023-03-12 21:05:54 +08:00
if (!this.data.is_ok_click) {
2023-02-18 16:24:17 +08:00
that.setData({
2023-03-12 21:05:54 +08:00
is_ok_click: true
2023-02-18 16:24:17 +08:00
})
2023-03-12 21:05:54 +08:00
//你要执行的操作
this.godetail()
2023-02-18 16:24:17 +08:00
setTimeout(function () {
that.setData({
is_ok_click: false
})
}, 10000) //阻止一秒点击多次
2023-03-12 21:05:54 +08:00
} else {
2023-02-18 16:24:17 +08:00
// wx.showToast({
// title: '请勿重复操作!',
// })
}
},
2023-03-12 21:05:54 +08:00
godetail() {
2023-02-18 16:24:17 +08:00
console.log('点击了去付款');
2023-03-12 21:05:54 +08:00
var _this = this;
console.log(this.data.id + 'tttttttttttttttttttttttttttttttttt')
2023-02-18 16:24:17 +08:00
wx.request({
2023-04-25 23:33:40 +08:00
// url: app.globalData.url + '/system/weixinPayNew/12345666',
//order_id为8位数字
url: app.globalData.url + '/system/order/weixinPay/' + this.data.item.orderId,
2023-03-01 22:50:02 +08:00
header: app.getRequestHeader(),
method: 'GET',
data: {
2023-04-25 23:33:40 +08:00
2023-03-01 22:50:02 +08:00
},
2023-03-12 21:05:54 +08:00
success(res) {
if (res.data.code == 200) {
2023-04-25 23:33:40 +08:00
console.log('timeStamp==' + res.data.data.timeStamp)
console.log('nonceStr==' + res.data.data.nonceStr)
console.log('package==' + res.data.data.package)
console.log('signType==' + res.data.data.signType)
console.log('paySign==' + res.data.data.paySign)
2023-03-12 21:05:54 +08:00
wx.requestPayment({
timeStamp: res.data.data.timeStamp,
nonceStr: res.data.data.nonceStr,
package: res.data.data.package,
signType: res.data.data.signType,
paySign: res.data.data.paySign,
success(res) {
console.log('支付成功');
wx.navigateTo({
url: '/shopping/pages/paysuccess/paysuccess',
})
},
fail(res) {
console.log('支付失败');
2023-02-18 16:24:17 +08:00
}
2023-03-12 21:05:54 +08:00
})
} else {
wx.showToast({
title: res.data.msg,
icon: 'error',
duration: 2000
})
2023-02-18 16:24:17 +08:00
}
2023-03-12 21:05:54 +08:00
}
})
2023-02-18 16:24:17 +08:00
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
2023-03-12 21:05:54 +08:00
// this.getOrderDetail();
2023-02-18 16:24:17 +08:00
//假数据
var that = this;
2023-03-12 21:05:54 +08:00
if (this.data.resp.erro == 0) {
that.setData({
detail: this.data.resp.detail,
order: this.data.resp.order,
goods_id: this.data.resp.detail.goods_id,
id: this.data.resp.detail.id,
refund: this.data.resp.detail.refund,
charge_phone: this.data.resp.detail.charge_phone
});
}
2023-02-18 16:24:17 +08:00
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
onClickLeft() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
2023-03-12 21:05:54 +08:00
//订单详情
getOrderDetail: function () {
2023-02-18 16:24:17 +08:00
var that = this;
wx.request({
2023-03-29 00:00:43 +08:00
url: app.globalData.url + '/system/view/getInfo',
2023-03-12 21:05:54 +08:00
header: app.getRequestHeader(),
2023-03-29 00:00:43 +08:00
method: 'get',
2023-03-12 21:05:54 +08:00
data: {
2023-03-29 00:00:43 +08:00
orderId: this.data.order_id
2023-03-12 21:05:54 +08:00
},
success: function (res) {
var resp = res.data;
2023-03-29 00:00:43 +08:00
if (res.data.code == 200) {
2023-03-12 21:05:54 +08:00
that.setData({
2023-04-25 23:33:40 +08:00
item: res.data.data
2023-03-12 21:05:54 +08:00
});
2023-02-18 16:24:17 +08:00
}
2023-03-12 21:05:54 +08:00
}
2023-02-18 16:24:17 +08:00
});
2023-03-12 21:05:54 +08:00
},
2023-02-18 16:24:17 +08:00
})