فهرست منبع

【ID1006535】默认进入首页,记录登录态

chenrui 4 سال پیش
والد
کامیت
ec1603e52d
3فایلهای تغییر یافته به همراه22 افزوده شده و 9 حذف شده
  1. 11 0
      libs/axios.js
  2. 8 8
      pages.json
  3. 3 1
      pages/login/login.vue

+ 11 - 0
libs/axios.js

@@ -43,6 +43,17 @@ const request = (opts, hasToken) => {
 							mask: true,
 							duration: 5000 
 						})
+					}else{
+						uni.showToast({
+							icon:'none',
+							title: '未登录或登录已过期,请重新登录',
+							duration: 5000 
+						})
+						setTimeout(function() {
+						  const currentRoute = getRoutePath()
+						  const url = `/pages/login/login?lanuch=${currentRoute.lanuch}&path=` + encodeURIComponent(currentRoute.url)
+						  uni.redirectTo({ url })
+						}, 1000);
 					}
 					resolve(ret)
 				}

+ 8 - 8
pages.json

@@ -4,23 +4,23 @@
 	},
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 		{
-			"path": "pages/login/login",
+			"path": "pages/index/index", // 待清运
 			"style": {
-				"navigationBarTitleText": "登录"
+				"navigationBarTitleText": "待清运清单",
+				"enablePullDownRefresh": false,
+				"navigationStyle": "custom"
 			}
 		},
 		{
-			"path": "pages/login/pwLogin",
+			"path": "pages/login/login",
 			"style": {
-				"navigationBarTitleText": "密码登录"
+				"navigationBarTitleText": "登录"
 			}
 		},
 		{
-			"path": "pages/index/index", // 待清运
+			"path": "pages/login/pwLogin",
 			"style": {
-				"navigationBarTitleText": "待清运清单",
-				"enablePullDownRefresh": false,
-				"navigationStyle": "custom"
+				"navigationBarTitleText": "密码登录"
 			}
 		},
 		{

+ 3 - 1
pages/login/login.vue

@@ -39,6 +39,8 @@
 		},
 		mounted() {},
 		onLoad(option) {
+			//  隐藏小房子
+			uni.hideHomeButton()
 			// 为解决首次登录异常问题 进入页面先调微信登录获取code
 			this.wxLogin()
 			const {
@@ -80,7 +82,7 @@
 						}).then(res => {
 							uni.hideLoading();
 							_this.code = ''
-							if (res.status == '200') {
+							if (res.status == 200) {
 								getApp().globalData.token = res.data
 								_this.$u.vuex('vuex_token',res.data)
 								uni.$emit("getUserInfo")