|
@@ -46,6 +46,39 @@ Page({
|
|
const { item } = e.currentTarget.dataset;
|
|
const { item } = e.currentTarget.dataset;
|
|
wx.navigateTo({ url: `/pages/usermyteam/add?id=${item._id}` })
|
|
wx.navigateTo({ url: `/pages/usermyteam/add?id=${item._id}` })
|
|
},
|
|
},
|
|
|
|
+ // 支付
|
|
|
|
+ toPay: async function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const id = e.currentTarget.dataset?.item?._id;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'user',
|
|
|
|
+ success: async (res) => {
|
|
|
|
+ let obj = { openid: res.data.openid, money: 0.1, enroll_id: id, type: '报名' }
|
|
|
|
+ const arr = await app.$post(`/newCourt/api/payOrder`, obj)
|
|
|
|
+ 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(); }
|
|
|
|
+ },
|
|
|
|
+ "fail": function (res) {
|
|
|
|
+ wx.showToast({ title: `支付未成功`, icon: 'error', duration: 2000 })
|
|
|
|
+ that.watchLogin()
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: async (res) => {
|
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' });
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ },
|
|
// 关闭弹框
|
|
// 关闭弹框
|
|
toClose: function () {
|
|
toClose: function () {
|
|
const that = this;
|
|
const that = this;
|