Jelajahi Sumber

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

zs 2 tahun lalu
induk
melakukan
0e19dc2d13
3 mengubah file dengan 14 tambahan dan 10 penghapusan
  1. 10 7
      pages/my/index.js
  2. 1 1
      pages/my/index.wxml
  3. 3 2
      utils/dict.js

+ 10 - 7
pages/my/index.js

@@ -29,19 +29,22 @@ Page({
         const that = this;
         that.watchLogin();
     },
-
-    watchLogin: function () {
+    watchLogin: async function () {
         const that = this;
         wx.getStorage({
             key: 'user',
             success: async (res) => {
-                console.log('已登陆');
+                const arr = await app.$get(`/newCourt/api/user/${res.data.openid}`);
+                if (arr.errcode == '0') {
+                    let user = arr.data;
+                    that.setData({ user: user });
+                    let btn = myBtn.filter((i) => i.type.includes(user.type));
+                    that.setData({ btnList: btn })
+
+                } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
             },
             fail: async (res) => {
-                console.log('未登陆');
-                let user = { icon: '/image/icon.jpg', name: '顾红伟', phone: '12345678901', type: '1' }
-                that.setData({ user: user })
-                console.log(user);
+                wx.redirectTo({ url: '/pages/index/index' });
             },
         });
     },

+ 1 - 1
pages/my/index.wxml

@@ -5,7 +5,7 @@
             <view class="one_2">
                 <view class="l">
                     <view class="l_1">
-                        <image class="icon" src="{{user.icon}}"></image>
+                        <image class="icon" src="{{user.icon&&user.icon.length>0?user.icon[0].url:''}}"></image>
                     </view>
                     <view class="l_2">
                         <view class="info textOver">{{user.name}}</view>

+ 3 - 2
utils/dict.js

@@ -16,9 +16,10 @@ export const match_status = [
     { label: '5', value: '比赛结束' },
 ]
 // 我的页面,功能按钮
+// -1:管理员,0:普通用户,1:裁判用户
 export const myBtn = [
-    { title: '我的赛事', route: 'usermymatch' },
-    { title: '账号设置', route: 'setting' }
+    { title: '我的赛事', route: 'usermymatch', type: '0' },
+    { title: '账号设置', route: 'setting', type: '-1|0' }
 ]
 
 export const gender = [