| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- <template>
- <view class="container">
- <view class="tab-bar">
- <view
- v-for="(tab, idx) in tabs"
- :key="idx"
- class="tab-item"
- :class="{ 'tab-active': activeTab === idx }"
- @click="activeTab = idx; loadData()"
- >
- <text>{{ tab.label }}</text>
- </view>
- </view>
- <view class="search-bar">
- <input
- class="search-input"
- v-model="keyword"
- placeholder="搜索报告标题或成员名称..."
- @confirm="loadData()"
- />
- </view>
- <scroll-view scroll-y class="report-list" @scrolltolower="loadMore">
- <view
- v-for="item in reports"
- :key="item.id"
- class="report-card"
- :class="'card-' + getCardClass(item.reportType)"
- @click="goToDetail(item)"
- >
- <view class="card-left">
- <view class="type-badge" :class="'badge-' + getCardClass(item.reportType)">
- <text>{{ item.reportTypeName }}</text>
- </view>
- <text class="card-title">{{ item.title }}</text>
- <view class="card-meta">
- <text class="subject-name">{{ item.subjectName }}</text>
- <text class="date-text">{{ formatDate(item.reportDate) }}</text>
- </view>
- </view>
- <view class="card-right">
- <text v-if="item.overallScore !== null && item.overallScore !== undefined" class="score">{{ item.overallScore }}<text class="score-unit">分</text></text>
- <text v-else class="score-text">{{ item.hasFile ? '有文件' : '结构化数据' }}</text>
- <text class="arrow">›</text>
- </view>
- </view>
- <view v-if="reports.length === 0 && !loading" class="empty">
- <text class="empty-icon">📋</text>
- <text class="empty-title">暂无报告</text>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import { getReportSummaryList } from '../../utils/api.js'
- import { parseDate } from '../../utils/format.js'
- export default {
- data() {
- return {
- tabs: [
- { label: '全部', type: 'all' },
- { label: '菌群', type: 'gut_flora' },
- { label: '体检', type: 'physical_exam' },
- { label: 'DAN', type: 'dan' },
- { label: '保单', type: 'insurance' },
- { label: '周报', type: 'fortune' }
- ],
- activeTab: 0,
- keyword: '',
- reports: [],
- page: 1,
- loading: false,
- hasMore: true
- }
- },
- onLoad() {
- this.loadData()
- },
- onPullDownRefresh() {
- this.page = 1
- this.reports = []
- this.hasMore = true
- this.loadData()
- },
- methods: {
- loadData() {
- var self = this
- if (self.loading) return
- if (!self.hasMore) return
- self.loading = true
- var params = {
- page: self.page,
- size: 20,
- type: self.tabs[self.activeTab].type,
- keyword: self.keyword
- }
- getReportSummaryList(params).then(function(res) {
- var list = res && res.data && res.data.records ? res.data.records : []
- if (self.page === 1) {
- self.reports = list
- } else {
- self.reports = self.reports.concat(list)
- }
- self.hasMore = list.length >= 20
- self.page++
- }).catch(function(e) {
- console.log('获取报告列表失败', e)
- uni.showToast({ title: '加载失败', icon: 'none' })
- }).finally(function() {
- self.loading = false
- uni.stopPullDownRefresh()
- })
- },
- loadMore() {
- if (!this.loading && this.hasMore) {
- this.loadData()
- }
- },
- goToDetail(item) {
- uni.navigateTo({
- url: '/pages/profile/report-detail?id=' + item.id + '&title=' + encodeURIComponent(item.title)
- })
- },
- getCardClass(reportType) {
- return reportType || 'default'
- },
- 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>
- .container {
- min-height: 100vh;
- background: #f5f7fa;
- display: flex;
- flex-direction: column;
- }
- .tab-bar {
- display: flex;
- flex-direction: row;
- background: #fff;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #eee;
- overflow-x: auto;
- white-space: nowrap;
- }
- .tab-item {
- padding: 12rpx 24rpx;
- font-size: 26rpx;
- color: #666;
- margin: 0 8rpx;
- border-radius: 20rpx;
- }
- .tab-active {
- background: #5B9BD5;
- color: #fff;
- }
- .search-bar {
- padding: 16rpx 24rpx;
- background: #fff;
- }
- .search-input {
- background: #f5f5f5;
- border-radius: 12rpx;
- padding: 16rpx 24rpx;
- font-size: 26rpx;
- }
- .report-list {
- flex: 1;
- padding: 16rpx 24rpx;
- }
- .report-card {
- background: #fff;
- border-radius: 16rpx;
- padding: 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);
- }
- .card-left {
- display: flex;
- flex-direction: column;
- flex: 1;
- min-width: 0;
- }
- .type-badge {
- display: inline-block;
- font-size: 20rpx;
- padding: 4rpx 16rpx;
- border-radius: 12rpx;
- align-self: flex-start;
- margin-bottom: 8rpx;
- }
- .badge-gut_flora { background: #E8F5E9; color: #2E7D32; }
- .badge-physical_exam { background: #E3F2FD; color: #1565C0; }
- .badge-dan { background: #F3E5F5; color: #7B1FA2; }
- .badge-insurance { background: #FFF3E0; color: #E65100; }
- .badge-fortune { background: #FCE4EC; color: #C62828; }
- .card-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 8rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .card-meta {
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .subject-name {
- font-size: 24rpx;
- color: #888;
- margin-right: 16rpx;
- }
- .date-text {
- font-size: 24rpx;
- color: #aaa;
- }
- .card-right {
- display: flex;
- flex-direction: row;
- align-items: center;
- gap: 8rpx;
- margin-left: 16rpx;
- }
- .score {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- }
- .score-unit {
- font-size: 20rpx;
- color: #999;
- font-weight: normal;
- margin-left: 4rpx;
- }
- .score-text {
- font-size: 24rpx;
- color: #888;
- }
- .arrow {
- font-size: 32rpx;
- color: #ccc;
- }
- .empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 100rpx 0;
- }
- .empty-icon {
- font-size: 80rpx;
- margin-bottom: 20rpx;
- }
- .empty-title {
- font-size: 28rpx;
- color: #999;
- }
- </style>
|