<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>
|