wlzboy
2026-03-31 61c4c3f45e4257e2e7662f033e2719e62366c632
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
<template>
  <view class="invoice-detail-container">
    <view v-if="loading" class="loading-box">
      <text class="text-gray">加载中...</text>
    </view>
 
    <block v-else-if="info">
      <!-- 状态横幅 -->
      <view class="status-banner" :class="statusBannerClass">
        <text class="status-icon">{{ statusIcon }}</text>
        <text class="status-text">{{ statusLabel }}</text>
      </view>
 
      <!-- 驳回原因 -->
      <view v-if="info.status === 2 && info.auditRemarks" class="reject-reason">
        <text class="reject-label">驳回原因:</text>
        <text class="reject-content">{{ info.auditRemarks }}</text>
      </view>
 
      <!-- 基本信息 -->
      <view class="section-card">
        <view class="section-title">申请信息</view>
        <view class="detail-row">
          <text class="d-label">服务单号</text>
          <text class="d-value">{{ info.serviceCode || info.legacyServiceOrderId || '—' }}</text>
        </view>
        <view class="detail-row">
          <text class="d-label">开票类型</text>
          <text class="d-value">{{ info.invoiceType == 2 ? '企业' : '个人' }}</text>
        </view>
        <view class="detail-row">
          <text class="d-label">发票抬头</text>
          <text class="d-value">{{ info.invoiceName || '—' }}</text>
        </view>
        <view class="detail-row">
          <text class="d-label">申请金额</text>
          <text class="d-value text-price">¥{{ info.invoiceMoney ? Number(info.invoiceMoney).toFixed(2) : '0.00' }}</text>
        </view>
        <view class="detail-row" v-if="info.invoiceRemarks">
          <text class="d-label">发票备注</text>
          <text class="d-value">{{ info.invoiceRemarks }}</text>
        </view>
        <view class="detail-row">
          <text class="d-label">申请时间</text>
          <text class="d-value">{{ formatTime(info.applyTime) }}</text>
        </view>
      </view>
 
      <!-- 企业信息 -->
      <view class="section-card" v-if="info.invoiceType == 2">
        <view class="section-title">企业信息</view>
        <view class="detail-row" v-if="info.companyAddress">
          <text class="d-label">注册地址</text>
          <text class="d-value">{{ info.companyAddress }}</text>
        </view>
        <view class="detail-row" v-if="info.companyBank">
          <text class="d-label">开户银行</text>
          <text class="d-value">{{ info.companyBank }}</text>
        </view>
        <view class="detail-row" v-if="info.companyBankNo">
          <text class="d-label">银行帐号</text>
          <text class="d-value">{{ info.companyBankNo }}</text>
        </view>
      </view>
 
      <!-- 邮寄信息 -->
      <view class="section-card" v-if="info.zipCode || info.mailAddress || info.contactName || info.contactPhone">
        <view class="section-title">邮寄信息</view>
        <view class="detail-row" v-if="info.zipCode">
          <text class="d-label">邮编</text>
          <text class="d-value">{{ info.zipCode }}</text>
        </view>
        <view class="detail-row" v-if="info.mailAddress">
          <text class="d-label">邮寄地址</text>
          <text class="d-value">{{ info.mailAddress }}</text>
        </view>
        <view class="detail-row" v-if="info.contactName">
          <text class="d-label">联系人</text>
          <text class="d-value">{{ info.contactName }}</text>
        </view>
        <view class="detail-row" v-if="info.contactPhone">
          <text class="d-label">联系电话</text>
          <text class="d-value">{{ info.contactPhone }}</text>
        </view>
      </view>
 
      <!-- 审核/发票信息 -->
      <view class="section-card" v-if="info.status === 1">
        <view class="section-title">发票信息</view>
        <view class="detail-row" v-if="info.invoiceNo">
          <text class="d-label">发票编号</text>
          <text class="d-value">{{ info.invoiceNo }}</text>
        </view>
        <view class="detail-row" v-if="info.auditTime">
          <text class="d-label">审核时间</text>
          <text class="d-value">{{ formatTime(info.auditTime) }}</text>
        </view>
      </view>
 
      <!-- 操作按钮 -->
      <view class="action-area">
        <button v-if="info.invoiceUrl" class="cu-btn block bg-green lg margin-bottom-sm" @click="handleDownload">
          查看发票
        </button>
        <button v-if="info.status === 0 || info.status === 2" class="cu-btn block bg-blue lg" @click="handleEdit">
          编辑申请
        </button>
      </view>
    </block>
 
    <view v-else class="empty-box">
      <text class="text-gray">暂无数据</text>
    </view>
  </view>
</template>
 
<script>
import { myInvoiceDetail } from "@/api/invoice"
import config from '@/config.js'
 
