report-list.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="list-container">
  3. <!-- 顶部导航 -->
  4. <view class="nav-bar">
  5. <text class="nav-back" @click="goBack">‹ 返回</text>
  6. <text class="nav-title">健康报告</text>
  7. <view class="nav-placeholder"></view>
  8. </view>
  9. <!-- 加载状态 -->
  10. <view class="loading-wrap" v-if="loading">
  11. <text class="loading-text">加载中...</text>
  12. </view>
  13. <!-- 报告列表 -->
  14. <view class="report-list" v-else-if="reports.length > 0">
  15. <view
  16. class="report-card"
  17. v-for="item in reports"
  18. :key="item.id"
  19. @click="goToDetail(item.id, item.reportType)"
  20. >
  21. <view class="report-card-left">
  22. <view class="report-type-badge" :class="'badge-' + (item.reportType === 'gut_flora' ? 'gut' : item.reportType === 'tongue' ? 'tongue' : 'exam')">
  23. <text>{{ item.reportType === 'gut_flora' ? '肠道检测' : item.reportType === 'tongue' ? '舌诊' : '体检报告' }}</text>
  24. </view>
  25. <text class="report-date">{{ formatDate(item.reportDate) }}</text>
  26. </view>
  27. <view class="report-card-right">
  28. <text class="report-score">{{ item.overallScore || '--' }}<text class="score-unit">分</text></text>
  29. <text class="report-arrow">›</text>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 空状态 -->
  34. <view class="empty-wrap" v-else>
  35. <text class="empty-icon">📋</text>
  36. <text class="empty-title">暂无健康报告</text>
  37. <text class="empty-desc">上传体检报告或肠道检测报告,获取 AI 解读</text>
  38. <view class="empty-btn" @click="goToUpload">上传报告</view>
  39. </view>
  40. <!-- 底部占位 -->
  41. <view class="bottom-spacer"></view>
  42. </view>
  43. </template>
  44. <script>
  45. import { getReportList } from '../../utils/api.js'
  46. export default {
  47. data() {
  48. return {
  49. reports: [],
  50. loading: false,
  51. childId: null
  52. }
  53. },
  54. onLoad(options) {
  55. this.childId = options.childId ? parseInt(options.childId) : null
  56. this.loadData()
  57. },
  58. methods: {
  59. loadData() {
  60. var self = this
  61. self.loading = true
  62. getReportList(self.childId).then(function(res) {
  63. self.reports = res.data || []
  64. }).catch(function(e) {
  65. console.log('获取报告列表失败', e)
  66. uni.showToast({ title: '加载失败', icon: 'none' })
  67. }).finally(function() {
  68. self.loading = false
  69. })
  70. },
  71. goBack() {
  72. uni.navigateBack()
  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. try {
  89. var d = new Date(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. } catch (e) {
  95. return dateStr
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. .list-container {
  103. min-height: 100vh;
  104. background: #F5F7FA;
  105. }
  106. /* ===== 导航栏 ===== */
  107. .nav-bar {
  108. position: sticky;
  109. top: 0;
  110. background: #fff;
  111. display: flex;
  112. flex-direction: row;
  113. align-items: center;
  114. justify-content: space-between;
  115. padding: 20rpx 30rpx;
  116. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  117. z-index: 100;
  118. }
  119. .nav-back {
  120. font-size: 32rpx;
  121. color: #5B9BD5;
  122. }
  123. .nav-title {
  124. font-size: 32rpx;
  125. font-weight: bold;
  126. color: #333;
  127. }
  128. .nav-placeholder {
  129. width: 80rpx;
  130. }
  131. /* ===== 加载状态 ===== */
  132. .loading-wrap {
  133. display: flex;
  134. justify-content: center;
  135. padding: 80rpx 0;
  136. }
  137. .loading-text {
  138. font-size: 28rpx;
  139. color: #999;
  140. }
  141. /* ===== 报告列表 ===== */
  142. .report-list {
  143. margin: 20rpx 30rpx;
  144. }
  145. .report-card {
  146. background: #fff;
  147. border-radius: 16rpx;
  148. padding: 28rpx 24rpx;
  149. margin-bottom: 16rpx;
  150. display: flex;
  151. flex-direction: row;
  152. align-items: center;
  153. justify-content: space-between;
  154. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  155. }
  156. .report-card:active {
  157. opacity: 0.8;
  158. }
  159. .report-card-left {
  160. display: flex;
  161. flex-direction: column;
  162. gap: 8rpx;
  163. }
  164. .report-type-badge {
  165. display: inline-block;
  166. font-size: 22rpx;
  167. padding: 4rpx 18rpx;
  168. border-radius: 20rpx;
  169. align-self: flex-start;
  170. }
  171. .badge-exam {
  172. background: #E3F2FD;
  173. color: #1565C0;
  174. }
  175. .badge-gut {
  176. background: #E8F5E9;
  177. color: #2E7D32;
  178. }
  179. .badge-tongue {
  180. background: #FFF3E0;
  181. color: #E65100;
  182. }
  183. .report-date {
  184. font-size: 24rpx;
  185. color: #888;
  186. }
  187. .report-card-right {
  188. display: flex;
  189. flex-direction: row;
  190. align-items: center;
  191. gap: 12rpx;
  192. }
  193. .report-score {
  194. font-size: 36rpx;
  195. font-weight: bold;
  196. color: #333;
  197. }
  198. .score-unit {
  199. font-size: 22rpx;
  200. color: #999;
  201. font-weight: normal;
  202. }
  203. .report-arrow {
  204. font-size: 36rpx;
  205. color: #CCC;
  206. }
  207. /* ===== 空状态 ===== */
  208. .empty-wrap {
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. padding: 120rpx 60rpx;
  213. }
  214. .empty-icon {
  215. font-size: 80rpx;
  216. margin-bottom: 24rpx;
  217. }
  218. .empty-title {
  219. font-size: 32rpx;
  220. font-weight: bold;
  221. color: #333;
  222. margin-bottom: 12rpx;
  223. }
  224. .empty-desc {
  225. font-size: 26rpx;
  226. color: #999;
  227. text-align: center;
  228. margin-bottom: 40rpx;
  229. line-height: 1.5;
  230. }
  231. .empty-btn {
  232. background: #5B9BD5;
  233. color: #fff;
  234. font-size: 28rpx;
  235. padding: 20rpx 60rpx;
  236. border-radius: 40rpx;
  237. }
  238. .empty-btn:active {
  239. opacity: 0.8;
  240. }
  241. /* ===== 底部 ===== */
  242. .bottom-spacer {
  243. height: 60rpx;
  244. }
  245. </style>