feat(sms): align provider and verification flow
This commit is contained in:
@@ -1112,10 +1112,16 @@
|
||||
if (!form) return;
|
||||
if (form.dataset.aksrtSettingsInitialized === 'true') return;
|
||||
form.dataset.aksrtSettingsInitialized = 'true';
|
||||
function isValidSmsPhone(phone) {
|
||||
if (!window.aksrtData || aksrtData.smsNumberLimitCh !== false) {
|
||||
return /^1[3-9]\d{9}$/.test(phone);
|
||||
}
|
||||
return /^(?:\d{5,}|\+\d{6,}|\+?\d{2,}[-\s]\d{2,}[0-9\-\s]{0,15})$/.test(phone);
|
||||
}
|
||||
var sendButton = form.querySelector('[data-aksrt-sms-trigger]');
|
||||
if (sendButton) sendButton.addEventListener('click', function () {
|
||||
var phone = String((form.querySelector('[name="phone"]') || {}).value || '').trim();
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) { notyf('请输入正确的手机号', 'warning'); return; }
|
||||
if (!isValidSmsPhone(phone)) { notyf('请输入正确的手机号', 'warning'); return; }
|
||||
var toastId = 'aksrt-settings-phone-code-toast';
|
||||
var restRoot = (window.aksrtData && aksrtData.apiUrl) || '/wp-json/aksrt/v1';
|
||||
var nonce = (window.aksrtData && aksrtData.restNonce) || '';
|
||||
@@ -1146,11 +1152,11 @@
|
||||
var codeEl = form.querySelector('[name="code"]');
|
||||
var phone = phoneEl ? String(phoneEl.value || '').trim() : '';
|
||||
var code = codeEl ? String(codeEl.value || '').trim() : '';
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
if (!isValidSmsPhone(phone)) {
|
||||
notyf('请输入正确的手机号', 'warning');
|
||||
return;
|
||||
}
|
||||
if (!code) {
|
||||
if (!/^\d{6}$/.test(code)) {
|
||||
notyf('请输入短信验证码', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user