recordDetail.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="container">
  3. <Breadcrumb :items="['乐跑记录', '记录详情']" />
  4. <a-card title="记录详情">
  5. <a-skeleton animation :loading="loading">
  6. <a-space direction="vertical" :style="{ width: '100%' }" size="large">
  7. <a-skeleton-shape size="large" />
  8. <a-skeleton-line :rows="5" />
  9. </a-space>
  10. </a-skeleton>
  11. <a-descriptions :data="info" :column="2" />
  12. <MapContainer v-if="showMap" :point_list="data.result.point_list" :log_list="data.point_data" :pathData="data.data" threeD
  13. style="margin-top: 10px;" />
  14. </a-card>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ref, onMounted } from 'vue'
  19. import { adminGetRecordDetail } from '@/api/lepao'
  20. import { Notification } from '@arco-design/web-vue'
  21. import { useRoute } from 'vue-router'
  22. import MapContainer from '@/components/Map/MapContainer.vue'
  23. const route = useRoute()
  24. const uuidLike = /^[0-9a-fA-F-]{16,}$/
  25. const loading = ref(false)
  26. const showMap = ref(false)
  27. const data = ref({})
  28. const info = ref([])
  29. const GetRecordDetail = async (routeId) => {
  30. try {
  31. loading.value = true
  32. showMap.value = false
  33. const raw = decodeURIComponent(String(routeId || ''))
  34. const payload = uuidLike.test(raw)
  35. ? { public_id: raw }
  36. : { id: raw }
  37. const res = await adminGetRecordDetail(payload)
  38. if (!res || res.code !== 0)
  39. return Notification.error({
  40. title: '获取路径数据失败!',
  41. content: res?.msg ?? '请稍后再试'
  42. })
  43. data.value = res.data
  44. showMap.value = true
  45. info.value = [
  46. { label: '账号名称', value: res.data.name },
  47. { label: '乐跑账号', value: res.data.lepao_account },
  48. { label: '乐跑类型', value: res.data.run_mode === 'manual' ? '手动乐跑' : '自动乐跑' },
  49. { label: '跑区名称', value: res.data.result.pass_tit },
  50. { label: '路线ID', value: res.data.path_id },
  51. { label: '记录时间', value: stramptoTime(res.data.time) },
  52. { label: '开始时间', value: stramptoTime(res.data.result.start_time * 1000) },
  53. { label: '乐跑状态', value: res.data.result.record_failed_reason },
  54. { label: '打卡点数量', value: res.data.result.point_list.length },
  55. { label: '跑步距离', value: res.data.result.distance + ' Km' },
  56. { label: '跑步时长', value: formatSecondsToMinSec(res.data.result.time) },
  57. { label: '平均配速', value: calculatePace(res.data.result.time, res.data.result.distance) }
  58. ]
  59. } catch (error) {
  60. Notification.error({
  61. title: '获取路径数据失败!',
  62. content: error.message || '请稍后再试'
  63. })
  64. } finally {
  65. loading.value = false
  66. }
  67. }
  68. onMounted(() => {
  69. GetRecordDetail(route.params.id)
  70. })
  71. const stramptoTime = (time) => {
  72. return new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })
  73. }
  74. function calculatePace(seconds, kilometers) {
  75. const paceInSeconds = seconds / kilometers;
  76. const minutes = Math.floor(paceInSeconds / 60);
  77. const remainingSeconds = Math.round(paceInSeconds % 60);
  78. return `${minutes}'${remainingSeconds.toString().padStart(2, '0')}''`;
  79. }
  80. function formatSecondsToMinSec(totalSeconds) {
  81. const minutes = Math.floor(totalSeconds / 60);
  82. const seconds = totalSeconds % 60;
  83. return `${minutes}分${seconds.toString().padStart(2, '0')}秒`;
  84. }
  85. </script>
  86. <style scoped lang="less">
  87. .container {
  88. padding: 0 20px 20px 20px;
  89. }
  90. </style>