From 7ccd828bcc341adb81815368f19b002878201730 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 05 十二月 2025 17:22:30 +0800
Subject: [PATCH] release: @12333/underTakeMiniApp v1.1.15

---
 apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue |  167 ++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 139 insertions(+), 28 deletions(-)

diff --git a/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue b/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
index 61dc409..3f3fa50 100644
--- a/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
+++ b/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
@@ -1,44 +1,64 @@
 <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>
+
     <!-- <div class="go-register-btn" @click="goRegister">绔嬪嵆娉ㄥ唽</div> -->
   </div>
 </template>
 
 <script setup lang="ts">
 import { Message } from '@12333/utils';
+import { AccessOpenTypeButton } from '@12333/components';
 import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types';
 import { LargeButton } from '@/components';
 import { useLoginedJump } from '@/hooks';
 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';
+import { subscribeMessageTemplateIdsForB } from '@12333/constants';
+import { ButtonProps, CommonEventFunction } from '@tarojs/components';
 
 defineOptions({
   name: 'AccountLoginForm',
@@ -57,6 +77,9 @@
 const isShowPassword = ref(false);
 
 const formRef = ref(null);
+const isAccount = ref(false);
+const wxMiniAppUserLoginRes = ref<API.LoginCommandCallback>();
+const loginRes = ref(null);
 
 const form = reactive({
   loading: false,
@@ -69,6 +92,17 @@
   userPassword: [{ required: true, message: '璇疯緭鍏ュ瘑鐮�' }],
 });
 
+async function handleLoginByHasAccount() {
+  try {
+    if (props.policyChecked) {
+      userStore.loginSuccess(wxMiniAppUserLoginRes.value);
+      handleLoginSuccess();
+    } else {
+      noAccess();
+    }
+  } catch (error) {}
+}
+
 async function handleLogin() {
   try {
     if (props.policyChecked) {
@@ -78,13 +112,15 @@
         await userStore.loginByPassword({
           userName: form.userName,
           password: form.userPassword,
+          code: loginRes.value?.code,
         });
-        jump();
+        handleLoginSuccess();
       }
     } else {
       noAccess();
     }
   } catch (error) {
+    loginRes.value = await Taro.login();
   } finally {
     form.loading = false;
   }
@@ -94,12 +130,66 @@
   Message.warning('璇峰厛闃呰骞跺嬀閫夊崗璁�');
 }
 
+async function handleLoginSuccess() {
+  try {
+    if (!Taro.requestSubscribeMessage) {
+      await Message.confirm({ message: '浣犵殑寰俊鐗堟湰杩囦綆锛屼笉鏀寔璁㈤槄娑堟伅锛屾槸鍚︾户缁紵' });
+    }
+    const res = await Taro.getSetting({
+      withSubscriptions: true,
+    });
+    let setting: boolean[] = [];
+    if (res.subscriptionsSetting && res.subscriptionsSetting.itemSettings) {
+      setting = subscribeMessageTemplateIdsForB
+        .map((id) => res.subscriptionsSetting.itemSettings[id] !== 'accept')
+        .filter(Boolean);
+    }
+    Taro.requestSubscribeMessage({
+      tmplIds: subscribeMessageTemplateIdsForB,
+      success: function (res) {
+        console.log('res: ', res);
+      },
+    });
+    console.log('setting: ', setting);
+    Message.success('鐧诲綍鎴愬姛', {
+      onClosed: () => {
+        jump();
+      },
+    });
+  } catch (error) {
+    console.log('error: ', error);
+  }
+}
+
 function goRegister() {
   console.log('RouterPath.registerForm: ', RouterPath.registerForm);
   Taro.navigateTo({
     url: RouterPath.registerForm,
   });
 }
+
+onMounted(async () => {
+  try {
+    loginRes.value = await Taro.login();
+    const params: API.WxmpLoginCommand = {
+      code: loginRes.value?.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;
+    }
+  } finally {
+    loginRes.value = await Taro.login();
+  }
+});
 </script>
 
 <style lang="scss">
@@ -114,5 +204,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