zs 2 years ago
parent
commit
f95c4e039c
2 changed files with 39 additions and 5 deletions
  1. 33 0
      pages/usermysign/index.js
  2. 6 5
      pages/usermysign/index.wxml

+ 33 - 0
pages/usermysign/index.js

@@ -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;

+ 6 - 5
pages/usermysign/index.wxml

@@ -13,14 +13,15 @@
                                 <text>是否支付报名费:</text>
                                 <text>是否支付报名费:</text>
                                 <text>{{item.pay_status=='0'?'待支付':item.pay_status=='1'?'已支付':'支付失败'}}</text>
                                 <text>{{item.pay_status=='0'?'待支付':item.pay_status=='1'?'已支付':'支付失败'}}</text>
                             </view>
                             </view>
-                            <view class="other_1">
+                            <!-- <view class="other_1">
                                 <text>是否转发朋友圈:</text>
                                 <text>是否转发朋友圈:</text>
                                 <text>{{item.has_turn=='0'?'未转发':'已转发'}}</text>
                                 <text>{{item.has_turn=='0'?'未转发':'已转发'}}</text>
-                            </view>
+                            </view> -->
                         </view>
                         </view>
                         <view class="btn">
                         <view class="btn">
                             <button type="primary" size="mini" bindtap="toView" data-item="{{item}}">详细信息</button>
                             <button type="primary" size="mini" bindtap="toView" data-item="{{item}}">详细信息</button>
-                            <button type="primary" size="mini" bindtap="toTeam" data-item="{{item}}">组队申请</button>
+                            <button type="warn" size="mini" bindtap="toOut" data-item="{{item}}" wx:if="{{item.pay_status=='1'&&item.project_type=='双打'}}">退出比赛</button>
+                            <button type="primary" size="mini" bindtap="toPay" data-item="{{item}}" wx:if="{{item.pay_status==='0'}}">支付</button>
                             <button type="primary" size="mini" bindtap="toTeam" data-item="{{item}}" wx:if="{{item.pay_status=='1'&&item.project_type=='双打'}}">组队申请</button>
                             <button type="primary" size="mini" bindtap="toTeam" data-item="{{item}}" wx:if="{{item.pay_status=='1'&&item.project_type=='双打'}}">组队申请</button>
                         </view>
                         </view>
                     </view>
                     </view>
@@ -48,10 +49,10 @@
                 <text>组别项目:</text>
                 <text>组别项目:</text>
                 <text>{{info.project_name||'暂无'}}</text>
                 <text>{{info.project_name||'暂无'}}</text>
             </view>
             </view>
-            <view class="one_1">
+            <!-- <view class="one_1">
                 <text>是否转发了朋友圈:</text>
                 <text>是否转发了朋友圈:</text>
                 <text>{{info.has_turn=='0'?'未转发':'已转发'}}</text>
                 <text>{{info.has_turn=='0'?'未转发':'已转发'}}</text>
-            </view>
+            </view> -->
             <view class="one_1">
             <view class="one_1">
                 <text>支付状态:</text>
                 <text>支付状态:</text>
                 <text>{{info.pay_status=='0'?'待支付':info.pay_status=='1'?'已支付':'支付失败'}}</text>
                 <text>{{info.pay_status=='0'?'待支付':info.pay_status=='1'?'已支付':'支付失败'}}</text>