report-list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. if (reportType === 'gut_flora') {
  76. uni.showToast({ title: '报告详情页开发中', icon: 'none' })
  77. } else {
  78. uni.navigateTo({ url: '/pages/body/health-report?reportId=' + reportId })
  79. }
  80. },
  81. goToUpload() {
  82. uni.navigateTo({ url: '/pages/health/report-upload' })
  83. },
  84. formatDate(dateStr) {
  85. if (!dateStr) return '--'
  86. try {
  87. var d = new Date(dateStr)
  88. var y = d.getFullYear()
  89. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  90. var day = ('' + d.getDate()).padStart(2, '0')
  91. return y + '-' + m + '-' + day
  92. } catch (e) {
  93. return dateStr
  94. }
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped>
  100. .list-container {
  101. min-height: 100vh;
  102. background: #F5F7FA;
  103. }
  104. /* ===== 导航栏 ===== */
  105. .nav-bar {
  106. position: sticky;
  107. top: 0;
  108. background: #fff;
  109. display: flex;
  110. flex-direction: row;
  111. align-items: center;
  112. justify-content: space-between;
  113. padding: 20rpx 30rpx;
  114. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  115. z-index: 100;
  116. }
  117. .nav-back {
  118. font-size: 32rpx;
  119. color: #5B9BD5;
  120. }
  121. .nav-title {
  122. font-size: 32rpx;
  123. font-weight: bold;
  124. color: #333;
  125. }
  126. .nav-placeholder {
  127. width: 80rpx;
  128. }
  129. /* ===== 加载状态 ===== */
  130. .loading-wrap {
  131. display: flex;
  132. justify-content: center;
  133. padding: 80rpx 0;
  134. }
  135. .loading-text {
  136. font-size: 28rpx;
  137. color: #999;
  138. }
  139. /* ===== 报告列表 ===== */
  140. .report-list {
  141. margin: 20rpx 30rpx;
  142. }
  143. .report-card {
  144. background: #fff;
  145. border-radius: 16rpx;
  146. padding: 28rpx 24rpx;
  147. margin-bottom: 16rpx;
  148. display: flex;
  149. flex-direction: row;
  150. align-items: center;
  151. justify-content: space-between;
  152. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  153. }
  154. .report-card:active {
  155. opacity: 0.8;
  156. }
  157. .report-card-left {
  158. display: flex;
  159. flex-direction: column;
  160. gap: 8rpx;
  161. }
  162. .report-type-badge {
  163. display: inline-block;
  164. font-size: 22rpx;
  165. padding: 4rpx 18rpx;
  166. border-radius: 20rpx;
  167. align-self: flex-start;
  168. }
  169. .badge-exam {
  170. background: #E3F2FD;
  171. color: #1565C0;
  172. }
  173. .badge-gut {
  174. background: #E8F5E9;
  175. color: #2E7D32;
  176. }
  177. .badge-tongue {
  178. background: #FFF3E0;
  179. color: #E65100;
  180. }
  181. .report-date {
  182. font-size: 24rpx;
  183. color: #888;
  184. }
  185. .report-card-right {
  186. display: flex;
  187. flex-direction: row;
  188. align-items: center;
  189. gap: 12rpx;
  190. }
  191. .report-score {
  192. font-size: 36rpx;
  193. font-weight: bold;
  194. color: #333;
  195. }
  196. .score-unit {
  197. font-size: 22rpx;
  198. color: #999;
  199. font-weight: normal;
  200. }
  201. .report-arrow {
  202. font-size: 36rpx;
  203. color: #CCC;
  204. }
  205. /* ===== 空状态 ===== */
  206. .empty-wrap {
  207. display: flex;
  208. flex-direction: column;
  209. align-items: center;
  210. padding: 120rpx 60rpx;
  211. }
  212. .empty-icon {
  213. font-size: 80rpx;
  214. margin-bottom: 24rpx;
  215. }
  216. .empty-title {
  217. font-size: 32rpx;
  218. font-weight: bold;
  219. color: #333;
  220. margin-bottom: 12rpx;
  221. }
  222. .empty-desc {
  223. font-size: 26rpx;
  224. color: #999;
  225. text-align: center;
  226. margin-bottom: 40rpx;
  227. line-height: 1.5;
  228. }
  229. .empty-btn {
  230. background: #5B9BD5;
  231. color: #fff;
  232. font-size: 28rpx;
  233. padding: 20rpx 60rpx;
  234. border-radius: 40rpx;
  235. }
  236. .empty-btn:active {
  237. opacity: 0.8;
  238. }
  239. /* ===== 底部 ===== */
  240. .bottom-spacer {
  241. height: 60rpx;
  242. }
  243. </style>