0f48d7abda
Allow store contactPhone as landline, show pending package audit badge, and split live vs pending packages in HQ review. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/** 11 位大陆手机号(登录凭证) */
|
||
export const MOBILE_PHONE_RE = /^1[3-9]\d{9}$/;
|
||
|
||
/**
|
||
* 国内座机:区号 0 开头(3~4 位),本地号 7~8 位,允许 `-`,可选分机。
|
||
* 例:0379-8888888、010-12345678、03798888888
|
||
*/
|
||
export const LANDLINE_PHONE_RE = /^0\d{2,3}-?\d{7,8}(-\d{1,6})?$/;
|
||
|
||
export const STORE_CONTACT_PHONE_HINT = '请输入正确的联系电话(手机号或座机,如 0379-8888888)';
|
||
|
||
export function normalizeContactPhone(raw: string): string {
|
||
return String(raw ?? '')
|
||
.trim()
|
||
.replace(/\s+/g, '');
|
||
}
|
||
|
||
export function isMobilePhone(raw: string): boolean {
|
||
return MOBILE_PHONE_RE.test(normalizeContactPhone(raw));
|
||
}
|
||
|
||
export function isLandlinePhone(raw: string): boolean {
|
||
return LANDLINE_PHONE_RE.test(normalizeContactPhone(raw));
|
||
}
|
||
|
||
/** 门店对外联系电话:手机号或座机 */
|
||
export function isStoreContactPhone(raw: string): boolean {
|
||
const s = normalizeContactPhone(raw);
|
||
return isMobilePhone(s) || isLandlinePhone(s);
|
||
}
|
||
|
||
/** 拨号用:去掉空格和横线 */
|
||
export function toDialablePhone(raw: string): string {
|
||
return String(raw ?? '').replace(/[\s-]/g, '');
|
||
}
|