Browse Source

修复bug

chenxiong 3 years ago
parent
commit
7371990062
2 changed files with 27 additions and 18 deletions
  1. 7 3
      common/request.js
  2. 20 15
      pages/index/index.vue

+ 7 - 3
common/request.js

@@ -105,9 +105,13 @@ export const myRequest = (options) => {
 			let onset = await myRequest(response)
 			return onset
 		} else {
-			uni.navigateTo({
-				url: '/pages/login/login'
-			});
+			var pages = getCurrentPages() // 获取栈实例
+			let currentRoute  = pages[pages.length-1].route; // 获取当前页面路由
+			if(currentRoute != 'pages/login/login') {
+				uni.navigateTo({
+					url: '/pages/login/login'
+				});
+			}
 		}
 	}
 }

+ 20 - 15
pages/index/index.vue

@@ -182,11 +182,11 @@ export default {
 		};
 	},
 	onPullDownRefresh() {},
-	onLoad(option) {
-		this.init()
+	async onLoad(option) {
 		this.courseList();
 		this.bankList();
 		this.getAdvertising();
+		await this.init()
 	},
 	onShow() {
 		if (uni.getStorageSync('updateHome')){
@@ -481,19 +481,24 @@ export default {
 			}
 		},
 		async init() {
-			if (!this.$method.isLogin()) {
-				//未登录
-				this.date_num = [];
-				this.workList = [];
-				this.planGoodsList = [];
-				this.initDay();
-			} else {
-				this.date_num = [];
-				this.workList = [];
-				this.planGoodsList = [];
-				await this.userPlanSeven();
-				await this.getUserSubscribeRecentExam();
-			}
+			return new Promise(async resolve => {
+				if (!this.$method.isLogin()) {
+					//未登录
+					this.date_num = [];
+					this.workList = [];
+					this.planGoodsList = [];
+					this.initDay();
+				} else {
+					this.date_num = [];
+					this.workList = [];
+					this.planGoodsList = [];
+					await this.userPlanSeven();
+					await this.getUserSubscribeRecentExam();
+				}
+				
+				resolve()
+			})
+			
 		},
 		getMonDate() {
 			var d = new Date(),