|
|
@@ -27,26 +27,35 @@ Page({ |
|
|
|
couponId: e.id
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 支付订单更新
|
|
|
|
*/
|
|
|
|
payOrderUpdate: (orderId, payOrderId, status, reason) => {
|
|
|
|
// 支付成功
|
|
|
|
return Http.post({
|
|
|
|
url: config.api.payOrderUpdate,
|
|
|
|
data: {
|
|
|
|
payOrderId: payOrderId,
|
|
|
|
orderId: orderId,
|
|
|
|
status: status,
|
|
|
|
reason: reason
|
|
|
|
}
|
|
|
|
})
|
|
|
|
Http.post({
|
|
|
|
url: config.api.payOrderUpdate,
|
|
|
|
data: {
|
|
|
|
payOrderId: payOrderId,
|
|
|
|
orderId: orderId,
|
|
|
|
status: status,
|
|
|
|
reason: reason
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
console.log("payOrderUpdate then", res);
|
|
|
|
wx.showToast({
|
|
|
|
title: '购买成功',
|
|
|
|
duration: 2500
|
|
|
|
})
|
|
|
|
}).catch(err => {
|
|
|
|
console.log("payOrderUpdate catch", err);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
payment: (res) => {
|
|
|
|
var that = this;
|
|
|
|
var payOrderId = '' + res.payOrderId;
|
|
|
|
var payOrderId = '' + res.data.out_trade_no;
|
|
|
|
wx.requestPayment({
|
|
|
|
timeStamp: res.timeStamp,
|
|
|
|
nonceStr: res.nonceStr,
|
|
|
@@ -123,7 +132,7 @@ Page({ |
|
|
|
if (err.code == 11005) {
|
|
|
|
// 用户手机未授权
|
|
|
|
wx.redirectTo({
|
|
|
|
url: '../../getphoneInfo/index?couponId='+that.data.couponId,
|
|
|
|
url: '../../getphoneInfo/index?couponId=' + that.data.couponId,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (err.code == 11006) {
|
|
|
@@ -134,36 +143,38 @@ Page({ |
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
const orderId = '' + res.data.id;
|
|
|
|
that.setData({
|
|
|
|
orderId: orderId
|
|
|
|
})
|
|
|
|
if (res.data.payment > 0) {
|
|
|
|
// real pay
|
|
|
|
return Http.post({
|
|
|
|
url: config.api.payOrderCreate,
|
|
|
|
data: {
|
|
|
|
orderId: orderId
|
|
|
|
}
|
|
|
|
if (res != "undefined") {
|
|
|
|
const orderId = '' + res.data.id;
|
|
|
|
that.setData({
|
|
|
|
orderId: orderId
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
// 免费券
|
|
|
|
that.payOrderUpdate(orderId, "0", 1) // 支付成功
|
|
|
|
.then(res => {
|
|
|
|
wx.showToast({
|
|
|
|
title: "支付成功",
|
|
|
|
duration: 3000
|
|
|
|
})
|
|
|
|
if (res.data.payment > 0) {
|
|
|
|
// 支付金额不为0
|
|
|
|
Http.post({
|
|
|
|
url: config.api.payOrderCreate,
|
|
|
|
data: {
|
|
|
|
orderId: orderId
|
|
|
|
}
|
|
|
|
}).then(res => {
|
|
|
|
console.log(res)
|
|
|
|
var payOrderId = '' + res.data.out_trade_no;
|
|
|
|
wx.hideLoading();
|
|
|
|
//payment(res);
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1) // 支付成功
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
// 免费券
|
|
|
|
that.payOrderUpdate(orderId, "0", 1) // 支付成功
|
|
|
|
.then(res => {
|
|
|
|
wx.showToast({
|
|
|
|
title: "支付成功",
|
|
|
|
duration: 3000
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).then(res => {
|
|
|
|
console.log(res)
|
|
|
|
if (res) {
|
|
|
|
var payOrderId = '' + res.payOrderId;
|
|
|
|
wx.hideLoading();
|
|
|
|
//payment(res);
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1) // 支付成功
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}) |