WXL
2025-12-19 da459f4addc08dede5b91f1f4e87e6c1c6d3c88e
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<template>
  <view class="invoice-container">
    <!-- 发票状态 -->
    <view class="status-card">
      <image :src="invoice.qrCode" mode="aspectFit" class="qr-code" />
      <text class="title">电子发票</text>
      <text class="desc">可通过微信/支付宝扫码查看</text>
    </view>
    
    <!-- 发票信息 -->
    <view class="info-card">
      <view class="section-title">发票信息</view>
      <view class="info-list">
        <view class="info-item">
          <text class="label">发票代码</text>
          <text class="value">{{ invoice.code }}</text>
          <text class="copy" @tap="copyText(invoice.code)">复制</text>
        </view>
        <view class="info-item">
          <text class="label">发票号码</text>
          <text class="value">{{ invoice.number }}</text>
          <text class="copy" @tap="copyText(invoice.number)">复制</text>
        </view>
        <view class="info-item">
          <text class="label">开票日期</text>
          <text class="value">{{ invoice.date }}</text>
        </view>
        <view class="info-item">
          <text class="label">发票金额</text>
          <text class="value amount">¥{{ invoice.amount }}</text>
        </view>
      </view>
    </view>
    
    <!-- 开票信息 -->
    <view class="info-card">
      <view class="section-title">开票信息</view>
      <view class="info-list">
        <view class="info-item">
          <text class="label">发票抬头</text>
          <text class="value">{{ invoice.title }}</text>
        </view>
        <view class="info-item">
          <text class="label">纳税人识别号</text>
          <text class="value">{{ invoice.taxNumber }}</text>
        </view>
        <view class="info-item">
          <text class="label">开票单位</text>
          <text class="value">{{ invoice.issuer }}</text>
        </view>
      </view>
    </view>
    
    <!-- 订单信息 -->
    <view class="info-card">
      <view class="section-title">订单信息</view>
      <view class="info-list">
        <view class="info-item">
          <text class="label">医院</text>
          <text class="value">{{ invoice.hospitalName }}</text>
        </view>
        <view class="info-item">
          <text class="label">就诊人</text>
          <text class="value">{{ invoice.patientName }}</text>
        </view>
        <view class="info-item">
          <text class="label">就诊科室</text>
          <text class="value">{{ invoice.departmentName }}</text>
        </view>
        <view class="info-item">
          <text class="label">订单编号</text>
          <text class="value">{{ invoice.orderNo }}</text>
        </view>
      </view>
    </view>
    
    <!-- 预览弹窗 -->
    <uni-popup ref="previewPopup" type="center">
      <view class="preview-popup">
        <view class="popup-header">
          <text class="title">发票预览</text>
          <text class="close" @tap="closePreview">×</text>
        </view>
        <view class="preview-content">
          <image 
            :src="invoice.previewImage" 
            mode="widthFix" 
            class="preview-image"
            @tap="previewFullImage"
          />
        </view>
      </view>
    </uni-popup>
    
    <!-- 打印设置弹窗 -->
    <uni-popup ref="printPopup" type="bottom">
      <view class="print-popup">
        <view class="popup-header">
          <text class="title">打印设置</text>
          <text class="close" @tap="closePrint">×</text>
        </view>
        <view class="print-options">
          <view class="option-item">
            <text class="label">打印份数</text>
            <view class="counter">
              <text 
                class="minus" 
                :class="{ disabled: printCount <= 1 }"
                @tap="printCount > 1 && printCount--"
              >-</text>
              <text class="count">{{ printCount }}</text>
              <text 
                class="plus"
                :class="{ disabled: printCount >= 5 }"
                @tap="printCount < 5 && printCount++"
              >+</text>
            </view>
          </view>
          <view class="option-item">
            <text class="label">打印颜色</text>
            <view class="color-options">
              <text 
                v-for="option in colorOptions"
                :key="option.value"
                :class="{ active: printColor === option.value }"
                @tap="printColor = option.value"
              >{{ option.label }}</text>
            </view>
          </view>
        </view>
        <button 
          class="confirm-btn primary-btn"
          @tap="confirmPrint"
        >确认打印</button>
      </view>
    </uni-popup>
    
    <!-- 底部按钮 -->
    <view class="bottom-buttons">
      <button class="action-btn outline" @tap="showPreview">预览发票</button>
      <button class="action-btn outline" @tap="showPrint">打印发票</button>
      <button class="action-btn primary" @tap="shareInvoice">分享发票</button>
    </view>
  </view>
