feat: migrate app routes and business modules
This commit is contained in:
@@ -1,414 +0,0 @@
|
||||
<!-- 页面编号:A-06;用途:只承接账号冻结、停用与风险限制等阻断登录状态。 -->
|
||||
<template>
|
||||
<AuthPageShell class="auth-page status-page">
|
||||
<view class="status-content">
|
||||
<view class="page-heading">
|
||||
<view class="back-button" hover-class="tap-fade" @click="requestBack">
|
||||
<image
|
||||
class="back-button__icon"
|
||||
src="/static/assets/foundation/transparent/chevron-right.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
<text class="page-title">登录受限</text>
|
||||
<text class="page-subtitle">请根据当前账号状态完成恢复</text>
|
||||
<image
|
||||
class="status-divider"
|
||||
src="/static/assets/modules/auth/transparent/a01-vnext-divider-v1.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="status-body">
|
||||
<image
|
||||
class="status-icon"
|
||||
src="/static/assets/foundation/transparent/auth-login-outline.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="status-eyebrow">{{ currentState.eyebrow }}</text>
|
||||
<text class="status-title">{{ currentState.title }}</text>
|
||||
<text class="status-description">{{ currentState.description }}</text>
|
||||
|
||||
<view class="status-details">
|
||||
<view class="status-detail">
|
||||
<text class="status-detail__label">{{
|
||||
currentState.reasonLabel
|
||||
}}</text>
|
||||
<text class="status-detail__value">{{ currentState.reason }}</text>
|
||||
</view>
|
||||
<view class="status-detail">
|
||||
<text class="status-detail__label">{{
|
||||
currentState.impactLabel
|
||||
}}</text>
|
||||
<text class="status-detail__value">{{ currentState.impact }}</text>
|
||||
</view>
|
||||
<view class="status-detail">
|
||||
<text class="status-detail__label">{{
|
||||
currentState.recoveryLabel
|
||||
}}</text>
|
||||
<text class="status-detail__value">{{
|
||||
currentState.recovery
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="status-primary"
|
||||
hover-class="button-hover"
|
||||
@click="openRecovery"
|
||||
>
|
||||
<image
|
||||
class="status-primary__skin"
|
||||
src="/static/assets/foundation/transparent/a01-scroll-primary-v3.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="status-primary__copy">查看恢复方式</text>
|
||||
</view>
|
||||
<view class="status-secondary" hover-class="tap-fade" @click="requestBack"
|
||||
>返回登录</view
|
||||
>
|
||||
</view>
|
||||
|
||||
<template #overlay>
|
||||
<view
|
||||
v-if="recoveryVisible"
|
||||
class="recovery-layer"
|
||||
@click="closeRecovery"
|
||||
>
|
||||
<view class="recovery-dialog" @click.stop>
|
||||
<image
|
||||
class="recovery-dialog__skin"
|
||||
src="/static/assets/modules/auth/transparent/a01-scroll-dialog-v3.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<view class="recovery-dialog__content">
|
||||
<text class="recovery-title">{{ currentState.recoveryTitle }}</text>
|
||||
<text class="recovery-copy">{{ currentState.recoveryDetail }}</text>
|
||||
<text class="recovery-note"
|
||||
>账号恢复服务将在功能阶段接入,当前仅审核页面样式与状态位置。</text
|
||||
>
|
||||
<view
|
||||
class="recovery-action"
|
||||
hover-class="button-hover"
|
||||
@click="closeRecovery"
|
||||
>
|
||||
<image
|
||||
class="recovery-action__skin"
|
||||
src="/static/assets/foundation/transparent/a01-scroll-primary-v3.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="recovery-action__copy">我知道了</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</AuthPageShell>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onBackPress, onLoad } from "@dcloudio/uni-app";
|
||||
import AuthPageShell from "@/components/AuthPageShell.vue";
|
||||
import { goRoot, handleBackPress, runBackGuard } from "@/utils/navigation.js";
|
||||
|
||||
const status = ref("risk");
|
||||
const recoveryVisible = ref(false);
|
||||
|
||||
// A06 阻断状态的唯一合同;普通登录错误必须留在 A01 就近处理。
|
||||
const statusConfig = {
|
||||
frozen: {
|
||||
eyebrow: "账号冻结",
|
||||
title: "账号已被冻结",
|
||||
description: "当前账号因安全审核暂时无法登录。",
|
||||
reasonLabel: "限制原因",
|
||||
reason: "账号进入人工安全审核",
|
||||
impactLabel: "影响范围",
|
||||
impact: "暂时无法进入家谱及管理资料",
|
||||
recoveryLabel: "恢复方式",
|
||||
recovery: "提交账号申诉并等待审核结果",
|
||||
recoveryTitle: "申请解除冻结",
|
||||
recoveryDetail: "请准备注册手机号与身份说明,提交后由平台进行人工核验。",
|
||||
},
|
||||
disabled: {
|
||||
eyebrow: "账号停用",
|
||||
title: "账号已被停用",
|
||||
description: "当前账号处于停用状态,登录入口已关闭。",
|
||||
reasonLabel: "限制原因",
|
||||
reason: "账号已执行停用处理",
|
||||
impactLabel: "影响范围",
|
||||
impact: "无法登录,原有家谱资料不会被删除",
|
||||
recoveryLabel: "恢复方式",
|
||||
recovery: "联系平台核实停用原因与恢复条件",
|
||||
recoveryTitle: "联系平台核实",
|
||||
recoveryDetail:
|
||||
"请提供注册手机号和账号归属信息,平台核实后告知是否可以恢复。",
|
||||
},
|
||||
risk: {
|
||||
eyebrow: "风险限制",
|
||||
title: "账号存在安全风险",
|
||||
description: "系统检测到异常登录,为保护家谱资料已暂停本次登录。",
|
||||
reasonLabel: "限制原因",
|
||||
reason: "登录环境或操作行为存在异常",
|
||||
impactLabel: "影响范围",
|
||||
impact: "本次登录被阻断,账号资料保持不变",
|
||||
recoveryLabel: "恢复方式",
|
||||
recovery: "完成身份核验后重新登录",
|
||||
recoveryTitle: "完成身份核验",
|
||||
recoveryDetail: "请使用注册手机号完成身份核验;核验通过后可重新尝试登录。",
|
||||
},
|
||||
};
|
||||
|
||||
const currentState = computed(() => statusConfig[status.value]);
|
||||
|
||||
const resolveStatus = (options = {}) => {
|
||||
const requestedStatus = options.status || "risk";
|
||||
status.value = Object.prototype.hasOwnProperty.call(
|
||||
statusConfig,
|
||||
requestedStatus,
|
||||
)
|
||||
? requestedStatus
|
||||
: "risk";
|
||||
recoveryVisible.value = false;
|
||||
};
|
||||
|
||||
onLoad(resolveStatus);
|
||||
|
||||
const openRecovery = () => {
|
||||
recoveryVisible.value = true;
|
||||
};
|
||||
const closeRecovery = () => {
|
||||
recoveryVisible.value = false;
|
||||
};
|
||||
const requestBack = () => {
|
||||
if (recoveryVisible.value) {
|
||||
return runBackGuard({
|
||||
transientOpen: true,
|
||||
"close-transient": closeRecovery,
|
||||
});
|
||||
}
|
||||
return goRoot("A01");
|
||||
};
|
||||
|
||||
onBackPress((event) => handleBackPress(event, requestBack));
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.status-content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
min-width: 0;
|
||||
margin: 0 auto;
|
||||
padding: clamp(10px, 2.2vh, 20px) clamp(24px, 8.5vw, 44px);
|
||||
}
|
||||
.page-heading {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: auto auto auto;
|
||||
justify-items: center;
|
||||
min-height: 154rpx;
|
||||
}
|
||||
.back-button {
|
||||
display: flex;
|
||||
grid-row: 1 / -1;
|
||||
grid-column: 1;
|
||||
align-self: start;
|
||||
justify-self: start;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: var(--app-touch-min);
|
||||
height: var(--app-touch-min);
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.back-button__icon {
|
||||
width: 42rpx;
|
||||
height: 42rpx;
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
.page-title {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
color: #9f170f;
|
||||
font-size: clamp(29px, 58rpx, 36px);
|
||||
font-weight: 700;
|
||||
letter-spacing: 7rpx;
|
||||
}
|
||||
.page-subtitle {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
margin-top: 12rpx;
|
||||
color: #806c58;
|
||||
font-size: clamp(15px, 25rpx, 18px);
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
.status-divider {
|
||||
grid-column: 1;
|
||||
grid-row: 3;
|
||||
width: 300rpx;
|
||||
height: 50rpx;
|
||||
margin-top: 2rpx;
|
||||
filter: brightness(0.68) saturate(1.5) contrast(1.2);
|
||||
}
|
||||
|
||||
.status-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding-top: 6rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.status-icon {
|
||||
width: 94rpx;
|
||||
height: 94rpx;
|
||||
opacity: 0.82;
|
||||
}
|
||||
.status-eyebrow {
|
||||
margin-top: 10rpx;
|
||||
color: #a7160c;
|
||||
font-size: clamp(14px, 22rpx, 17px);
|
||||
letter-spacing: 3rpx;
|
||||
}
|
||||
.status-title {
|
||||
margin-top: 10rpx;
|
||||
color: #3f2c1d;
|
||||
font-size: clamp(20px, 40rpx, 26px);
|
||||
font-weight: 700;
|
||||
letter-spacing: 3rpx;
|
||||
}
|
||||
.status-description {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
margin-top: 12rpx;
|
||||
color: #786654;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.65;
|
||||
}
|
||||
.status-details {
|
||||
width: 100%;
|
||||
margin-top: 22rpx;
|
||||
border-top: 1rpx solid #cfaa70;
|
||||
}
|
||||
.status-detail {
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
min-height: 78rpx;
|
||||
padding: 16rpx 0;
|
||||
border-bottom: 1rpx solid rgba(207, 170, 112, 0.72);
|
||||
text-align: left;
|
||||
}
|
||||
.status-detail__label {
|
||||
flex: 0 0 116rpx;
|
||||
color: #9f170f;
|
||||
font-size: clamp(14px, 23rpx, 17px);
|
||||
}
|
||||
.status-detail__value {
|
||||
flex: 1;
|
||||
color: #5f4a38;
|
||||
font-size: clamp(14px, 23rpx, 17px);
|
||||
line-height: max(1.35em, clamp(19px, 34rpx, 24px));
|
||||
}
|
||||
|
||||
.status-primary {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
min-height: var(--app-touch-min);
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.status-primary__skin,
|
||||
.recovery-action__skin {
|
||||
grid-area: 1 / 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.status-primary__copy {
|
||||
z-index: 1;
|
||||
grid-area: 1 / 1;
|
||||
color: #fffaf0;
|
||||
font-size: clamp(20px, 38rpx, 26px);
|
||||
letter-spacing: 5rpx;
|
||||
}
|
||||
.status-secondary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: var(--app-touch-min);
|
||||
color: #a7160c;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
}
|
||||
|
||||
.recovery-layer {
|
||||
position: fixed;
|
||||
z-index: 20;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
padding: 42rpx;
|
||||
background: rgba(35, 18, 10, 0.62);
|
||||
}
|
||||
.recovery-dialog {
|
||||
display: grid;
|
||||
width: 620rpx;
|
||||
min-height: 520rpx;
|
||||
max-height: calc(var(--app-viewport-height) - 40px);
|
||||
}
|
||||
.recovery-dialog__skin {
|
||||
grid-area: 1 / 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.recovery-dialog__content {
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
grid-area: 1 / 1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
min-height: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 58rpx 58rpx 36rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.recovery-title {
|
||||
color: #8f160f;
|
||||
font-size: clamp(22px, 42rpx, 28px);
|
||||
font-weight: 700;
|
||||
letter-spacing: 4rpx;
|
||||
}
|
||||
.recovery-copy {
|
||||
margin-top: 20rpx;
|
||||
color: #513a28;
|
||||
font-size: clamp(16px, 26rpx, 20px);
|
||||
line-height: max(1.35em, clamp(20px, 40rpx, 26px));
|
||||
}
|
||||
.recovery-note {
|
||||
margin-top: 12rpx;
|
||||
color: #8d7965;
|
||||
font-size: clamp(13px, 20rpx, 16px);
|
||||
line-height: max(1.35em, clamp(17px, 31rpx, 22px));
|
||||
}
|
||||
.recovery-action {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 100%;
|
||||
min-height: 80rpx;
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
.recovery-action__copy {
|
||||
z-index: 1;
|
||||
grid-area: 1 / 1;
|
||||
color: #fffaf0;
|
||||
font-size: clamp(16px, 29rpx, 20px);
|
||||
letter-spacing: 4rpx;
|
||||
}
|
||||
.tap-fade,
|
||||
.button-hover {
|
||||
opacity: 0.72;
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,3 @@
|
||||
<!-- 页面编号:A-04;用途:注册账号与本页服务协议确认。 -->
|
||||
<template>
|
||||
<AuthPageShell class="auth-page register-page">
|
||||
<view class="register-content">
|
||||
@@ -20,7 +19,7 @@
|
||||
<text class="page-subtitle">创建属于你的家谱账号</text>
|
||||
<image
|
||||
class="register-divider"
|
||||
src="/static/assets/modules/auth/transparent/a01-vnext-divider-v1.png"
|
||||
src="/static/assets/modules/auth/transparent/title-divider.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
@@ -31,11 +30,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.phone }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label" for="a04-phone"
|
||||
<label class="input-label" for="register-phone"
|
||||
><text class="required-mark">*</text>手机号</label
|
||||
>
|
||||
<input
|
||||
id="a04-phone"
|
||||
id="register-phone"
|
||||
v-model.trim="phone"
|
||||
class="auth-input"
|
||||
type="number"
|
||||
@@ -51,14 +50,14 @@
|
||||
placeholder-class="placeholder"
|
||||
:aria-invalid="Boolean(fieldErrors.phone)"
|
||||
:aria-describedby="
|
||||
fieldErrors.phone ? 'a04-phone-error' : undefined
|
||||
fieldErrors.phone ? 'register-phone-error' : undefined
|
||||
"
|
||||
@input="handlePhoneInput"
|
||||
/>
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.phone"
|
||||
id="a04-phone-error"
|
||||
id="register-phone-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.phone }}</text
|
||||
@@ -67,9 +66,9 @@
|
||||
|
||||
<view class="field-block">
|
||||
<view class="input-row">
|
||||
<label class="input-label" for="a04-nickname">昵称</label>
|
||||
<label class="input-label" for="register-nickname">昵称</label>
|
||||
<input
|
||||
id="a04-nickname"
|
||||
id="register-nickname"
|
||||
v-model.trim="nickName"
|
||||
class="auth-input"
|
||||
:disabled="submitting || registrationCommitted"
|
||||
@@ -84,11 +83,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.verificationCode }"
|
||||
>
|
||||
<view class="input-row code-row">
|
||||
<label class="input-label" for="a04-verification-code"
|
||||
<label class="input-label" for="register-verification-code"
|
||||
><text class="required-mark">*</text>验证码</label
|
||||
>
|
||||
<input
|
||||
id="a04-verification-code"
|
||||
id="register-verification-code"
|
||||
v-model.trim="verificationCode"
|
||||
class="auth-input"
|
||||
type="number"
|
||||
@@ -99,7 +98,7 @@
|
||||
:aria-invalid="Boolean(fieldErrors.verificationCode)"
|
||||
:aria-describedby="
|
||||
fieldErrors.verificationCode
|
||||
? 'a04-verification-code-error'
|
||||
? 'register-verification-code-error'
|
||||
: undefined
|
||||
"
|
||||
@input="clearFieldError('verificationCode')"
|
||||
@@ -129,7 +128,7 @@
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.verificationCode"
|
||||
id="a04-verification-code-error"
|
||||
id="register-verification-code-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.verificationCode }}</text
|
||||
@@ -141,11 +140,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.password }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label input-label--password" for="a04-password"
|
||||
<label class="input-label input-label--password" for="register-password"
|
||||
><text class="required-mark">*</text>设置密码</label
|
||||
>
|
||||
<input
|
||||
id="a04-password"
|
||||
id="register-password"
|
||||
v-model="password"
|
||||
class="auth-input"
|
||||
password
|
||||
@@ -155,14 +154,14 @@
|
||||
placeholder-class="placeholder"
|
||||
:aria-invalid="Boolean(fieldErrors.password)"
|
||||
:aria-describedby="
|
||||
fieldErrors.password ? 'a04-password-error' : undefined
|
||||
fieldErrors.password ? 'register-password-error' : undefined
|
||||
"
|
||||
@input="clearFieldError('password')"
|
||||
/>
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.password"
|
||||
id="a04-password-error"
|
||||
id="register-password-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.password }}</text
|
||||
@@ -174,11 +173,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.confirmPassword }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label input-label--password" for="a04-confirm-password"
|
||||
<label class="input-label input-label--password" for="register-confirm-password"
|
||||
><text class="required-mark">*</text>确认密码</label
|
||||
>
|
||||
<input
|
||||
id="a04-confirm-password"
|
||||
id="register-confirm-password"
|
||||
v-model="confirmPassword"
|
||||
class="auth-input"
|
||||
password
|
||||
@@ -189,7 +188,7 @@
|
||||
:aria-invalid="Boolean(fieldErrors.confirmPassword)"
|
||||
:aria-describedby="
|
||||
fieldErrors.confirmPassword
|
||||
? 'a04-confirm-password-error'
|
||||
? 'register-confirm-password-error'
|
||||
: undefined
|
||||
"
|
||||
@input="clearFieldError('confirmPassword')"
|
||||
@@ -197,7 +196,7 @@
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.confirmPassword"
|
||||
id="a04-confirm-password-error"
|
||||
id="register-confirm-password-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.confirmPassword }}</text
|
||||
@@ -214,7 +213,7 @@
|
||||
>
|
||||
<image
|
||||
class="register-submit__skin"
|
||||
src="/static/assets/foundation/transparent/a01-scroll-primary-v3.png"
|
||||
src="/static/assets/foundation/transparent/scroll-primary.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="register-submit__content">{{
|
||||
@@ -249,8 +248,8 @@
|
||||
class="agreement-icon"
|
||||
:src="
|
||||
agreed
|
||||
? '/static/assets/modules/auth/transparent/a02-agreement-checked.png'
|
||||
: '/static/assets/modules/auth/transparent/a02-agreement-unchecked.png'
|
||||
? '/static/assets/modules/auth/transparent/agreement-checked.png'
|
||||
: '/static/assets/modules/auth/transparent/agreement-unchecked.png'
|
||||
"
|
||||
mode="aspectFit"
|
||||
aria-hidden="true"
|
||||
@@ -322,30 +321,26 @@ import { computed, ref } from "vue";
|
||||
import { onBackPress, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import AppDialog from "@/components/AppDialog.vue";
|
||||
import AppToast from "@/components/AppToast.vue";
|
||||
import AuthPageShell from "@/components/AuthPageShell.vue";
|
||||
import TacVerification from "@/components/TacVerification.vue";
|
||||
import AuthPageShell from "@/components/auth/PageShell.vue";
|
||||
import TacVerification from "@/components/auth/TacVerification.vue";
|
||||
import { useSmsVerification } from "@/composables/auth/use-sms-verification.js";
|
||||
import {
|
||||
appApi,
|
||||
createRequestController,
|
||||
isRequestCancelled,
|
||||
} from "@/utils/api.js";
|
||||
isRequestCancelled
|
||||
} from "@/services/api/request-controller.js";
|
||||
import { authApi } from "@/services/api/auth-service.js";
|
||||
import {
|
||||
AUTH_VERIFICATION_OPERATION,
|
||||
createTacRenderContext,
|
||||
isAuthPhone,
|
||||
isSmsDeliveryOutcomeUnknown,
|
||||
normalizeCaptchaRequirement,
|
||||
normalizeTacSuccess,
|
||||
} from "@/utils/auth-verification.js";
|
||||
import { createAuthSmsCooldown } from "@/utils/auth-sms-cooldown.js";
|
||||
import { runtimeConfig } from "@/utils/config.js";
|
||||
} from "@/utils/auth/verification.js";
|
||||
import { createDiscardConfirmation } from "@/utils/discard-confirmation.js";
|
||||
import { calcMD5 } from "@/utils/md5.js";
|
||||
import { goRoot, handleBackPress, runBackGuard } from "@/utils/navigation.js";
|
||||
import { createNonIdempotentWriteGuard } from "@/utils/non-idempotent-write-guard.js";
|
||||
import { goRoot, handleBackPress, runBackGuard } from "@/utils/navigation/gateway.js";
|
||||
import {
|
||||
PASSWORD_POLICY_MESSAGE,
|
||||
validatePassword,
|
||||
} from "@/utils/validation.js";
|
||||
} from "@/utils/auth/password-policy.js";
|
||||
|
||||
const phone = ref("");
|
||||
const nickName = ref("");
|
||||
@@ -363,13 +358,8 @@ const fieldErrors = ref({
|
||||
const feedbackVisible = ref(false);
|
||||
const feedbackMessage = ref("");
|
||||
const discardVisible = ref(false);
|
||||
const tacVisible = ref(false);
|
||||
const tacContext = ref(null);
|
||||
const sendingCode = ref(false);
|
||||
const submitting = ref(false);
|
||||
const registrationCommitted = ref(false);
|
||||
const cooldownSeconds = ref(0);
|
||||
const sentPhone = ref("");
|
||||
const isDirty = computed(
|
||||
() =>
|
||||
!registrationCommitted.value &&
|
||||
@@ -383,17 +373,11 @@ const isDirty = computed(
|
||||
),
|
||||
);
|
||||
let feedbackTimer = null;
|
||||
let tacSequence = 0;
|
||||
let pageActive = true;
|
||||
const registrationNavigationFailure =
|
||||
"注册已完成,但暂时无法进入家谱,请再次点击进入";
|
||||
const authRequestController = createRequestController();
|
||||
const smsCooldown = createAuthSmsCooldown({
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.REGISTER,
|
||||
onChange: (seconds) => {
|
||||
cooldownSeconds.value = seconds;
|
||||
},
|
||||
});
|
||||
const registrationSubmissionRequestController = createRequestController();
|
||||
const registrationGuard = createNonIdempotentWriteGuard();
|
||||
const discardConfirmation = createDiscardConfirmation((visible) => {
|
||||
discardVisible.value = visible;
|
||||
});
|
||||
@@ -401,17 +385,6 @@ const requestDiscardConfirmation = discardConfirmation.request;
|
||||
const confirmDiscard = discardConfirmation.confirm;
|
||||
const cancelDiscard = discardConfirmation.cancel;
|
||||
|
||||
const closeTac = () => {
|
||||
tacVisible.value = false;
|
||||
tacContext.value = null;
|
||||
};
|
||||
|
||||
const cancelPendingRequest = () => {
|
||||
authRequestController.abort();
|
||||
sendingCode.value = false;
|
||||
submitting.value = false;
|
||||
};
|
||||
|
||||
const requestBack = () =>
|
||||
registrationCommitted.value
|
||||
? enterAuthenticatedRoot()
|
||||
@@ -420,10 +393,7 @@ const requestBack = () =>
|
||||
submitting: submitting.value || sendingCode.value,
|
||||
dirty: isDirty.value,
|
||||
"close-transient": tacVisible.value ? closeTac : cancelDiscard,
|
||||
"block-submitting": () => {
|
||||
cancelPendingRequest();
|
||||
return requestBack();
|
||||
},
|
||||
"block-submitting": () => true,
|
||||
"confirm-discard": requestDiscardConfirmation,
|
||||
});
|
||||
|
||||
@@ -431,12 +401,12 @@ onBackPress((event) => handleBackPress(event, requestBack));
|
||||
|
||||
onUnload(() => {
|
||||
pageActive = false;
|
||||
authRequestController.abort();
|
||||
smsVerification.dispose();
|
||||
registrationSubmissionRequestController.abort();
|
||||
if (feedbackTimer) clearTimeout(feedbackTimer);
|
||||
smsCooldown.dispose();
|
||||
discardConfirmation.dispose();
|
||||
});
|
||||
onShow(() => smsCooldown.sync());
|
||||
onShow(() => smsVerification.syncCooldown());
|
||||
|
||||
const showFeedback = (message) => {
|
||||
feedbackMessage.value = message;
|
||||
@@ -448,6 +418,25 @@ const showFeedback = (message) => {
|
||||
}, 2200);
|
||||
};
|
||||
|
||||
const smsVerification = useSmsVerification({
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.REGISTER,
|
||||
requestIdPrefix: "register",
|
||||
phone,
|
||||
isActive: () => pageActive,
|
||||
showFeedback,
|
||||
});
|
||||
const {
|
||||
tacVisible,
|
||||
tacContext,
|
||||
sendingCode,
|
||||
cooldownSeconds,
|
||||
sentPhone,
|
||||
closeTac,
|
||||
completeTac,
|
||||
handleTacFailure,
|
||||
handleTacError,
|
||||
} = smsVerification;
|
||||
|
||||
const enterAuthenticatedRoot = async () => {
|
||||
if (!pageActive) return false;
|
||||
submitting.value = true;
|
||||
@@ -495,92 +484,7 @@ const prepareGetCode = async () => {
|
||||
agreementError.value = true;
|
||||
return;
|
||||
}
|
||||
sendingCode.value = true;
|
||||
try {
|
||||
const operationCode = AUTH_VERIFICATION_OPERATION.REGISTER;
|
||||
const requestedPhone = phone.value;
|
||||
const response = await appApi.getCaptchaRequirement(
|
||||
{ operationCode, subject: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
if (phone.value !== requestedPhone)
|
||||
throw new Error("手机号已变化,请重新获取验证码");
|
||||
const requirement = normalizeCaptchaRequirement(response);
|
||||
if (!requirement.required) {
|
||||
await appApi.sendSmsCode(
|
||||
{ operationCode, phone: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
sentPhone.value = requestedPhone;
|
||||
smsCooldown.start();
|
||||
showFeedback("验证码已发送");
|
||||
return;
|
||||
}
|
||||
tacSequence += 1;
|
||||
tacContext.value = createTacRenderContext({
|
||||
requestId: `a04-register-${tacSequence}`,
|
||||
baseUrl: runtimeConfig.baseUrl,
|
||||
clientId: runtimeConfig.clientId,
|
||||
tenantId: runtimeConfig.tenantId,
|
||||
operationCode,
|
||||
subject: requestedPhone,
|
||||
requirement,
|
||||
});
|
||||
tacVisible.value = true;
|
||||
} catch (error) {
|
||||
if (pageActive && !isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "安全验证暂不可用");
|
||||
}
|
||||
} finally {
|
||||
if (pageActive) sendingCode.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const completeTac = async (result) => {
|
||||
const expectedContext = tacContext.value;
|
||||
if (!expectedContext) return;
|
||||
try {
|
||||
const ticket = normalizeTacSuccess(result, expectedContext.requestId);
|
||||
if (phone.value !== expectedContext.subject)
|
||||
throw new Error("手机号已变化,请重新验证");
|
||||
closeTac();
|
||||
sendingCode.value = true;
|
||||
await appApi.sendSmsCode(
|
||||
{
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.REGISTER,
|
||||
phone: expectedContext.subject,
|
||||
validToken: ticket.validToken,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
sentPhone.value = expectedContext.subject;
|
||||
smsCooldown.start();
|
||||
showFeedback("验证码已发送");
|
||||
} catch (error) {
|
||||
closeTac();
|
||||
if (pageActive) {
|
||||
if (isSmsDeliveryOutcomeUnknown(error)) {
|
||||
sentPhone.value = expectedContext.subject;
|
||||
smsCooldown.start();
|
||||
showFeedback("发送结果未知,如收到短信可直接填写;60 秒后可重试");
|
||||
} else if (!isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "验证码发送失败");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (pageActive) sendingCode.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleTacFailure = ({ message } = {}) =>
|
||||
showFeedback(message || "行为验证未通过,请重试");
|
||||
|
||||
const handleTacError = ({ message } = {}) => {
|
||||
closeTac();
|
||||
showFeedback(message || "安全验证暂不可用");
|
||||
return smsVerification.requestCode();
|
||||
};
|
||||
|
||||
const validateForm = () => {
|
||||
@@ -610,23 +514,37 @@ const submitRegister = async () => {
|
||||
const formValid = validateForm();
|
||||
if (!agreed.value) agreementError.value = true;
|
||||
if (!formValid || !agreed.value) return;
|
||||
const registrationPayload = {
|
||||
phone: phone.value,
|
||||
nickName: nickName.value,
|
||||
passwordHash: calcMD5(password.value),
|
||||
smsCode: verificationCode.value,
|
||||
};
|
||||
const registrationAttempt = registrationGuard.begin(registrationPayload);
|
||||
if (registrationAttempt === null) {
|
||||
showFeedback(
|
||||
"上次注册结果暂时无法确认,请先返回登录页尝试登录,不要重复注册。",
|
||||
);
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
await appApi.registerWithPassword(
|
||||
{
|
||||
phone: phone.value,
|
||||
nickName: nickName.value,
|
||||
passwordHash: calcMD5(password.value),
|
||||
smsCode: verificationCode.value,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
await authApi.registerWithPassword(
|
||||
registrationPayload,
|
||||
{ requestController: registrationSubmissionRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
registrationCommitted.value = true;
|
||||
} catch (error) {
|
||||
if (pageActive && !isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "注册失败,请稍后重试");
|
||||
if (!pageActive) return;
|
||||
if (registrationGuard.recordFailure(registrationAttempt, error)) {
|
||||
showFeedback(
|
||||
"注册结果暂时无法确认,请先返回登录页尝试登录,不要重复注册。",
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!isRequestCancelled(error))
|
||||
showFeedback(error.message || "注册失败,请稍后重试");
|
||||
return;
|
||||
} finally {
|
||||
if (pageActive) submitting.value = false;
|
||||
@@ -1,4 +1,3 @@
|
||||
<!-- 页面编号:A-05;用途:通过手机号验证后重设登录密码。 -->
|
||||
<template>
|
||||
<AuthPageShell class="auth-page reset-page">
|
||||
<view class="reset-content">
|
||||
@@ -20,7 +19,7 @@
|
||||
<text class="page-subtitle">验证手机号后设置新的登录密码</text>
|
||||
<image
|
||||
class="reset-divider"
|
||||
src="/static/assets/modules/auth/transparent/a01-vnext-divider-v1.png"
|
||||
src="/static/assets/modules/auth/transparent/title-divider.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
@@ -31,11 +30,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.phone }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label" for="a05-phone"
|
||||
<label class="input-label" for="reset-password-phone"
|
||||
><text class="required-mark">*</text>手机号</label
|
||||
>
|
||||
<input
|
||||
id="a05-phone"
|
||||
id="reset-password-phone"
|
||||
v-model.trim="phone"
|
||||
class="auth-input"
|
||||
type="number"
|
||||
@@ -49,14 +48,14 @@
|
||||
placeholder-class="placeholder"
|
||||
:aria-invalid="Boolean(fieldErrors.phone)"
|
||||
:aria-describedby="
|
||||
fieldErrors.phone ? 'a05-phone-error' : undefined
|
||||
fieldErrors.phone ? 'reset-password-phone-error' : undefined
|
||||
"
|
||||
@input="handlePhoneInput"
|
||||
/>
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.phone"
|
||||
id="a05-phone-error"
|
||||
id="reset-password-phone-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.phone }}</text
|
||||
@@ -68,11 +67,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.verificationCode }"
|
||||
>
|
||||
<view class="input-row code-row">
|
||||
<label class="input-label" for="a05-verification-code"
|
||||
<label class="input-label" for="reset-password-verification-code"
|
||||
><text class="required-mark">*</text>验证码</label
|
||||
>
|
||||
<input
|
||||
id="a05-verification-code"
|
||||
id="reset-password-verification-code"
|
||||
v-model.trim="verificationCode"
|
||||
class="auth-input"
|
||||
type="number"
|
||||
@@ -83,7 +82,7 @@
|
||||
:aria-invalid="Boolean(fieldErrors.verificationCode)"
|
||||
:aria-describedby="
|
||||
fieldErrors.verificationCode
|
||||
? 'a05-verification-code-error'
|
||||
? 'reset-password-verification-code-error'
|
||||
: undefined
|
||||
"
|
||||
@input="clearFieldError('verificationCode')"
|
||||
@@ -108,7 +107,7 @@
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.verificationCode"
|
||||
id="a05-verification-code-error"
|
||||
id="reset-password-verification-code-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.verificationCode }}</text
|
||||
@@ -120,11 +119,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.password }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label" for="a05-password"
|
||||
<label class="input-label" for="reset-password-new-password"
|
||||
><text class="required-mark">*</text>新密码</label
|
||||
>
|
||||
<input
|
||||
id="a05-password"
|
||||
id="reset-password-new-password"
|
||||
v-model="password"
|
||||
class="auth-input"
|
||||
password
|
||||
@@ -134,14 +133,14 @@
|
||||
placeholder-class="placeholder"
|
||||
:aria-invalid="Boolean(fieldErrors.password)"
|
||||
:aria-describedby="
|
||||
fieldErrors.password ? 'a05-password-error' : undefined
|
||||
fieldErrors.password ? 'reset-password-new-password-error' : undefined
|
||||
"
|
||||
@input="clearFieldError('password')"
|
||||
/>
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.password"
|
||||
id="a05-password-error"
|
||||
id="reset-password-new-password-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.password }}</text
|
||||
@@ -153,11 +152,11 @@
|
||||
:class="{ 'field-block--error': fieldErrors.confirmPassword }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label input-label--confirm" for="a05-confirm-password"
|
||||
<label class="input-label input-label--confirm" for="reset-password-confirm-password"
|
||||
><text class="required-mark">*</text>确认新密码</label
|
||||
>
|
||||
<input
|
||||
id="a05-confirm-password"
|
||||
id="reset-password-confirm-password"
|
||||
v-model="confirmPassword"
|
||||
class="auth-input"
|
||||
password
|
||||
@@ -168,7 +167,7 @@
|
||||
:aria-invalid="Boolean(fieldErrors.confirmPassword)"
|
||||
:aria-describedby="
|
||||
fieldErrors.confirmPassword
|
||||
? 'a05-confirm-password-error'
|
||||
? 'reset-password-confirm-password-error'
|
||||
: undefined
|
||||
"
|
||||
@input="clearFieldError('confirmPassword')"
|
||||
@@ -176,7 +175,7 @@
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.confirmPassword"
|
||||
id="a05-confirm-password-error"
|
||||
id="reset-password-confirm-password-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.confirmPassword }}</text
|
||||
@@ -193,7 +192,7 @@
|
||||
>
|
||||
<image
|
||||
class="reset-submit__skin"
|
||||
src="/static/assets/foundation/transparent/a01-scroll-primary-v3.png"
|
||||
src="/static/assets/foundation/transparent/scroll-primary.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="reset-submit__content">{{
|
||||
@@ -263,30 +262,26 @@ import { computed, ref } from "vue";
|
||||
import { onBackPress, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import AppDialog from "@/components/AppDialog.vue";
|
||||
import AppToast from "@/components/AppToast.vue";
|
||||
import AuthPageShell from "@/components/AuthPageShell.vue";
|
||||
import TacVerification from "@/components/TacVerification.vue";
|
||||
import AuthPageShell from "@/components/auth/PageShell.vue";
|
||||
import TacVerification from "@/components/auth/TacVerification.vue";
|
||||
import { useSmsVerification } from "@/composables/auth/use-sms-verification.js";
|
||||
import {
|
||||
appApi,
|
||||
createRequestController,
|
||||
isRequestCancelled,
|
||||
} from "@/utils/api.js";
|
||||
isRequestCancelled
|
||||
} from "@/services/api/request-controller.js";
|
||||
import { authApi } from "@/services/api/auth-service.js";
|
||||
import {
|
||||
AUTH_VERIFICATION_OPERATION,
|
||||
createTacRenderContext,
|
||||
isAuthPhone,
|
||||
isSmsDeliveryOutcomeUnknown,
|
||||
normalizeCaptchaRequirement,
|
||||
normalizeTacSuccess,
|
||||
} from "@/utils/auth-verification.js";
|
||||
import { createAuthSmsCooldown } from "@/utils/auth-sms-cooldown.js";
|
||||
import { runtimeConfig } from "@/utils/config.js";
|
||||
} from "@/utils/auth/verification.js";
|
||||
import { createDiscardConfirmation } from "@/utils/discard-confirmation.js";
|
||||
import { calcMD5 } from "@/utils/md5.js";
|
||||
import { handleBackPress, returnTo, runBackGuard } from "@/utils/navigation.js";
|
||||
import { createNonIdempotentWriteGuard } from "@/utils/non-idempotent-write-guard.js";
|
||||
import { handleBackPress, returnTo, runBackGuard } from "@/utils/navigation/gateway.js";
|
||||
import {
|
||||
PASSWORD_POLICY_MESSAGE,
|
||||
validatePassword,
|
||||
} from "@/utils/validation.js";
|
||||
} from "@/utils/auth/password-policy.js";
|
||||
|
||||
const phone = ref("");
|
||||
const verificationCode = ref("");
|
||||
@@ -296,12 +291,7 @@ const successVisible = ref(false);
|
||||
const feedbackVisible = ref(false);
|
||||
const feedbackMessage = ref("");
|
||||
const discardVisible = ref(false);
|
||||
const tacVisible = ref(false);
|
||||
const tacContext = ref(null);
|
||||
const sendingCode = ref(false);
|
||||
const submitting = ref(false);
|
||||
const cooldownSeconds = ref(0);
|
||||
const sentPhone = ref("");
|
||||
const fieldErrors = ref({
|
||||
phone: "",
|
||||
verificationCode: "",
|
||||
@@ -319,15 +309,9 @@ const isDirty = computed(
|
||||
),
|
||||
);
|
||||
let feedbackTimer = null;
|
||||
let tacSequence = 0;
|
||||
let pageActive = true;
|
||||
const authRequestController = createRequestController();
|
||||
const smsCooldown = createAuthSmsCooldown({
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.FORGOT_PASSWORD,
|
||||
onChange: (seconds) => {
|
||||
cooldownSeconds.value = seconds;
|
||||
},
|
||||
});
|
||||
const passwordResetSubmissionRequestController = createRequestController();
|
||||
const passwordResetGuard = createNonIdempotentWriteGuard();
|
||||
const discardConfirmation = createDiscardConfirmation((visible) => {
|
||||
discardVisible.value = visible;
|
||||
});
|
||||
@@ -338,17 +322,6 @@ const cancelDiscard = discardConfirmation.cancel;
|
||||
// 重设成功不产生可跨页消费的数据;只有远端 PUT 已成功后才显示该终态。
|
||||
const leaveResetSuccess = () => returnTo("A01", {});
|
||||
|
||||
const closeTac = () => {
|
||||
tacVisible.value = false;
|
||||
tacContext.value = null;
|
||||
};
|
||||
|
||||
const cancelPendingRequest = () => {
|
||||
authRequestController.abort();
|
||||
sendingCode.value = false;
|
||||
submitting.value = false;
|
||||
};
|
||||
|
||||
const requestBack = () => {
|
||||
if (successVisible.value) return leaveResetSuccess();
|
||||
return runBackGuard({
|
||||
@@ -356,10 +329,7 @@ const requestBack = () => {
|
||||
submitting: submitting.value || sendingCode.value,
|
||||
dirty: isDirty.value,
|
||||
"close-transient": tacVisible.value ? closeTac : cancelDiscard,
|
||||
"block-submitting": () => {
|
||||
cancelPendingRequest();
|
||||
return requestBack();
|
||||
},
|
||||
"block-submitting": () => true,
|
||||
"confirm-discard": requestDiscardConfirmation,
|
||||
});
|
||||
};
|
||||
@@ -368,12 +338,12 @@ onBackPress((event) => handleBackPress(event, requestBack));
|
||||
|
||||
onUnload(() => {
|
||||
pageActive = false;
|
||||
authRequestController.abort();
|
||||
smsVerification.dispose();
|
||||
passwordResetSubmissionRequestController.abort();
|
||||
if (feedbackTimer) clearTimeout(feedbackTimer);
|
||||
smsCooldown.dispose();
|
||||
discardConfirmation.dispose();
|
||||
});
|
||||
onShow(() => smsCooldown.sync());
|
||||
onShow(() => smsVerification.syncCooldown());
|
||||
|
||||
const showFeedback = (message) => {
|
||||
feedbackMessage.value = message;
|
||||
@@ -385,6 +355,25 @@ const showFeedback = (message) => {
|
||||
}, 2200);
|
||||
};
|
||||
|
||||
const smsVerification = useSmsVerification({
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.FORGOT_PASSWORD,
|
||||
requestIdPrefix: "forgot-password",
|
||||
phone,
|
||||
isActive: () => pageActive,
|
||||
showFeedback,
|
||||
});
|
||||
const {
|
||||
tacVisible,
|
||||
tacContext,
|
||||
sendingCode,
|
||||
cooldownSeconds,
|
||||
sentPhone,
|
||||
closeTac,
|
||||
completeTac,
|
||||
handleTacFailure,
|
||||
handleTacError,
|
||||
} = smsVerification;
|
||||
|
||||
const clearFieldError = (field) => {
|
||||
fieldErrors.value[field] = "";
|
||||
};
|
||||
@@ -404,92 +393,7 @@ const prepareGetCode = async () => {
|
||||
return;
|
||||
}
|
||||
fieldErrors.value.phone = "";
|
||||
sendingCode.value = true;
|
||||
try {
|
||||
const operationCode = AUTH_VERIFICATION_OPERATION.FORGOT_PASSWORD;
|
||||
const requestedPhone = phone.value;
|
||||
const response = await appApi.getCaptchaRequirement(
|
||||
{ operationCode, subject: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
if (phone.value !== requestedPhone)
|
||||
throw new Error("手机号已变化,请重新获取验证码");
|
||||
const requirement = normalizeCaptchaRequirement(response);
|
||||
if (!requirement.required) {
|
||||
await appApi.sendSmsCode(
|
||||
{ operationCode, phone: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
sentPhone.value = requestedPhone;
|
||||
smsCooldown.start();
|
||||
showFeedback("验证码已发送");
|
||||
return;
|
||||
}
|
||||
tacSequence += 1;
|
||||
tacContext.value = createTacRenderContext({
|
||||
requestId: `a05-forgot-${tacSequence}`,
|
||||
baseUrl: runtimeConfig.baseUrl,
|
||||
clientId: runtimeConfig.clientId,
|
||||
tenantId: runtimeConfig.tenantId,
|
||||
operationCode,
|
||||
subject: requestedPhone,
|
||||
requirement,
|
||||
});
|
||||
tacVisible.value = true;
|
||||
} catch (error) {
|
||||
if (pageActive && !isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "安全验证暂不可用");
|
||||
}
|
||||
} finally {
|
||||
if (pageActive) sendingCode.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const completeTac = async (result) => {
|
||||
const expectedContext = tacContext.value;
|
||||
if (!expectedContext) return;
|
||||
try {
|
||||
const ticket = normalizeTacSuccess(result, expectedContext.requestId);
|
||||
if (phone.value !== expectedContext.subject)
|
||||
throw new Error("手机号已变化,请重新验证");
|
||||
closeTac();
|
||||
sendingCode.value = true;
|
||||
await appApi.sendSmsCode(
|
||||
{
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.FORGOT_PASSWORD,
|
||||
phone: expectedContext.subject,
|
||||
validToken: ticket.validToken,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
sentPhone.value = expectedContext.subject;
|
||||
smsCooldown.start();
|
||||
showFeedback("验证码已发送");
|
||||
} catch (error) {
|
||||
closeTac();
|
||||
if (pageActive) {
|
||||
if (isSmsDeliveryOutcomeUnknown(error)) {
|
||||
sentPhone.value = expectedContext.subject;
|
||||
smsCooldown.start();
|
||||
showFeedback("发送结果未知,如收到短信可直接填写;60 秒后可重试");
|
||||
} else if (!isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "验证码发送失败");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (pageActive) sendingCode.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleTacFailure = ({ message } = {}) =>
|
||||
showFeedback(message || "行为验证未通过,请重试");
|
||||
|
||||
const handleTacError = ({ message } = {}) => {
|
||||
closeTac();
|
||||
showFeedback(message || "安全验证暂不可用");
|
||||
return smsVerification.requestCode();
|
||||
};
|
||||
|
||||
const validateForm = () => {
|
||||
@@ -516,22 +420,36 @@ const validateForm = () => {
|
||||
const submitReset = async () => {
|
||||
if (submitting.value || sendingCode.value) return;
|
||||
if (!validateForm()) return;
|
||||
const resetPayload = {
|
||||
phone: phone.value,
|
||||
passwordHash: calcMD5(password.value),
|
||||
smsCode: verificationCode.value,
|
||||
};
|
||||
const resetAttempt = passwordResetGuard.begin(resetPayload);
|
||||
if (resetAttempt === null) {
|
||||
showFeedback(
|
||||
"上次重设结果暂时无法确认,请先返回登录页尝试新密码,不要重复提交。",
|
||||
);
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
await appApi.resetPassword(
|
||||
{
|
||||
phone: phone.value,
|
||||
passwordHash: calcMD5(password.value),
|
||||
smsCode: verificationCode.value,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
await authApi.resetPassword(
|
||||
resetPayload,
|
||||
{ requestController: passwordResetSubmissionRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
successVisible.value = true;
|
||||
} catch (error) {
|
||||
if (pageActive && !isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "密码重设失败,请稍后重试");
|
||||
if (!pageActive) return;
|
||||
if (passwordResetGuard.recordFailure(resetAttempt, error)) {
|
||||
showFeedback(
|
||||
"密码重设结果暂时无法确认,请先返回登录页尝试新密码,不要重复提交。",
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!isRequestCancelled(error))
|
||||
showFeedback(error.message || "密码重设失败,请稍后重试");
|
||||
} finally {
|
||||
if (pageActive) submitting.value = false;
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
<!-- 页面编号:A-01;用途:APP 唯一登录入口,承载密码与验证码登录。 -->
|
||||
<template>
|
||||
<AuthPageShell class="auth-page login-page">
|
||||
<view class="login-content">
|
||||
@@ -6,7 +5,7 @@
|
||||
<text class="login-title">登录家谱</text>
|
||||
<image
|
||||
class="title-divider"
|
||||
src="/static/assets/modules/auth/transparent/a01-vnext-divider-v1.png"
|
||||
src="/static/assets/modules/auth/transparent/title-divider.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
@@ -40,7 +39,7 @@
|
||||
<view class="input-row input-row--required">
|
||||
<image
|
||||
class="input-icon"
|
||||
src="/static/assets/modules/auth/transparent/a01-icon-phone-v1.png"
|
||||
src="/static/assets/modules/auth/transparent/icon-phone.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<input
|
||||
@@ -69,7 +68,7 @@
|
||||
>
|
||||
<image
|
||||
class="input-icon"
|
||||
src="/static/assets/modules/auth/transparent/a01-icon-lock-v1.png"
|
||||
src="/static/assets/modules/auth/transparent/icon-password.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<input
|
||||
@@ -96,8 +95,8 @@
|
||||
class="password-toggle__icon"
|
||||
:src="
|
||||
passwordVisible
|
||||
? '/static/assets/modules/auth/transparent/a01-icon-eye-open-v1.png'
|
||||
: '/static/assets/modules/auth/transparent/a01-icon-eye-closed-pupil-v2.png'
|
||||
? '/static/assets/modules/auth/transparent/password-visible.png'
|
||||
: '/static/assets/modules/auth/transparent/password-hidden.png'
|
||||
"
|
||||
mode="aspectFit"
|
||||
aria-hidden="true"
|
||||
@@ -108,7 +107,7 @@
|
||||
<view v-else class="input-row input-row--required">
|
||||
<image
|
||||
class="input-icon input-icon--sms"
|
||||
src="/static/assets/modules/auth/transparent/a01-icon-sms-code-v2.png"
|
||||
src="/static/assets/modules/auth/transparent/icon-verification-code.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<input
|
||||
@@ -162,7 +161,7 @@
|
||||
>
|
||||
<image
|
||||
class="button-skin"
|
||||
src="/static/assets/foundation/transparent/a01-scroll-primary-v3.png"
|
||||
src="/static/assets/foundation/transparent/scroll-primary.png"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="login-submit__copy">{{
|
||||
@@ -208,8 +207,8 @@
|
||||
class="agreement-icon"
|
||||
:src="
|
||||
agreed
|
||||
? '/static/assets/modules/auth/transparent/a02-agreement-checked.png'
|
||||
: '/static/assets/modules/auth/transparent/a02-agreement-unchecked.png'
|
||||
? '/static/assets/modules/auth/transparent/agreement-checked.png'
|
||||
: '/static/assets/modules/auth/transparent/agreement-unchecked.png'
|
||||
"
|
||||
mode="aspectFit"
|
||||
aria-hidden="true"
|
||||
@@ -256,14 +255,14 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onBackPress, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import AuthPageShell from "@/components/AuthPageShell.vue";
|
||||
import AuthPageShell from "@/components/auth/PageShell.vue";
|
||||
import AppToast from "@/components/AppToast.vue";
|
||||
import TacVerification from "@/components/TacVerification.vue";
|
||||
import TacVerification from "@/components/auth/TacVerification.vue";
|
||||
import {
|
||||
appApi,
|
||||
createRequestController,
|
||||
isRequestCancelled,
|
||||
} from "@/utils/api.js";
|
||||
isRequestCancelled
|
||||
} from "@/services/api/request-controller.js";
|
||||
import { authApi } from "@/services/api/auth-service.js";
|
||||
import {
|
||||
AUTH_VERIFICATION_OPERATION,
|
||||
createTacRenderContext,
|
||||
@@ -271,9 +270,9 @@ import {
|
||||
isSmsDeliveryOutcomeUnknown,
|
||||
normalizeCaptchaRequirement,
|
||||
normalizeTacSuccess,
|
||||
} from "@/utils/auth-verification.js";
|
||||
import { createAuthSmsCooldown } from "@/utils/auth-sms-cooldown.js";
|
||||
import { runtimeConfig } from "@/utils/config.js";
|
||||
} from "@/utils/auth/verification.js";
|
||||
import { createAuthSmsCooldown } from "@/utils/auth/sms-cooldown.js";
|
||||
import { runtimeConfig } from "@/utils/runtime-config.js";
|
||||
import { calcMD5 } from "@/utils/md5.js";
|
||||
import { session } from "@/utils/session.js";
|
||||
import {
|
||||
@@ -281,7 +280,7 @@ import {
|
||||
handleBackPress,
|
||||
openPage,
|
||||
runBackGuard,
|
||||
} from "@/utils/navigation.js";
|
||||
} from "@/utils/navigation/gateway.js";
|
||||
|
||||
const activeLoginMethod = ref("password");
|
||||
const passwordVisible = ref(false);
|
||||
@@ -306,7 +305,9 @@ let pendingTacAction = null;
|
||||
let pageActive = true;
|
||||
const authenticationNavigationFailure =
|
||||
"登录已完成,但暂时无法进入家谱,请再次点击进入";
|
||||
const authRequestController = createRequestController();
|
||||
const captchaRequirementRequestController = createRequestController();
|
||||
const smsDeliveryRequestController = createRequestController();
|
||||
const signInSubmissionRequestController = createRequestController();
|
||||
const smsCooldown = createAuthSmsCooldown({
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.SMS_LOGIN,
|
||||
onChange: (seconds) => {
|
||||
@@ -316,7 +317,9 @@ const smsCooldown = createAuthSmsCooldown({
|
||||
|
||||
onUnload(() => {
|
||||
pageActive = false;
|
||||
authRequestController.abort();
|
||||
captchaRequirementRequestController.abort();
|
||||
smsDeliveryRequestController.abort();
|
||||
signInSubmissionRequestController.abort();
|
||||
if (feedbackTimer) clearTimeout(feedbackTimer);
|
||||
smsCooldown.dispose();
|
||||
});
|
||||
@@ -409,7 +412,9 @@ const closeTac = () => {
|
||||
};
|
||||
|
||||
const cancelPendingRequest = () => {
|
||||
authRequestController.abort();
|
||||
captchaRequirementRequestController.abort();
|
||||
smsDeliveryRequestController.abort();
|
||||
signInSubmissionRequestController.abort();
|
||||
sendingCode.value = false;
|
||||
submitting.value = false;
|
||||
};
|
||||
@@ -425,7 +430,7 @@ const requestBack = () =>
|
||||
},
|
||||
});
|
||||
|
||||
// A01 是认证根页:没有浮层时必须把系统返回交还 Android,只在行为验证浮层
|
||||
// 登录页是认证根页:没有浮层时必须把系统返回交还 Android,只在行为验证浮层
|
||||
// 可见时消费返回键,避免根页被守卫误拦而无法正常退出应用。
|
||||
onBackPress((event) => {
|
||||
if (!tacVisible.value && (submitting.value || sendingCode.value)) {
|
||||
@@ -439,22 +444,24 @@ onBackPress((event) => {
|
||||
const prepareGetCode = async () => {
|
||||
if (sendingCode.value || cooldownSeconds.value > 0) return;
|
||||
if (!validatePhone() || !requireAgreement()) return;
|
||||
const requestedPhone = phone.value;
|
||||
let smsDeliveryStarted = false;
|
||||
sendingCode.value = true;
|
||||
try {
|
||||
const operationCode = AUTH_VERIFICATION_OPERATION.SMS_LOGIN;
|
||||
const requestedPhone = phone.value;
|
||||
const response = await appApi.getCaptchaRequirement(
|
||||
const response = await authApi.getCaptchaRequirement(
|
||||
{ operationCode, subject: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: captchaRequirementRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
if (phone.value !== requestedPhone)
|
||||
throw new Error("手机号已变化,请重新获取验证码");
|
||||
const requirement = normalizeCaptchaRequirement(response);
|
||||
if (!requirement.required) {
|
||||
await appApi.sendSmsCode(
|
||||
smsDeliveryStarted = true;
|
||||
await authApi.sendSmsCode(
|
||||
{ operationCode, phone: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: smsDeliveryRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
sentPhone.value = requestedPhone;
|
||||
@@ -464,7 +471,7 @@ const prepareGetCode = async () => {
|
||||
}
|
||||
tacSequence += 1;
|
||||
tacContext.value = createTacRenderContext({
|
||||
requestId: `a01-sms-${tacSequence}`,
|
||||
requestId: `sign-in-sms-${tacSequence}`,
|
||||
baseUrl: runtimeConfig.baseUrl,
|
||||
clientId: runtimeConfig.clientId,
|
||||
tenantId: runtimeConfig.tenantId,
|
||||
@@ -478,8 +485,14 @@ const prepareGetCode = async () => {
|
||||
};
|
||||
tacVisible.value = true;
|
||||
} catch (error) {
|
||||
if (pageActive && !isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "安全验证暂不可用");
|
||||
if (pageActive) {
|
||||
if (smsDeliveryStarted && isSmsDeliveryOutcomeUnknown(error)) {
|
||||
sentPhone.value = requestedPhone;
|
||||
smsCooldown.start();
|
||||
showFeedback("发送结果未知,如收到短信可直接填写;60 秒后可重试");
|
||||
} else if (!isRequestCancelled(error)) {
|
||||
showFeedback(error.message || "安全验证暂不可用");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (pageActive) sendingCode.value = false;
|
||||
@@ -492,9 +505,9 @@ const preparePasswordLogin = async () => {
|
||||
submitting.value = true;
|
||||
try {
|
||||
const operationCode = AUTH_VERIFICATION_OPERATION.PASSWORD_LOGIN;
|
||||
const response = await appApi.getCaptchaRequirement(
|
||||
const response = await authApi.getCaptchaRequirement(
|
||||
{ operationCode, subject: requestedPhone },
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: captchaRequirementRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
if (phone.value !== requestedPhone) {
|
||||
@@ -502,9 +515,9 @@ const preparePasswordLogin = async () => {
|
||||
}
|
||||
const requirement = normalizeCaptchaRequirement(response);
|
||||
if (!requirement.required) {
|
||||
await appApi.loginWithPassword(
|
||||
await authApi.loginWithPassword(
|
||||
{ phone: requestedPhone, passwordHash },
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: signInSubmissionRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
authenticationCommitted.value = true;
|
||||
@@ -513,7 +526,7 @@ const preparePasswordLogin = async () => {
|
||||
}
|
||||
tacSequence += 1;
|
||||
tacContext.value = createTacRenderContext({
|
||||
requestId: `a01-password-${tacSequence}`,
|
||||
requestId: `sign-in-password-${tacSequence}`,
|
||||
baseUrl: runtimeConfig.baseUrl,
|
||||
clientId: runtimeConfig.clientId,
|
||||
tenantId: runtimeConfig.tenantId,
|
||||
@@ -555,13 +568,13 @@ const completeTac = async (result) => {
|
||||
tacContext.value = null;
|
||||
pendingTacAction = null;
|
||||
submitting.value = true;
|
||||
await appApi.loginWithPassword(
|
||||
await authApi.loginWithPassword(
|
||||
{
|
||||
phone: action.phone,
|
||||
passwordHash: action.passwordHash,
|
||||
validToken: ticket.validToken,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: signInSubmissionRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
authenticationCommitted.value = true;
|
||||
@@ -575,13 +588,13 @@ const completeTac = async (result) => {
|
||||
}
|
||||
closeTac();
|
||||
sendingCode.value = true;
|
||||
await appApi.sendSmsCode(
|
||||
await authApi.sendSmsCode(
|
||||
{
|
||||
operationCode: AUTH_VERIFICATION_OPERATION.SMS_LOGIN,
|
||||
phone: expectedContext.subject,
|
||||
validToken: ticket.validToken,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: smsDeliveryRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
sentPhone.value = expectedContext.subject;
|
||||
@@ -644,12 +657,12 @@ const submitLogin = async () => {
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
await appApi.loginWithSms(
|
||||
await authApi.loginWithSms(
|
||||
{
|
||||
phone: phone.value,
|
||||
smsCode: verificationCode.value,
|
||||
},
|
||||
{ requestController: authRequestController },
|
||||
{ requestController: signInSubmissionRequestController },
|
||||
);
|
||||
if (!pageActive) return;
|
||||
authenticationCommitted.value = true;
|
||||
Reference in New Issue
Block a user