format.js 961 Bytes
export function formatSeconds(seconds) {
  if (isNaN(seconds)) return seconds;
  return numFormat(parseInt(seconds / 3600)) + ':' + numFormat(parseInt(seconds % 3600 / 60)) + ':' + numFormat(
    parseInt(seconds % 60));
}
export function numFormat(val) {
  return val >= 10 ? val : ("0" + val)
}

// 依次: 试衣率、进店率、深逛率、接待率、年龄
export const percentKeys = ['FittingRate', 'EnterRate', 'DeepShoppingRate', 'ReceptionRate', 'AgeRate']

// 依次: 停留时长、关注时长、平均停留时长、平均关注时长
export const timeKeys = ['ResidenceTime', 'validDwellTime', 'avgDwellTime', 'avgValidDwellTime']

// 获取指标值
export function formatIndicatorValue(key, value) {
  try {
    if (percentKeys.includes(key)) {
      return value + '%'
    } else if (timeKeys.includes(key)) {
      return formatSeconds(value)
    } else {
      return value
    }
  } catch (e) {
    return value
    console.log(e);
  }
}