wangxy il y a 4 jours
Parent
commit
deb3982f0f
1 fichiers modifiés avec 52 ajouts et 114 suppressions
  1. 52 114
      pages/Login/test.vue

+ 52 - 114
pages/Login/test.vue

@@ -6,18 +6,8 @@
 				<view class="bjcx-logo-title">家政学</view>
 				<view class="bjcx-logo-title">家政学</view>
 			</view>
 			</view>
 
 
-			<!-- 如果是APP分享过来的,显示微信授权界面    		@getuserinfo="onWechatAuth"-->
-
-			<view v-if="fromAppShare" class="wechat-auth-box">
-				<view class="auth-tips">欢迎使用小程序</view>
-				<button class="wechat-auth-btn" open-type="getUserInfo"@getuserinfo="onWechatAuth">
-					微信一键登录
-				</button>
-				<view class="switch-login" @click="switchToNormalLogin">使用账号登录</view>
-			</view>
-
 			<!-- 普通登录表单 -->
 			<!-- 普通登录表单 -->
-			<view v-else>
+			<view>
 				<view class="login-input-box">
 				<view class="login-input-box">
 					<icon class="user-icon"></icon>
 					<icon class="user-icon"></icon>
 					<input class="login-input" type="text" v-model="userName" placeholder="请输入手机号"
 					<input class="login-input" type="text" v-model="userName" placeholder="请输入手机号"
@@ -47,6 +37,10 @@
 
 
 				<button type="default" @click="handleLogin" :disabled="!isAgreed"
 				<button type="default" @click="handleLogin" :disabled="!isAgreed"
 					class="phone-green-btn login-btn">登录</button>
 					class="phone-green-btn login-btn">登录</button>
+
+        <button @click="handleChangeYijiandenglu">
+          切换微信一键登录
+        </button>
 			</view>
 			</view>
 		</view>
 		</view>
 	</view>
 	</view>
@@ -87,88 +81,34 @@
 	const store = useIsCanBack();
 	const store = useIsCanBack();
 
 
 	onLoad((options) => {
 	onLoad((options) => {
-		// 判断是否来自APP分享
-		if (options.from === 'appcx') {
-			fromAppShare.value = true
-			id.value = options.id
-			// APP分享过来直接显示微信授权界面,不需要自动弹窗
-			fromPage.value = options.from;
-		}
+    fromPage.value = options.from;
+    id.value = options.id
 		getAllImg();
 		getAllImg();
 	})
 	})
 
 
-	// 切换到普通登录
-	function switchToNormalLogin() {
-		fromAppShare.value = false
-	}
-
-	function phoneBind() {
-		uni.navigateTo({
-			url: '/pages/Login/AliyunCaptcha?code='+code.value,
-			events: {
-				getCaptchaVerifyParam: (captchaVerifyParam) => {
-					// 接收到验证码返回结果
-					console.log('验证码返回结果:', captchaVerifyParam)
-				}
-			},
-			success: () => {
-				console.log('跳转到验证码页面成功')
-			},
-			fail: (err) => {
-				console.error('跳转到验证码页面失败:', err)
-				toast('验证码加载失败,请重试')
-			}
-		})
-	}
 
 
-	// 微信授权登录
-	async function onWechatAuth(e) {
-		if (e.detail.errMsg.includes('fail')) {
-			toast('授权失败')
-			return
-		}
-
-		uni.showLoading({
-			title: '登录中'
-		})
-		console.log('e', e);
-		try {
-			// 获取微信code
-			const loginRes = await uni.login()
-			console.log('loginRes', loginRes);
-			code.value = loginRes.code
-			// 调用后端微信登录接口
-			const result = await httpApi.loginApplet({
-				code: loginRes.code,
-				userInfo: e.detail.userInfo
-			})
-			console.log('result', result);
-			console.log('result', result);
-				phoneBind()
-			// if (result.data.bind) {
-			// 	// 保存用户信息
-			// 	if (result.data.loginVo.type == 4) {
-			// 		cacheManager.set('auth', result.data.loginVo)
-			// 		store.setIsCanBack(false)
-			// 		gotoPage();
-			// 	} else if (result.data.loginVo.type == 6) {
-			// 		cacheManager.set('auth', result.data.loginVo)
-			// 		store.setIsCanBack(false)
-			// 		gotoPage2();
-			// 	} else {
-			// 		toast('登录失败,您的身份有误,请联系管理员。')
-			// 	}
-			// } else {
-			// 	//  bind 为 false 未绑定
-
-			// 	phoneBind()
-			// }
-		} catch (error) {
-			toast('微信登录失败')
-		} finally {
-			uni.hideLoading()
-		}
-	}
+  function handleChangeYijiandenglu() {
+    let str = ``;
+    if (id.value) {
+      str = str+`id=${id.value}`
+    }
+    if ( id.value && fromPage.value ) {
+      str = str +`&from=${fromPage.value}`
+    } else if (!id.value && fromPage.value) {
+      str = str + `from=${fromPage.value}`
+    }
+
+    if (str) {
+      uni.redirectTo({
+        url: `/pages/Login/clientIndex?${str}`
+      })
+    } else {
+      uni.redirectTo({
+        url: `/pages/Login/clientIndex`
+      })
+    }
+
+  }
 
 
 	// 你原有的所有方法都不变
 	// 你原有的所有方法都不变
 	function handleChange() {
 	function handleChange() {
@@ -258,31 +198,29 @@
 		})
 		})
 	}
 	}
 
 
-	function gotoPage() {
-			console.log('ididid',id.value);
-		if (id.value) {
-			uni.navigateTo({
-				url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
-			})
-		} else {
-			uni.navigateTo({
-				url: `/pages/client/ShouYe/shouye`
-			})
-		}
-	}
-
-	function gotoPage2() {
-			console.log('ididid222222',id.value);
-		if (id.value) {
-			uni.navigateTo({
-				url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
-			})
-		} else {
-			uni.navigateTo({
-				url: `/pages/kehu/shouye/shouye`
-			})
-		}
-	}
+  function gotoPage() {
+    if (id.value) {
+      uni.navigateTo({
+        url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
+      })
+    } else {
+      uni.navigateTo({
+        url: `/pages/client/ShouYe/shouye`
+      })
+    }
+  }
+
+  function gotoPage2() {
+    if (id.value) {
+      uni.navigateTo({
+        url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
+      })
+    } else {
+      uni.navigateTo({
+        url: `/pages/kehu/shouye/shouye`
+      })
+    }
+  }
 
 
 	function getAllImg() {
 	function getAllImg() {
 		httpApi.getAllImgList({}).then(res => {
 		httpApi.getAllImgList({}).then(res => {