wangguoyu hai 9 horas
pai
achega
3459e3f1d8
Modificáronse 1 ficheiros con 47 adicións e 47 borrados
  1. 47 47
      pages/Login/clientIndex.vue

+ 47 - 47
pages/Login/clientIndex.vue

@@ -90,12 +90,9 @@
         fromAppShare.value = false
     }
     
-    // 微信授权登录
-    async function onWechatAuth(e) {
-		
-		
+	phoneBind(){
 		uni.navigateTo({
-		    url: '/pages/Login/AliyunCaptcha?scene=login',
+		    url: '/pages/Login/AliyunCaptcha',
 		    events: {
 		        getCaptchaVerifyParam: (captchaVerifyParam) => {
 		            // 接收到验证码返回结果
@@ -105,53 +102,56 @@
 		    success: () => {
 		        console.log('跳转到验证码页面成功')
 		    },
-		    fail: (err) => {
+		    fail: (err) => {	
 		        console.error('跳转到验证码页面失败:', err)
 		        toast('验证码加载失败,请重试')
 		    }
 		})
-		
-   //      if (e.detail.errMsg.includes('fail')) {
-   //          toast('授权失败')
-   //          return
-   //      }
+	}
+	
+    // 微信授权登录
+    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);
-   //          // 调用后端微信登录接口
-   //          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()
-                
-   //              // if (bindResult.data.hasPhone) {
-   //              //     // 已绑定手机号,进入首页
-   //              //     store.setIsCanBack(false)
-   //              //     gotoPage()
-   //              // } else {
-   //              //     // 未绑定手机号,跳转绑定页面
-   //              //     uni.navigateTo({
-   //              //         url: '/pages/bind-phone/bind-phone'
-   //              //     })
-   //              // }
-   //          }
-   //      } catch (error) {
-   //          toast('微信登录失败')
-   //      } finally {
-   //          uni.hideLoading()
-   //      }
+        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.bind) {
+                // 保存用户信息
+				if(res.data.loginVo.type ===4){
+				    cacheManager.set('auth', res.data.loginVo)
+				    store.setIsCanBack(false)
+				    gotoPage();
+				}else if(res.data.loginVo.type ===6){
+					cacheManager.set('auth', res.data.loginVo)
+					store.setIsCanBack(false)
+					gotoPage2();
+				}else{
+				    toast('登录失败,您的身份有误,请联系管理员。')
+				}        
+            }else{
+				//  bind 为 false 未绑定
+				
+				phoneBind()
+			}
+        } catch (error) {
+            toast('微信登录失败')
+        } finally {
+            uni.hideLoading()
+        }
     }
 
     // 你原有的所有方法都不变