</template>
 
<script setup>
import { ref, onMounted } from 'vue'
 
// 发票数据
const invoice = ref({
  code: '044031900111',
  number: '37164339',
  date: '2024-03-25',
  amount: 360.00,
  title: '个人',
  taxNumber: '-',
  issuer: '青岛镜湖医院',
  hospitalName: '青岛镜湖医院',
  patientName: '张三',
  departmentName: '心内科',
  orderNo: 'P202403250001',
  qrCode: '/static/payment/invoice-qr.png',
  previewImage: '/static/payment/invoice-preview.png',
})
 
// 复制文本
const copyText = (text) => {
  uni.setClipboardData({
    data: text,
    success: () => {
      uni.showToast({
        title: '复制成功',
        icon: 'success'
      })
    }
  })
}
 
// 保存发票
const saveInvoice = () => {
  uni.showLoading({
    title: '保存中...'
  })
  
  // 这里调用保存发票API
  setTimeout(() => {
    uni.hideLoading()
    uni.showToast({
      title: '保存成功',
      icon: 'success'
    })
  }, 1000)
}
 
// 分享发票
const shareInvoice = () => {
  uni.share({
    provider: 'weixin',
    scene: 'WXSceneSession',
    type: 2,
    imageUrl: invoice.value.qrCode,
    success: (res) => {
      console.log('分享成功:', res)
    },
    fail: (err) => {
      console.error('分享失败:', err)
    }
  })
}
 
// 预览相关
const previewPopup = ref(null)
const showPreview = () => {
  previewPopup.value?.open()
}
const closePreview = () => {
  previewPopup.value?.close()
}
const previewFullImage = () => {
  uni.previewImage({
    urls: [invoice.value.previewImage]
  })
}
 
// 打印相关
const printPopup = ref(null)
const printCount = ref(1)
const colorOptions = [
  { label: '彩色', value: 'color' },
  { label: '黑白', value: 'bw' }
]
const printColor = ref('color')
 
const showPrint = () => {
  printPopup.value?.open()
}
const closePrint = () => {
  printPopup.value?.close()
}
const confirmPrint = () => {
  uni.showLoading({
    title: '打印中...'
  })
  
  // 这里调用打印API
  const params = {
    invoiceId: invoice.value.id,
    count: printCount.value,
    color: printColor.value
  }
  console.log('打印参数:', params)
  
  setTimeout(() => {
    uni.hideLoading()
    uni.showToast({
      title: '打印成功',
      icon: 'success'
    })
    closePrint()
  }, 2000)
}
 
onMounted(() => {
  const pages = getCurrentPages()
  const page = pages[pages.length - 1]
  const id = page.$page?.options?.id
  
  // 加载发票数据
  loadInvoice(id)
})
 
// 加载发票数据
const loadInvoice = (id) => {
  // 这里调用API获取数据
  console.log('加载发票:', id)
}
</script>
 
