index.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="page-records">
  3. <view v-if="store.records.length === 0" class="empty-state">
  4. <text class="empty-icon">📋</text>
  5. <text class="empty-text">暂无分析记录</text>
  6. <text class="empty-desc">去首页分析您的手机号码</text>
  7. </view>
  8. <view v-else class="records-list">
  9. <view
  10. v-for="record in store.records"
  11. :key="record.id"
  12. class="record-card"
  13. @click="viewDetail(record)"
  14. >
  15. <view class="record-header">
  16. <text class="record-name">{{ record.name || record.birthday || '未知' }}</text>
  17. <text class="record-date">{{ formatDate(record.createdAt) }}</text>
  18. </view>
  19. <text class="record-phone">{{ record.birthday || '' }}</text>
  20. <view class="record-tags">
  21. <text v-if="record.difyResponse" class="tag-status">已解读</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup>
  28. import { onShow } from '@dcloudio/uni-app'
  29. import { useChartStore } from '@/stores/chart'
  30. const store = useChartStore()
  31. onShow(() => {
  32. store.fetchRecords()
  33. })
  34. function formatDate(dateStr) {
  35. if (!dateStr) return ''
  36. return dateStr.slice(0, 10)
  37. }
  38. function viewDetail(record) {
  39. store.loadChart(record.id).then(() => {
  40. uni.navigateTo({ url: '/pages/chart/index' })
  41. })
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. .page-records { padding: 16px; }
  46. .empty-state {
  47. display: flex; flex-direction: column; align-items: center;
  48. padding-top: 80px;
  49. }
  50. .empty-icon { font-size: 48px; margin-bottom: 12px; }
  51. .empty-text { font-size: 16px; color: #6B7280; margin-bottom: 4px; }
  52. .empty-desc { font-size: 14px; color: #9CA3AF; }
  53. .records-list { display: flex; flex-direction: column; gap: 10px; }
  54. .record-card {
  55. background: #fff; border-radius: 12px; padding: 16px;
  56. box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  57. }
  58. .record-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
  59. .record-name { font-weight: 600; color: #1F2937; }
  60. .record-date { font-size: 12px; color: #9CA3AF; }
  61. .record-phone { font-size: 18px; color: #3B82F6; font-weight: 500; }
  62. .tag-status {
  63. display: inline-block; background: #D1FAE5; color: #059669;
  64. font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-top: 8px;
  65. }
  66. </style>