feat: 小程序手机号登录获取openid逻辑
This commit is contained in:
@ -15,6 +15,7 @@ import { useInterface } from "@/hooks/useInterface";
|
||||
import { privacyAgreementUrl, sendSmsCode as sendSmsCodeRequest, smsLogin, userAgreementUrl } from '@/api/auth'
|
||||
import { useMainStore } from "@/store/modules/useMainStore";
|
||||
import { afterLogin } from "@/utils";
|
||||
import { wxLogin } from "@/utils/wechatUtils";
|
||||
|
||||
const {getParams, goBack, push, pushToTab} = useRouter()
|
||||
const {toast} = useInterface();
|
||||
@ -30,6 +31,7 @@ const codeFocus = ref(false)
|
||||
const form = ref({
|
||||
mobile: '',
|
||||
code: '',
|
||||
loginCode: undefined,// 微信环境的CODE
|
||||
invitationCode: undefined
|
||||
})
|
||||
|
||||
@ -146,6 +148,10 @@ async function doLogin() {
|
||||
if (!(unref(form).code)) return toast({title: '请输入正确的验证码'})
|
||||
try {
|
||||
loginLoading.value = true
|
||||
// 如果是微信小程序环境,获取wx.login的code给后端去获取openid
|
||||
// #ifdef MP-WEIXIN
|
||||
form.value.loginCode = await wxLogin();
|
||||
// #endif
|
||||
const res = await smsLogin(form.value);
|
||||
if (res) {
|
||||
await mainStore.setAccessToken(res)
|
||||
|
Reference in New Issue
Block a user