zs před 2 roky
rodič
revize
50bb58d457
2 změnil soubory, kde provedl 35 přidání a 37 odebrání
  1. 28 22
      pages/usermysign/index.js
  2. 7 15
      pages/usermysign/index.wxml

+ 28 - 22
pages/usermysign/index.js

@@ -18,42 +18,32 @@ Page({
         wx.navigateBack({ delta: 1 })
     },
     // 查询
-    search: function (e) { console.log('查询'); },
+    search: function (e) {
+        const that = this;
+        that.setData({ 'searchInfo.name': e.detail.value });
+        that.watchLogin()
+    },
     // 查看
     toView: async function (e) {
         const that = this;
         const { item } = e.currentTarget.dataset;
-        const arr = await app.$get(`/newCourt/api/enroll/${item._id}`);
-        if (arr.errcode == '0') {
-            // 用户信息
-            const user = await app.$get(`/newCourt/api/user/${arr.data.openid}`);
-            if (user.errcode = '0') { arr.data.user_name = user.data.name };
-            // 赛事信息
-            const match = await app.$get(`/newCourt/api/match/${arr.data.match_id}`);
-            if (match.errcode = '0') { arr.data.match_name = match.data.name };
-            // 赛事组别
-            let group = match.data.grouping.find((i) => i._id == arr.data.grouping_id);
-            if (group) { arr.data.grouping_name = group.name; arr.data.project_type = group.type }
-            // 赛事项目
-            const project = await app.$get(`/newCourt/api/matchProject/${arr.data.project_id}`)
-            if (project.errcode = '0') { arr.data.project_name = project.data.name };
-            that.setData({ info: arr.data })
-            that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
-        }
+        that.setData({ info: item })
+        that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
     },
     // 组队申请
     toTeam: function (e) {
         const { item } = e.currentTarget.dataset;
-        wx.navigateTo({ url: `/pages/usermyteam/add?id=${item._id}` })
+        wx.navigateTo({ url: `/pages/usermyteam/add?id=${item.enroll_id}` })
     },
     // 支付
     toPay: async function (e) {
         const that = this;
-        const id = e.currentTarget.dataset?.item?._id;
+        const enroll_id = e.currentTarget.dataset?.item?.enroll_id;
+        debugger
         wx.getStorage({
             key: 'user',
             success: async (res) => {
-                let obj = { openid: res.data.openid, money: 0.1, enroll_id: id, type: '报名' }
+                let obj = { openid: res.data.openid, money: 0.1, enroll_id: enroll_id, type: '报名' }
                 const arr = await app.$post(`/newCourt/api/payOrder`, obj)
                 if (arr.errcode == '0') {
                     wx.requestPayment({
@@ -79,6 +69,18 @@ Page({
             },
         });
     },
+    // 退款
+    toOut: async function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        const arr = await app.$post('/newCourt/api/payOrder/toRefund', { id: item.pay_id })
+        if (arr.errcode == '0') {
+            wx.showToast({ title: `退款成功`, icon: 'success', duration: 2000 });
+            that.watchLogin();
+        } else {
+            wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 });
+        }
+    },
     // 关闭弹框
     toClose: function () {
         const that = this;
@@ -94,10 +96,13 @@ Page({
     // 监听用户是否登录
     watchLogin: async function () {
         const that = this;
+        let searchInfo = that.data.searchInfo;
         wx.getStorage({
             key: 'user',
             success: async res => {
-                const arr = await app.$get(`/newCourt/api/enroll/`, { openid: res.data.openid });
+                let info = {};
+                if (searchInfo && searchInfo.name) info.match_name = searchInfo.name;
+                const arr = await app.$get(`/newCourt/api/view/myMatchList/`, { openid: res.data.openid, ...info });
                 if (arr.errcode == '0') {
                     for (const val of arr.data) {
                         // 赛事信息
@@ -105,6 +110,7 @@ Page({
                         if (match.errcode = '0') { val.match_name = match.data.name };
                     }
                     that.setData({ list: arr.data })
+                    console.log(arr.data);
                 }
             },
             fail: res => {

+ 7 - 15
pages/usermysign/index.wxml

@@ -13,16 +13,12 @@
                                 <text>是否支付报名费:</text>
                                 <text>{{item.pay_status=='0'?'待支付':item.pay_status=='1'?'已支付':'支付失败'}}</text>
                             </view>
-                            <!-- <view class="other_1">
-                                <text>是否转发朋友圈:</text>
-                                <text>{{item.has_turn=='0'?'未转发':'已转发'}}</text>
-                            </view> -->
                         </view>
                         <view class="btn">
                             <button type="primary" size="mini" bindtap="toView" 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.needTeammate==true}}">组队申请</button>
+                            <button type="warn" size="mini" bindtap="toOut" data-item="{{item}}" wx:if="{{item.pay_status=='1'&&item.is_sign_end==false}}">退出比赛</button>
                         </view>
                     </view>
                 </view>
@@ -33,26 +29,22 @@
 <e-dialog dialog="{{dialog}}" bind:toClose="toClose">
     <view slot="info">
         <view class="dialog_one" wx:if="{{dialog.type=='1'}}">
-            <view class="one_1">
-                <text>报名用户:</text>
-                <text>{{info.user_name||'暂无昵称'}}</text>
-            </view>
             <view class="one_1">
                 <text>赛事名称:</text>
                 <text>{{info.match_name||'暂无'}}</text>
             </view>
             <view class="one_1">
                 <text>赛事组别:</text>
-                <text>{{info.grouping_name||'暂无'}}</text>
+                <text>{{info.group_name||'暂无'}}</text>
             </view>
             <view class="one_1">
                 <text>组别项目:</text>
                 <text>{{info.project_name||'暂无'}}</text>
             </view>
-            <!-- <view class="one_1">
-                <text>是否转发了朋友圈:</text>
-                <text>{{info.has_turn=='0'?'未转发':'已转发'}}</text>
-            </view> -->
+            <view class="one_1">
+                <text>比赛项目人数:</text>
+                <text>{{info.num||0}}人</text>
+            </view>
             <view class="one_1">
                 <text>支付状态:</text>
                 <text>{{info.pay_status=='0'?'待支付':info.pay_status=='1'?'已支付':'支付失败'}}</text>