diff --git a/src/api/http.js b/src/api/http.js index b8e4749..7d492fb 100644 --- a/src/api/http.js +++ b/src/api/http.js @@ -9,11 +9,11 @@ const DEFAULT_TIMEOUT = 15000; // 错误码定义 const ERR_CODE = { - SUCCESS: 200, - UNAUTHORIZED: 401, - FORBIDDEN: 403, - NOT_FOUND: 404, - SERVER_ERROR: 500, + SUCCESS: 200, + UNAUTHORIZED: 401, + FORBIDDEN: 403, + NOT_FOUND: 404, + SERVER_ERROR: 500, }; function getHeaders(contentType = 'application/json') { @@ -63,6 +63,11 @@ function handleResponse(response) { * 处理 token 失效 */ function handleUnauthorized() { + // 如果 localStorage 中本来就没有 token,说明是未登录状态,不做处理 + if (!localStorage.getItem('member_token')) { + return; + } + // 清除登录状态 localStorage.removeItem('member_token'); localStorage.removeItem('member_username'); diff --git a/src/components/ManagerPopup.vue b/src/components/ManagerPopup.vue index ab29cc5..60f6d90 100644 --- a/src/components/ManagerPopup.vue +++ b/src/components/ManagerPopup.vue @@ -87,6 +87,11 @@ export default { }) }, getPermissions() { + if (!this.$isLogin()) { + // this.$showFailToast('登录状态异常,请重新登录') + // location.replace('#/Login') + return + } this.$get('/v1/client/DUsersClient').then(res => { this.PermissionsData = { id: res.data.id, diff --git a/src/router.js b/src/router.js index a4f3642..7975ce1 100644 --- a/src/router.js +++ b/src/router.js @@ -310,6 +310,9 @@ const routes = [ path: '/SyncAuth', name: 'SyncAuth', component: () => import('./views/SyncAuth.vue'), + meta: { + noLogin: true, + } }, { path: '/404', diff --git a/src/styles/public.less b/src/styles/public.less index e6ecd79..6133c99 100644 --- a/src/styles/public.less +++ b/src/styles/public.less @@ -538,8 +538,9 @@ img { >img { width: 16vw; height: 16vw; - .y50; + border-radius: 50%; margin-right: 2.933vw; + object-fit: contain; } .text { diff --git a/src/views/Account/Login.vue b/src/views/Account/Login.vue index 2a0de54..2532bb4 100644 --- a/src/views/Account/Login.vue +++ b/src/views/Account/Login.vue @@ -164,6 +164,12 @@ export default { location.replace('#/') return } + if (!this.$isLogin) { + this.$showFailToast?.('登录状态异常,请重新登录') + // localStorage.removeItem('member_token') + location.replace('#/Login') + return + } // this.checkWxLogin(); const code = JSON.stringify(this.$route.query.code); if (code) { diff --git a/src/views/Merchant/Merchant.vue b/src/views/Merchant/Merchant.vue index 5fac887..e8be602 100644 --- a/src/views/Merchant/Merchant.vue +++ b/src/views/Merchant/Merchant.vue @@ -149,7 +149,21 @@ export default { name: 'Merchant', components: { ManagerPopup }, mounted() { - this.init() + this.$get('/v1/client/DUsersClient').then(res => { + this.id = res.data.id; + if (!res.data.isshop) { + this.$showFailToast('您不是商家账号!') + // localStorage.removeItem('member_token') + location.replace('#/My') + return + } + this.init(); + }).catch(() => { + this.$showFailToast('登录状态异常,请重新登录') + // localStorage.removeItem('member_token') + location.replace('#/Login') + }) + window.addEventListener('showManagerPopup', this.onShowManagerPopup) window.addEventListener('closeManagerPopup', this.onCloseManagerPopup) }, @@ -160,7 +174,7 @@ export default { data() { return { managerPopupVisible: false, - id: this.$route.query.id, + id: this.$route.query.id || this.$ls.get('user_id'), data: { endTimes: new Date().toLocaleString('zh-CN', { hour12: false }) }, @@ -203,5 +217,4 @@ export default { - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/Platform/Business_School.vue b/src/views/Platform/Business_School.vue index 9500938..d87c97c 100644 --- a/src/views/Platform/Business_School.vue +++ b/src/views/Platform/Business_School.vue @@ -28,7 +28,7 @@
{{ $formatGMT(item.addtime, 'yyyy-MM-dd HH:mm:ss') }} - 阅览量 {{ item.ReadCount }} + 阅览量 {{ item.click }}
diff --git a/src/views/SyncAuth.vue b/src/views/SyncAuth.vue index ec72f4a..0a721f0 100644 --- a/src/views/SyncAuth.vue +++ b/src/views/SyncAuth.vue @@ -3,21 +3,27 @@