|  |  |  | 
|---|
|  |  |  | <script setup lang="ts"> | 
|---|
|  |  |  | import LoginPageLayout from '../components/LoginPageLayout/LoginPageLayout.vue'; | 
|---|
|  |  |  | import { Policy } from '@/components'; | 
|---|
|  |  |  | import * as commonServices from '@12333/services/api/Common'; | 
|---|
|  |  |  | import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types'; | 
|---|
|  |  |  | import { FormValidator, Message } from '@12333/utils'; | 
|---|
|  |  |  | import { LargeButton } from '@/components'; | 
|---|
|  |  |  | 
|---|
|  |  |  | import { VerificationCodeBusinessType } from '@12333/constants'; | 
|---|
|  |  |  | import Taro from '@tarojs/taro'; | 
|---|
|  |  |  | import { ResponseCode } from '@12333/constants'; | 
|---|
|  |  |  | import * as accountServices from '@12333/services/api/Account'; | 
|---|
|  |  |  | import * as authServices from '@12333/services/apiV2/auth'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | defineOptions({ | 
|---|
|  |  |  | name: 'registerForm', | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | async function onGetCaptcha() { | 
|---|
|  |  |  | await commonServices.sendVerificationCode( | 
|---|
|  |  |  | await authServices.sendLoginOrRegisterVerifyCode( | 
|---|
|  |  |  | { | 
|---|
|  |  |  | phoneNumber: form.phoneNumber, | 
|---|
|  |  |  | businessType: VerificationCodeBusinessType.PhoneMesssageCodeRegister, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | showLoading: false, | 
|---|
|  |  |  | customErrorHandler(error) { | 
|---|
|  |  |  | if (error?.response?.data?.error?.code === ResponseCode.RegisterExistsPhoneNumber) { | 
|---|
|  |  |  | Message.confirm({ | 
|---|
|  |  |  | message: '该手机号已注册,请去登录页登录', | 
|---|
|  |  |  | confirmText: '去登录', | 
|---|
|  |  |  | }).then(() => { | 
|---|
|  |  |  | goLogin(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // customErrorHandler(error) { | 
|---|
|  |  |  | //   if (error?.response?.data?.error?.code === ResponseCode.RegisterExistsPhoneNumber) { | 
|---|
|  |  |  | //     Message.confirm({ | 
|---|
|  |  |  | //       message: '该手机号已注册,请去登录页登录', | 
|---|
|  |  |  | //       confirmText: '去登录', | 
|---|
|  |  |  | //     }).then(() => { | 
|---|
|  |  |  | //       goLogin(); | 
|---|
|  |  |  | //     }); | 
|---|
|  |  |  | //     return true; | 
|---|
|  |  |  | //   } | 
|---|
|  |  |  | // }, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (state.policyChecked) { | 
|---|
|  |  |  | const { valid } = await formRef.value.validate(); | 
|---|
|  |  |  | if (valid) { | 
|---|
|  |  |  | let params: API.PhoneMesssageCodeRegisterInput = { | 
|---|
|  |  |  | code: form.verificationCode, | 
|---|
|  |  |  | phoneNumber: form.phoneNumber, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | let res = await accountServices.phoneMesssageCodeRegister(params); | 
|---|
|  |  |  | if (res) { | 
|---|
|  |  |  | Message.success('注册成功', { | 
|---|
|  |  |  | onClosed: () => { | 
|---|
|  |  |  | goLogin(); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // let params: API.PhoneMesssageCodeRegisterInput = { | 
|---|
|  |  |  | //   code: form.verificationCode, | 
|---|
|  |  |  | //   phoneNumber: form.phoneNumber, | 
|---|
|  |  |  | // }; | 
|---|
|  |  |  | // let res = await accountServices.phoneMesssageCodeRegister(params); | 
|---|
|  |  |  | // if (res) { | 
|---|
|  |  |  | //   Message.success('注册成功', { | 
|---|
|  |  |  | //     onClosed: () => { | 
|---|
|  |  |  | //       goLogin(); | 
|---|
|  |  |  | //     }, | 
|---|
|  |  |  | //   }); | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | noAccess(); | 
|---|