调整验证码有效期提示和重发状态

This commit is contained in:
2026-09-16 10:47:01 +08:00
parent e8e8e5a404
commit 5288dbf9b0
4 changed files with 6 additions and 3 deletions
+2
View File
@@ -89,6 +89,7 @@ Page({
loading: false,
codeLoading: false,
countdown: 0,
codeSent: false,
countdownTimer: null,
agreementAccepted: false,
agreementLoading: false,
@@ -153,6 +154,7 @@ Page({
try {
await authApi.sendLoginCode(phone)
wx.showToast({ title: '验证码已发送' })
this.setData({ codeSent: true })
this.startCountdown()
} catch (error) {
wx.showToast({ title: error.message || '验证码发送失败', icon: 'none' })
+1 -1
View File
@@ -31,7 +31,7 @@
<input class="code-input" value="{{form.code}}" data-field="code" bindinput="onInput" type="text" maxlength="6" placeholder="请输入验证码" />
<button class="code-btn {{countdown > 0 ? 'counting' : ''}}" loading="{{codeLoading}}" disabled="{{codeLoading || countdown > 0}}" bindtap="sendLoginCode">
<text wx:if="{{countdown > 0}}">重新获取 {{countdown}}s</text>
<text wx:else>获取验证码</text>
<text wx:else>{{codeSent ? '重新获取' : '获取验证码'}}</text>
</button>
</view>
</view>
+2 -1
View File
@@ -18,6 +18,7 @@ Page({
loading: false,
codeLoading: false,
countdown: 0,
codeSent: false,
countdownTimer: null,
agreementAccepted: false
},
@@ -58,7 +59,7 @@ Page({
if (!PHONE_REGEX.test(phone)) { wx.showToast({ title: '请输入正确手机号', icon: 'none' }); return }
if (this.data.codeLoading || this.data.countdown > 0) return
this.setData({ codeLoading: true })
try { await authApi.sendCode(phone); wx.showToast({ title: '验证码已发送' }); this.startCountdown() } catch (error) { wx.showToast({ title: error.message || '发送失败', icon: 'none' }) } finally { this.setData({ codeLoading: false }) }
try { await authApi.sendCode(phone); wx.showToast({ title: '验证码已发送' }); this.setData({ codeSent: true }); this.startCountdown() } catch (error) { wx.showToast({ title: error.message || '发送失败', icon: 'none' }) } finally { this.setData({ codeLoading: false }) }
},
continueFromPhone() {
+1 -1
View File
@@ -4,7 +4,7 @@
<view wx:if="{{step === 1}}" class="card form-card">
<view class="section-title">验证手机号</view><view class="section-desc">手机号将作为你的工作台登录账号</view>
<view class="field"><text class="field-label">手机号</text><input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" disabled="{{phoneVerified}}" placeholder="请输入手机号" /><text wx:if="{{phoneVerified}}" class="verified-tip">手机号已验证</text></view>
<view class="field"><text class="field-label">验证码</text><view class="code-row"><input class="code-input" value="{{form.code}}" data-field="code" bindinput="onInput" type="number" placeholder="请输入6位验证码" /><button class="code-btn {{countdown > 0 ? 'counting' : ''}}" loading="{{codeLoading}}" disabled="{{codeLoading || countdown > 0}}" bindtap="sendCode"><text wx:if="{{countdown > 0}}">{{countdown}}s 后重发</text><text wx:else>获取验证码</text></button></view></view>
<view class="field"><text class="field-label">验证码</text><view class="code-row"><input class="code-input" value="{{form.code}}" data-field="code" bindinput="onInput" type="number" placeholder="请输入6位验证码" /><button class="code-btn {{countdown > 0 ? 'counting' : ''}}" loading="{{codeLoading}}" disabled="{{codeLoading || countdown > 0}}" bindtap="sendCode"><text wx:if="{{countdown > 0}}">{{countdown}}s 后重发</text><text wx:else>{{codeSent ? '重新获取' : '获取验证码'}}</text></button></view></view>
<view class="agreement-row" bindtap="toggleAgreement"><view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view><view class="agreement-copy">我已阅读并同意《用户协议》和《隐私政策》</view></view><view class="secondary-entry" bindtap="togglePasswordMode">使用密码注册 <text>›</text></view>
<view wx:if="{{passwordMode}}" class="password-panel"><view class="field"><text class="field-label">设置密码</text><input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="至少8位密码" /></view><view class="field"><text class="field-label">确认密码</text><input value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" password placeholder="再次输入密码" /></view></view>
<button class="primary-btn" loading="{{loading}}" bindtap="continueFromPhone">继续</button>