| | |
| | | <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'; |
| | |
| | | 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', |
| | |
| | | try { |
| | | if (props.policyChecked) { |
| | | userStore.loginSuccess(wxMiniAppUserLoginRes.value); |
| | | Message.success('登录成功', { |
| | | onClosed: async () => { |
| | | if (!Taro.requestSubscribeMessage) { |
| | | await Message.confirm({ message: '你的微信版本过低,不支持订阅消息,是否继续?' }); |
| | | } |
| | | await Taro.requestSubscribeMessage({ |
| | | tmplIds: subscribeMessageTemplateIdsForB, |
| | | success: function (res) { |
| | | console.log('res: ', res); |
| | | }, |
| | | }); |
| | | jump(); |
| | | }, |
| | | }); |
| | | handleLoginSuccess(); |
| | | } else { |
| | | noAccess(); |
| | | } |
| | |
| | | password: form.userPassword, |
| | | code: loginRes.code, |
| | | }); |
| | | if (!Taro.requestSubscribeMessage) { |
| | | await Message.confirm({ message: '你的微信版本过低,不支持订阅消息,是否继续?' }); |
| | | } |
| | | await Taro.requestSubscribeMessage({ |
| | | tmplIds: subscribeMessageTemplateIdsForB, |
| | | success: function (res) { |
| | | console.log('res: ', res); |
| | | }, |
| | | }); |
| | | jump(); |
| | | handleLoginSuccess(); |
| | | } |
| | | } else { |
| | | noAccess(); |
| | |
| | | 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({ |