Răsfoiți Sursa

登录流程修改

shish 6 ani în urmă
părinte
comite
0471fe84a6

+ 1 - 1
mall/src/App.vue

@@ -20,7 +20,7 @@ export default {
     // #endif
     // #endif
 
 
     // #ifdef H5
     // #ifdef H5
-    // h5开发环境使用固定的用户 shish 2020.4.30
+    // H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
     if (process.env.NODE_ENV == "development") {
     if (process.env.NODE_ENV == "development") {
       uni.setStorageSync(
       uni.setStorageSync(
         "token",
         "token",

+ 37 - 45
mall/src/mixins/globalMixins.js

@@ -19,7 +19,7 @@ export default {
 	// 	...mapGetters({ userInfo: 'getUser' })
 	// 	...mapGetters({ userInfo: 'getUser' })
 	// },
 	// },
 	// 页面生命周期才触发
 	// 页面生命周期才触发
-	onLoad: function(option) {
+	onLoad: function (option) {
 		this.option = option || null
 		this.option = option || null
 		if (option.token) {
 		if (option.token) {
 			uni.setStorageSync('token', option.token)
 			uni.setStorageSync('token', option.token)
@@ -33,67 +33,59 @@ export default {
 			}
 			}
 		}
 		}
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
+
+		// #ifdef MP-WEIXIN
+		//检查小程序的登录态是否有效 checkSession
+        uni.checkSession({  
+            success(){  
+                console.log('checkSession success')
+            },  
+            fail(){  
+				uni.removeStorageSync('token');
+            }  
+		})
+		// #endif
+
 		// 登录
 		// 登录
-		if (constant.source == 'business' || constant.source == 'mall') {
-			if (isLogin()) {
-				// #ifdef H5
-				if (this.init) {
-					if (constant.source == 'business') {
-						getUser()
-					}
-					this.init()
-					// console.log('init', this.init)
-				}
-				// #endif
-				// #ifdef MP-WEIXIN
-				wxLoginFn().then(res => {
-					if (this.init) {
-						if (constant.source == 'business') {
-							getUser()
-						}
-						this.init()
-					}
-				})
-				// #endif
-			} else {
-				// #ifdef H5
-				getCheckLogin().then(res => {
-					if (constant.source == 'business') {
-						if (res) {
-							getUser()
-						}
-					}
-				})
-				// #endif
-				// #ifdef MP-WEIXIN
-				wxLoginFn().then(res => {
-					if (this.init) {
-						if (constant.source == 'business') {
-							getUser()
-						}
-						this.init()
-					}
-				})
-				// #endif
+		if (isLogin()) {
+			// #ifdef H5
+			if (this.init) {
+				this.init()
 			}
 			}
-		}
-		if (constant.source == 'official') {
+			// #endif
+			// #ifdef MP-WEIXIN
 			if (this.init) {
 			if (this.init) {
 				this.init()
 				this.init()
 			}
 			}
+			// #endif
+		} else {
+			// #ifdef H5
+			getCheckLogin().then(res => {
+			})
+			// #endif
+			// #ifdef MP-WEIXIN
+			console.log('执行这里。。。111')
+			wxLoginFn().then(res => {
+				if (this.init) {
+					this.init()
+				}
+			})
+
+			// #endif
 		}
 		}
+
 	},
 	},
 	mounted() {
 	mounted() {
 		if (this.mInit) {
 		if (this.mInit) {
 			// #ifdef H5
 			// #ifdef H5
 			this.mInit()
 			this.mInit()
 			// #endif
 			// #endif
+
 			// #ifdef MP-WEIXIN
 			// #ifdef MP-WEIXIN
 			// wxLoginFn().then(res => {
 			// wxLoginFn().then(res => {
 			// 	this.mInit()
 			// 	this.mInit()
 			// })
 			// })
 			// #endif
 			// #endif
-			// console.log('init', this.mInit)
 		}
 		}
 	}
 	}
 }
 }

+ 6 - 6
mall/src/plugins/luch-request_0.0.7/request.js

@@ -170,9 +170,9 @@ class Request {
 							})
 							})
 							setTimeout(() => {
 							setTimeout(() => {
 								getCheckLogin()
 								getCheckLogin()
-								// uni.reLaunch({
-								// 	url: `/pages/page/login/index`
-								// })
+								uni.reLaunch({
+									url: `/pages/home/index`
+								})
 							}, 1000)
 							}, 1000)
 						} else if (response.data.code == 2) {
 						} else if (response.data.code == 2) {
 							uni.removeStorageSync('token')
 							uni.removeStorageSync('token')
@@ -185,9 +185,9 @@ class Request {
 							})
 							})
 							setTimeout(() => {
 							setTimeout(() => {
 								getCheckLogin()
 								getCheckLogin()
-								// uni.reLaunch({
-								// 	url: `/pages/page/login/index`
-								// })
+								uni.reLaunch({
+									url: `/pages/home/index`
+								})
 							}, 1000)
 							}, 1000)
 						} else {
 						} else {
 							console.log('response.data', response.data)
 							console.log('response.data', response.data)