export { formatTime, timestampToTime, formatterContent, endtimeFilter, secondToDuring } from '@/utils'

/**
 * 多长时间之前
 * @param {time} 时间如'2019-03-28' '2019-03-28 17:25'
 */
export function timesAgo(time) {
  let d = new Date(time)
  if (('' + d).length === 10) {
    d = parseInt(d) * 1000
  }
  const now = Date.now()
  const diff = (now - d) / 1000
  if (diff < 30) {
    return '刚刚'
  } else if (diff < 3600) {
    return Math.ceil(diff / 60) + '分钟前'
  } else if (diff < 3600 * 24) {
    return Math.ceil(diff / 3600) + '小时前'
  } else if (diff < 3600 * 24 * 2) {
    return '昨天'
  } else if (diff < 3600 * 24 * 365) {
    return `${d.getMonth() + 1}月${d.getDate()}日`
  } else {
    return `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日`
  }
}

/**
 * 工单状态
 * 0为待指派，2为待接单，3为待处理，9为已处理
 */
export function orderStateFilter(status) {
  const statusMap = {
    0: '待指派',
    2: '待接单',
    3: '待处理',
    9: '已处理'
  }
  return statusMap[status]
}

export function orderStateTypeFilter(status) {
  const statusMap = {
    0: '#fd72b9',
    2: '#febd23',
    3: '#fd7c78',
    9: '#5ccb91'
  }
  return statusMap[status]
}
