feat: 完成前端业务闭环与后端联调
This commit is contained in:
+58
-7
@@ -78,6 +78,34 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="field-block"
|
||||
:class="{ 'field-block--error': fieldErrors.referralCode }"
|
||||
>
|
||||
<view class="input-row">
|
||||
<label class="input-label" for="register-referral-code">推荐码</label>
|
||||
<input
|
||||
id="register-referral-code"
|
||||
v-model.trim="referralCode"
|
||||
class="auth-input"
|
||||
maxlength="64"
|
||||
:disabled="submitting || registrationCommitted"
|
||||
placeholder="选填,来自邀请人的推荐码"
|
||||
placeholder-class="placeholder"
|
||||
:aria-invalid="Boolean(fieldErrors.referralCode)"
|
||||
:aria-describedby="fieldErrors.referralCode ? 'register-referral-code-error' : undefined"
|
||||
@input="clearFieldError('referralCode')"
|
||||
/>
|
||||
</view>
|
||||
<text
|
||||
v-if="fieldErrors.referralCode"
|
||||
id="register-referral-code-error"
|
||||
class="field-error"
|
||||
role="alert"
|
||||
>{{ fieldErrors.referralCode }}</text
|
||||
>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="field-block"
|
||||
:class="{ 'field-block--error': fieldErrors.verificationCode }"
|
||||
@@ -259,14 +287,14 @@
|
||||
<text>我已阅读并同意</text>
|
||||
<button
|
||||
class="auth-plain-button agreement-link"
|
||||
@click="prepareAgreement"
|
||||
@click="openComplianceDocument('user_agreement')"
|
||||
>
|
||||
《用户协议》
|
||||
</button>
|
||||
<text>与</text>
|
||||
<button
|
||||
class="auth-plain-button agreement-link"
|
||||
@click="prepareAgreement"
|
||||
@click="openComplianceDocument('privacy_policy')"
|
||||
>
|
||||
《隐私政策》
|
||||
</button>
|
||||
@@ -318,7 +346,7 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onBackPress, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import { onBackPress, onLoad, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import AppDialog from "@/components/AppDialog.vue";
|
||||
import AppToast from "@/components/AppToast.vue";
|
||||
import AuthPageShell from "@/components/auth/PageShell.vue";
|
||||
@@ -336,7 +364,12 @@ import {
|
||||
import { createDiscardConfirmation } from "@/utils/discard-confirmation.js";
|
||||
import { calcMD5 } from "@/utils/md5.js";
|
||||
import { createNonIdempotentWriteGuard } from "@/utils/non-idempotent-write-guard.js";
|
||||
import { goRoot, handleBackPress, runBackGuard } from "@/utils/navigation/gateway.js";
|
||||
import {
|
||||
goRoot,
|
||||
handleBackPress,
|
||||
openPage,
|
||||
runBackGuard,
|
||||
} from "@/utils/navigation/gateway.js";
|
||||
import {
|
||||
PASSWORD_POLICY_MESSAGE,
|
||||
validatePassword,
|
||||
@@ -344,6 +377,7 @@ import {
|
||||
|
||||
const phone = ref("");
|
||||
const nickName = ref("");
|
||||
const referralCode = ref("");
|
||||
const verificationCode = ref("");
|
||||
const password = ref("");
|
||||
const confirmPassword = ref("");
|
||||
@@ -351,6 +385,7 @@ const agreed = ref(false);
|
||||
const agreementError = ref(false);
|
||||
const fieldErrors = ref({
|
||||
phone: "",
|
||||
referralCode: "",
|
||||
verificationCode: "",
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
@@ -366,6 +401,7 @@ const isDirty = computed(
|
||||
Boolean(
|
||||
phone.value ||
|
||||
nickName.value ||
|
||||
referralCode.value ||
|
||||
verificationCode.value ||
|
||||
password.value ||
|
||||
confirmPassword.value ||
|
||||
@@ -374,6 +410,10 @@ const isDirty = computed(
|
||||
);
|
||||
let feedbackTimer = null;
|
||||
let pageActive = true;
|
||||
|
||||
onLoad((options = {}) => {
|
||||
referralCode.value = String(options.referralCode || "").trim().slice(0, 64);
|
||||
});
|
||||
const registrationNavigationFailure =
|
||||
"注册已完成,但暂时无法进入家谱,请再次点击进入";
|
||||
const registrationSubmissionRequestController = createRequestController();
|
||||
@@ -452,7 +492,11 @@ const enterAuthenticatedRoot = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const prepareAgreement = () => showFeedback("协议页面准备中");
|
||||
const openComplianceDocument = (documentKey) => {
|
||||
if (sendingCode.value || submitting.value || registrationCommitted.value)
|
||||
return;
|
||||
return openPage("M13", { documentKey }, "A04");
|
||||
};
|
||||
|
||||
const toggleAgreement = () => {
|
||||
if (sendingCode.value || submitting.value || registrationCommitted.value)
|
||||
@@ -490,11 +534,15 @@ const prepareGetCode = async () => {
|
||||
const validateForm = () => {
|
||||
const nextErrors = {
|
||||
phone: "",
|
||||
referralCode: "",
|
||||
verificationCode: "",
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
};
|
||||
if (!isAuthPhone(phone.value)) nextErrors.phone = "请输入正确手机号";
|
||||
if (referralCode.value && !/^[A-Za-z0-9_-]{4,64}$/.test(referralCode.value)) {
|
||||
nextErrors.referralCode = "推荐码应为 4 至 64 位字母、数字、短横线或下划线";
|
||||
}
|
||||
if (sentPhone.value !== phone.value)
|
||||
nextErrors.verificationCode = "请先获取当前手机号的验证码";
|
||||
else if (!/^\d{4}$/.test(verificationCode.value))
|
||||
@@ -517,6 +565,7 @@ const submitRegister = async () => {
|
||||
const registrationPayload = {
|
||||
phone: phone.value,
|
||||
nickName: nickName.value,
|
||||
referralCode: referralCode.value,
|
||||
passwordHash: calcMD5(password.value),
|
||||
smsCode: verificationCode.value,
|
||||
};
|
||||
@@ -732,7 +781,7 @@ const submitRegister = async () => {
|
||||
.agreement-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
min-height: var(--app-touch-min);
|
||||
font-size: clamp(12px, 22rpx, 14px);
|
||||
@@ -761,12 +810,14 @@ const submitRegister = async () => {
|
||||
.agreement-copy {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 0;
|
||||
padding-top: 2rpx;
|
||||
}
|
||||
.agreement-copy text {
|
||||
white-space: nowrap;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
|
||||
Reference in New Issue
Block a user