From 333c9f575a7fe7fd445a8ae6fb44d0fe23d93ae2 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期四, 04 十二月 2025 16:53:51 +0800
Subject: [PATCH] feat: 通知

---
 apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue |   62 +++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue b/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
index ae09023..031b8b1 100644
--- a/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
+++ b/apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
@@ -43,22 +43,13 @@
       <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>
 
 <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';
@@ -66,6 +57,8 @@
 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',
@@ -86,6 +79,7 @@
 const formRef = ref(null);
 const isAccount = ref(false);
 const wxMiniAppUserLoginRes = ref<API.LoginCommandCallback>();
+const loginRes = ref(null);
 
 const form = reactive({
   loading: false,
@@ -102,11 +96,7 @@
   try {
     if (props.policyChecked) {
       userStore.loginSuccess(wxMiniAppUserLoginRes.value);
-      Message.success('鐧诲綍鎴愬姛', {
-        onClosed: () => {
-          jump();
-        },
-      });
+      handleLoginSuccess();
     } else {
       noAccess();
     }
@@ -115,7 +105,6 @@
 
 async function handleLogin() {
   try {
-    let loginRes = await Taro.login();
     if (props.policyChecked) {
       const { valid } = await formRef.value.validate();
       if (valid) {
@@ -123,9 +112,9 @@
         await userStore.loginByPassword({
           userName: form.userName,
           password: form.userPassword,
-          code: loginRes.code,
+          code: loginRes.value?.code,
         });
-        jump();
+        handleLoginSuccess();
       }
     } else {
       noAccess();
@@ -140,6 +129,37 @@
   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({
@@ -149,9 +169,9 @@
 
 onMounted(async () => {
   try {
-    let loginRes = await Taro.login();
+    loginRes.value = await Taro.login();
     const params: API.WxmpLoginCommand = {
-      code: loginRes.code,
+      code: loginRes.value?.code,
       type: AppLocalConfig.userType,
       enterpriseType: AppLocalConfig.enterpriseType,
     };
@@ -165,6 +185,8 @@
     if (error?.info?.errorCode == 's401') {
       isAccount.value = false;
     }
+  } finally {
+    loginRes.value = await Taro.login();
   }
 });
 </script>

--
Gitblit v1.9.1