Prechádzať zdrojové kódy

修改 参赛历史

zs 3 rokov pred
rodič
commit
239b0310a3
1 zmenil súbory, kde vykonal 31 pridanie a 51 odobranie
  1. 31 51
      pages/team/examine.js

+ 31 - 51
pages/team/examine.js

@@ -30,74 +30,54 @@ Page({
     // 监听用户是否登录
     this.watchLogin();
   },
-   // 监听用户是否登录
-   watchLogin: function () {
+  // 监听用户是否登录
+  watchLogin: function () {
     var that = this;
+    let id = that.data.ids;
     wx.getStorage({
       key: 'token',
       success: res => {
         //查询数据
         wx.request({
-          url: `${app.globalData.publicUrl}/courtAdmin/api/team/${this.data.ids}`, //接口地址
+          url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
           method: 'get',
           data: '',
           success(res) {
-            if (res.data.errcode == 0) {
-              that.setData({
-                teamlist: res.data.data,
-              });
-            } else {
-              wx.showToast({
-                title: res.data.errmsg,
-                icon: 'none',
-                duration: 2000
-              })
-            }
-          }
-        })
-        //参赛历史
-        var that = this;
-        var list = that.data.teamlist;
-        var match_id = that.data.ids;
-        var match_name = list.name;
-        wx.request({
-          url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
-          method: 'get',
-          data: {
-            "match_id": match_id,
-            "match_name": match_name,
-          },
-          success(res) {
-            if (res.data.errcode == 0) {
-              that.setData({
-                historylist: res.data.data,
-              });
-            } else {
-              wx.showToast({
-                title: res.data.errmsg,
-                icon: 'none',
-                duration: 2000
-              })
-            }
+            that.setData({
+              teamlist: res.data.data,
+            });
           }
         })
+        //查询历史比赛
+        this.searchMatch(res.data.data);
       },
       fail: res => {
         return wx.redirectTo({ url: '/pages/login/index', })
       }
     })
   },
- // 计算高度
- searchHeight: function () {
-  let frameStyle = this.data.frameStyle;
-  let client = app.globalData.client;
-  let infoHeight = client.windowHeight;
-  // 是否去掉状态栏
-  if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
-  // 是否减去底部菜单
-  if (frameStyle.useBar) infoHeight = infoHeight - 50;
-  if (infoHeight) this.setData({ infoHeight: infoHeight })
-},
+  //查询历史比赛
+  searchMatch: async function (e) {
+    const that = this;
+    let id = that.data.ids;
+    let data = [];
+    const res = await app.$get('/courtAdmin/api/schedule', { red_id: id, status: '2' });
+    if (res.errcode === 0) data = res.data;
+    const arr = await app.$get('/courtAdmin/api/schedule', { blue_id: id, status: '2' });
+    if (arr.errcode === 0) data = [...data, ...arr.data];
+    that.setData({ historylist: data })
+  },
+  // 计算高度
+  searchHeight: function () {
+    let frameStyle = this.data.frameStyle;
+    let client = app.globalData.client;
+    let infoHeight = client.windowHeight;
+    // 是否去掉状态栏
+    if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
+    // 是否减去底部菜单
+    if (frameStyle.useBar) infoHeight = infoHeight - 50;
+    if (infoHeight) this.setData({ infoHeight: infoHeight })
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成