report-list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. // 优先用导航参数传入的 memberId;未传时后端回退到家庭报告列表
  51. this.memberId = options.memberId ? parseInt(options.memberId) : null
  52. this.loadData()
  53. },
  54. methods: {
  55. loadData() {
  56. var self = this
  57. self.loading = true
  58. getReportList(self.memberId).then(function(res) {
  59. self.reports = res.data || []
  60. }).catch(function(e) {
  61. console.log('获取报告列表失败', e)
  62. uni.showToast({ title: '加载失败', icon: 'none' })
  63. }).finally(function() {
  64. self.loading = false
  65. })
  66. },
  67. goToDetail(reportId, reportType) {
  68. var detailPages = {
  69. 'gut_flora': '/pages/health/report-detail?reportType=gut_flora',
  70. 'dan': '/pages/health/report-detail?reportType=dan',
  71. 'physical_exam': '/pages/health/physical-exam-detail',
  72. 'tongue': '/pages/health/tongue-index'
  73. }
  74. var url = detailPages[reportType] || '/pages/body/health-report'
  75. var sep = url.indexOf('?') >= 0 ? '&' : '?'
  76. uni.navigateTo({ url: url + sep + 'reportId=' + reportId })
  77. },
  78. goToUpload() {
  79. uni.navigateTo({ url: '/pages/health/report-upload' })
  80. },
  81. formatDate(dateStr) {
  82. if (!dateStr) return '--'
  83. var d = parseDate(dateStr)
  84. if (!d) return dateStr
  85. var y = d.getFullYear()
  86. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  87. var day = ('' + d.getDate()).padStart(2, '0')
  88. return y + '-' + m + '-' + day
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. .list-container {
  95. min-height: 100vh;
  96. background: #F5F7FA;
  97. }
  98. /* ===== 加载状态 ===== */
  99. .loading-wrap {
  100. display: flex;
  101. justify-content: center;
  102. padding: 80rpx 0;
  103. }
  104. .loading-text {
  105. font-size: 28rpx;
  106. color: #999;
  107. }
  108. /* ===== 报告列表 ===== */
  109. .report-list {
  110. margin: 20rpx 30rpx;
  111. }
  112. .report-card {
  113. background: #fff;
  114. border-radius: 16rpx;
  115. padding: 28rpx 24rpx;
  116. margin-bottom: 16rpx;
  117. display: flex;
  118. flex-direction: row;
  119. align-items: center;
  120. justify-content: space-between;
  121. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  122. }
  123. .report-card:active {
  124. opacity: 0.8;
  125. }
  126. .report-card-left {
  127. display: flex;
  128. flex-direction: column;
  129. gap: 8rpx;
  130. }
  131. .report-type-badge {
  132. display: inline-block;
  133. font-size: 22rpx;
  134. padding: 4rpx 18rpx;
  135. border-radius: 20rpx;
  136. align-self: flex-start;
  137. }
  138. .badge-exam {
  139. background: #E3F2FD;
  140. color: #1565C0;
  141. }
  142. .badge-gut {
  143. background: #E8F5E9;
  144. color: #2E7D32;
  145. }
  146. .badge-tongue {
  147. background: #FFF3E0;
  148. color: #E65100;
  149. }
  150. .report-date {
  151. font-size: 24rpx;
  152. color: #888;
  153. }
  154. .report-card-right {
  155. display: flex;
  156. flex-direction: row;
  157. align-items: center;
  158. gap: 12rpx;
  159. }
  160. .report-score {
  161. font-size: 36rpx;
  162. font-weight: bold;
  163. color: #333;
  164. }
  165. .score-unit {
  166. font-size: 22rpx;
  167. color: #999;
  168. font-weight: normal;
  169. }
  170. .report-arrow {
  171. font-size: 36rpx;
  172. color: #CCC;
  173. }
  174. /* ===== 空状态 ===== */
  175. .empty-wrap {
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. padding: 120rpx 60rpx;
  180. }
  181. .empty-icon {
  182. font-size: 80rpx;
  183. margin-bottom: 24rpx;
  184. }
  185. .empty-title {
  186. font-size: 32rpx;
  187. font-weight: bold;
  188. color: #333;
  189. margin-bottom: 12rpx;
  190. }
  191. .empty-desc {
  192. font-size: 26rpx;
  193. color: #999;
  194. text-align: center;
  195. margin-bottom: 40rpx;
  196. line-height: 1.5;
  197. }
  198. .empty-btn {
  199. background: #5B9BD5;
  200. color: #fff;
  201. font-size: 28rpx;
  202. padding: 20rpx 60rpx;
  203. border-radius: 40rpx;
  204. }
  205. .empty-btn:active {
  206. opacity: 0.8;
  207. }
  208. /* ===== 底部 ===== */
  209. .bottom-spacer {
  210. height: 60rpx;
  211. }
  212. </style>