| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <template>
- <view class="list-container">
- <!-- 加载状态 -->
- <view class="loading-wrap" v-if="loading">
- <text class="loading-text">加载中...</text>
- </view>
- <!-- 报告列表 -->
- <view class="report-list" v-else-if="reports.length > 0">
- <view
- class="report-card"
- v-for="item in reports"
- :key="item.id"
- @click="goToDetail(item.id, item.reportType)"
- >
- <view class="report-card-left">
- <view class="report-type-badge" :class="'badge-' + (item.reportType === 'gut_flora' ? 'gut' : item.reportType === 'tongue' ? 'tongue' : 'exam')">
- <text>{{ item.reportType === 'gut_flora' ? '肠道检测' : item.reportType === 'tongue' ? '舌诊' : '体检报告' }}</text>
- </view>
- <text class="report-date">{{ formatDate(item.reportDate) }}</text>
- </view>
- <view class="report-card-right">
- <text class="report-score">{{ item.overallScore || '--' }}<text class="score-unit">分</text></text>
- <text class="report-arrow">›</text>
- </view>
- </view>
- </view>
- <!-- 空状态 -->
- <view class="empty-wrap" v-else>
- <text class="empty-icon">📋</text>
- <text class="empty-title">暂无健康报告</text>
- <text class="empty-desc">上传体检报告或肠道检测报告,获取 AI 解读</text>
- <view class="empty-btn" @click="goToUpload">上传报告</view>
- </view>
- <!-- 底部占位 -->
- <view class="bottom-spacer"></view>
- </view>
- </template>
- <script>
- import { getReportList } from '../../utils/api.js'
- import { parseDate } from '../../utils/format.js'
- export default {
- data() {
- return {
- reports: [],
- loading: false,
- memberId: null
- }
- },
- onLoad(options) {
- this.memberId = options.memberId ? parseInt(options.memberId) : this.getMemberId()
- this.loadData()
- },
- methods: {
- getMemberId: function() {
- // 优先当前选中的孩子/成员,兜底用登录用户 ID(与 health-main 一致)
- var store = this.$store
- if (store && store.state && store.state.currentChildId) return store.state.currentChildId
- if (store && store.state && store.state.currentMemberId) return store.state.currentMemberId
- if (store && store.state && store.state.userId) return store.state.userId
- return uni.getStorageSync('userId') || ''
- },
- loadData() {
- var self = this
- self.loading = true
- getReportList(self.memberId).then(function(res) {
- self.reports = res.data || []
- }).catch(function(e) {
- console.log('获取报告列表失败', e)
- uni.showToast({ title: '加载失败', icon: 'none' })
- }).finally(function() {
- self.loading = false
- })
- },
- goToDetail(reportId, reportType) {
- var detailPages = {
- 'gut_flora': '/pages/health/gut-flora-detail',
- 'physical_exam': '/pages/health/physical-exam-detail',
- 'tongue': '/pages/health/tongue-index'
- }
- var url = detailPages[reportType] || '/pages/body/health-report'
- uni.navigateTo({ url: url + '?reportId=' + reportId })
- },
- goToUpload() {
- uni.navigateTo({ url: '/pages/health/report-upload' })
- },
- formatDate(dateStr) {
- if (!dateStr) return '--'
- var d = parseDate(dateStr)
- if (!d) return dateStr
- var y = d.getFullYear()
- var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
- var day = ('' + d.getDate()).padStart(2, '0')
- return y + '-' + m + '-' + day
- }
- }
- }
- </script>
- <style scoped>
- .list-container {
- min-height: 100vh;
- background: #F5F7FA;
- }
- /* ===== 加载状态 ===== */
- .loading-wrap {
- display: flex;
- justify-content: center;
- padding: 80rpx 0;
- }
- .loading-text {
- font-size: 28rpx;
- color: #999;
- }
- /* ===== 报告列表 ===== */
- .report-list {
- margin: 20rpx 30rpx;
- }
- .report-card {
- background: #fff;
- border-radius: 16rpx;
- padding: 28rpx 24rpx;
- margin-bottom: 16rpx;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- }
- .report-card:active {
- opacity: 0.8;
- }
- .report-card-left {
- display: flex;
- flex-direction: column;
- gap: 8rpx;
- }
- .report-type-badge {
- display: inline-block;
- font-size: 22rpx;
- padding: 4rpx 18rpx;
- border-radius: 20rpx;
- align-self: flex-start;
- }
- .badge-exam {
- background: #E3F2FD;
- color: #1565C0;
- }
- .badge-gut {
- background: #E8F5E9;
- color: #2E7D32;
- }
- .badge-tongue {
- background: #FFF3E0;
- color: #E65100;
- }
- .report-date {
- font-size: 24rpx;
- color: #888;
- }
- .report-card-right {
- display: flex;
- flex-direction: row;
- align-items: center;
- gap: 12rpx;
- }
- .report-score {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- }
- .score-unit {
- font-size: 22rpx;
- color: #999;
- font-weight: normal;
- }
- .report-arrow {
- font-size: 36rpx;
- color: #CCC;
- }
- /* ===== 空状态 ===== */
- .empty-wrap {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 120rpx 60rpx;
- }
- .empty-icon {
- font-size: 80rpx;
- margin-bottom: 24rpx;
- }
- .empty-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 12rpx;
- }
- .empty-desc {
- font-size: 26rpx;
- color: #999;
- text-align: center;
- margin-bottom: 40rpx;
- line-height: 1.5;
- }
- .empty-btn {
- background: #5B9BD5;
- color: #fff;
- font-size: 28rpx;
- padding: 20rpx 60rpx;
- border-radius: 40rpx;
- }
- .empty-btn:active {
- opacity: 0.8;
- }
- /* ===== 底部 ===== */
- .bottom-spacer {
- height: 60rpx;
- }
- </style>
|