|
|
@@ -26,16 +26,56 @@ Page({ |
|
|
|
wx.hideLoading(); |
|
|
|
console.log(res) |
|
|
|
if (res.data.code == 200) { |
|
|
|
wx.showToast({ |
|
|
|
title: '购买成功', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
wx.hideToast(); |
|
|
|
}, 2000) |
|
|
|
wx.navigateBack({ |
|
|
|
delta: 2 |
|
|
|
Common.payOrderCreate(res.data.data.id) |
|
|
|
.then(res =>{ |
|
|
|
wx.requestPayment({ |
|
|
|
timeStamp: res.data.data.timeStamp, |
|
|
|
nonceStr: res.data.data.nonceStr, |
|
|
|
package: res.data.data.package, |
|
|
|
signType: 'MD5', |
|
|
|
paySign: res.data.data.paySign, |
|
|
|
'success': function (res) { |
|
|
|
console.log('支付成功'); |
|
|
|
wx.showToast({ |
|
|
|
title: '购买成功', |
|
|
|
duration: 2500 |
|
|
|
}) |
|
|
|
wx.navigateBack({ |
|
|
|
delta: 2 |
|
|
|
}) |
|
|
|
}, |
|
|
|
'fail': function (res) { |
|
|
|
console.log('支付失败'); |
|
|
|
console.log(res) |
|
|
|
return; |
|
|
|
}, |
|
|
|
'complete': function (res) { |
|
|
|
console.log('支付完成'); |
|
|
|
var url = that.data.url; |
|
|
|
console.log('get url', url) |
|
|
|
if (res.errMsg == 'requestPayment:ok') { |
|
|
|
wx.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '支付成功' |
|
|
|
}); |
|
|
|
if (url) { |
|
|
|
setTimeout(function () { |
|
|
|
wx.redirectTo({ |
|
|
|
url: '/pages' + url |
|
|
|
}); |
|
|
|
}, 2000) |
|
|
|
} else { |
|
|
|
setTimeout(() => { |
|
|
|
wx.navigateBack() |
|
|
|
}, 2000) |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: res.data.message, |
|
|
|