This commit is contained in:
FengHui
2026-04-10 13:18:15 +08:00
parent c742a65aa0
commit 3fe4dbe47f
2 changed files with 64 additions and 22 deletions

View File

@@ -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;
}