let validateRulesObj = {
  phone: {
    rules: [
      {
        validator: (rule, value, callback) => {
          const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
          if (value === '') {
            return Promise.resolve()
          } else if (!reg.test(value)) {
            return Promise.reject(new Error('请输入正确的手机号码'))
          }
          return Promise.resolve()
        }
      }
    ]
  },
  email: {
    rules: [
      {
        validator: (rule, value, callback) => {
          const reg =
            /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
          if (!reg.test(value)) {
            return Promise.reject(new Error('请输入正确的邮箱'))
          }
          return Promise.resolve()
        }
      }
    ]
  },

  pwd: {
    rules: [
      {
        validator: (rule, value, callback) => {
          const reg = /^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$/
          if (!reg.test(value)) {
            return Promise.reject(new Error('请输入密码,密码由6-20位字母、字符或数字组成'))
          }
          return Promise.resolve()
        }
      }
    ]
  },

  //  新密码与旧密码是否一致校验
  checkOpwd: {
    rules: [
      {
        validator: (rule, value, callback) => {
          //  获取旧密码
          let opwd = this.props.form.getFieldValue('oldPsd')
          if (!(opwd && opwd !== value)) {
            return Promise.reject(new Error('旧密码与新密码一致'))
          } else {
            return Promise.resolve()
          }
        }
      }
    ]
  },

  gphone: {
    rules: [
      {
        validator: (rule, value, callback) => {
          const reg = /^([0-9]{3,4}-)?[0-9]{7,8}$/
          if (!reg.test(value)) {
            return Promise.reject(new Error('请输入正确的固定电话'))
          } else {
            return Promise.resolve()
          }
        }
      }
    ]
  },

  lng: {
    rules: [
      {
        validator: (rule, value, callback) => {
          const reg =
            /^(\-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,6})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,6}|180)$/
          if (value !== '' && value !== null && value !== undefined) {
            if (!reg.test(value)) {
              return Promise.reject(new Error('经度整数部分为-180 至 180,小数部分为0到6位!'))
            } else {
              return Promise.resolve()
            }
          } else {
            return Promise.resolve()
          }
        }
      }
    ]
  },
  lat: {
    rules: [
      {
        validator: (rule, value, callback) => {
          const reg = /^(\-|\+)?([0-8]?\d{1}\.\d{0,6}|90\.0{0,6}|[0-8]?\d{1}|90)$/
          if (value !== '' && value !== null && value !== undefined) {
            if (!reg.test(value)) {
              return Promise.reject(new Error('纬度整数部分为-90 至 90,小数部分为0到6位!'))
            } else {
              return Promise.resolve()
            }
          } else {
            return Promise.resolve()
          }
        }
      }
    ]
  }
}
export default validateRulesObj
