完善手机号校验和验证码发送限制
This commit is contained in:
+1
-2
@@ -97,11 +97,10 @@ public class VerificationCodeServiceImpl implements VerificationCodeService {
|
||||
String codeKey = CODE_PREFIX + phone;
|
||||
String sendTimeKey = SEND_TIME_PREFIX + phone;
|
||||
|
||||
messageHubClientService.sendSmsVerificationCode(sceneCode, phone, code);
|
||||
redisTemplate.opsForValue().set(codeKey, code, Duration.ofMinutes(CODE_EXPIRE_MINUTES));
|
||||
redisTemplate.opsForValue().set(sendTimeKey, String.valueOf(System.currentTimeMillis()),
|
||||
Duration.ofSeconds(RESEND_INTERVAL_SECONDS));
|
||||
|
||||
messageHubClientService.sendSmsVerificationCode(sceneCode, phone, code);
|
||||
log.info("验证码已发送,手机号: {}, sceneCode: {}", phone, sceneCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -693,6 +693,10 @@ Page({
|
||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(String(form.phone).trim())) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!durationMinutes) {
|
||||
wx.showToast({ title: '请填写预约时长', icon: 'none' })
|
||||
return
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入手机号" />
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" maxlength="11" type="number" placeholder="搜索或输入手机号" />
|
||||
</view>
|
||||
<view wx:if="{{customerDropdownVisible}}" class="customer-dropdown">
|
||||
<view wx:if="{{customerLoading}}" class="customer-option muted-option">正在搜索客户...</view>
|
||||
|
||||
@@ -85,6 +85,10 @@ Page({
|
||||
wx.showToast({ title: '请填写客户姓名和手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
await customersApi.create({ nickname, phone })
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">手机号</text>
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" placeholder="请输入手机号" />
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" maxlength="11" placeholder="请输入手机号" />
|
||||
</view>
|
||||
</view>
|
||||
<button class="primary-btn modal-submit" loading="{{creating}}" bindtap="submitCustomer">保存客户</button>
|
||||
|
||||
@@ -161,6 +161,10 @@ Page({
|
||||
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
await employeesApi.createUser({
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">手机号</text>
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" placeholder="请输入手机号" />
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" maxlength="11" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">登录账号</text>
|
||||
|
||||
@@ -121,8 +121,11 @@ Page({
|
||||
|
||||
onInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = field === 'phone'
|
||||
? String(event.detail.value || '').replace(/\D/g, '').slice(0, 11)
|
||||
: event.detail.value
|
||||
this.setData({
|
||||
[`form.${field}`]: event.detail.value
|
||||
[`form.${field}`]: value
|
||||
})
|
||||
},
|
||||
|
||||
@@ -135,6 +138,9 @@ Page({
|
||||
},
|
||||
|
||||
async sendLoginCode() {
|
||||
if (!this.ensureAgreementAccepted()) {
|
||||
return
|
||||
}
|
||||
const phone = String(this.data.form.phone || '').trim()
|
||||
if (!PHONE_REGEX.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
|
||||
@@ -220,6 +220,11 @@ Page({
|
||||
async saveProfile() {
|
||||
const form = this.data.profileForm
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const contactPhone = String(form.contactPhone || '').trim()
|
||||
if (contactPhone && !/^1[3-9]\d{9}$/.test(contactPhone)) {
|
||||
wx.showToast({ title: '请输入正确联系电话', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!nickname) {
|
||||
wx.showToast({ title: '请填写昵称', icon: 'none' })
|
||||
return
|
||||
@@ -229,7 +234,7 @@ Page({
|
||||
await userApi.updateInfo({
|
||||
nickname,
|
||||
avatar: form.avatar || '',
|
||||
contactPhone: String(form.contactPhone || '').trim(),
|
||||
contactPhone,
|
||||
wechatId: String(form.wechatId || '').trim(),
|
||||
signature: String(form.signature || '').trim()
|
||||
})
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>联系电话</text>
|
||||
<input value="{{profileForm.contactPhone}}" data-field="contactPhone" bindinput="onProfileInput" type="number" placeholder="请输入联系电话" />
|
||||
<input value="{{profileForm.contactPhone}}" data-field="contactPhone" bindinput="onProfileInput" type="number" maxlength="11" placeholder="请输入联系电话" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>微信号</text>
|
||||
|
||||
@@ -18,7 +18,8 @@ Page({
|
||||
loading: false,
|
||||
codeLoading: false,
|
||||
countdown: 0,
|
||||
countdownTimer: null
|
||||
countdownTimer: null,
|
||||
agreementAccepted: false
|
||||
},
|
||||
|
||||
async onLoad(options) {
|
||||
@@ -39,11 +40,20 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
|
||||
onInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = field === 'phone'
|
||||
? String(event.detail.value || '').replace(/\D/g, '').slice(0, 11)
|
||||
: event.detail.value
|
||||
this.setData({ [`form.${field}`]: value })
|
||||
},
|
||||
|
||||
togglePasswordMode() { this.setData({ passwordMode: !this.data.passwordMode }) },
|
||||
|
||||
toggleAgreement() { this.setData({ agreementAccepted: !this.data.agreementAccepted }) },
|
||||
|
||||
async sendCode() {
|
||||
if (!this.data.agreementAccepted) { wx.showToast({ title: '请先同意用户协议和隐私政策', icon: 'none' }); return }
|
||||
const phone = String(this.data.form.phone || '').trim()
|
||||
if (!PHONE_REGEX.test(phone)) { wx.showToast({ title: '请输入正确手机号', icon: 'none' }); return }
|
||||
if (this.data.codeLoading || this.data.countdown > 0) return
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<view class="progress-row"><view class="progress-step {{step >= 1 ? 'active' : ''}}"><text>1</text><label>验证手机</label></view><view class="progress-line {{step >= 2 ? 'active' : ''}}"></view><view class="progress-step {{step >= 2 ? 'active' : ''}}"><text>2</text><label>选择身份</label></view><view class="progress-line {{step >= 3 ? 'active' : ''}}"></view><view class="progress-step {{step >= 3 ? 'active' : ''}}"><text>3</text><label>提交审核</label></view></view>
|
||||
<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" disabled="{{phoneVerified}}" placeholder="请输入手机号" /><text wx:if="{{phoneVerified}}" class="verified-tip">手机号已验证</text></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="secondary-entry" bindtap="togglePasswordMode">使用密码注册 <text>›</text></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>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user