fix(madao): 修复换号后国家区号残留

让 MaDao activation 使用 ISO country code,并避免 routing replace 沿用旧 ticket 的 country。
提交 OpenAI add-phone 前校验当前国家区号与手机号匹配,防止页面残留 Thailand 区号。
This commit is contained in:
Isulew
2026-05-29 12:12:19 +08:00
parent f26f7e949e
commit e50b0fbfeb
5 changed files with 325 additions and 29 deletions
+22 -3
View File
@@ -199,6 +199,23 @@
return String(visibleSpan?.textContent || '').trim();
}
function phoneNumberMatchesDialCode(phoneNumber = '', dialCode = '') {
const digits = normalizePhoneDigits(phoneNumber);
const normalizedDialCode = normalizePhoneDigits(dialCode);
if (!digits || !normalizedDialCode) {
return false;
}
return digits.startsWith(normalizedDialCode) && digits.length > normalizedDialCode.length;
}
function selectedCountryMatchesPhoneNumber(phoneNumber = '') {
const digits = normalizePhoneDigits(phoneNumber);
if (!digits) {
return true;
}
return phoneNumberMatchesDialCode(phoneNumber, getDisplayedDialCode());
}
function toNationalPhoneNumber(value, dialCode) {
const digits = normalizePhoneDigits(value);
const normalizedDialCode = normalizePhoneDigits(dialCode);
@@ -364,15 +381,17 @@
const byLabel = findCountryOptionByLabel(countryLabel);
if (await trySelectCountryOption(select, byLabel)) {
return true;
if (selectedCountryMatchesPhoneNumber(phoneNumber)) {
return true;
}
}
const byPhoneNumber = findCountryOptionByPhoneNumber(phoneNumber);
if (await trySelectCountryOption(select, byPhoneNumber)) {
return true;
return selectedCountryMatchesPhoneNumber(phoneNumber);
}
return Boolean(getSelectedCountryOption());
return selectedCountryMatchesPhoneNumber(phoneNumber);
}
function getAddPhoneSubmitButton() {