wangguoyu il y a 13 heures
Parent
commit
2fa54b21e6
1 fichiers modifiés avec 80 ajouts et 90 suppressions
  1. 80 90
      pages/Login/clientIndex.vue

+ 80 - 90
pages/Login/clientIndex.vue

@@ -5,11 +5,12 @@
 				<icon class="bjcx-logo-box"></icon>
 				<icon class="bjcx-logo-box"></icon>
 				<view class="bjcx-logo-title">家政学</view>
 				<view class="bjcx-logo-title">家政学</view>
 			</view>
 			</view>
+			<!-- 合同分享下 -->
 			<view v-if="fromAppShare" class="wechat-auth-box">
 			<view v-if="fromAppShare" class="wechat-auth-box">
 				<view class="auth-tips">欢迎使用小程序</view>
 				<view class="auth-tips">欢迎使用小程序</view>
-				
-				
-				<!-- 协议勾选框和按钮 -->
+				<button class="wechat-auth-btn" open-type="getPhoneNumber" @getphonenumber="onWechatAuth">
+					微信一键登录
+				</button>
 				<view class="agreement-checkbox-box">
 				<view class="agreement-checkbox-box">
 					<checkbox-group @change="handleChange">
 					<checkbox-group @change="handleChange">
 						<checkbox class="agreement-checkbox-input" color="#3fd2a1" value="agree" :checked="isAgreed"
 						<checkbox class="agreement-checkbox-input" color="#3fd2a1" value="agree" :checked="isAgreed"
@@ -20,18 +21,10 @@
 							@click="agreeBtn('ystk')" class="agreement-text">《诚祥学隐私政策》</view>,如您同意,请勾选后开始使用
 							@click="agreeBtn('ystk')" class="agreement-text">《诚祥学隐私政策》</view>,如您同意,请勾选后开始使用
 					</view>
 					</view>
 				</view>
 				</view>
-				
-				<button v-if="!isAgreed">微信一键登录</button>
-				<button v-else class="wechat-auth-btn" open-type="getPhoneNumber" @getphonenumber="onWechatAuth">
-					微信一键登录
-				</button>
-
 				<button @click="handleChangeFangshi">
 				<button @click="handleChangeFangshi">
-				  切换微信一键登录
+					切换微信一键登录
 				</button>
 				</button>
-		
 			</view>
 			</view>
-		<!-- 	<view @click="ceshi" class="auth-tips">欢迎使用小程序12312312312312</view> -->
 		</view>
 		</view>
 	</view>
 	</view>
 </template>
 </template>
@@ -67,46 +60,14 @@
 	const openId = ref('');
 	const openId = ref('');
 
 
 	// 新增变量
 	// 新增变量
-	const fromAppShare = ref(false) // 是否来自APP分享
+	const fromAppShare = ref(true) // 是否来自APP分享
 
 
 	const store = useIsCanBack();
 	const store = useIsCanBack();
 
 
 	onLoad((options) => {
 	onLoad((options) => {
-		if (options.from === 'appcx') {
-			id.value = options.id
-			fromPage.value = options.from;
-		}
-		uni.login().then(res1 => {
-			console.log('res1', res1);
-			code.value = res1.code
-			httpApi.loginApplet({
-				code: res1.code,
-			}).then(result => {
-				console.log('result', result);
-				openId.value = result.data.openId
-				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('登录失败,您的身份有误,请联系管理员。')
-						return
-					}
-				} else {
-					fromAppShare.value = true
-				}
-			})
-		})
 		getAllImg();
 		getAllImg();
 	})
 	})
 
 
-	// 你原有的所有方法都不变
 	function handleChange() {
 	function handleChange() {
 		isAgreed.value = !isAgreed.value
 		isAgreed.value = !isAgreed.value
 	}
 	}
@@ -122,8 +83,34 @@
 			})
 			})
 		}
 		}
 	}
 	}
