From fa5ee26bb701b816efc811c193ee55504a6efd51 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期三, 03 十二月 2025 17:51:23 +0800
Subject: [PATCH] feat: 通知

---
 apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue |  142 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 115 insertions(+), 27 deletions(-)

diff --git a/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue b/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
index 61dc409..ae09023 100644
--- a/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
+++ b/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
@@ -1,32 +1,58 @@
 <template>
   <div class="verification-code-login-form-wrapper">
-    <nut-form class="verification-code-login-form" ref="formRef" :model-value="form" :rules="rules">
-      <nut-form-item label="" class="bole-form-item" prop="userName" required>
-        <nut-input
-          v-model.trim="form.userName"
-          class="bole-input-text"
-          placeholder="璇疯緭鍏ヨ处鍙�/鎵嬫満鍙�/閭"
-          type="text"
-        />
-      </nut-form-item>
-      <nut-form-item label="" class="bole-form-item" prop="userPassword" required>
-        <nut-input
-          v-model.trim="form.userPassword"
-          class="bole-input-text"
-          placeholder="璇疯緭鍏ュ瘑鐮�"
-          :type="isShowPassword ? 'text' : 'password'"
-          :key="isShowPassword ? 'text' : 'password'"
-        >
-          <template #right>
-            <div class="password-icon-wrapper" @click="isShowPassword = !isShowPassword">
-              <Eye v-if="isShowPassword"></Eye>
-              <Marshalling v-else></Marshalling>
-            </div>
-          </template>
-        </nut-input>
-      </nut-form-item>
-    </nut-form>
-    <LargeButton class="login-btn" @click="handleLogin" :loading="form.loading">鐧诲綍</LargeButton>
+    <nut-button
+      v-if="isAccount"
+      type="primary"
+      class="authorization-page-wechat-wrapper"
+      @click="handleLoginByHasAccount"
+    >
+      <div class="authorization-page-wechat">鎵嬫満鍙峰揩閫熺櫥褰�</div></nut-button
+    >
+    <template v-else>
+      <nut-form
+        class="verification-code-login-form"
+        ref="formRef"
+        :model-value="form"
+        :rules="rules"
+      >
+        <nut-form-item label="" class="bole-form-item" prop="userName" required>
+          <nut-input
+            v-model.trim="form.userName"
+            class="bole-input-text"
+            placeholder="璇疯緭鍏ヨ处鍙�/鎵嬫満鍙�/閭"
+            type="text"
+          />
+        </nut-form-item>
+        <nut-form-item label="" class="bole-form-item" prop="userPassword" required>
+          <nut-input
+            v-model.trim="form.userPassword"
+            class="bole-input-text"
+            placeholder="璇疯緭鍏ュ瘑鐮�"
+            :type="isShowPassword ? 'text' : 'password'"
+            :key="isShowPassword ? 'text' : 'password'"
+          >
+            <template #right>
+              <div class="password-icon-wrapper" @click="isShowPassword = !isShowPassword">
+                <Eye v-if="isShowPassword"></Eye>
+                <Marshalling v-else></Marshalling>
+              </div>
+            </template>
+          </nut-input>
+        </nut-form-item>
+      </nut-form>
+      <LargeButton class="login-btn" @click="handleLogin" :loading="form.loading">鐧诲綍</LargeButton>
+    </template>
+
+    <!-- <AccessOpenTypeButton
+      type="primary"
+      class="authorization-page-wechat-wrapper"
+      open-type="getPhoneNumber"
+      :access="policyChecked"
+      @noAccess="noAccess"
+      @getphonenumber="handleLogin"
+    >
+      <div class="authorization-page-wechat">鐧诲綍</div>
+    </AccessOpenTypeButton> -->
     <!-- <div class="go-register-btn" @click="goRegister">绔嬪嵆娉ㄥ唽</div> -->
   </div>
 </template>
@@ -39,6 +65,7 @@
 import { useUserStore } from '@/stores/modules/user';
 import { Eye, Marshalling } from '@nutui/icons-vue-taro';
 import Taro from '@tarojs/taro';
+import * as authServices from '@12333/services/apiV2/auth';
 
 defineOptions({
   name: 'AccountLoginForm',
@@ -57,6 +84,8 @@
 const isShowPassword = ref(false);
 
 const formRef = ref(null);
+const isAccount = ref(false);
+const wxMiniAppUserLoginRes = ref<API.LoginCommandCallback>();
 
 const form = reactive({
   loading: false,
@@ -69,8 +98,24 @@
   userPassword: [{ required: true, message: '璇疯緭鍏ュ瘑鐮�' }],
 });
 
+async function handleLoginByHasAccount() {
+  try {
+    if (props.policyChecked) {
+      userStore.loginSuccess(wxMiniAppUserLoginRes.value);
+      Message.success('鐧诲綍鎴愬姛', {
+        onClosed: () => {
+          jump();
+        },
+      });
+    } else {
+      noAccess();
+    }
+  } catch (error) {}
+}
+
 async function handleLogin() {
   try {
+    let loginRes = await Taro.login();
     if (props.policyChecked) {
       const { valid } = await formRef.value.validate();
       if (valid) {
@@ -78,6 +123,7 @@
         await userStore.loginByPassword({
           userName: form.userName,
           password: form.userPassword,
+          code: loginRes.code,
         });
         jump();
       }
@@ -100,6 +146,27 @@
     url: RouterPath.registerForm,
   });
 }
+
+onMounted(async () => {
+  try {
+    let loginRes = await Taro.login();
+    const params: API.WxmpLoginCommand = {
+      code: loginRes.code,
+      type: AppLocalConfig.userType,
+      enterpriseType: AppLocalConfig.enterpriseType,
+    };
+    wxMiniAppUserLoginRes.value = await authServices.wxmpLogin(params, {
+      skipErrorHandler: true,
+    });
+    if (wxMiniAppUserLoginRes.value?.isBindPhoneNumber) {
+      isAccount.value = true;
+    }
+  } catch (error) {
+    if (error?.info?.errorCode == 's401') {
+      isAccount.value = false;
+    }
+  }
+});
 </script>
 
 <style lang="scss">
@@ -114,5 +181,26 @@
       font-size: 28px;
     }
   }
+
+  .authorization-page-wechat-wrapper {
+    width: 100%;
+    height: 88px;
+  }
+
+  .authorization-page-wechat {
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    font-weight: 400;
+    font-size: 32px;
+    color: #ffffff;
+    line-height: 44px;
+
+    .authorization-page-wechat-icon {
+      width: 44px;
+      height: 36px;
+      margin-right: 10px;
+    }
+  }
 }
 </style>

--
Gitblit v1.9.1