yuxingxing 2 years ago
parent
commit
c9c6d51156
2 changed files with 34 additions and 19 deletions
  1. 15 0
      pages/goods_details/index.vue
  2. 19 19
      pages/users/wechat_login/index.vue

+ 15 - 0
pages/goods_details/index.vue

@@ -486,6 +486,21 @@ export default {
 		},
 	},
 	onLoad(options) {
+		// 判断是否登录
+		if(!this.isLogin){
+			this.$Cache.set('INVITE_CODE', options.inviteCode);
+			uni.showToast({
+				title: "您暂未登录,即将跳登录界面",
+				icon: 'none',
+				duration: 2000
+			});
+			setTimeout(() => {
+				// 未登录跳转登录
+				uni.navigateTo({
+					url: '/pages/users/wechat_login/index'
+				})
+			}, 1500);
+		}
 		let userInfo = this.$Cache.get("USER_INFO", true)
 		console.log("用户自己的推荐码:" + userInfo.code);
 		console.log("受邀的推荐码:"+ options.inviteCode);

+ 19 - 19
pages/users/wechat_login/index.vue

@@ -27,7 +27,7 @@
 				open-type="getPhoneNumber" @getphonenumber="getphonenumber"
 					class="bg-green btn1">{{ $t(`微信用户一键登录`) }}</button> -->
 				<button v-if="canUseGetUserProfile && code" open-type="getPhoneNumber" hover-class="none"
-				@getphonenumber="getPhoneCode" class="bg-green btn1">{{ $t(`微信用户一键登录`) }}</button>
+					@getphonenumber="getPhoneCode" class="bg-green btn1">{{ $t(`微信用户一键登录`) }}</button>
 				<button v-else hover-class="none" open-type="getUserInfo" @getuserinfo="setUserInfo"
 					class="bg-green btn1">{{ $t(`微信用户一键登录`) }}</button>
 				<!-- #endif -->
@@ -185,7 +185,7 @@ export default {
 				this.isPhoneBox = false;
 			}
 		},
-		getPhoneCode (e) {
+		getPhoneCode(e) {
 			console.log(e.detail.code)
 			uni.showLoading({
 				title: this.$t(`正在登录中`)
@@ -198,26 +198,26 @@ export default {
 				// spread_code: app.globalData.code
 			})
 				.then(res => {
-					if(res.code == 200){
+					if (res.code == 200) {
 						this.$store.commit('LOGIN', {
-						token: res.data.access_token,
-						time: res.data.expires_in
-					});
-					this.$store.commit('OPENID',res.data.openId);
-					this.getUserInfo();
-					}else {
+							token: res.data.access_token,
+							time: res.data.expires_in
+						});
+						this.$store.commit('OPENID', res.data.openId);
+						this.getUserInfo();
+					} else {
 						uni.hideLoading();
 						uni.showToast({
-						title: "手机号暂未注册,即将跳转注册界面",
-						icon: 'none',
-						duration: 2000
-					});
-					setTimeout(() => {
-						// 自动登录失败时,跳转用户注册
-						uni.navigateTo({
-							url: '/pages/users/register/index?account='+res.data.user_name
-						})
-					}, 2000);
+							title: "手机号暂未注册,即将跳转注册界面",
+							icon: 'none',
+							duration: 2000
+						});
+						setTimeout(() => {
+							// 自动登录失败时,跳转用户注册
+							uni.navigateTo({
+								url: '/pages/users/register/index?account=' + res.data.user_name
+							})
+						}, 2000);
 					}
 				})
 				.catch(res => {