+
+	function handleChangeFangshi() {
+		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/test?${str}`
+			})
+		} else {
+			uni.redirectTo({
+				url: `/pages/Login/test`
+			})
+		}
+	}
 	// 微信授权登录
 	// 微信授权登录
 	function onWechatAuth(e) {
 	function onWechatAuth(e) {
+		if (!isAgreed.value) {
+			toast('请先阅读并同意用户协议和隐私政策')
+			return // 直接返回,不执行后面的授权逻辑
+		}
 		if (e.detail.errMsg.includes('fail')) {
 		if (e.detail.errMsg.includes('fail')) {
 			toast('授权失败')
 			toast('授权失败')
 			return
 			return
@@ -131,25 +118,51 @@
 		uni.showLoading({
 		uni.showLoading({
 			title: '登录中'
 			title: '登录中'
 		})
 		})
-		console.log('e123123123', e);
 		try {
 		try {
-			httpApi.bindApplet({
-				code: e.detail.code,
-				openId: openId.value,
-			}).then(result => {
-				if (result.data.type == 4) {
-					cacheManager.set('auth', result.data)
-					store.setIsCanBack(false)
-					gotoPage();
-				} else if (result.data.type == 6) {
-					cacheManager.set('auth', result.data)
-					store.setIsCanBack(false)
-					gotoPage2();
-				} else {
-					toast('登录失败,您的身份有误,请联系管理员。')
-				}
+			uni.login().then(res1 => {
+				console.log('res2222222', res1);
+				code.value = res1.code
+				httpApi.loginApplet({
+					code: res1.code,
+				}).then(result => {
+					console.log('result2222', result);
+					openId.value = result.data.openId
+					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('登录失败,您的身份有误,请联系管理员。')
+							return
+						}
+					} else {
+						console.log('1231');
+						//.value = true
+						httpApi.bindApplet({
+							code: e.detail.code,
+							openId: openId.value,
+						}).then(result => {
+							if (result.data.type == 4) {
+								cacheManager.set('auth', result.data)
+								store.setIsCanBack(false)
+								gotoPage();
+							} else if (result.data.type == 6) {
+								cacheManager.set('auth', result.data)
+								store.setIsCanBack(false)
+								gotoPage2();
+							} else {
+								toast('登录失败,您的身份有误,请联系管理员。')
+							}
+						})
+					}
+				})
 			})
 			})
-
 		} catch (error) {
 		} catch (error) {
 			toast('bindApplet失败')
 			toast('bindApplet失败')
 		} finally {
 		} finally {
@@ -160,11 +173,11 @@
 	function gotoPage() {
 	function gotoPage() {
 		console.log('ididid', id.value);
 		console.log('ididid', id.value);
 		if (id.value) {
 		if (id.value) {
-			uni.redirectTo({
+			uni.navigateTo({
 				url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
 				url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
 			})
 			})
 		} else {
 		} else {
-			uni.redirectTo({
+			uni.navigateTo({
 				url: `/pages/client/ShouYe/shouye`
 				url: `/pages/client/ShouYe/shouye`
 			})
 			})
 		}
 		}
@@ -173,12 +186,12 @@
 	function gotoPage2() {
 	function gotoPage2() {
 		console.log('ididid222222', id.value);
 		console.log('ididid222222', id.value);
 		if (id.value) {
 		if (id.value) {
-			uni.redirectTo({
+			uni.navigateTo({
 				url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
 				url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
 			})
 			})
 		} else {
 		} else {
-			uni.redirectTo({
-				url: `/pages/kehu/shouye/shouye`
+			uni.navigateTo({
+				url: `/pages/kehu/shouYe/shouye`
 			})
 			})
 		}
 		}
 	}
 	}
@@ -188,29 +201,6 @@
 			cacheManager.set('projectImg', res.data)
 			cacheManager.set('projectImg', res.data)
 		});
 		});
 	}
 	}
-
-  function handleChangeFangshi() {
-    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/test?${str}`
-      })
-    } else {
-      uni.redirectTo({
-        url: `/pages/Login/test`
-      })
-    }
-  }
-
 </script>
 </script>
 
 
 <style scoped>
 <style scoped>