|
|
@@ -17,6 +17,8 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
orderfunc(){ |
|
|
|
var orderId = ''; |
|
|
|
var payOrderId = ''; |
|
|
|
wx.showLoading({ |
|
|
|
title: '加载中...', |
|
|
|
}) |
|
|
@@ -26,9 +28,22 @@ Page({ |
|
|
|
wx.hideLoading(); |
|
|
|
console.log(res) |
|
|
|
if (res.data.code == 200) { |
|
|
|
|
|
|
|
Common.payOrderCreate('' + res.data.data.id) |
|
|
|
.then(res =>{ |
|
|
|
return res; |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: res.data.message, |
|
|
|
duration: 3000 |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
orderId = '' + res.data.data.id; |
|
|
|
return Common.payOrderCreate(orderId) |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
console.log(res) |
|
|
|
payOrderId = res.data.data.payOrderId; |
|
|
|
if (res.data.code == 200) { |
|
|
|
wx.requestPayment({ |
|
|
|
timeStamp: res.data.data.timeStamp, |
|
|
|
nonceStr: res.data.data.nonceStr, |
|
|
@@ -36,6 +51,8 @@ Page({ |
|
|
|
signType: 'MD5', |
|
|
|
paySign: res.data.data.paySign, |
|
|
|
'success': function (res) { |
|
|
|
Common.payOrderUpdate(orderId, payOrderId, 1); // 支付成功 |
|
|
|
console.log(res); |
|
|
|
console.log('支付成功'); |
|
|
|
wx.showToast({ |
|
|
|
title: '购买成功', |
|
|
@@ -46,11 +63,13 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
'fail': function (res) { |
|
|
|
console.log('支付失败'); |
|
|
|
Common.payOrderUpdate(orderId, payOrderId, 2); // 支付失败 |
|
|
|
console.log(res) |
|
|
|
console.log('支付失败'); |
|
|
|
return; |
|
|
|
}, |
|
|
|
'complete': function (res) { |
|
|
|
console.log(res); |
|
|
|
console.log('支付完成'); |
|
|
|
var url = that.data.url; |
|
|
|
console.log('get url', url) |
|
|
@@ -70,19 +89,16 @@ Page({ |
|
|
|
wx.navigateBack() |
|
|
|
}, 2000) |
|
|
|
} |
|
|
|
} else { |
|
|
|
wx.showModal({ |
|
|
|
title: '错误提示', |
|
|
|
content: res.errMsg |
|
|
|
}); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: res.data.message, |
|
|
|
duration: 3000 |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |