wangguoyu 1 месяц назад
Родитель
Сommit
901ca680ed
2 измененных файлов с 37 добавлено и 13 удалено
  1. 31 10
      pages/Login/AliyunCaptcha.vue
  2. 6 3
      pages/Login/clientIndex.vue

+ 31 - 10
pages/Login/AliyunCaptcha.vue

@@ -1,21 +1,42 @@
 <template>
 	<!-- <web-view src="https://uniapp.dcloud.io/static/web-view.html" @message="onMessage"></web-view> -->
-	<web-view src="https://www.chengxiangjiaoyu.com/indexAli.html" @message="onMessage"></web-view>
+	<!-- <web-view src="https://www.chengxiangjiaoyu.com/indexAli.html" @message="onMessage"></web-view> -->
+	<web-view :src="webViewUrl"  @message="onMessage"></web-view>
 </template>
 
 <script>
 	export default {
+		data() {
+			return {
+				webViewUrl: ''
+			}
+		},
+		onLoad(options) {
+			console.log('接收到参数:', options);
+
+			// 构造web-view的URL,传递code参数
+			let url = 'https://www.chengxiangjiaoyu.com/h5/pages/Login/clientIndex';
+
+			if (options.code) {
+				// 将code参数拼接到URL中
+				url += `?code=${options.code}`;
+				console.log('生成的URL:', url);
+			}
+
+			this.webViewUrl = url;
+		},
 		methods: {
 			onMessage(e) {
-				console.log('e.detail.data[0]',e.detail.data[0]);
-			  const captchaVerifyParam = e.detail.data[0];
-			  // 通过事件通道,触发在业务页面中定义的 'getCaptchaVerifyParam' 事件,并把验证参数发送至业务页面
-			  const eventChannel = this.getOpenerEventChannel();
-			  eventChannel && eventChannel.emit('getCaptchaVerifyParam',captchaVerifyParam);
-			  setTimeout(() => {
-			  					uni.navigateBack();
-			  				}, 300);
+				console.log('e.detail.data[0]', e.detail.data[0]);
+				const captchaVerifyParam = e.detail.data[0];
+				// 通过事件通道,触发在业务页面中定义的 'getCaptchaVerifyParam' 事件,并把验证参数发送至业务页面
+				const eventChannel = this.getOpenerEventChannel();
+				eventChannel && eventChannel.emit('getCaptchaVerifyParam', captchaVerifyParam);
+				setTimeout(() => {
+					console.log('back');
+				//	uni.navigateBack();
+				}, 300);
 			}
 		}
 	}
-</script>
+</script>

+ 6 - 3
pages/Login/clientIndex.vue

@@ -77,10 +77,12 @@
 	const clearPwIcon = ref(false)
 	const isAgreed = ref(false)
 	const id = ref('')
+	const code = ref('')
+
 	const fromPage = ref('');
 
 	// 新增变量
-	const fromAppShare = ref(false) // 是否来自APP分享
+	const fromAppShare = ref(true) // 是否来自APP分享
 
 	const store = useIsCanBack();
 
@@ -102,7 +104,7 @@
 
 	function phoneBind() {
 		uni.navigateTo({
-			url: '/pages/Login/AliyunCaptcha',
+			url: '/pages/Login/AliyunCaptcha?code='+code.value,
 			events: {
 				getCaptchaVerifyParam: (captchaVerifyParam) => {
 					// 接收到验证码返回结果
@@ -134,6 +136,7 @@
 			// 获取微信code
 			const loginRes = await uni.login()
 			console.log('loginRes', loginRes);
+			code.value = loginRes.code
 			// 调用后端微信登录接口
 			const result = await httpApi.loginApplet({
 				code: loginRes.code,
@@ -313,4 +316,4 @@
 	}
 
 	/* 你原有的所有样式都保持不变 */
-</style>
+</style>