Kaynağa Gözat

Merge branch '2025北京诚祥-家政版' of https://gogs.mtavip.com/wangguoyu/uniProject into 2025北京诚祥-家政版

tanxue 13 saat önce
ebeveyn
işleme
89faebf5de
4 değiştirilmiş dosya ile 119 ekleme ve 46 silme
  1. 11 0
      api/login.js
  2. 5 0
      pages.json
  3. 21 0
      pages/Login/AliyunCaptcha.vue
  4. 82 46
      pages/Login/clientIndex.vue

+ 11 - 0
api/login.js

@@ -59,4 +59,15 @@ export function getAllImgList(data = {}) {
     data,
     timeout: 20000
   })
+}
+export function loginApplet(data = {}) {
+  return request({
+    'url': '/common/app/login/applet',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
 }

+ 5 - 0
pages.json

@@ -5,6 +5,11 @@
 			"style": {
 				"navigationStyle": "custom"
 			}
+		},	{
+			"path": "pages/Login/AliyunCaptcha",
+			"style": {
+				"navigationStyle": "custom"
+			}
 		}, {
 			"path": "pages/client/ShouYe/shouye",
 			"style": {

+ 21 - 0
pages/Login/AliyunCaptcha.vue

@@ -0,0 +1,21 @@
+<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>
+</template>
+
+<script>
+	export default {
+		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);
+			}
+		}
+	}
+</script>

+ 82 - 46
pages/Login/clientIndex.vue

@@ -6,20 +6,22 @@
 				<view class="bjcx-logo-title">家政学</view>
 			</view>
 			
-			<!-- 新增:APP分享过来的微信授权 -->
-			<view v-if="fromAppShare && !showNormalLogin" class="wechat-auth-box">
+			<!-- 如果是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"
+					@click="onWechatAuth"
+			
 				>
 					微信一键登录
 				</button>
-				<view class="switch-login" @click="showNormalLogin = true">使用账号登录</view>
+				<view class="switch-login" @click="switchToNormalLogin">使用账号登录</view>
 			</view>
 			
-			<!-- 原有登录表单 -->
+			<!-- 普通登录表单 -->
 			<view v-else>
 				<view class="login-input-box">
 					<icon class="user-icon"></icon>
@@ -56,7 +58,7 @@
 <script setup>
 	import cacheManager from '@/utils/cacheManager.js'
 	import * as httpApi from "@/api/login.js"
-	import {ref} from "vue"
+	import {ref, onMounted} from "vue"
 	import {toast} from "@/utils/common";
 	import {useIsCanBack} from "@/store/isCanBack.js"
     import { onLoad } from "@dcloudio/uni-app";
@@ -70,8 +72,7 @@
 	const isAgreed = ref(false)
 	
 	// 新增变量
-	const fromAppShare = ref(false) // 是否来自APP分享
-	const showNormalLogin = ref(false) // 是否显示普通登录
+	const fromAppShare = ref(true) // 是否来自APP分享
 	
 	const store = useIsCanBack();
 
@@ -79,52 +80,78 @@
         // 判断是否来自APP分享
         if (options.from === 'appcx') {
             fromAppShare.value = true
+            // APP分享过来直接显示微信授权界面,不需要自动弹窗
         }
         getAllImg();
     })
     
+    // 切换到普通登录
+    function switchToNormalLogin() {
+        fromAppShare.value = false
+    }
+    
     // 微信授权登录
     async function onWechatAuth(e) {
-        if (e.detail.errMsg.includes('fail')) {
-            toast('授权失败')
-            return
-        }
-        
-        uni.showLoading({ title: '登录中' })
+		
+		
+		uni.navigateTo({
+		    url: '/pages/Login/AliyunCaptcha?scene=login',
+		    events: {
+		        getCaptchaVerifyParam: (captchaVerifyParam) => {
+		            // 接收到验证码返回结果
+		            console.log('验证码返回结果:', captchaVerifyParam)
+		        }
+		    },
+		    success: () => {
+		        console.log('跳转到验证码页面成功')
+		    },
+		    fail: (err) => {
+		        console.error('跳转到验证码页面失败:', err)
+		        toast('验证码加载失败,请重试')
+		    }
+		})
+		
+   //      if (e.detail.errMsg.includes('fail')) {
+   //          toast('授权失败')
+   //          return
+   //      }
         
-        try {
-            // 获取微信code
-            const loginRes = await uni.login()
-            
-            // 调用后端微信登录接口
-            const result = await httpApi.wechatLogin({
-                code: loginRes.code,
-                userInfo: e.detail.userInfo
-            })
-            
-            if (result.data.success) {
-                // 保存用户信息
-                cacheManager.set('auth', result.data)
+   //      uni.showLoading({ title: '登录中' })
+   //      console.log('e',e);
+   //      try {
+   //          // 获取微信code
+   //          const loginRes = await uni.login()
+   //          		console.log('loginRes',loginRes);
+   //          // 调用后端微信登录接口
+   //          const result = await httpApi.loginApplet({
+   //              code: loginRes.code,
+   //              userInfo: e.detail.userInfo
+   //          })
+			// console.log('result',result);
+   //             console.log('result',result);
+   //          if (result.data.success) {
+   //              // 保存用户信息
+   //              cacheManager.set('auth', result.data)
                 
-                // 检查手机号绑定状态
-                const bindResult = await httpApi.checkPhoneBind()
+   //              // // 检查手机号绑定状态
+   //              // const bindResult = await httpApi.checkPhoneBind()
                 
-                if (bindResult.data.hasPhone) {
-                    // 已绑定手机号,进入首页
-                    store.setIsCanBack(false)
-                    gotoPage()
-                } else {
-                    // 未绑定手机号,跳转绑定页面
-                    uni.navigateTo({
-                        url: '/pages/bind-phone/bind-phone'
-                    })
-                }
-            }
-        } catch (error) {
-            toast('微信登录失败')
-        } finally {
-            uni.hideLoading()
-        }
+   //              // if (bindResult.data.hasPhone) {
+   //              //     // 已绑定手机号,进入首页
+   //              //     store.setIsCanBack(false)
+   //              //     gotoPage()
+   //              // } else {
+   //              //     // 未绑定手机号,跳转绑定页面
+   //              //     uni.navigateTo({
+   //              //         url: '/pages/bind-phone/bind-phone'
+   //              //     })
+   //              // }
+   //          }
+   //      } catch (error) {
+   //          toast('微信登录失败')
+   //      } finally {
+   //          uni.hideLoading()
+   //      }
     }
 
     // 你原有的所有方法都不变
@@ -201,7 +228,11 @@
                 cacheManager.set('auth', res.data)
                 store.setIsCanBack(false)
                 gotoPage();
-            }else{
+            }else if(res.data.type ===6){
+				cacheManager.set('auth', res.data)
+				store.setIsCanBack(false)
+				gotoPage2();
+			}else{
                 toast('登录失败,您的身份有误,请联系管理员。')
             }
         }).catch(err => {
@@ -215,6 +246,11 @@
         uni.navigateTo({
             url: `/pages/client/ShouYe/shouye`
         })
+    } 
+	function gotoPage2(){
+        uni.navigateTo({
+            url: `/pages/kehu/shouYe/shouye`
+        })
     }
 
     function getAllImg() {