diff --git a/apis/request.js b/apis/request.js index 35a7498..a9ce542 100644 --- a/apis/request.js +++ b/apis/request.js @@ -15,22 +15,22 @@ const request = options => { method: options.method || 'GET', // 请求类型,默认为GET data: options.data || {}, // 请求参数,默认空对象 success: ({ data }) => { - const { status, message } = data + const { status, code, message } = data // 状态判断,根据后台定义并提示 if (status === 200) { resolve(data) - } else if (status == 401) { + } else if (status == 401 || code == 401) { if (!logouted) { // 登录过期 uni.clearStorageSync() uni.showToast({ - title: message, + title: message || '登录过期,请重新登录', icon: 'none' }) setTimeout(() => { logouted = 0 uni.reLaunch({ - url: '/pages/index/index' + url: '/pages/login/login' }) }, 1500) reject(data) diff --git a/pages/index/index.vue b/pages/index/index.vue index ddae866..f2271e5 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -112,30 +112,32 @@ methods: { // 查询当前角色权限 getAuth() { - uni.showLoading({ - title: '加载中' - }) - uni.getStorageSync('token') && getUserRolesPermissionMenu({ - platformId: 3 - }).then(res => { - uni.hideLoading() - const auth = [] - // 生成权限数组 - const generateAuth = (list, parent) => { - list.map(e => { - const name = `${parent ? parent + ':' : ''}${e.name}` - auth.push(name) - generateAuth(e.children, name) - }) - } - generateAuth(res.permissionMenu[0].children, '') - uni.setStorageSync('dataPermission', res.dataPermissionList) - uni.setStorageSync('auth', auth) - this.$forceUpdate() - }).catch(e => { - uni.hideLoading() - uni.setStorageSync('auth', []) - }) + if (uni.getStorageSync('token')) { + uni.showLoading({ + title: '加载中' + }) + getUserRolesPermissionMenu({ + platformId: 3 + }).then(res => { + uni.hideLoading() + const auth = [] + // 生成权限数组 + const generateAuth = (list, parent) => { + list.map(e => { + const name = `${parent ? parent + ':' : ''}${e.name}` + auth.push(name) + generateAuth(e.children, name) + }) + } + generateAuth(res.permissionMenu[0].children, '') + uni.setStorageSync('dataPermission', res.dataPermissionList) + uni.setStorageSync('auth', auth) + this.$forceUpdate() + }).catch(e => { + uni.hideLoading() + uni.setStorageSync('auth', []) + }) + } }, // 提示暂未开放 toPanel(i) { diff --git a/team/setting/setting.vue b/team/setting/setting.vue index 909ddc6..fcaf093 100644 --- a/team/setting/setting.vue +++ b/team/setting/setting.vue @@ -3,7 +3,7 @@ - +