guhongwei 2 лет назад
Родитель
Сommit
c6ca2f3bb0
2 измененных файлов с 12 добавлено и 19 удалено
  1. 11 18
      pages/me/index.js
  2. 1 1
      pages/me/index.wxml

+ 11 - 18
pages/me/index.js

@@ -23,6 +23,8 @@ Page({
         // 弹框
         dialog: { title: '上传比分', show: false, type: '1' },
         form: {},
+        // 上传比分
+        scoreList: []
 
     },
     initValidate() {
@@ -36,21 +38,19 @@ Page({
         if (route) wx.redirectTo({ url: `/${route}` })
     },
     // 上传比分
-    toScore: function () {
+    toScore: async function () {
         const that = this;
+        const arr = await app.$get(`/courtAdmin/api/schedule/getByTeamCreater`, { user_id: that.data.userInfo._id, status: '1' });
+        if (arr.errcode == '0') that.setData({ scoreList: arr.data })
         that.setData({ dialog: { title: '上传比分', show: true, type: '1' } })
     },
     // 选择比赛
     ismatchChange: function (e) {
         const that = this;
-        const list = that.data.ismatchList;
+        const list = that.data.scoreList;
         const { value } = e.detail;
         const data = list[value];
-        if (data) {
-            that.setData({ 'form._id': data._id })
-            that.setData({ 'form.red_name': data.red_name })
-            that.setData({ 'form.blue_name': data.blue_name })
-        }
+        if (data) that.setData({ form: data })
     },
     // 提交上传比分
     async onSubmit(e) {
@@ -108,8 +108,8 @@ Page({
         this.initValidate();
         // 计算高度
         this.searchHeight();
-        // // 监听用户是否登录
-        // this.watchLogin();
+        // 监听用户是否登录
+        this.watchLogin();
     },
     // 监听用户是否登录
     watchLogin: function () {
@@ -139,15 +139,8 @@ Page({
                             that.setData({ userInfo: user })
                         } else { wx.showToast({ title: `${err.errmsg}`, icon: 'error', duration: 2000 }) }
                         // 查询正在比赛的赛事
-                        let ismatchList = [];
-                        // 红方
-                        arr = await app.$get(`/courtAdmin/api/schedule`, { red_id: team[0]._id });
-                        // arr = await app.$get(`/courtAdmin/api/schedule`, { red_id: team[0]._id });
-                        // if (arr.errcode == '0') ismatchList.push(...arr.data);
-                        // // 蓝方
-                        // arr = await app.$get(`/courtAdmin/api/schedule`, { blue_id: team[0]._id });
-                        // if (arr.errcode == '0') ismatchList.push(...arr.data);
-                        // that.setData({ ismatchList: ismatchList })
+                        arr = await app.$get(`/courtAdmin/api/schedule/getByTeamCreater`, { user_id: res.data._id });
+                        if (arr.errcode == '0') that.setData({ ismatchList: arr.data })
                     } else if (user.type == '2') {
                         arr = await app.$get(`/courtAdmin/api/team/userteams`, { user_id: user._id });
                         if (arr.errcode == '0') {

+ 1 - 1
pages/me/index.wxml

@@ -97,7 +97,7 @@
                 <view class="content">
                     <view class="label textOver">比赛</view>
                     <view class="value">
-                        <picker mode="selector" bindchange="ismatchChange" name="_id" value="{{form._id}}" range-key="{{'red_name'}}" range="{{ismatchList}}">
+                        <picker mode="selector" bindchange="ismatchChange" name="_id" value="{{form._id}}" range-key="{{'red_name'}}" range="{{scoreList}}">
                             <view class="input">{{form.red_name||"红方团队"}}--{{form.blue_name||'蓝方团队'}}</view>
                         </picker>
                     </view>