guhongwei 3 years ago
parent
commit
23a01793d7
2 changed files with 42 additions and 25 deletions
  1. 32 15
      pages/home/index.js
  2. 10 10
      pages/home/index.wxml

+ 32 - 15
pages/home/index.js

@@ -11,6 +11,7 @@ Page({
     // 主体高度
     infoHeight: '',
     teamlist: [],
+    schedule: []
   },
   // 跳转菜单
   tabPath(e) {
@@ -57,29 +58,34 @@ Page({
     wx.getStorage({
       key: 'token',
       success: res => {
+        // 查询赛程列表
+        wx.request({
+          url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
+          method: 'get',
+          data: {},
+          success(res) {
+            if (res.data.errcode == 0) {
+              that.setData({ schedule: res.data.data })
+            } else {
+              wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
+            }
+          }
+        })
+        // 查询比赛列表
         wx.request({
           url: `${app.globalData.publicUrl}/courtAdmin/api/match`,
           method: 'get',
           data: {},
           success(res) {
             if (res.data.errcode == 0) {
-              for (const val of res.data.data) {
+              let data = res.data.data;
+              for (const val of data) {
                 if (val.status == '3') {
-                  wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
-                    method: 'get',
-                    data: { match_id: val._id },
-                    success(res) {
-                      if (res.data.errcode == 0) {
-                        val.schedulelist = res.data.data;
-                      } else {
-                        wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
-                      }
-                    }
-                  })
+                  let schedulelist = that.data.schedule.filter((i) => i.match_id == val._id);
+                  val.schedulelist = schedulelist;
                 }
               }
-              that.setData({ teamlist: res.data.data })
+              if (data) that.setData({ teamlist: data })
             } else {
               wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
             }
@@ -91,7 +97,18 @@ Page({
       }
     })
   },
-
+  searchschedule: function (e) {
+    wx.request({
+      url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
+      method: 'get',
+      data: { match_id: e._id },
+      success(res) {
+        if (res.data.errcode == 0) { } else {
+          wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
+        }
+      }
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 10 - 10
pages/home/index.wxml

@@ -4,9 +4,9 @@
       <image class="image" src="{{src}}"></image>
     </view>
     <view class="two">
-      <view class="list" wx:key="item" wx:for="{{teamlist}}">
+      <view class="list" wx:for="{{teamlist}}" wx:key="item">
         <view class="listtou">
-          <view class="name"  bindtap="tiao" data-id="{{item._id}}">{{item.name}}</view>
+          <view class="name" bindtap="tiao" data-id="{{item._id}}">{{item.name}}</view>
           <view class="listbut"> <button class="color{{item.status}}" size="mini">{{item.status=='0'?'未开始':item.status=='1'?'报名中':item.status=='2'?'待比赛':item.status=='3'?'进行中':'已结束'}}</button>
           </view>
         </view>
@@ -16,20 +16,20 @@
           </view>
           <view class="otherInfo textOver"><text class="text3">{{item.address}}</text></view>
         </view>
-        <view class="right1" wx:if="{{item.status=='3'}}" wx:for="{{schedulelist}}" wx:for-item="items" wx:key="key" >
-          <view class="right1_2" bindtap="xun" data-id="{{items._id}}" >
+        <view class="right1" wx:for="{{item.schedulelist}}" wx:for-item="tag" wx:key="{{tag}}">
+          <view class="right1_2" bindtap="xun" data-id="{{tag._id}}">
             <view class="right1_2o">
-              <image class="head1" src="{{items.blue_logo[0].url}}"></image>
+              <image class="head1" src="{{tag.blue_logo[0].url}}"></image>
             </view>
-            <view class="right1_2t"><text>{{items.blue_name}}</text></view>
+            <view class="right1_2t"><text>{{tag.blue_name}}</text></view>
             <view class="right1_2i">
-              <text class="text6">{{items.blue_branch||0}}</text>
+              <text class="text6">{{tag.blue_branch||0}}</text>
               <text class="text8">:</text>
-              <text class="text7">{{items.red_branch||0}}</text>
+              <text class="text7">{{tag.red_branch||0}}</text>
             </view>
-            <view class="right1_2tb"><text>{{items.red_name}}</text></view>
+            <view class="right1_2tb"><text>{{tag.red_name}}</text></view>
             <view class="right1_2ob">
-              <image class="head2" src="{{items.red_logo[0].url}}"></image>
+              <image class="head2" src="{{tag.red_logo[0].url}}"></image>
             </view>
           </view>
         </view>