路泰科技体检小程序UI设计新版本
1
wwl
5 天以前 a6cdbcfe28fcc40ebb4919f57d60fb20122e8e57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<template>
    <view class="page">
        <!-- 通知栏 -->
        <uni-notice-bar show-icon text="仅能查出该亲友最新的体检报告哦!" class="notice-bar" />
 
        <!-- 报告列表 -->
        <scroll-view scroll-y class="report-list" v-if="reports.length > 0">
            <view class="card" v-for="(report, index) in reports" :key="report.tjNum">
                <view class="card-inner">
                    <view class="card-left">
                        <text class="name">{{ report.name || '未知姓名' }}</text>
                        <text class="sex">{{ report.sex || '未知性别' }}</text>
                    </view>
                    <view class="card-right">
                        <view class="info">
                            <text class="time">{{ report.time || '未知时间' }}</text>
                            <text class="hospital">泾川县人民医院体检中心</text>
                            <text class="tj-num">体检号:{{ report.tjNum }}</text>
                        </view>
                        <view class="label">
                            <text class="label-text">体检报告</text>
                        </view>
                    </view>
                </view>
                <!-- 按钮:打开PDF和跳转到ReportBaogao页面 -->
                <view class="button-group">
                    <view class="action-button open-pdf" @click.stop="openPDF(report)">打开PDF</view>
                    <view class="action-button go-report" @click.stop="goToReportBaogao(report)">查看报告详情</view>
                </view>
            </view>
        </scroll-view>
 
        <!-- 无数据提示 -->
        <view v-else class="no-data">
            <text>暂无体检报告</text>
        </view>
    </view>
</template>
 
<script>
    import {
        PDF
    } from "@/api/system/report";
 
    export default {
        name: 'FriendReportOverview',
        data() {
            return {
                reports: [],
                customer: null,
            };
        },
        onLoad(option) {
            if (option.reportData) {
                const reportData = JSON.parse(decodeURIComponent(option.reportData));
                console.log('Parsed reportData:', reportData);
                this.reports = reportData;
                this.customer = {
                    name: reportData[0]?.name
                };
            }
        },
        methods: {
    goToReportBaogao(report) {
      console.log('跳转到 ReportBaogao', {
        tjNum: report.tjNum
      });
      uni.navigateTo({
        url: `/pagesA/ReportBaogao/ReportBaogao?tjNum=${report.tjNum}`
      });
    },
 
 
openPDF(report) {
  console.log('加载中...', { tjNum: report.tjNum });
  uni.showLoading({
    title: '加载中...'
  });
 
  PDF({
    tjNum: report.tjNum
  })
    .then((res) => {
      console.log('PDF response:', res);
      if (!res.msg || typeof res.msg !== 'string') {
        uni.showToast({
          title: '无效的 PDF 文件路径',
          icon: 'none'
        });
        uni.hideLoading();
        return;
      }
 
      // 统一拼接前缀
      const isTestEnv = process.env.VUE_APP_ENV === 'test' || process.env.NODE_ENV === 'development';
      const baseUrl = isTestEnv
        ? 'http://ltpeis.xaltjdkj.cn:5904'
        : `${window.location.origin}`;
 
      const fullUrl = res.msg.startsWith('http')
        ? res.msg
        : `${baseUrl}/report-file${res.msg.startsWith('/') ? '' : '/'}${res.msg}`;
 
      console.log('完整 PDF URL:', fullUrl);
 
      // 小程序端
      //#ifdef MP-WEIXIN
      uni.downloadFile({
        url: fullUrl,
        success: (downloadRes) => {
          console.log('downloadFile success:', downloadRes);
          if (downloadRes.statusCode === 200) {
            uni.openDocument({
              filePath: downloadRes.tempFilePath,
              fileType: 'pdf',
              success: () => {
                console.log('打开文档成功');
              },
              fail: (e) => {
                console.error('打开文档失败', e);
                uni.showToast({
                  title: '打开 PDF 失败',
                  icon: 'none'
                });
              },
              complete: () => {
                uni.hideLoading();
              }
            });
          } else {
            uni.showToast({
              title: '下载 PDF 失败',
              icon: 'none'
            });
            uni.hideLoading();
          }
        },
        fail: (e) => {
          console.error('下载失败', e);
          uni.showToast({
            title: '下载 PDF 失败',
            icon: 'none'
          });
          uni.hideLoading();
        }
      });
      //#endif
 
      // H5 端
      //#ifdef H5
      const newWindow = window.open(fullUrl, '_blank');
      if (!newWindow) {
        const downloadLink = document.createElement('a');
        downloadLink.href = fullUrl;
        downloadLink.download = res.msg;
        downloadLink.click();
        uni.showToast({
          title: '窗口被阻止,已触发下载',
          icon: 'none'
        });
      }
      uni.hideLoading();
      //#endif
 
    })
    .catch((err) => {
      console.error('PDF 接口错误:', err);
      uni.showToast({
        title: err?.msg || '获取 PDF 失败,请稍后重试',
        icon: 'none'
      });
      uni.hideLoading();
    });
}
 
 
        }
 
    };
