|
@@ -7,9 +7,7 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '我的', leftArrow: false, useBar: true },
|
|
|
- user: {
|
|
|
-
|
|
|
- },
|
|
|
+ user: {},
|
|
|
btnList: [],
|
|
|
},
|
|
|
// 跳转菜单
|
|
@@ -31,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' });
|
|
|
},
|
|
|
});
|
|
|
},
|