import md5 from 'js-md5'
// 计算缩放指数
export function getIndex(data, type = 'max') {
  if (type === 'max') {
    console.log(data)
    const max = Math.max(...data)
    const index = Math.floor(70000 / max)
    console.log(index)
    return index
  } else {
    console.log(data)
    const min = Math.min(...data)
    const index = Math.floor(5000 / min)
    console.log(index)
    return index
  }
}

// 获取签名时间戳
export function getSignTimeStamp() {
  const username = 'admin'
  const key = 'packingdata'
  const timestamp = new Date().getTime().toString()
  const str = username + key + timestamp
  const sign = md5.base64(str)
  return { sign, username, timestamp }
}
