| | |
| | | import { CommonEventFunction, ButtonProps } from '@tarojs/components'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { useLoginedJump } from '@/hooks'; |
| | | import * as accountServices from '@12333/services/api/Account'; |
| | | import IconCaptcha from '@/assets/login/icon-btn-captcha.png'; |
| | | import IconPassword from '@/assets/login/icon-btn-password.png'; |
| | | import { LoginFormTabs } from '../constants'; |
| | | import { WxMiniAppEnum } from '@12333/constants'; |
| | | import * as authServices from '@12333/services/apiV2/auth'; |
| | | |
| | | defineOptions({ |
| | | name: 'authorization', |
| | |
| | | RouterPath.authorization.includes(launchOptions.path) && launchOptions.scene === 1047 && uuid |
| | | ); |
| | | |
| | | const wxIndentityRes = ref<API.WxMiniAppIndentityInfo>(); |
| | | const wxMiniAppUserLoginRes = ref<API.IdentityModelTokenCacheItem>(); |
| | | const wxIndentityRes = ref<API.LoginCommandCallback>(); |
| | | const wxMiniAppUserLoginRes = ref<API.LoginCommandCallback>(); |
| | | |
| | | const isAccount = ref(false); |
| | | |
| | |
| | | try { |
| | | let loginRes = await Taro.login(); |
| | | if (isLoginByWeb.value) { |
| | | const wxIndentity = await accountServices.getWxIndentity({ |
| | | code: loginRes.code, |
| | | wxMiniApp: WxMiniAppEnum.人单合一, |
| | | }); |
| | | wxIndentityRes.value = wxIndentity; |
| | | if (wxIndentityRes.value.userName) { |
| | | isAccount.value = true; |
| | | } |
| | | // const wxIndentity = await authServices.wxmpLogin({ |
| | | // code: loginRes.code, |
| | | // type: AppLocalConfig.userType, |
| | | // }); |
| | | // wxIndentityRes.value = wxIndentity; |
| | | // if (wxIndentityRes.value.isBindPhoneNumber) { |
| | | // isAccount.value = true; |
| | | // } |
| | | } else { |
| | | const params: API.APIwxMiniAppUserLoginParams = { |
| | | const params: API.WxmpLoginCommand = { |
| | | code: loginRes.code, |
| | | wxMiniApp: WxMiniAppEnum.人单合一, |
| | | type: AppLocalConfig.userType, |
| | | }; |
| | | wxMiniAppUserLoginRes.value = await accountServices.wxMiniAppUserLogin(params); |
| | | if (wxMiniAppUserLoginRes.value.accessToken) { |
| | | wxMiniAppUserLoginRes.value = await authServices.wxmpLogin(params); |
| | | if (wxMiniAppUserLoginRes.value?.isBindPhoneNumber) { |
| | | isAccount.value = true; |
| | | } |
| | | } |
| | |
| | | console.log('errMsg: ', errMsg, isLoginByWeb.value); |
| | | if (errMsg === 'getPhoneNumber:ok') { |
| | | if (isLoginByWeb.value) { |
| | | let res = await userStore.wxMiniAppPhoneAuthLoginFromScan( |
| | | ev.detail, |
| | | wxIndentityRes.value, |
| | | uuid |
| | | ); |
| | | if (res) { |
| | | handleLoginSuccess(); |
| | | } |
| | | // let res = await userStore.wxMiniAppPhoneAuthLoginFromScan( |
| | | // ev.detail, |
| | | // wxIndentityRes.value, |
| | | // uuid |
| | | // ); |
| | | // if (res) { |
| | | // handleLoginSuccess(); |
| | | // } |
| | | } else { |
| | | let res = await userStore.getTokenByPhone(ev.detail, wxMiniAppUserLoginRes.value); |
| | | if (res) { |
| | |
| | | if (state.policyChecked) { |
| | | if (isLoginByWeb.value) { |
| | | console.log('uuid: ', uuid); |
| | | let res = await userStore.wxMiniAppUserLoginFromScan(wxIndentityRes.value, uuid); |
| | | if (res) { |
| | | handleLoginSuccess(); |
| | | } |
| | | // let res = await userStore.wxMiniAppUserLoginFromScan(wxIndentityRes.value, uuid); |
| | | // if (res) { |
| | | // handleLoginSuccess(); |
| | | // } |
| | | } else { |
| | | userStore.loginSuccess(wxMiniAppUserLoginRes.value); |
| | | handleLoginSuccess(); |