|
@@ -62,9 +62,7 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- toForward: function () {
|
|
|
-
|
|
|
- },
|
|
|
+ toForward: function () { },
|
|
|
// 支付
|
|
|
toPay: async function () {
|
|
|
const that = this;
|
|
@@ -72,9 +70,26 @@ Page({
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async (res) => {
|
|
|
- let obj = { openid: res.data.openid, money: 0.1, enroll_id: enroll._id }
|
|
|
+ let obj = { openid: res.data.openid, money: 0.1, enroll_id: enroll._id, type: '报名' }
|
|
|
const arr = await app.$post(`/newCourt/api/payOrder`, obj)
|
|
|
- console.log(arr);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.requestPayment({
|
|
|
+ "timeStamp": arr.data.wxSign.timestamp,
|
|
|
+ "nonceStr": arr.data.wxSign.nonceStr,
|
|
|
+ "package": `prepay_id=${arr.data.wxSign.prepay_id}`,
|
|
|
+ "signType": arr.data.wxSign.signType,
|
|
|
+ "paySign": arr.data.wxSign.paySign,
|
|
|
+ "success": async function (res) {
|
|
|
+ wx.showToast({ title: `支付成功`, icon: 'success', duration: 2000 });
|
|
|
+ const aee = await app.$post(`/newCourt/api/payOrder/${arr.data.data._id}`, { status: '1' });
|
|
|
+ if (aee.errcode == '0') { that.watchLogin(); that.toclose(); that.back() }
|
|
|
+ },
|
|
|
+ "fail": function (res) {
|
|
|
+ wx.showToast({ title: `支付未成功`, icon: 'error', duration: 2000 })
|
|
|
+ that.watchLogin()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
fail: async (res) => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' });
|
|
@@ -162,6 +177,5 @@ Page({
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
- console.log('1');
|
|
|
},
|
|
|
})
|