<style lang="scss">
.invoice-container {
  min-height: 100vh;
  background: $bg-color;
  padding: 40rpx 20rpx;
  
  .status-card {
    background: #fff;
    border-radius: $radius-lg;
    padding: 40rpx;
    text-align: center;
    margin-bottom: 30rpx;
    box-shadow: $shadow-sm;
    
    .qr-code {
      width: 300rpx;
      height: 300rpx;
      margin-bottom: 30rpx;
    }
    
    .title {
      font-size: 36rpx;
      color: $text-primary;
      font-weight: bold;
      margin-bottom: 12rpx;
      display: block;
    }
    
    .desc {
      font-size: 26rpx;
      color: $text-secondary;
    }
  }
  
  .info-card {
    background: #fff;
    border-radius: $radius-lg;
    padding: 30rpx;
    margin-bottom: 30rpx;
    box-shadow: $shadow-sm;
    
    .info-list {
      .info-item {
        display: flex;
        align-items: center;
        margin-bottom: 20rpx;
        
        &:last-child {
          margin-bottom: 0;
        }
        
        .label {
          width: 200rpx;
          font-size: 28rpx;
          color: $text-regular;
        }
        
        .value {
          flex: 1;
          font-size: 28rpx;
          color: $text-primary;
          
          &.amount {
            color: $danger;
            font-weight: bold;
          }
        }
        
        .copy {
          font-size: 24rpx;
          color: $primary-color;
          margin-left: 20rpx;
          padding: 4rpx 12rpx;
          background: $primary-light;
          border-radius: $radius-sm;
          
          &:active {
            opacity: 0.8;
          }
        }
      }
    }
  }
  
  .bottom-buttons {
    display: flex;
    gap: 16rpx;
    padding: 0 20rpx;
    margin-top: 60rpx;
    
    .action-btn {
      flex: 1;
      height: 80rpx;
      line-height: 80rpx;
      font-size: 28rpx;
      border-radius: $radius-xl;
      
      &.outline {
        color: $primary-color;
        background: #fff;
        border: 2rpx solid $primary-color;
      }
      
      &.primary {
        color: #fff;
        background: $primary-gradient;
      }
      
      &:active {
        transform: scale(0.98);
      }
    }
  }
}
 
/* 预览弹窗样式 */
.preview-popup {
  width: 600rpx;
  background: #fff;
  border-radius: $radius-lg;
  overflow: hidden;
  
  .popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30rpx;
    border-bottom: 1rpx solid #eee;
    
    .title {
      font-size: 32rpx;
      color: $text-primary;
      font-weight: bold;
    }
    
    .close {
      font-size: 40rpx;
      color: $text-secondary;
      padding: 0 20rpx;
    }
  }
  
  .preview-content {
    padding: 30rpx;
    max-height: 800rpx;
    overflow-y: auto;
    
    .preview-image {
      width: 100%;
      border-radius: $radius-sm;
    }
  }
}
 
/* 打印设置弹窗样式 */
.print-popup {
  background: #fff;
  border-radius: $radius-lg $radius-lg 0 0;
  overflow: hidden;
  
  .popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30rpx;
    border-bottom: 1rpx solid #eee;
    
    .title {
      font-size: 32rpx;
      color: $text-primary;
      font-weight: bold;
    }
    
    .close {
      font-size: 40rpx;
      color: $text-secondary;
      padding: 0 20rpx;
    }
  }
  
  .print-options {
    padding: 30rpx;
    
    .option-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 30rpx;
      
      .label {
        font-size: 28rpx;
        color: $text-primary;
      }
      
      .counter {
        display: flex;
        align-items: center;
        background: $bg-color;
        border-radius: $radius-lg;
        overflow: hidden;
        
        text {
          width: 80rpx;
          height: 60rpx;
          line-height: 60rpx;
          text-align: center;
          font-size: 28rpx;
          
          &.minus,
          &.plus {
            color: $primary-color;
            background: $primary-light;
            
            &.disabled {
              opacity: 0.5;
            }
          }
          
          &.count {
            color: $text-primary;
            background: #fff;
            font-weight: bold;
          }
        }
      }
      
      .color-options {
        display: flex;
        gap: 20rpx;
        
        text {
          padding: 10rpx 30rpx;
          font-size: 28rpx;
          color: $text-regular;
          background: $bg-color;
          border-radius: $radius-lg;
          
          &.active {
            color: #fff;
            background: $primary-gradient;
          }
        }
      }
    }
  }
  
  .confirm-btn {
    margin: 0 30rpx 30rpx;
  }
}
</style>