constant.js 2.55 KB
// 新值,旧值,整数部分位数,小数部分位数,最小值,最大值,规则
function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minValue, maxValue, regRule) {
  /* eslint-disable */
  var reg = {
    priceReg: /^\d[\d\.]*$/,
    numReg: /^[1-9]\d*$/
  }
  /* eslint-enable */
  regRule = regRule || 'priceReg'
  if (newValue && ((minValue && newValue < minValue) || (maxValue && newValue > maxValue))) {
    return oldValue || ''
  }
  if (newValue && reg[regRule].test(newValue + '')) {
    if (/\./.test(newValue)) {
      newValue = newValue + ''
      var interger = newValue.split('.')[0]
      var point = newValue.split('.')[1]
      var intergerNum = interger.length > intergerDigit ? oldValue.split('.')[0] : interger
      var pointNum = point.length > pointDigit ? point.slice(0, pointDigit) : point
      newValue = pointDigit ? intergerNum + '.' + pointNum : newValue.split('.')[0]
    } else {
      newValue = newValue.length > intergerDigit ? oldValue.slice(0, intergerDigit) : newValue
    }
    return newValue
  } else {
    return newValue ? oldValue : ''
  }
}

const liveStatusList = [
  {
    confId: '101',
    confName: '直播中'
  },
  {
    confId: '102',
    confName: '未开始'
  },
  {
    confId: '103',
    confName: '已结束'
  },
  {
    confId: '104',
    confName: '禁播'
  },
  {
    confId: '105',
    confName: '暂停'
  },
  {
    confId: '106',
    confName: '异常'
  },
  {
    confId: '107',
    confName: '已过期'
  }
]
// /**
//  * 深克隆 所有原型链上的对象和属性
//  * 例: const bar=deepClone(foo)
//  * console.log(bar===foo) false
//  * @param {*} obj
//  */
function deepClone(obj) {
  const clone = require('rfdc')({ proto: false, circles: false })
  return clone(obj)
}
const auditStatusList = [
  {
    confId: 0,
    confName: '未审核'
  },
  {
    confId: 1,
    confName: '审核中'
  },
  {
    confId: 2,
    confName: '审核通过'
  },
  {
    confId: 3,
    confName: '审核失败'
  }
]
// 太阳膜升级产品供货模式
const upgradeSupplyModeList = [
  {
    confId: 1,
    confName: '嘀加'
  },
  {
    confId: 3,
    confName: '门店套码+嘀加'
  },
  {
    confId: 4,
    confName: '门店回收原厂+嘀加'
  },
  {
    confId: 5,
    confName: '服务商自采+嘀加'
  }
]
// 1.3场景 升级产品供货模式
const crowdUpgradeSupplyModeList = [
  {
    confId: 1,
    confName: '嘀加'
  },
  {
    confId: 2,
    confName: '门店'
  }
]

export { limitPrice, deepClone, liveStatusList, auditStatusList, upgradeSupplyModeList, crowdUpgradeSupplyModeList }