|
@@ -1,5 +1,6 @@
|
|
|
|
|
|
-const app = getApp()
|
|
|
+const app = getApp();
|
|
|
+const { system, admin, county, user } = require('../../utils/dict');
|
|
|
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
|
|
Page({
|
|
|
|
|
@@ -12,16 +13,7 @@ Page({
|
|
|
infoHeight: '',
|
|
|
avatarUrl: defaultAvatarUrl,
|
|
|
userInfo: {},
|
|
|
- routerList: [
|
|
|
- { icon: 'icon-quxiantongxunlu', title: '区县人员', router: 'county' },
|
|
|
- { icon: 'icon-kuaibananjian', title: '办案人员', router: 'user' },
|
|
|
- { icon: 'icon-shanghuguanli', title: '商户信息', router: 'merchant' },
|
|
|
- { icon: 'icon-shouye', title: '检查历史', router: 'inspect' },
|
|
|
- { icon: 'icon-shangpinxinxi', title: '商品信息', router: 'market' },
|
|
|
- { icon: 'icon-bangdingweixin', title: '绑定微信', router: '', is_routine: '1' },
|
|
|
- { icon: 'icon-xiugaimima', title: '修改密码', router: 'password', },
|
|
|
- { icon: 'icon-tuichudenglu', title: '退出登录', router: 'login' },
|
|
|
- ]
|
|
|
+ routerList: []
|
|
|
},
|
|
|
|
|
|
onChooseAvatar(e) {
|
|
@@ -33,6 +25,14 @@ Page({
|
|
|
const { data } = e.currentTarget.dataset;
|
|
|
if (data.is_routine && data.is_routine == '1') {
|
|
|
wx.showToast({ title: `绑定微信成功`, icon: 'success', duration: 2000 })
|
|
|
+ } else if (data.is_routine && data.is_routine == '2') {
|
|
|
+ wx.clearStorage({
|
|
|
+ key: 'toekn',
|
|
|
+ success: res => {
|
|
|
+ wx.showToast({ title: `退出登录成功`, icon: 'success', duration: 2000 })
|
|
|
+ wx.redirectTo({ url: '/pages/login/index', })
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
wx.navigateTo({ url: `/pages/${data.router}/index` })
|
|
|
}
|
|
@@ -41,10 +41,23 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
+
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'token',
|
|
|
+ success: res => {
|
|
|
+ if (res.data) {
|
|
|
+ let userInfo = app.globalData.userInfo;
|
|
|
+ if (userInfo) this.setData({ userInfo: userInfo });
|
|
|
+
|
|
|
+ if (userInfo) this.searchRouter();
|
|
|
+ } else {
|
|
|
+ wx.redirectTo({ url: '/pages/login/index', })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- this.searchHeight()
|
|
|
- let userInfo = app.globalData.userInfo;
|
|
|
- if (userInfo) this.setData({ userInfo: userInfo })
|
|
|
+ this.searchHeight();
|
|
|
+
|
|
|
},
|
|
|
|
|
|
searchHeight: function () {
|
|
@@ -56,6 +69,19 @@ Page({
|
|
|
if (frameStyle.useBar) infoHeight = infoHeight - 50;
|
|
|
if (infoHeight) this.setData({ infoHeight: infoHeight })
|
|
|
},
|
|
|
+
|
|
|
+ searchRouter() {
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'role',
|
|
|
+ success: res => {
|
|
|
+ var data = [];
|
|
|
+ if (res.data == '1') { data = [...admin, ...system] }
|
|
|
+ else if (res.data == '2') { data = [...county, ...system] }
|
|
|
+ else if (res.data == '3') { data = [...user, ...system] }
|
|
|
+ this.setData({ routerList: data })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|