|
|
@@ -20,8 +20,7 @@ Page({
|
|
|
value: "",
|
|
|
placeholder: "联系人手机号码",
|
|
|
valueName: "phonenumber",
|
|
|
- required: true,
|
|
|
- checking: "phone"
|
|
|
+ required: true
|
|
|
}, {
|
|
|
label: "省市县",
|
|
|
error: false,
|
|
|
@@ -74,6 +73,27 @@ Page({
|
|
|
"workaddress": 1,
|
|
|
"isdefault": 0
|
|
|
}, this.selectComponent("#Form").submit());
|
|
|
+
|
|
|
+ function validatePhoneNumber(value) {
|
|
|
+ // 空值/非字符串直接返回false
|
|
|
+ if (!value || typeof value !== 'string') return false;
|
|
|
+ const trimmedValue = value.trim();
|
|
|
+
|
|
|
+ // 1. 精准手机号校验(使用你提供的规则)
|
|
|
+ const mobileReg = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
|
|
|
+ if (mobileReg.test(trimmedValue)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 手机号不通过,校验座机号(0开头区号+3-4位区号+7-8位号码)
|
|
|
+ const cleanedTel = trimmedValue.replace(/[- ]/g, ''); // 去除分隔符
|
|
|
+ const telReg = /^0\d{2,3}\d{7,8}$/; // 座机号规则:0开头区号(3-4位)+ 7-8位号码
|
|
|
+ return telReg.test(cleanedTel);
|
|
|
+ }
|
|
|
+ if (!validatePhoneNumber(content.phonenumber)) return wx.showToast({
|
|
|
+ title: '手机号不符合规格',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
content.province = content.region[0] || "";
|
|
|
content.city = content.region[1] || "";
|
|
|
content.county = content.region[2] || "";
|