Show dialog for user SMS login errors
This commit is contained in:
@@ -15,6 +15,7 @@ const captchaImage = ref("");
|
||||
const loading = ref(false);
|
||||
const captchaLoading = ref(false);
|
||||
const message = ref("请先完成图形验证码,再获取短信验证码。");
|
||||
const errorDialog = ref("");
|
||||
|
||||
onMounted(() => {
|
||||
void loadCaptcha();
|
||||
@@ -36,7 +37,7 @@ async function loadCaptcha() {
|
||||
|
||||
async function sendCode() {
|
||||
if (!captchaId.value || captchaCode.value.length < 4) {
|
||||
message.value = "请先输入图形验证码";
|
||||
showError("请先输入图形验证码");
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
@@ -46,7 +47,7 @@ async function sendCode() {
|
||||
message.value = "短信验证码已发送,请查收。";
|
||||
await loadCaptcha();
|
||||
} catch (error) {
|
||||
message.value = error instanceof Error ? error.message : "发送失败";
|
||||
showError(error instanceof Error ? error.message : "发送失败");
|
||||
await loadCaptcha();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
@@ -66,6 +67,11 @@ async function login() {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function showError(text: string) {
|
||||
message.value = text;
|
||||
errorDialog.value = text;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -109,5 +115,13 @@ async function login() {
|
||||
{{ loading ? "处理中..." : "立即进入" }}
|
||||
</button>
|
||||
<div class="form-tip">{{ message }}</div>
|
||||
|
||||
<div v-if="errorDialog" class="dialog-mask" role="alertdialog" aria-modal="true" aria-labelledby="login-error-title">
|
||||
<div class="dialog-box">
|
||||
<strong id="login-error-title">无法发送验证码</strong>
|
||||
<p>{{ errorDialog }}</p>
|
||||
<button type="button" class="primary" @click="errorDialog = ''">知道了</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user