From 88d42470c4fc7cfa6d579c947eebec16a2fb124b Mon Sep 17 00:00:00 2001 From: Rogee Date: Sat, 20 Dec 2025 13:42:49 +0800 Subject: [PATCH] Refactor code structure for improved readability and maintainability --- frontend/wechat/src/views/VerifyPhone.vue | 51 +++++++++++++++-------- frontend/wechat/stats.html | 2 +- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/frontend/wechat/src/views/VerifyPhone.vue b/frontend/wechat/src/views/VerifyPhone.vue index 0815cf8..a80a1d4 100644 --- a/frontend/wechat/src/views/VerifyPhone.vue +++ b/frontend/wechat/src/views/VerifyPhone.vue @@ -13,8 +13,21 @@ const verifying = ref(false); const countdown = ref(0); let countdownTimer = null; -const canSend = computed(() => !sending.value && countdown.value <= 0 && phone.value.trim().length >= 6); -const canVerify = computed(() => !verifying.value && phone.value.trim() !== "" && code.value.trim() !== ""); +const normalizeDigits = (value, maxLen) => String(value || "").replace(/\D/g, "").slice(0, maxLen); + +const onPhoneInput = (e) => { + phone.value = normalizeDigits(e?.target?.value, 11); +}; + +const onCodeInput = (e) => { + code.value = normalizeDigits(e?.target?.value, 4); +}; + +const isValidPhone = computed(() => phone.value.length === 11); +const isValidCode = computed(() => code.value.length === 4); + +const canSend = computed(() => !sending.value && countdown.value <= 0 && isValidPhone.value); +const canVerify = computed(() => !verifying.value && isValidPhone.value && isValidCode.value); const startCountdown = (seconds = 60) => { countdown.value = seconds; @@ -90,24 +103,26 @@ onMounted(() => {

手机号验证

- 未认证用户需要验证手机号后才能访问「已购买」「我的」并进行购买操作。 + 请登录后再进行操作, 无法验证请联系管理员微信:13932043996

-
-
- - -
+
+
+ + +
-
- -
- - @@ -121,7 +136,7 @@ onMounted(() => {
diff --git a/frontend/wechat/stats.html b/frontend/wechat/stats.html index 080759e..84f79a9 100644 --- a/frontend/wechat/stats.html +++ b/frontend/wechat/stats.html @@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {