吉安感知网项目-前端
罗广辉
2026-02-03 bbf6d58d453cda88220d8513e98df808a698c7c7
applications/drone-command/src/utils/validate.js
@@ -176,24 +176,30 @@
 * 判断手机号码是否正确
 */
export function isvalidatemobile(phone) {
  let list = [];
  let result = true;
  const list = [];
  let result = true; // true=不通过(保持你的语义)
  let msg = '';
  var isPhone = /^0\d{2,3}-?\d{7,8}$/;
  //增加134 减少|1349[0-9]{7},增加181,增加145,增加17[678]
  if (!validatenull(phone)) {
    if (phone.length === 11) {
      if (isPhone.test(phone)) {
        msg = '手机号码格式不正确';
      } else {
        result = false;
      }
    } else {
      msg = '手机号码长度不为11位';
    }
  } else {
    msg = '手机号码不能为空';
  const raw = String(phone ?? '').trim();
  if (!raw) {
    return [true, '手机号不能为空'];
  }
  // 1) 归一化:去空格/括号/短横线
  // 2) 去掉 +86/86 前缀
  const value = raw
    .replace(/[\s()()-]+/g, '')
    .replace(/^(?:\+?86)/, '');
  // 只允许纯数字11位手机号
  const mobile = /^1[3-9]\d{9}$/;
  if (mobile.test(value)) {
    result = false; // 通过
  } else {
    msg = '手机号格式不正确';
  }
  list.push(result);
  list.push(msg);
  return list;