YY hace 2 años
padre
commit
4c3b1591d5
Se han modificado 3 ficheros con 29 adiciones y 7 borrados
  1. 4 1
      pages/index/index.js
  2. 20 2
      pages/match/index.js
  3. 5 4
      pagesMatch/system/index.js

+ 4 - 1
pages/index/index.js

@@ -45,7 +45,10 @@ Page({
             // 没有用户,去注册
             // 没有用户,去注册
             if (!data) wx.redirectTo({ url: '/pages/register/index' });
             if (!data) wx.redirectTo({ url: '/pages/register/index' });
             // 有用户,存起来,跳转
             // 有用户,存起来,跳转
-            else { wx.setStorageSync('user', data); wx.redirectTo({ url: '/pages/school/index' }); }
+            else {
+                wx.setStorageSync('user', data);
+                wx.redirectTo({ url: '/pages/school/index' });
+            }
         }
         }
     },
     },
     /**
     /**

+ 20 - 2
pages/match/index.js

@@ -20,8 +20,26 @@ Page({
     // 进入系统
     // 进入系统
     toJoin: function () {
     toJoin: function () {
         const that = this;
         const that = this;
-        that.setData({ skip: 0, page: 0, list: [] })
-        wx.navigateTo({ url: `/pagesMatch/system/index` })
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                if (res.data.type == '10') {
+                    wx.showModal({ title: '提示', content: '游客不能进入比赛系统,请注册成为正式用户' })
+                } else {
+                    const arr = await app.$post(`/user/login`, { openid: res.data.openid }, 'race');
+                    if (arr.errcode == '0') {
+                        wx.setStorageSync('raceuser', arr.data);
+                        that.setData({ skip: 0, page: 0, list: [] })
+                        wx.navigateTo({ url: `/pagesMatch/system/index` })
+                    } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
+                }
+
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+
     },
     },
     // 选择类型
     // 选择类型
     typeChange: function (e) {
     typeChange: function (e) {

+ 5 - 4
pagesMatch/system/index.js

@@ -42,12 +42,13 @@ Page({
     watchLogin: async function () {
     watchLogin: async function () {
         const that = this;
         const that = this;
         wx.getStorage({
         wx.getStorage({
-            key: 'user',
+            key: 'raceuser',
             success: async res => {
             success: async res => {
-                const arr = await app.$post(`/user/login`, { openid: res.data.openid }, 'race');
+                const arr = await app.$get(`/user/${res.data._id}`, {}, 'race');
                 if (arr.errcode == '0') {
                 if (arr.errcode == '0') {
-                    that.setData({ user: arr.data.user_id })
-                    let btnData = match_menu.find((i) => i.type == arr.data.type);
+                    console.log(arr.data);
+                    that.setData({ user: arr.data })
+                    let btnData = match_menu.find((i) => i.type == '1');
                     that.setData({ list: [...btnData.menu, ...school_sysmenu] })
                     that.setData({ list: [...btnData.menu, ...school_sysmenu] })
                 }
                 }
                 else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
                 else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }