Bladeren bron

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

YY 3 jaren geleden
bovenliggende
commit
28523e7b46
8 gewijzigde bestanden met toevoegingen van 64 en 77 verwijderingen
  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. 10 20
      pages/login/index.js
  7. 1 1
      project.config.json
  8. 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 })
-},
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 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 })
+      }
     }
   },
   // 微信登录

+ 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),
     });