11111
This commit is contained in:
@@ -194,13 +194,27 @@ const resendSms = async () => {
|
||||
uni.showLoading({ title: '发送中...' });
|
||||
try {
|
||||
// 调用重新发送验证码接口
|
||||
await $api.createRequest('/app/sendSmsAgain', { phone: phone.value }, 'post');
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '验证码已发送', icon: 'success' });
|
||||
startCountdown();
|
||||
const requestParams = { phone: phone.value };
|
||||
// 只有单位用户才传递机构类型
|
||||
if (userType.value === '0') {
|
||||
requestParams.orgType = orgType.value;
|
||||
requestParams.userType = userType.value;
|
||||
}
|
||||
const res = await $api.createRequest('/app/sendSmsAgain', requestParams, 'post');
|
||||
|
||||
// 检查状态码
|
||||
if (res.code === 200 ) {
|
||||
uni.hideLoading();
|
||||
|
||||
uni.showToast({ title: '验证码已发送', icon: 'success' });
|
||||
startCountdown();
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: res.msg || '发送失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: error.msg || '发送失败', icon: 'none' });
|
||||
uni.showToast({ title: error.msg || '发送失败,请重试', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -305,16 +319,29 @@ const submitVerification = async () => {
|
||||
|
||||
try {
|
||||
// 调用接口 /app/appLoginPhone
|
||||
const res = await $api.createRequest('/app/appLoginPhone', {
|
||||
const requestParams = {
|
||||
smsCode: code,
|
||||
phone: phone.value,
|
||||
openid: openid.value,
|
||||
unionid: unionid.value,
|
||||
userType: userType.value,
|
||||
orgType: orgType.value
|
||||
}, 'post');
|
||||
userType: userType.value
|
||||
};
|
||||
// 只有单位用户才传递机构类型
|
||||
if (userType.value === '0') {
|
||||
requestParams.orgType = orgType.value;
|
||||
}
|
||||
const res = await $api.createRequest('/app/appLoginPhone', requestParams, 'post');
|
||||
|
||||
if (res.token) {
|
||||
if (res.token && res.code === 200) {
|
||||
// 检查idCard是否为null,如果是则跳转到个人信息不全页面
|
||||
if (res.idCard) {
|
||||
uni.showToast({ title: '个人信息不全,请完善信息', icon: 'none' });
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: '/pages/personal-info/incomplete' });
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
|
||||
// 登录成功,存储token
|
||||
const userStore = useUserStore();
|
||||
await userStore.loginSetToken(res.token);
|
||||
@@ -336,7 +363,7 @@ const submitVerification = async () => {
|
||||
uni.showToast({ title: res.msg || '验证失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error.msg || '验证失败,请重试', icon: 'none' });
|
||||
uni.showToast({ title: error || '验证失败,请重试', icon: 'none' });
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -260,13 +260,19 @@ const onWxGetPhoneNumber = async (e) => {
|
||||
// 调用接口 /app/appWxphoneSmsCode
|
||||
uni.showLoading({ title: '获取验证码中...' });
|
||||
|
||||
$api.createRequest('/app/appWxphoneSmsCode', {
|
||||
// 根据用户类型构建参数
|
||||
const requestParams = {
|
||||
code,
|
||||
encryptedData,
|
||||
iv,
|
||||
userType: userType.value,
|
||||
orgType: orgType.value
|
||||
}, 'post').then((resData) => {
|
||||
userType: userType.value
|
||||
};
|
||||
// 只有单位用户才传递机构类型
|
||||
if (userType.value === 0) {
|
||||
requestParams.orgType = orgType.value;
|
||||
}
|
||||
|
||||
$api.createRequest('/app/appWxphoneSmsCode', requestParams, 'post').then((resData) => {
|
||||
uni.hideLoading();
|
||||
// 检查可能的手机号字段
|
||||
const possiblePhoneFields = ['phone', 'mobile', 'phoneNumber', 'tel', 'mobilePhone'];
|
||||
@@ -285,9 +291,12 @@ const onWxGetPhoneNumber = async (e) => {
|
||||
phone: phoneValue || '', // 接口返回的手机号
|
||||
openid: resData.openid || '',
|
||||
unionid: resData.unionid || '',
|
||||
userType: userType.value,
|
||||
orgType: orgType.value
|
||||
userType: userType.value
|
||||
};
|
||||
// 只有单位用户才传递机构类型
|
||||
if (userType.value === 0) {
|
||||
params.orgType = orgType.value;
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/sms-verify?' + Object.keys(params)
|
||||
@@ -351,12 +360,18 @@ const wxLogin = () => {
|
||||
success: (loginRes) => {
|
||||
console.log('微信登录成功:', loginRes);
|
||||
|
||||
// 调用后端接口进行登录
|
||||
$api.createRequest('/app/appLogin', {
|
||||
// 根据用户类型构建参数
|
||||
const loginParams = {
|
||||
code: loginRes.code,
|
||||
userType: userType.value,
|
||||
orgType: orgType.value
|
||||
}, 'post').then((resData) => {
|
||||
userType: userType.value
|
||||
};
|
||||
// 只有单位用户才传递机构类型
|
||||
if (userType.value === 0) {
|
||||
loginParams.orgType = orgType.value;
|
||||
}
|
||||
|
||||
// 调用后端接口进行登录
|
||||
$api.createRequest('/app/appLogin', loginParams, 'post').then((resData) => {
|
||||
if (resData.token) {
|
||||
userStore.loginSetToken(resData.token).then((resume) => {
|
||||
// 更新用户类型到缓存
|
||||
|
||||
Reference in New Issue
Block a user