export default {
  data() {
    return {
      loading: true,
      info: null,
      invoiceId: null
    }
  },
  computed: {
    statusLabel() {
      const map = { 0: '待审核', 1: '已通过', 2: '已驳回' }
      return this.info ? (map[this.info.status] || '未知') : ''
    },
    statusBannerClass() {
      if (!this.info) return ''
      const map = { 0: 'banner-pending', 1: 'banner-passed', 2: 'banner-rejected' }
      return map[this.info.status] || ''
    },
    statusIcon() {
      if (!this.info) return ''
      const map = { 0: '⏳', 1: '✅', 2: '❌' }
      return map[this.info.status] || ''
    }
  },
  onLoad(options) {
    if (options && options.invoiceId) {
      this.invoiceId = Number(options.invoiceId)
      this.loadDetail()
    } else {
      this.loading = false
    }
  },
  methods: {
    loadDetail() {
      this.loading = true
      myInvoiceDetail(this.invoiceId).then(res => {
        this.info = res.data
      }).catch(err => {
        console.error('加载发票详情失败:', err)
        this.$modal.msgError('加载失败,请返回重试')
      }).finally(() => {
        this.loading = false
      })
    },
    formatTime(time) {
      if (!time) return '—'
      const date = new Date(time)
      const y = date.getFullYear()
      const m = String(date.getMonth() + 1).padStart(2, '0')
      const d = String(date.getDate()).padStart(2, '0')
      const h = String(date.getHours()).padStart(2, '0')
      const min = String(date.getMinutes()).padStart(2, '0')
      return `${y}-${m}-${d} ${h}:${min}`
    },
    handleEdit() {
      const invoiceInfo = encodeURIComponent(JSON.stringify(this.info))
      this.$tab.navigateTo(`/pages/mine/invoice/edit?invoiceInfo=${invoiceInfo}`)
    },
    handleDownload() {
      const url = this.info.invoiceUrl
      if (!url) return
      let fullUrl = url.startsWith('http') ? url : config.baseUrl + url
      const fileExt = fullUrl.match(/\.(\w+)$/)?.[1]?.toLowerCase()
 
      // #ifdef H5
      window.open(fullUrl)
      // #endif
 
      // #ifndef H5
      const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']
      if (imageExts.includes(fileExt)) {
        uni.previewImage({ urls: [fullUrl], current: fullUrl })
        return
      }
      uni.showLoading({ title: '下载中...', mask: true })
      uni.downloadFile({
        url: fullUrl,
        success: (res) => {
          uni.hideLoading()
          if (res.statusCode === 200) {
            uni.openDocument({
              filePath: res.tempFilePath,
              showMenu: true,
              fail: (err) => {
                uni.showModal({ title: '提示', content: `无法打开文件: ${err.errMsg || '未知错误'}`, showCancel: false })
              }
            })
          } else {
            this.$modal.msgError(`下载失败,状态码: ${res.statusCode}`)
          }
        },
        fail: (err) => {
          uni.hideLoading()
          this.$modal.msgError(`下载失败: ${err.errMsg || '未知错误'}`)
        }
      })
      // #endif
    }
  }
}
</script>
 
<style lang="scss">
.invoice-detail-container {
  min-height: 100vh;
  background-color: #f5f6fa;
  padding-bottom: 60rpx;
 
  .loading-box, .empty-box {
    padding: 120rpx;
    text-align: center;
  }
 
  // 状态横幅
  .status-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36rpx 0;
    gap: 16rpx;
 
    .status-icon { font-size: 44rpx; }
    .status-text { font-size: 36rpx; font-weight: bold; }
 
    &.banner-pending { background: #fff8e1; .status-text { color: #e6a817; } }
    &.banner-passed  { background: #e8f5e9; .status-text { color: #4caf50; } }
    &.banner-rejected{ background: #fdecea; .status-text { color: #f44336; } }
  }
 
  // 驳回原因
  .reject-reason {
    margin: 0 24rpx 16rpx;
    padding: 24rpx;
    background: #fdecea;
    border-radius: 12rpx;
    border-left: 6rpx solid #f44336;
 
    .reject-label { font-size: 26rpx; color: #f44336; font-weight: bold; }
    .reject-content { font-size: 26rpx; color: #d32f2f; display: block; margin-top: 8rpx; }
  }
 
  // 信息卡片
  .section-card {
    margin: 16rpx 24rpx;
    background: #fff;
    border-radius: 16rpx;
    padding: 0 30rpx;
    box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
 
    .section-title {
      font-size: 28rpx;
      font-weight: bold;
      color: #333;
      padding: 28rpx 0 20rpx;
      border-bottom: 1rpx solid #f0f0f0;
      margin-bottom: 4rpx;
    }
 
    .detail-row {
      display: flex;
      align-items: flex-start;
      padding: 22rpx 0;
      border-bottom: 1rpx solid #f8f8f8;
 
      &:last-child { border-bottom: none; }
 
      .d-label {
        font-size: 26rpx;
        color: #999;
        min-width: 160rpx;
        flex-shrink: 0;
      }
 
      .d-value {
        font-size: 26rpx;
        color: #333;
        flex: 1;
        word-break: break-all;
 
        &.text-price {
          color: #f44336;
          font-weight: bold;
          font-size: 30rpx;
        }
      }
    }
  }
 
  // 操作区
  .action-area {
    margin: 30rpx 24rpx 0;
  }
}
</style>