Browse Source

Merge branch 'master' of http://git.cc-lotus.info/ball-court/court-mobile

zs 3 years ago
parent
commit
b22255a742
12 changed files with 88 additions and 87 deletions
  1. 1 1
      app.json
  2. 23 1
      package-lock.json
  3. 0 1
      package.json
  4. 10 49
      pages/home/index.js
  5. 17 2
      pages/index/index.js
  6. 2 2
      pages/layNew/index.js
  7. 10 20
      pages/login/index.js
  8. 19 4
      pages/me/index.js
  9. 1 1
      pages/me/index.wxml
  10. 2 3
      pages/me/index.wxss
  11. 1 1
      project.config.json
  12. 2 2
      utils/httpUtil.js

+ 1 - 1
app.json

@@ -1,7 +1,7 @@
 {
   "pages": [
-    "pages/login/index",
     "pages/index/index",
+    "pages/login/index",
     "pages/register/index",
     "pages/home/index",
     "pages/search/index",

+ 23 - 1
package-lock.json

@@ -1,8 +1,30 @@
 {
   "name": "court-mobile",
   "version": "1.0.0",
-  "lockfileVersion": 1,
+  "lockfileVersion": 2,
   "requires": true,
+  "packages": {
+    "": {
+      "name": "court-mobile",
+      "version": "1.0.0",
+      "license": "ISC",
+      "dependencies": {
+        "@vant/weapp": "^1.10.2",
+        "vant-weapp": "^0.5.29"
+      },
+      "devDependencies": {}
+    },
+    "node_modules/@vant/weapp": {
+      "version": "1.10.2",
+      "resolved": "https://registry.npmjs.org/@vant/weapp/-/weapp-1.10.2.tgz",
+      "integrity": "sha512-caqA0xQxM4lMRncFsRPPVMDdEzUBCJ4xdFXuKReXpEU3qwnVIP/WIjVDIi7mWyS7xqz8C9WfSW5JL4PrlSq31w=="
+    },
+    "node_modules/vant-weapp": {
+      "version": "0.5.29",
+      "resolved": "https://registry.npmjs.org/vant-weapp/-/vant-weapp-0.5.29.tgz",
+      "integrity": "sha512-RMc0Ga914XFwspw2WuOMU8bOHlIkua8X1DoQ/KPnGQzjwT1uEL4S7W186EmaHF1wN2krB9BVd0LdRRt39dGh6Q=="
+    }
+  },
   "dependencies": {
     "@vant/weapp": {
       "version": "1.10.2",

+ 0 - 1
package.json

@@ -11,7 +11,6 @@
     "@vant/weapp": "^1.10.2",
     "vant-weapp": "^0.5.29"
   },
-  "devDependencies": {},
   "repository": {
     "type": "git",
     "url": "http://git.cc-lotus.info/ball-court/court-mobile.git"

+ 10 - 49
pages/home/index.js

@@ -1,6 +1,5 @@
 // pages/login/login.js
 import WxValidate from '../../utils/wxValidate'
-import * as httpUtil from "../../utils/httpUtil";
 const app = getApp()
 Page({
   /**
@@ -12,7 +11,6 @@ Page({
     // 主体高度
     infoHeight: '',
     teamlist: [],
-    schedule: []
   },
   // 跳转菜单
   tabPath(e) {
@@ -46,58 +44,21 @@ Page({
     if (infoHeight) this.setData({ infoHeight: infoHeight })
   },
   // 监听用户是否登录
-  watchLogin: function () {
+  watchLogin: async function () {
     const that = this;
     wx.getStorage({
       key: 'token',
-      success: res => {
-        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;
-                  }
-                })
-              }
+      success: async res => {
+        const arr = await app.$get('/courtAdmin/api/match');
+        if (arr.errcode === 0) {
+          for (const val of arr.data) {
+            if (val.status == '3') {
+              const aee = await app.$get('/courtAdmin/api/schedule', { match_id: val._id });
+              if (aee.errcode === 0) val.schedulelist = aee.data;
             }
-            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 })
-        //     }
-        //   }
-        // })
+          that.setData({ teamlist: arr.data })
+        }
       },
       fail: res => {
         return wx.redirectTo({ url: '/pages/login/index', })

+ 17 - 2
pages/index/index.js

@@ -1,4 +1,5 @@
-const app = getApp()
+const app = getApp();
+import * as httpUtil from "../../utils/httpUtil";
 Page({
 
   /**
@@ -37,6 +38,20 @@ Page({
   },
   // 监听用户是否登录
   watchLogin: function () {
+    // 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;
+    //           }
+    //         })
+    //       }
+    //     }
+    //     console.log(res.data);
+    //   }
+    // })
     wx.getStorage({
       key: 'token',
       success: res => {
@@ -57,7 +72,7 @@ Page({
     // 是否减去底部菜单
     if (frameStyle.useBar) infoHeight = infoHeight - 50;
     if (infoHeight) this.setData({ infoHeight: infoHeight })
-},
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 2 - 2
pages/layNew/index.js

@@ -67,11 +67,11 @@ Page({
         var match_time = this.data.date + '  ' + this.data.time;
         const value = e.detail.value;
         value.match_id = this.data.id;
-        value.red_id = this.data.red._id;
+        value.red_id = this.data.red.team_id;
         value.red_name = this.data.red.team_name;
         value.red_logo = this.data.red.logo;
         value.red_members = this.data.red.members;
-        value.blue_id = this.data.blue._id;
+        value.blue_id = this.data.blue.team_id;
         value.blue_name = this.data.blue.team_name;
         value.blue_logo = this.data.blue.logo;
         value.blue_members = this.data.blue.members;

+ 10 - 20
pages/login/index.js

@@ -19,32 +19,22 @@ Page({
     this.WxValidate = new WxValidate(rules, messages)
   },
   // 提交登录
-  onSubmit: function (e) {
+  onSubmit: async function (e) {
     const params = e.detail.value;
     if (!this.WxValidate.checkForm(params)) {
       const error = this.WxValidate.errorList[0];
       wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
       return false
     } else {
-      wx.request({
-        url: `${app.globalData.publicUrl}/courtAdmin/api/user/login`, //接口地址
-        method: 'post',
-        data: params,
-        success(res) {
-          if (res.data.errcode == 0) {
-            app.globalData.userInfo = res.data.data;//存用户信息到app.js
-            wx.setStorage({ key: "token", data: res.data.data })// 存用户信息到storage,以便之后判断用户是否登录
-            wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 }) //登录成功提示
-            wx.navigateTo({ url: '/pages/home/index' })// 跳转页面
-          } else {
-            wx.showToast({
-              title: res.data.errmsg,
-              icon: 'none',
-              duration: 2000
-            })
-          }
-        }
-      })
+      const res = await app.$post('/courtAdmin/api/user/login', params);
+      if (res.errcode === 0) {
+        app.globalData.userInfo = res.data;//存用户信息到app.js
+        wx.setStorage({ key: "token", data: res.data })// 存用户信息到storage,以便之后判断用户是否登录
+        wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 }) //登录成功提示
+        wx.navigateTo({ url: '/pages/home/index' })// 跳转页面
+      } else {
+        wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
+      }
     }
   },
   // 微信登录

+ 19 - 4
pages/me/index.js

@@ -18,6 +18,7 @@ Page({
     total: '4',
     //上传比分
     match: [],
+    blue_red: [],
     //个人信息详情
     item1: {},
     //团队列表
@@ -180,20 +181,34 @@ Page({
   },
   //查询比赛列表
   searchMatch: function (e) {
+    const that = this;
     let id = e[0]._id
-    console.log(e[0]._id);
     wx.request({
       url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
       method: "get",
-      data: { blue_id: id , red_id :id},
+      data: { red_id: id },
+      header: {},
+      success: res => {
+        // that.setData({ blue_red: res.data.data })
+        that.setData({ match: res.data.data })
+      },
+      error: err => {
+      }
+    })
+    wx.request({
+      url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
+      method: "get",
+      data: { blue_id: id },
       header: {},
       success: res => {
-        console.log(res.data.data);
-        this.setData({ match: res.data.data })
+        // that.setData({ blue_red: res.data.data })
+        that.setData({ match: res.data.data })
       },
       error: err => {
       }
     })
+    // let blue_red = that.data.blue_red;
+    // that.setData({ match: that.data.blue_red})
   },
   // 计算高度
   searchHeight: function () {

+ 1 - 1
pages/me/index.wxml

@@ -76,7 +76,7 @@
       </view>
     </view>
     <!-- 上传比分-无比赛 -->
-    <view class="four-zan" wx:if="{{item.length==0}}" >
+    <view class="four-zan" wx:if="{{match.length==0}}" >
       <view class="zan-left">
         <text>暂无比赛</text>
       </view>

+ 2 - 3
pages/me/index.wxss

@@ -137,7 +137,7 @@
   top: -30px; */
   width: 100%;
   /* height: 105px; */
-  margin: 0 0 16px 0;
+  margin: 16px 0 0 0;
 }
 
 .left3 {
@@ -179,8 +179,7 @@
 }
 
 .four-zan {
-  position: relative;
-  top: 12%;
+  margin: 10px 20px;
   width: 91%;
   text-align: center;
   height: 70px;

+ 1 - 1
project.config.json

@@ -39,7 +39,7 @@
     "useCompilerPlugins": false
   },
   "compileType": "miniprogram",
-  "libVersion": "2.23.2",
+  "libVersion": "2.23.3",
   "appid": "wx0fd4b616bc7cf3bb",
   "projectname": "%E8%B5%9B%E5%9C%BA",
   "condition": {}

+ 2 - 2
utils/httpUtil.js

@@ -7,7 +7,7 @@ const $get = (uri, data) => {
       url: `${baseUrl}${uri}`,
       method: "get",
       data,
-      header: { "x-tenant": tenant },
+      header: {},
       success: (res) => toResolve(resolve, res),
       error: (e) => toReject(reject, e),
     });
@@ -21,7 +21,7 @@ const $post = (uri, data) => {
       url: `${baseUrl}${uri}`,
       method: "post",
       data,
-      header: { "x-tenant": tenant },
+      header: {},
       success: (res) => toResolve(resolve, res),
       error: (e) => toReject(reject, e),
     });