diff --git a/pages/home/liquidation.vue b/pages/home/liquidation.vue index 2c501bb..622f4f3 100644 --- a/pages/home/liquidation.vue +++ b/pages/home/liquidation.vue @@ -32,7 +32,18 @@ 请输入去变现数量 - + + + + + {}); - } - const mobile = userStore?.userInfo?.mobile; - if (!mobile) { - sheep.$helper.toast('未绑定手机号'); - return; - } + const mobile = resolveMobile(); + if (!mobile) return; const money = Math.round(amt * 100); const payload = { money, mobile, scene: smsScene, code: smsCode.value }; const res = await incrementApi.walletLiquidation(payload).catch(() => ({ code: -1 })); @@ -157,6 +162,15 @@ } }; + const resolveMobile = () => { + const mobile = String(smsMobile.value || '').trim(); + if (!/^1\d{10}$/.test(mobile)) { + sheep.$helper.toast('请输入正确手机号'); + return ''; + } + return mobile; + }; + const sendSmsCode = async () => { if (smsCountdown.value > 0) return; const amt = amountNumber.value; @@ -168,15 +182,8 @@ sheep.$helper.toast('变现金额不能大于钱包余额'); return; } - const userStore = sheep.$store('user'); - if (!userStore?.userInfo?.mobile) { - await userStore?.getInfo?.().catch(() => {}); - } - const mobile = userStore?.userInfo?.mobile; - if (!mobile) { - sheep.$helper.toast('未绑定手机号'); - return; - } + const mobile = resolveMobile(); + if (!mobile) return; const res = await AuthUtil.sendSmsCode({ mobile, scene: smsScene }).catch(() => ({ code: -1 })); if (res?.code !== 0) return; smsCountdown.value = 60; @@ -199,6 +206,9 @@ onShow(() => { refreshWallet(); + const userStore = sheep.$store('user'); + const mobile = userStore?.userInfo?.mobile; + if (!smsMobile.value && mobile) smsMobile.value = mobile; }); @@ -283,6 +293,10 @@ align-items: center; } + .code-row--mobile { + margin-bottom: 12rpx; + } + .code-btn { margin-left: 18rpx; min-width: 168rpx;