|
@@ -0,0 +1,90 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <view class="page">
|
|
|
|
|
+ <view class="nav-bar">
|
|
|
|
|
+ <view class="nav-back" @tap="goBack"><text class="back-text">‹ 返回</text></view>
|
|
|
|
|
+ <text class="nav-title">{{ typeLabel }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <scroll-view class="content" scroll-y>
|
|
|
|
|
+ <!-- 报告头 -->
|
|
|
|
|
+ <view class="report-head" v-if="headInfo">
|
|
|
|
|
+ <view class="head-name">{{ headInfo.personName || headInfo.childName || '健康报告' }}</view>
|
|
|
|
|
+ <view class="head-meta">
|
|
|
|
|
+ <text class="type-badge">{{ typeLabel }}</text>
|
|
|
|
|
+ <text class="head-date">{{ headInfo.reportDateText || '' }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <!-- blocks 渲染 -->
|
|
|
|
|
+ <report-blocks-renderer v-if="blocks && blocks.length > 0" :blocks="blocks" />
|
|
|
|
|
+ <view class="empty-hint" v-else>暂无报告内容</view>
|
|
|
|
|
+ </scroll-view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import ReportBlocksRenderer from '../../components/report-blocks-renderer.vue'
|
|
|
|
|
+import { getReportDetail, getDanReportDetail } from '../../utils/api.js'
|
|
|
|
|
+import { parseDate } from '../../utils/format.js'
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ components: { ReportBlocksRenderer },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ reportType: '',
|
|
|
|
|
+ reportId: null,
|
|
|
|
|
+ blocks: [],
|
|
|
|
|
+ headInfo: null
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ typeLabel: function() {
|
|
|
|
|
+ var map = { 'gut_flora': '肠道菌群报告', 'dan': 'DAN测评报告', 'physical_exam': '体检报告', 'tongue': '舌诊报告' }
|
|
|
|
|
+ return map[this.reportType] || '报告详情'
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onLoad: function(options) {
|
|
|
|
|
+ this.reportType = options.reportType || 'gut_flora'
|
|
|
|
|
+ this.reportId = options.reportId ? parseInt(options.reportId) : null
|
|
|
|
|
+ if (this.reportId) this.loadData()
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ goBack: function() { uni.navigateBack() },
|
|
|
|
|
+ loadData: function() {
|
|
|
|
|
+ var self = this
|
|
|
|
|
+ var loadFn = self.reportType === 'dan' ? getDanReportDetail : getReportDetail
|
|
|
|
|
+ loadFn(self.reportId).then(function(res) {
|
|
|
|
|
+ if (res.code === 200 && res.data) {
|
|
|
|
|
+ self.blocks = res.data.blocks || []
|
|
|
|
|
+ var report = res.data.report || res.data
|
|
|
|
|
+ var head = {}
|
|
|
|
|
+ if (self.reportType === 'dan') {
|
|
|
|
|
+ head.childName = report.childName
|
|
|
|
|
+ head.reportDateText = report.assessmentDate || ''
|
|
|
|
|
+ } else {
|
|
|
|
|
+ head.personName = report.personName
|
|
|
|
|
+ var d = parseDate(report.reportDate)
|
|
|
|
|
+ head.reportDateText = d ? (d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()) : ''
|
|
|
|
|
+ }
|
|
|
|
|
+ self.headInfo = head
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(function() {
|
|
|
|
|
+ uni.showToast({ title: '加载失败', icon: 'none' })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+.page { min-height: 100vh; background: #f8f8f8; }
|
|
|
|
|
+.nav-bar { display: flex; align-items: center; padding: 20rpx 30rpx; background: #fff; position: relative; }
|
|
|
|
|
+.nav-back { padding: 10rpx 0; }
|
|
|
|
|
+.back-text { font-size: 28rpx; color: #4A9BD7; }
|
|
|
|
|
+.nav-title { flex: 1; text-align: center; font-size: 32rpx; font-weight: 600; }
|
|
|
|
|
+.content { padding: 20rpx 30rpx; height: calc(100vh - 100rpx); }
|
|
|
|
|
+.report-head { background: #fff; border-radius: 16rpx; padding: 28rpx; margin-bottom: 20rpx; }
|
|
|
|
|
+.head-name { font-size: 34rpx; font-weight: 600; color: #333; }
|
|
|
|
|
+.head-meta { display: flex; align-items: center; margin-top: 12rpx; }
|
|
|
|
|
+.type-badge { font-size: 22rpx; color: #2E7D32; background: #E8F5E9; padding: 4rpx 16rpx; border-radius: 20rpx; margin-right: 16rpx; }
|
|
|
|
|
+.head-date { font-size: 24rpx; color: #999; }
|
|
|
|
|
+.empty-hint { text-align: center; color: #ccc; padding: 80rpx 0; font-size: 28rpx; }
|
|
|
|
|
+</style>
|