Files
decode-mini-app-new/wx214944c362629fc7/pages/order/detail.js
2024-08-22 12:53:28 +08:00

94 lines
2.6 KiB
JavaScript

var t = getApp();
Page({
data: {
order_id: null,
order: {},
utype: 0
},
onLoad: function(t) {
this.data.order_id = t.order_id, this.getOrderDetail(t.order_id), this.getUserDetail();
},
onShow: function() {
this.getUserDetail();
},
getOrderDetail: function(e) {
var r = this;
t._get("user.order/detail", {
order_id: e
}, function(t) {
r.setData(t.data);
});
},
getUserDetail: function() {
var e = this;
t._get("user.index/detail", {}, function(t) {
console.log(t), e.setData({
utype: t.data.userInfo.utype
});
});
},
goodsDetail: function(t) {
var e = t.currentTarget.dataset.id;
wx.navigateTo({
url: "../goods/index?goods_id=" + e
});
},
cancelOrder: function(e) {
var r = this.data.order_id;
wx.showModal({
title: "提示",
content: "确认取消订单?",
success: function(e) {
e.confirm && t._post_form("user.order/cancel", {
order_id: r
}, function(t) {
wx.navigateBack();
});
}
});
},
aftermarketOrder: function(t) {
var e = t.currentTarget.dataset.id;
wx.navigateTo({
url: "../aftermarket/create?order_goods_id=" + e
});
},
payOrder: function(e) {
var r = this, a = r.data.order_id;
wx.showLoading({
title: "正在处理..."
}), t._post_form("user.order/pay", {
order_id: a
}, function(e) {
if (-10 === e.code) return t.showError(e.msg), !1;
wx.requestPayment({
timeStamp: e.data.timeStamp,
nonceStr: e.data.nonceStr,
package: "prepay_id=" + e.data.prepay_id,
signType: "MD5",
paySign: e.data.paySign,
success: function(t) {
r.getOrderDetail(a);
},
fail: function() {
t.showError("订单未支付");
}
});
});
},
receipt: function(e) {
var r = this, a = r.data.order_id;
wx.showModal({
title: "提示",
content: "确认收到商品?",
success: function(e) {
e.confirm && t._post_form("user.order/receipt", {
order_id: a
}, function(t) {
r.getOrderDetail(a);
});
}
});
}
});