|
@@ -27,8 +27,25 @@
|
|
|
<wd-cell title="发票信息">
|
|
<wd-cell title="发票信息">
|
|
|
<!-- 发票信息展示 -->
|
|
<!-- 发票信息展示 -->
|
|
|
<view class="flex flex-wrap" v-if="invoiceImg.length">
|
|
<view class="flex flex-wrap" v-if="invoiceImg.length">
|
|
|
- <view class="flex-1" v-for="item in invoiceImg" :key="item.id">
|
|
|
|
|
- <wd-img :width="100" :height="100" :src="item.url" :enable-preview="true" />
|
|
|
|
|
|
|
+ <view class="flex-1 flex justify-end" v-for="item in invoiceImg" :key="item.attid">
|
|
|
|
|
+ <!-- 如果是PDF文件,显示文件名并可点击打开 -->
|
|
|
|
|
+ <view v-if="item.atttype === 'pdf'" class="file-item" @click="openPdfFile(item)">
|
|
|
|
|
+ <view class="file-icon">📄</view>
|
|
|
|
|
+ <view class="file-name">{{ item.attorginname }}</view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <!-- 如果是图片文件,使用wd-img展示 -->
|
|
|
|
|
+ <wd-img
|
|
|
|
|
+ v-else-if="isImageType(item.atttype)"
|
|
|
|
|
+ :width="100"
|
|
|
|
|
+ :height="100"
|
|
|
|
|
+ :src="item.url"
|
|
|
|
|
+ :enable-preview="true"
|
|
|
|
|
+ />
|
|
|
|
|
+ <!-- 其他类型文件的默认展示 -->
|
|
|
|
|
+ <view v-else class="file-item" @click="openPdfFile(item)">
|
|
|
|
|
+ <view class="file-icon">📎</view>
|
|
|
|
|
+ <view class="file-name">{{ item.attorginname }}</view>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<!-- 无发票信息时的提示 -->
|
|
<!-- 无发票信息时的提示 -->
|
|
@@ -62,12 +79,12 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { useOrderStore } from '@/store/order'
|
|
import { useOrderStore } from '@/store/order'
|
|
|
import { useFileStore } from '@/store/file'
|
|
import { useFileStore } from '@/store/file'
|
|
|
-import { useMessage } from 'wot-design-uni'
|
|
|
|
|
|
|
+import { useToast } from 'wot-design-uni'
|
|
|
import type { OrderType } from '@/types/order'
|
|
import type { OrderType } from '@/types/order'
|
|
|
|
|
|
|
|
const orderStore = useOrderStore()
|
|
const orderStore = useOrderStore()
|
|
|
const fileStore = useFileStore()
|
|
const fileStore = useFileStore()
|
|
|
-const message = useMessage()
|
|
|
|
|
|
|
+const toast = useToast()
|
|
|
const currentOrdersId = ref('')
|
|
const currentOrdersId = ref('')
|
|
|
const coupon2sid = ref('')
|
|
const coupon2sid = ref('')
|
|
|
const orderDetail = ref<OrderType>({} as OrderType)
|
|
const orderDetail = ref<OrderType>({} as OrderType)
|
|
@@ -108,6 +125,53 @@ function handleBack() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 判断文件是否为图片类型
|
|
|
|
|
+function isImageType(atttype: string) {
|
|
|
|
|
+ const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']
|
|
|
|
|
+ return imageTypes.includes(atttype.toLowerCase())
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 打开PDF文件
|
|
|
|
|
+function openPdfFile(item: any) {
|
|
|
|
|
+ // 拼接PDF文件完整URL
|
|
|
|
|
+ const pdfUrl = `${fileStore.fileHeadUrl}${item.attpath}${item.attname}.${item.atttype}`
|
|
|
|
|
+
|
|
|
|
|
+ // 使用浏览器打开PDF文件
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ window.open(pdfUrl, '_blank')
|
|
|
|
|
+ // #endif
|
|
|
|
|
+
|
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
|
+ // 微信小程序中下载后打开文档
|
|
|
|
|
+ uni.downloadFile({
|
|
|
|
|
+ url: pdfUrl,
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ if (res.statusCode === 200) {
|
|
|
|
|
+ uni.openDocument({
|
|
|
|
|
+ filePath: res.tempFilePath,
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ console.log('PDF打开成功')
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: (err) => {
|
|
|
|
|
+ console.error('PDF打开失败:', err)
|
|
|
|
|
+ toast.error('PDF文件打开失败')
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: (err) => {
|
|
|
|
|
+ console.error('PDF下载失败:', err)
|
|
|
|
|
+ toast.error('PDF文件下载失败')
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ // #endif
|
|
|
|
|
+
|
|
|
|
|
+ // #ifdef APP-PLUS
|
|
|
|
|
+ // App中使用系统默认方式打开
|
|
|
|
|
+ plus.runtime.openURL(pdfUrl)
|
|
|
|
|
+ // #endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const invoiceImg = ref([]) // 发票图片
|
|
const invoiceImg = ref([]) // 发票图片
|
|
|
const identityImg = ref([]) // 购机者证件照片
|
|
const identityImg = ref([]) // 购机者证件照片
|
|
|
const buyerImg = ref([]) // 购机者照片
|
|
const buyerImg = ref([]) // 购机者照片
|
|
@@ -116,7 +180,7 @@ const buyerImg = ref([]) // 购机者照片
|
|
|
const getInvoiceImg = async () => {
|
|
const getInvoiceImg = async () => {
|
|
|
const res = await fileStore.getAttachmentList({
|
|
const res = await fileStore.getAttachmentList({
|
|
|
attlsh: currentOrdersId.value, // 关联id为订单id
|
|
attlsh: currentOrdersId.value, // 关联id为订单id
|
|
|
- attmodel: 'orders_invoice',
|
|
|
|
|
|
|
+ attmodel: 'coupon_invoice',
|
|
|
})
|
|
})
|
|
|
invoiceImg.value = res
|
|
invoiceImg.value = res
|
|
|
}
|
|
}
|
|
@@ -162,4 +226,45 @@ onLoad(async (query) => {
|
|
|
:deep(.wd-upload) {
|
|
:deep(.wd-upload) {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+.file-item {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ width: 100px;
|
|
|
|
|
+ height: 100px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ background-color: #f9fafb;
|
|
|
|
|
+ border: 1px solid #e5e7eb;
|
|
|
|
|
+ border-radius: 8px;
|
|
|
|
|
+ transition: all 0.2s ease;
|
|
|
|
|
+
|
|
|
|
|
+ &:hover {
|
|
|
|
|
+ background-color: #f3f4f6;
|
|
|
|
|
+ border-color: #d1d5db;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &:active {
|
|
|
|
|
+ background-color: #e5e7eb;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.file-icon {
|
|
|
|
|
+ margin-bottom: 4px;
|
|
|
|
|
+ font-size: 24px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.file-name {
|
|
|
|
|
+ display: -webkit-box;
|
|
|
|
|
+ max-width: 90px;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ line-height: 1.2;
|
|
|
|
|
+ color: #374151;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ word-break: break-all;
|
|
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|