report-list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="list-container">
  3. <!-- 加载状态 -->
  4. <view class="loading-wrap" v-if="loading">
  5. <text class="loading-text">加载中...</text>
  6. </view>
  7. <!-- 报告列表 -->
  8. <view class="report-list" v-else-if="reports.length > 0">
  9. <view
  10. class="report-card"
  11. v-for="item in reports"
  12. :key="item.id"
  13. @click="goToDetail(item.id, item.reportType)"
  14. >
  15. <view class="report-card-left">
  16. <view class="report-type-badge" :class="'badge-' + (item.reportType === 'gut_flora' ? 'gut' : item.reportType === 'tongue' ? 'tongue' : 'exam')">
  17. <text>{{ item.reportType === 'gut_flora' ? '肠道检测' : item.reportType === 'tongue' ? '舌诊' : '体检报告' }}</text>
  18. </view>
  19. <text class="report-date">{{ formatDate(item.reportDate) }}</text>
  20. </view>
  21. <view class="report-card-right">
  22. <text class="report-score">{{ item.overallScore || '--' }}<text class="score-unit">分</text></text>
  23. <text class="report-arrow">›</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 空状态 -->
  28. <view class="empty-wrap" v-else>
  29. <text class="empty-icon">📋</text>
  30. <text class="empty-title">暂无健康报告</text>
  31. <text class="empty-desc">上传体检报告或肠道检测报告,获取 AI 解读</text>
  32. <view class="empty-btn" @click="goToUpload">上传报告</view>
  33. </view>
  34. <!-- 底部占位 -->
  35. <view class="bottom-spacer"></view>
  36. </view>
  37. </template>
  38. <script>
  39. import { getReportList } from '../../utils/api.js'
  40. import { parseDate } from '../../utils/format.js'
  41. export default {
  42. data() {
  43. return {
  44. reports: [],
  45. loading: false,
  46. memberId: null
  47. }
  48. },
  49. onLoad(options) {
  50. this.memberId = options.memberId ? parseInt(options.memberId) : this.getMemberId()
  51. this.loadData()
  52. },
  53. methods: {
  54. getMemberId: function() {
  55. // 优先当前选中的孩子/成员,兜底用登录用户 ID(与 health-main 一致)
  56. var store = this.$store
  57. if (store && store.state && store.state.currentChildId) return store.state.currentChildId
  58. if (store && store.state && store.state.currentMemberId) return store.state.currentMemberId
  59. if (store && store.state && store.state.userId) return store.state.userId
  60. return uni.getStorageSync('userId') || ''
  61. },
  62. loadData() {
  63. var self = this
  64. self.loading = true
  65. getReportList(self.memberId).then(function(res) {
  66. self.reports = res.data || []
  67. }).catch(function(e) {
  68. console.log('获取报告列表失败', e)
  69. uni.showToast({ title: '加载失败', icon: 'none' })
  70. }).finally(function() {
  71. self.loading = false
  72. })
  73. },
  74. goToDetail(reportId, reportType) {
  75. var detailPages = {
  76. 'gut_flora': '/pages/health/gut-flora-detail',
  77. 'physical_exam': '/pages/health/physical-exam-detail',
  78. 'tongue': '/pages/health/tongue-index'
  79. }
  80. var url = detailPages[reportType] || '/pages/body/health-report'
  81. uni.navigateTo({ url: url + '?reportId=' + reportId })
  82. },
  83. goToUpload() {
  84. uni.navigateTo({ url: '/pages/health/report-upload' })
  85. },
  86. formatDate(dateStr) {
  87. if (!dateStr) return '--'
  88. var d = parseDate(dateStr)
  89. if (!d) return dateStr
  90. var y = d.getFullYear()
  91. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  92. var day = ('' + d.getDate()).padStart(2, '0')
  93. return y + '-' + m + '-' + day
  94. }
  95. }
  96. }
  97. </script>
  98. <style scoped>
  99. .list-container {
  100. min-height: 100vh;
  101. background: #F5F7FA;
  102. }
  103. /* ===== 加载状态 ===== */
  104. .loading-wrap {
  105. display: flex;
  106. justify-content: center;
  107. padding: 80rpx 0;
  108. }
  109. .loading-text {
  110. font-size: 28rpx;
  111. color: #999;
  112. }
  113. /* ===== 报告列表 ===== */
  114. .report-list {
  115. margin: 20rpx 30rpx;
  116. }
  117. .report-card {
  118. background: #fff;
  119. border-radius: 16rpx;
  120. padding: 28rpx 24rpx;
  121. margin-bottom: 16rpx;
  122. display: flex;
  123. flex-direction: row;
  124. align-items: center;
  125. justify-content: space-between;
  126. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  127. }
  128. .report-card:active {
  129. opacity: 0.8;
  130. }
  131. .report-card-left {
  132. display: flex;
  133. flex-direction: column;
  134. gap: 8rpx;
  135. }
  136. .report-type-badge {
  137. display: inline-block;
  138. font-size: 22rpx;
  139. padding: 4rpx 18rpx;
  140. border-radius: 20rpx;
  141. align-self: flex-start;
  142. }
  143. .badge-exam {
  144. background: #E3F2FD;
  145. color: #1565C0;
  146. }
  147. .badge-gut {
  148. background: #E8F5E9;
  149. color: #2E7D32;
  150. }
  151. .badge-tongue {
  152. background: #FFF3E0;
  153. color: #E65100;
  154. }
  155. .report-date {
  156. font-size: 24rpx;
  157. color: #888;
  158. }
  159. .report-card-right {
  160. display: flex;
  161. flex-direction: row;
  162. align-items: center;
  163. gap: 12rpx;
  164. }
  165. .report-score {
  166. font-size: 36rpx;
  167. font-weight: bold;
  168. color: #333;
  169. }
  170. .score-unit {
  171. font-size: 22rpx;
  172. color: #999;
  173. font-weight: normal;
  174. }
  175. .report-arrow {
  176. font-size: 36rpx;
  177. color: #CCC;
  178. }
  179. /* ===== 空状态 ===== */
  180. .empty-wrap {
  181. display: flex;
  182. flex-direction: column;
  183. align-items: center;
  184. padding: 120rpx 60rpx;
  185. }
  186. .empty-icon {
  187. font-size: 80rpx;
  188. margin-bottom: 24rpx;
  189. }
  190. .empty-title {
  191. font-size: 32rpx;
  192. font-weight: bold;
  193. color: #333;
  194. margin-bottom: 12rpx;
  195. }
  196. .empty-desc {
  197. font-size: 26rpx;
  198. color: #999;
  199. text-align: center;
  200. margin-bottom: 40rpx;
  201. line-height: 1.5;
  202. }
  203. .empty-btn {
  204. background: #5B9BD5;
  205. color: #fff;
  206. font-size: 28rpx;
  207. padding: 20rpx 60rpx;
  208. border-radius: 40rpx;
  209. }
  210. .empty-btn:active {
  211. opacity: 0.8;
  212. }
  213. /* ===== 底部 ===== */
  214. .bottom-spacer {
  215. height: 60rpx;
  216. }
  217. </style>