</script>
 
<style lang="scss">
    .page {
        width: 100%;
        min-height: 100vh;
        background: linear-gradient(180deg, #fff 10%, #f5f7fa 100%);
        padding-bottom: 20rpx;
    }
 
    .notice-bar {
        margin: 20rpx 30rpx;
        border-radius: 16rpx;
        background: rgba(255, 245, 230, 0.95);
        box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
        font-size: 28rpx;
        color: #e58e26;
    }
 
    .report-list {
        height: calc(100vh - 120rpx);
        padding: 0 30rpx;
    }
 
    .card {
        margin-top: 30rpx;
    }
 
    .card-inner {
        width: 100%;
        height: 180rpx;
        background: #ffffff;
        border-radius: 20rpx;
        box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.08);
        display: flex;
        align-items: center;
        justify-content: space-between;
        transition: transform 0.2s ease;
    }
 
    .card-inner:active {
        transform: scale(0.98);
    }
 
    .card-left {
        width: 140rpx;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        border-right: 2rpx dashed #e0e0e0;
    }
 
    .name {
        font-size: 34rpx;
        font-weight: 600;
        color: #333;
        margin-bottom: 10rpx;
    }
 
    .sex {
        font-size: 26rpx;
        color: #888;
    }
 
    .card-right {
        flex: 1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20rpx 0;
    }
 
    .info {
        padding: 0 30rpx;
        display: flex;
        flex-direction: column;
        gap: 12rpx;
    }
 
    .time {
        font-size: 28rpx;
        color: #666;
    }
 
    .hospital {
        font-size: 26rpx;
        color: #999;
    }
 
    .tj-num {
        font-size: 28rpx;
        color: #fd8b4d;
        font-weight: 500;
    }
 
    .label {
        width: 80rpx;
        height: 100%;
        background: linear-gradient(135deg, #fd8b4d, #ffaa70);
        border-radius: 0 20rpx 20rpx 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 22rpx;
    }
 
    .label-text {
        font-size: 30rpx;
        color: #fff;
        font-weight: 600;
        writing-mode: vertical-rl;
        letter-spacing: 4rpx;
    }
 
    .no-data {
        height: calc(100vh - 120rpx);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 32rpx;
        color: #999;
    }
 
    /* 按钮样式 */
    .button-group {
        display: flex;
        justify-content: space-between;
        padding: 20rpx 30rpx;
        margin-top: 10rpx;
    }
 
    .action-button {
        flex: 1;
        text-align: center;
        padding: 20rpx 0;
        font-size: 28rpx;
        color: #ffffff;
        border-radius: 8rpx;
        margin: 0 10rpx;
        cursor: pointer;
    }
 
    .open-pdf {
        background: #419ffd;
    }
 
    .go-report {
        background: #fd8b4d;
    }
</style>