let isChinaMobile = /^1(3[4-9]|5[012789]|8[23478]|4[7]|7[28]|9[578])\d{8}$/;
let isChinaUnion = /^1(3[0-2]|5[56]|8[56]|4[5]|7[156]|6[6]|9[6])\d{8}$/;
let isChinaTelcom = /^1(3[3])|(5[3])|(7[37])|(8[019])|(9[039])\d{8}$/;///^(?:133|153|17[37]|18[019])\\d{8}$/; //1349号段 /^1(3[3])|(8[019])\d{8}$/;
let isOtherTelphone = /^170([059])\d{7}$/;//其他运营商
// console.log("userPhone",this.userPhone)
// console.log("phoneList",this.phoneList)
if(this.userPhone.length < 11 ){
console.log("this.userPhone.length",this.userPhone.length)
this.belongTo = false
this.isUserPhone = false
this.getPhone = false
}else{
// console.log("判断")
this.belongTo = true
this.getPhone = true
if(this.userPhone == localStorage.getItem("mobile") ){
this.isUserPhone = true
}
if(isChinaMobile.test(this.userPhone)){
this.operator = "(中国移动)"
}
else if(isChinaUnion.test(this.userPhone)){
this.operator = "(中国联通)";
}
else if(isChinaTelcom.test(this.userPhone)){
this.operator = "(中国电信)";
}
else{
this.operator = "(未知)";
}
}
JS实现动态校验手机号是哪家运营商
于 2023-11-09 14:53:54 首次发布