| | |
| | | v-model="state.policyChecked" |
| | | policyBtnText="若手机号未注册,将为您直接注册账号,注册即为同意" |
| | | /> |
| | | <div class="other-login-channel-wrapper" v-if="!isLoginByWeb"> |
| | | <!-- <div class="other-login-channel-wrapper" v-if="!isLoginByWeb"> --> |
| | | <div class="other-login-channel-wrapper" v-if="NODE_ENV === 'development'"> |
| | | <nut-divider>其他登录方式</nut-divider> |
| | | <div class="other-login-channel-list"> |
| | | <div class="other-login-channel-list-item" @click="goLoginByForm()"> |
| | |
| | | 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'; |
| | | import { NODE_ENV } from '@/constants'; |
| | | import { subscribeMessageTemplateIdsForC } from '@12333/constants'; |
| | | console.log('NODE_ENV: ', NODE_ENV); |
| | | |
| | | 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.C端小程序, |
| | | }); |
| | | 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.C端小程序, |
| | | 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(); |
| | |
| | | } catch (error) {} |
| | | } |
| | | |
| | | function handleLoginSuccess() { |
| | | Message.success('授权登录成功', { |
| | | onClosed: () => { |
| | | jump(); |
| | | }, |
| | | }); |
| | | 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 = subscribeMessageTemplateIdsForC |
| | | .map((id) => res.subscriptionsSetting.itemSettings[id] !== 'accept') |
| | | .filter(Boolean); |
| | | } |
| | | // if (setting.length > 0) { |
| | | Taro.requestSubscribeMessage({ |
| | | tmplIds: subscribeMessageTemplateIdsForC, |
| | | success: function (res) { |
| | | console.log('res: ', res); |
| | | }, |
| | | }); |
| | | console.log('setting: ', setting); |
| | | // } |
| | | Message.success('授权登录成功', { |
| | | onClosed: () => { |
| | | jump(); |
| | | }, |
| | | }); |
| | | } catch (error) { |
| | | console.log('error: ', error); |
| | | } |
| | | } |
| | | |
| | | function goLoginByForm(tab = LoginFormTabs.VerificationCodeLogin) { |