guhongwei 3 lat temu
rodzic
commit
b1d24db41e
2 zmienionych plików z 45 dodań i 30 usunięć
  1. 44 29
      pages/home/index.js
  2. 1 1
      utils/httpUtil.js

+ 44 - 29
pages/home/index.js

@@ -1,5 +1,6 @@
 // pages/login/login.js
 // pages/login/login.js
 import WxValidate from '../../utils/wxValidate'
 import WxValidate from '../../utils/wxValidate'
+import * as httpUtil from "../../utils/httpUtil";
 const app = getApp()
 const app = getApp()
 Page({
 Page({
   /**
   /**
@@ -50,39 +51,53 @@ Page({
     wx.getStorage({
     wx.getStorage({
       key: 'token',
       key: 'token',
       success: res => {
       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) {
-              let data = res.data.data;
-              for (const val of data) {
-                if (val.status == '3') {
-                  let schedulelist = that.data.schedule.filter((i) => i.match_id == val._id);
-                  val.schedulelist = schedulelist;
-                }
+        httpUtil.$get('/courtAdmin/api/match').then(res => {
+          if (res.errcode === 0) {
+            for (const val of res.data) {
+              if (val.status == '3') {
+                httpUtil.$get('/courtAdmin/api/schedule', { match_id: val._id }).then(res => {
+                  if (res.errcode === 0) {
+                    val.schedulelist = res.data;
+                  }
+                })
               }
               }
-              if (data) that.setData({ teamlist: data })
-            } else {
-              wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
             }
             }
+            that.setData({ teamlist: res.data })
           }
           }
         })
         })
+        // // 查询赛程列表
+        // 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) {
+        //       let data = res.data.data;
+        //       for (const val of data) {
+        //         if (val.status == '3') {
+        //           let schedulelist = that.data.schedule.filter((i) => i.match_id == val._id);
+        //           val.schedulelist = schedulelist;
+        //         }
+        //       }
+        //       if (data) that.setData({ teamlist: data })
+        //     } else {
+        //       wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
+        //     }
+        //   }
+        // })
       },
       },
       fail: res => {
       fail: res => {
         return wx.redirectTo({ url: '/pages/login/index', })
         return wx.redirectTo({ url: '/pages/login/index', })

+ 1 - 1
utils/httpUtil.js

@@ -1,4 +1,4 @@
-let baseUrl = "";
+let baseUrl = "https://broadcast.waityou24.cn";
 const $get = (uri, data) => {
 const $get = (uri, data) => {
   let app = getApp();
   let app = getApp();
   let tenant = app.tenant || "test";
   let tenant = app.tenant || "test";