浏览代码

登陆确认弹窗

chenjj 12 小时之前
父节点
当前提交
754e4519f4
共有 2 个文件被更改,包括 20 次插入19 次删除
  1. 4 3
      pages/mine.vue
  2. 16 16
      utils/request.ts

+ 4 - 3
pages/mine.vue

@@ -72,10 +72,11 @@
 					</view>
 				</view>
 
-				<view class="logout-box">
+			</view>
+			
+			<view class="logout-box" v-if="getToken()">
 					<view class="logout-btn" @click="onLogou">退出登陆</view>
 				</view>
-			</view>
 		</view>
 		<CustomTabBar page="mine" />
 	</view>
@@ -614,7 +615,7 @@ const init = async () => {
 }
 
 .logout-box {
-	margin-top: 24rpx;
+	padding: 40rpx;
 
 	.logout-btn {
 		border-radius: 16rpx;

+ 16 - 16
utils/request.ts

@@ -42,23 +42,23 @@ const request = <T>(config:RequestConfig):Promise<ResponseData<T>> => {
       // @ts-ignore
       const msg:string = errorCode[code] || data.msg || errorCode['default']
       if (code === 401) {
-        // showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
-        //   if (res.confirm) {
-        //     store.dispatch('LogOut').then(res => {
-        //       uni.reLaunch({ url: '/pages/login' })
-        //     })
-        //   }
-        // })
+        showConfirm('您还未登陆系统,是否前往登陆?').then(res => {
+          if (res.confirm) {
+            store.dispatch('LogOut').then(res => {
+              uni.reLaunch({ url: '/pages/login' })
+            })
+          }
+        })
 
-        uni.showToast({
-          title: '登陆后可以享受更多的服务哦',
-          icon: 'none',
-        });
-        setTimeout(() => {
-          store.dispatch('LogOut').then(res => {
-            uni.reLaunch({ url: '/pages/login' })
-          })
-        }, 500);
+        // uni.showToast({
+        //   title: '登陆后可以享受更多的服务哦',
+        //   icon: 'none',
+        // });
+        // setTimeout(() => {
+        //   store.dispatch('LogOut').then(res => {
+        //     uni.reLaunch({ url: '/pages/login' })
+        //   })
+        // }, 500);
 
         reject('无效的会话,或者会话已过期,请重新登录。')
       } else if (code === 500) {