import { orderStatus, payStatus, otaStatus, papersType, prorateStatus } from '@/utils/constants'

export function otaStatusName (value) {
  return Number(value) === 0 ? '暂无' : (otaStatus[value] || value)
}

export function payWayName (value) {
  const obj = {
    WEIXIN: '微信',
    ALI: '支付宝',
    USERBALANCE: '余额'
  }
  return obj[value] || value || '暂无'
}

export function payType (value) {
  const obj = {
    JSAPI: '公众号支付',
    NATIVE: '扫码支付',
    MWEB: 'H5支付',
    H5: 'H5支付'
  }
  return obj[value] || value || '暂无'
}

export function wxProrateStatusName (value) {
  const obj = {
    CREATED: '已创建',
    SUBMIT: '已提交',
    FINSIHED_PART_SUCCESS: '部分成功',
    FINISHED_ALL_SUCCESS: '全部成功',
    FAIL: '失败'
  }
  return obj[value] || value || '暂无'
}

export function wxUserProrateStatusName (value) {
  const obj = {
    WAIT_PROFIT_SHANR: '待分账',
    PROFIT_SHARING: '分佣中',
    SUCCESS: '分佣成功',
    FAIL: '分佣失败'
  }
  return obj[value] || value || '暂无'
}

export function payStatusName (value) {
  return payStatus[value] || value
}

export function paperTypeName (value) {
  return papersType[value] || value
}

export function statusName (value) {
  return orderStatus[value] || value
}

export function prorateStatusName (value) {
  return prorateStatus[value] || value
}

export function statusColor (value) {
  const obj = {
    WAIT_CONFIRM: 'orange',
    CANCELED: '',
    CHANGED: 'red',
    WAIT_USE_WAIT_AUDIT: 'red',
    WAIT_CONFIRM_WAIT_AUDIT: 'red',
    REFUND_MONEYBACKING: 'orange',
    COMPLETE_WAIT_AUDIT: 'blue',
    AUDITED: 'green',
    WAIT_USE: 'blue',
    COMPLETE: 'green',
    PART_USE: 'pink',
    WAIT_USE_CHANGING: 'orange',
    REFUND_AUDIT_PASS: 'green',
    REFUND_WAIT_AUDIT: 'orange'
  }
  return obj[value]
}

export function payStatusColor (value) {
  const obj = {
    REFUNDED: 'red',
    REFUNDING: 'orange',
    WAIT_PAY: 'blue',
    PAYED: 'green'
  }
  return obj[value]
}
export function prorateStatusColor (value) {
  const obj = {
    WAIT_PRORATE: 'blue',
    PRORATING: 'orange',
    PRORATED: 'green',
    CREATED: 'orange',
    SUBMIT: 'cyan',
    FINSIHED_PART_SUCCESS: 'blue',
    FINISHED_ALL_SUCCESS: 'green',
    FAIL: 'red',
    WAIT_PROFIT_SHANR: 'orange',
    PROFIT_SHARING: 'orange',
    SUCCESS: 'green'
  }
  return obj[value]
}

export function fileType (value) {
  if (value.indexOf('image') > -1) {
    return '图片'
  } else if (value.indexOf('video') > -1) {
    return '视频'
  } else {
    return value
  }
}
