a5474b95 by lttnew

查看图片

1 parent 67a6778f
......@@ -89,6 +89,199 @@ export function fillMemberPhoto(item = {}, fallback = '') {
return photo ? fillImgUrl(photo) : fallback
}
export function previewAttachment(file, options = {}) {
const item = normalizeAttachment(file)
const rawUrl = item.rawUrl || item.url
const previewUrl = getAttachmentPreviewUrl(rawUrl, 0)
if (!previewUrl) {
uni.showToast({
title: '暂无可预览附件',
icon: 'none'
})
return
}
if (isAttachmentImage(item) || isImageUrl(rawUrl) || isImageUrl(previewUrl)) {
uni.previewImage({
urls: [previewUrl],
current: previewUrl,
fail: () => {
uni.showToast({
title: '图片预览失败',
icon: 'none'
})
}
})
return
}
if (getAttachmentExt(item) === 'zip') {
uni.showToast({
title: '压缩包暂不支持在线预览',
icon: 'none'
})
return
}
if (getAttachmentExt(item) === 'pdf' && options.preferWebView !== false) {
openAttachmentWebView(previewUrl, options.title || '附件预览')
return
}
openDocumentAttachment(item, getAttachmentPreviewUrl(rawUrl, 1), false, options)
}
export function normalizeAttachment(file) {
if (Array.isArray(file)) return normalizeAttachment(file[0])
if (typeof file === 'string') {
const parsed = parseAttachmentJson(file)
if (parsed !== file) return normalizeAttachment(parsed)
return {
rawUrl: file,
url: file,
name: ''
}
}
if (file && typeof file === 'object') {
const rawUrl = file.rawUrl || file.url || file.fileUrl || file.path || ''
return {
...file,
rawUrl,
url: rawUrl
}
}
return {}
}
export function parseAttachmentJson(value) {
if (!value || typeof value !== 'string') return value
try {
return JSON.parse(value)
} catch (e) {
return value
}
}
export function getAttachmentPreviewUrl(url, downFlag = 0) {
if (!url) return ''
const value = String(url).trim()
if (!value || value === 'null' || value === 'undefined') return ''
if (value.startsWith('msr:')) {
return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${value}&downFlag=${downFlag}`
}
return fillImgUrl(value)
}
function openDocumentAttachment(item, url, retried = false, options = {}) {
if (!url) {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
uni.showLoading({
title: '打开中',
mask: true
})
uni.downloadFile({
url,
header: {
Authorization: uni.getStorageSync('token')
},
success: res => {
if (res.statusCode && res.statusCode !== 200) {
if ((res.statusCode === 301 || res.statusCode === 302) && !retried) {
const redirectUrl = getRedirectUrl(res.header)
uni.hideLoading()
if (redirectUrl) {
openDocumentAttachment(item, redirectUrl, true, options)
} else if (getAttachmentExt(item) === 'pdf') {
openAttachmentWebView(getAttachmentPreviewUrl(item.rawUrl || item.url, 0), options.title || '附件预览')
} else {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
}
return
}
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
uni.openDocument({
filePath: res.tempFilePath,
fileType: getDocumentFileType(item),
showMenu: true,
fail: () => {
if (getAttachmentExt(item) === 'pdf') {
openAttachmentWebView(getAttachmentPreviewUrl(item.rawUrl || item.url, 0), options.title || '附件预览')
return
}
uni.showToast({
title: '文件暂不支持预览',
icon: 'none'
})
}
})
},
fail: () => {
if (getAttachmentExt(item) === 'pdf') {
openAttachmentWebView(getAttachmentPreviewUrl(item.rawUrl || item.url, 0), options.title || '附件预览')
return
}
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
},
complete: () => {
uni.hideLoading()
}
})
}
function openAttachmentWebView(url, title = '附件预览') {
if (!url) {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
uni.navigateTo({
url: `/pages/webview/webview?title=${encodeURIComponent(title)}&url=${encodeURIComponent(url)}`,
fail: () => {
uni.showToast({
title: '附件预览失败',
icon: 'none'
})
}
})
}
function getAttachmentExt(file) {
const name = `${file?.extname || file?.name || file?.rawUrl || file?.url || ''}`
const ext = name.includes('.') ? name.split('.').pop() : name
return ext.split('?')[0].toLowerCase()
}
function isAttachmentImage(file) {
return ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'svg'].includes(getAttachmentExt(file))
}
function getDocumentFileType(file) {
const ext = getAttachmentExt(file)
const types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
return types.includes(ext) ? ext : undefined
}
function getRedirectUrl(header = {}) {
const location = header.Location || header.location
if (!location) return ''
if (/^https?:\/\//.test(location)) return location
return `${trimBaseUrl(config.baseUrl_api)}/${String(location).replace(/^\/+/, '')}`
}
function isValidUrlValue(value) {
if (value === undefined || value === null) return false
const url = String(value).trim()
......
......@@ -78,9 +78,9 @@
</template>
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import * as api from '@/common/api.js'
import config from '@/config.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -265,77 +265,17 @@ function goGroupInfo(row) {
})
}
function viewSettleFile(doc) {
let url
if (doc.payEvidence) {
url = JSON.parse(doc.payEvidence)[0].url || null
console.log(url)
if (url) {
showImg(url)
}
}
}
function showImg(n) {
const str = fillImgUrl(n)
if (isImageUrl(n) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function (res) {
console.log('success', res)
},
fail: function (res) {
console.log('fail', res)
},
complete: function (res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function (res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
uni.hideLoading();
},
fail: function (err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function (error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
function viewSettleFile(doc) {
if (doc.payEvidence) {
const file = parseAttachmentJson(doc.payEvidence)
previewAttachment(file?.[0] || file, { title: '查看凭证' })
}
}
function showImg(n) {
previewAttachment(n, { title: '查看附件' })
}
</script>
<style scoped>
.mt0 {
......
......@@ -39,7 +39,7 @@
onLoad
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
const queryParams = ref({})
const total = ref(0)
const list = ref([])
......@@ -60,7 +60,7 @@
api.getChangeGroupByRangeId(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl)
})
total.value = res.total
uni.hideLoading()
......@@ -68,66 +68,9 @@
}
function showImg(n) {
const url = n.fileUrl[0]?.url
const str = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
.flexbox {
padding: 30rpx 30rpx 0
......
......@@ -90,9 +90,9 @@
</template>
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import * as api from '@/common/api.js'
import config from '@/config.js'
import { previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -213,71 +213,12 @@ function goDetail(item) {
});
}
function downloadOrder(item) {
//下载凭证
showImg(item.payEvidence[0]?.url)
}
function showImg(url) {
const str = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
function downloadOrder(item) {
//下载凭证
previewAttachment(item.payEvidence?.[0] || item.payEvidence, { title: '查看凭证' })
}
</script>
<style scoped lang="scss">
.appList .appItem .func button[disabled]{
......
......@@ -102,7 +102,7 @@
<script setup>
import * as api from '@/common/api.js'
import _ from 'underscore'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -236,57 +236,7 @@
}
function download(url) {
console.log(url)
const fileUrl = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(fileUrl)) {
uni.previewImage({
urls: [fileUrl],
success: function(res) {
}
})
} else {
goWebView(fileUrl)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title:`下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(url, { title: '查看附件' })
}
</script>
......
......@@ -151,7 +151,7 @@ import {
onShow
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import { fillImgUrl } from '@/common/utils.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
import config from '/config.js'
const queryParams = ref({})
const query = ref({})
......@@ -412,150 +412,7 @@ function isImageFile(file) {
}
function previewFile(file) {
const url = isImageFile(file) ? getPreviewUrl(file, 0) : getPreviewUrl(file, 1)
if (!url) {
uni.showToast({
title: '暂无可预览附件',
icon: 'none'
})
return
}
if (getFileExt(file) === 'zip') {
uni.showToast({
title: '压缩包暂不支持在线预览',
icon: 'none'
})
return
}
if (isImageFile(file)) {
uni.previewImage({
urls: [url],
current: url,
fail: () => {
uni.showToast({
title: '图片预览失败',
icon: 'none'
})
}
})
return
}
if (getDocumentFileType(file) === 'pdf') {
openPdfWebView(getPreviewUrl(file, 0))
return
}
openDocumentFile(file, url)
}
function openDocumentFile(file, url, retried = false) {
uni.showLoading({
title: '打开中',
mask: true
})
uni.downloadFile({
url,
header: {
Authorization: uni.getStorageSync('token')
},
success: res => {
if (res.statusCode && res.statusCode !== 200) {
if ((res.statusCode === 301 || res.statusCode === 302) && !retried) {
const redirectUrl = getRedirectUrl(res.header)
const fallbackUrl = redirectUrl || getPreviewUrl(file, 0)
uni.hideLoading()
if (redirectUrl) {
openDocumentFile(file, redirectUrl, true)
} else if (getDocumentFileType(file) === 'pdf') {
openPdfWebView(fallbackUrl)
} else {
openDocumentFile(file, fallbackUrl, true)
}
return
}
if (getDocumentFileType(file) === 'pdf') {
uni.hideLoading()
openPdfWebView(getPreviewUrl(file, 0))
return
}
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
const filePath = res.tempFilePath
uni.openDocument({
filePath,
fileType: getDocumentFileType(file),
showMenu: true,
fail: () => {
if (getDocumentFileType(file) === 'pdf') {
openPdfWebView(getPreviewUrl(file, 0))
return
}
uni.showToast({
title: '文件暂不支持预览',
icon: 'none'
})
}
})
},
fail: () => {
if (getDocumentFileType(file) === 'pdf') {
openPdfWebView(getPreviewUrl(file, 0))
return
}
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
},
complete: () => {
uni.hideLoading()
}
})
}
function getRedirectUrl(header = {}) {
const location = header.Location || header.location
if (!location) return ''
if (/^https?:\/\//.test(location)) return location
return `${config.baseUrl_api.replace(/\/+$/, '')}/${String(location).replace(/^\/+/, '')}`
}
function openPdfWebView(url) {
if (!url) {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
uni.navigateTo({
url: `/pages/webview/webview?title=${encodeURIComponent('PDF预览')}&url=${encodeURIComponent(url)}`,
fail: () => {
uni.showToast({
title: 'PDF预览失败',
icon: 'none'
})
}
})
}
function getPreviewUrl(file, downFlag = 0) {
const rawUrl = file?.rawUrl || file?.url
if (!rawUrl) return ''
const value = String(rawUrl).trim()
if (value.startsWith('msr:')) {
return `${config.baseUrl_api.replace(/\/+$/, '')}/fileServer/download?file=${value}&downFlag=${downFlag}`
}
return file?.url || fillImgUrl(value)
}
function getDocumentFileType(file) {
const ext = getFileExt(file)
const types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
return types.includes(ext) ? ext : undefined
previewAttachment(file, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
......
......@@ -230,7 +230,7 @@
<view class="form-label">证件类型</view>
<view class="form-input">
<picker :value="idcTypeIndex" :range="idcTypeList" range-key="text" @change="onIdcTypeChange">
<view class="picker-value">{{ idcTypeList[idcTypeIndex]?.text || '请选择证件类型' }}</view>
<view class="picker-value">{{ getSelectedIdcTypeText() }}</view>
</picker>
</view>
</view>
......@@ -347,13 +347,19 @@ const addForm = ref({
})
const idcTypeList = ref([
{ value: '0', text: '身份证' },
{ value: '1', text: '护照' },
{ value: '2', text: '军官证' }
{ value: '1', text: '来往大陆(内地)通行证' },
{ value: '3', text: '护照' },
{ value: '5', text: '香港身份证' }
])
const idcTypeIndex = ref(0)
let examId
function getSelectedIdcTypeText() {
const current = idcTypeList.value[idcTypeIndex.value]
return current && current.text ? current.text : '请选择证件类型'
}
function openConfirmModal(options = {}) {
confirmModal.value = {
title: options.title || '提示',
......
......@@ -24,64 +24,45 @@
<view class="order-list">
<view v-if="list.length > 0">
<view
class="order-card"
class="order-card-new"
v-for="(item, index) in list"
:key="index"
>
<!-- 卡片头部:日期 + 状态 -->
<view class="card-header">
<view class="date">
<image :src="config.baseUrl_api + '/fs/static/calendar@2x.png'" v-if="item.commitTime" mode="widthFix" style="width:30rpx;height:30rpx;"/>
<text class="date-text" v-if="item.commitTime">{{ item.commitTime }}</text>
</view>
<view class="status-tags">
<view class="status-tag" :class="getStatusClass(item.status)">
{{ item.statusStr || '待提交' }}
<view class="data-header">
<text class="member-label">{{ item.examCode || '--' }}</text>
<!-- <text class="value ml10">{{ item.examCode || '--' }}</text> -->
</view>
<text class="status-tag" :class="getStatusClass(item.status)">
{{ item.statusStr || '待提交' }}
</text>
</view>
</view>
<!-- 基本信息 -->
<view class="info-row">
<text class="label">缴费编号:</text>
<text class="value">{{ item.examCode || '--' }}</text>
</view>
<view class="info-row">
<text class="label">缴费名称:</text>
<text class="value">{{ item.name || '--' }}</text>
</view>
<view class="info-row">
<text class="label">上报单位:</text>
<text class="value">{{ item.memberName || '--' }}</text>
</view>
<!-- 费用信息区 -->
<view class="info-section">
<view class="info-item">
<text class="item-label">考试人数</text>
<text class="item-value">{{ item.totalNum || 0 }}</text>
</view>
<view class="info-line"></view>
<view class="info-item">
<text class="item-label">总金额</text>
<text class="item-value">¥{{ (Number(item.price) || 0).toFixed(2) }}</text>
<view class="member-time">
<view class="label">
<text class="star"></text>
{{ item.name || '--' }}
</view>
<view class="info-line"></view>
<view class="info-item">
<text class="item-label">支付方式</text>
<text class="item-value">{{ String(item.payType) === '3' ? '对公转账' : '民生付' }}</text>
<view class="price">
<view>{{ (Number(item.price) || 0).toFixed(2) }}</view>
<view class="person">{{ item.totalNum || 0 }}</view>
</view>
</view>
<!-- 审核信息 -->
<view class="price-section">
<view class="price-row">
<text class="price-label">提交日期</text>
<text class="price-value">{{ item.commitTime || '--' }}</text>
<view class="detail-section">
<view class="detail-row">
<text class="detail-label">上报单位</text>
<text class="detail-value">{{ item.memberName || '--' }}</text>
</view>
<view class="detail-row">
<text class="detail-label">提交日期</text>
<text class="detail-value">{{ item.commitTime || '--' }}</text>
</view>
<view class="price-row">
<text class="price-label">审核日期</text>
<text class="price-value">{{ item.handleDate || '--' }}</text>
<view class="detail-row">
<text class="detail-label">审核日期</text>
<text class="detail-value">{{ item.handleDate || '--' }}</text>
</view>
</view>
</view>
......@@ -189,7 +170,7 @@
<style lang="scss" scoped>
.order-page {
height: 100vh;
background: #f5f7fa;
background: #ededf0;
display: flex;
flex-direction: column;
}
......@@ -197,21 +178,22 @@
// Tab
.tab-bar {
display: flex;
background: #fff;
border-bottom: 1rpx solid #eee;
flex-shrink: 0;
padding: 22rpx 32rpx 4rpx;
background: #ededf0;
.tab-item {
flex: 1;
text-align: center;
padding: 24rpx 0;
font-size: 28rpx;
padding: 0 0 14rpx;
font-size: 30rpx;
color: #666;
position: relative;
font-weight: bold;
&.active {
color: #e4393c;
font-weight: 500;
color: #c30d23;
font-weight: bold;
&::after {
content: '';
......@@ -219,9 +201,9 @@
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60rpx;
width: 72rpx;
height: 4rpx;
background: linear-gradient(90deg, #FF755A, #F51722);
background: #c30d23;
border-radius: 2rpx;
}
}
......@@ -231,149 +213,173 @@
// 滚动列表容器 —— 这里是关键修复
.order-list-scroll {
flex: 1;
height: auto;
overflow: auto;
height: 0;
min-height: 0;
overflow: hidden;
background: #ededf0;
}
.order-list {
padding: 20rpx;
min-height: 100%;
box-sizing: border-box;
padding: 0 24rpx calc(120rpx + env(safe-area-inset-bottom));
}
.order-card {
.order-card-new {
background: #fff;
margin-bottom: 20rpx;
padding: 24rpx;
border-radius: 12rpx;
margin-bottom: 22rpx;
padding: 22rpx 18rpx 18rpx;
border-radius: 18rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
border-top: 6rpx solid transparent;
background-clip: padding-box, border-box;
background-origin: padding-box, border-box;
background-image: linear-gradient(#fff, #fff), linear-gradient(90deg, #FF755A, #F51722);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
margin-bottom: 20rpx;
border-bottom: 1rpx dashed #eee;
flex-direction: column;
.date {
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 8rpx;
.date-text {
padding-bottom: 10rpx;
.date {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8rpx;
font-size: 26rpx;
color: #666;
}
}
.status-tags {
display: flex;
gap: 10rpx;
}
.data-header {
display: flex;
align-items: center;
min-width: 0;
}
.status-tag {
font-size: 22rpx;
padding: 6rpx 16rpx;
border-radius: 20rpx;
.member-label {
color: #c30d23;
font-size: 28rpx;
font-weight: bold;
flex-shrink: 0;
}
&.success {
background: #e6f7ef;
color: #52c41a;
.value {
color: #000;
font-size: 27rpx;
font-weight: bold;
max-width: 360rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&.danger {
background: #fff1f0;
color: #ff4d4f;
.ml10 {
margin-left: 10rpx;
}
&.pending {
background: #f5f5f5;
.status-tag {
font-size: 24rpx;
color: #999;
}
flex-shrink: 0;
&.warning {
background: #fff7e6;
color: #faad14;
}
}
}
&.success {
color: #52c41a;
}
.info-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
font-size: 26rpx;
&.danger {
color: #ff4d4f;
}
.label {
color: #999;
flex-shrink: 0;
min-width: 140rpx;
}
&.pending {
color: #faad14;
}
.value {
color: #333;
word-break: break-all;
&.warning {
color: #999;
}
}
}
}
.info-section {
display: flex;
align-items: center;
background: #f3f6fc;
padding: 16rpx 20rpx;
margin: 16rpx 0;
border-radius: 8rpx;
.info-item {
flex: 1;
.member-time {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding-bottom: 8rpx;
.item-label {
font-size: 24rpx;
color: #999;
.label {
max-width: 480rpx;
color: #555;
font-size: 26rpx;
font-weight: 700;
line-height: 1.4;
word-break: break-all;
}
.item-value {
font-size: 28rpx;
.star {
color: #777;
font-size: 26rpx;
}
.price {
min-width: 150rpx;
color: #333;
font-size: 26rpx;
font-weight: 500;
margin-top: 8rpx;
text-align: right;
margin-left: 20rpx;
.person {
font-size: 24rpx;
color: #999;
text-align: right;
margin-top: 4rpx;
}
}
}
.info-line {
width: 1rpx;
height: 60rpx;
background: #ddd;
.detail-section {
background: #f3f6fc;
border-radius: 18rpx;
padding: 10rpx 18rpx;
margin-top: 10rpx;
}
}
.price-section {
border-top: 1rpx dashed #eee;
padding-top: 16rpx;
margin-top: 8rpx;
.price-row {
.detail-row {
display: flex;
justify-content: space-between;
align-items: center;
align-items: flex-start;
padding: 8rpx 0;
gap: 24rpx;
}
.price-label {
font-size: 26rpx;
color: #333;
}
.detail-label {
font-size: 26rpx;
color: #666;
flex-shrink: 0;
}
.price-value {
font-size: 26rpx;
color: #666;
}
.detail-value {
font-size: 26rpx;
color: #333;
text-align: right;
word-break: break-all;
}
}
.empty {
padding: 160rpx 0 80rpx;
display: flex;
flex-direction: column;
align-items: center;
.empty-img {
width: 240rpx;
height: 180rpx;
}
.empty-text {
margin-top: 20rpx;
color: #999;
font-size: 28rpx;
}
}
......@@ -385,4 +391,4 @@
color: #999;
font-size: 26rpx;
}
</style>
\ No newline at end of file
</style>
......
......@@ -112,7 +112,7 @@ import {onShow} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import config from '@/config.js'
import _ from 'underscore'
import { fillImgUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
const tabs = ref([
{ value: '', text: '全部' },
......@@ -249,30 +249,7 @@ function downloadInvoice(item) {
uni.showToast({ title: '暂无发票', icon: 'none' })
return
}
try {
const invoice = JSON.parse(item.fileUrl)
if (invoice && invoice[0]?.url) {
let fileUrl = invoice[0].url
fileUrl = fillImgUrl(fileUrl)
// 小程序中使用 previewImage 预览,让用户长按保存
uni.previewImage({
urls: [fileUrl],
success: () => {
console.log('previewImage success')
},
fail: (err) => {
console.error('previewImage fail:', err)
uni.showToast({ title: '打开图片失败', icon: 'none' })
}
})
} else {
uni.showToast({ title: '发票文件不存在', icon: 'none' })
}
} catch (e) {
console.error('解析发票数据失败', e)
uni.showToast({ title: '解析发票数据失败', icon: 'none' })
}
previewAttachment(parseAttachmentJson(item.fileUrl), { title: '查看发票' })
}
// 打开结算审核 - 跳转到审核页面
......
......@@ -119,7 +119,7 @@ import { ref, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
const loading = ref(false)
const loadingPayment = ref(false)
......@@ -188,56 +188,7 @@ function downloadInvoice() {
uni.showToast({ title: '暂无发票', icon: 'none' })
return
}
try {
const invoice = JSON.parse(form.value.fileUrl)
if (invoice && invoice[0]?.url) {
let url = invoice[0].url
url = fillImgUrl(url)
const isImage = isImageUrl(url)
uni.showLoading({ title: '加载中' })
uni.downloadFile({
url: url,
success: (res) => {
uni.hideLoading()
if (res.statusCode === 200) {
if (isImage) {
// 图片预览
uni.previewImage({
urls: [res.tempFilePath]
})
} else {
// 文件下载后打开
uni.saveFile({
tempFilePath: res.tempFilePath,
success: (saveRes) => {
uni.openDocument({
filePath: saveRes.savedFilePath,
showMenu: true,
fail: () => {
uni.showToast({ title: '打开失败', icon: 'none' })
}
})
},
fail: () => {
uni.showToast({ title: '保存失败', icon: 'none' })
}
})
}
} else {
uni.showToast({ title: '下载失败', icon: 'none' })
}
},
fail: () => {
uni.hideLoading()
uni.showToast({ title: '下载失败', icon: 'none' })
}
})
}
} catch (e) {
console.error('解析发票数据失败', e)
uni.showToast({ title: '解析发票数据失败', icon: 'none' })
}
previewAttachment(parseAttachmentJson(form.value.fileUrl), { title: '查看发票' })
}
</script>
......
......@@ -153,7 +153,7 @@
<script setup>
import * as api from '@/common/api_exam.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
import { ref, reactive, computed } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
......@@ -271,62 +271,7 @@ function handelInvoice(fileUrl) {
uni.showToast({ title: '暂无发票', icon: 'none' })
return
}
try {
const invoice = JSON.parse(fileUrl)
if (invoice && invoice.length > 0) {
let url = invoice[0].url || ''
if (!url) {
uni.showToast({ title: '暂无发票', icon: 'none' })
return
}
url = fillImgUrl(url)
const isImage = isImageUrl(url)
uni.showLoading({ title: '加载中' })
uni.downloadFile({
url: url,
success: (res) => {
uni.hideLoading()
if (res.statusCode === 200) {
if (isImage) {
// 图片预览
uni.previewImage({
urls: [res.tempFilePath]
})
} else {
// 文件下载后打开
uni.saveFile({
tempFilePath: res.tempFilePath,
success: (saveRes) => {
uni.openDocument({
filePath: saveRes.savedFilePath,
showMenu: true,
fail: () => {
uni.showToast({ title: '打开失败', icon: 'none' })
}
})
},
fail: () => {
uni.showToast({ title: '保存失败', icon: 'none' })
}
})
}
} else {
uni.showToast({ title: '下载失败', icon: 'none' })
}
},
fail: () => {
uni.hideLoading()
uni.showToast({ title: '下载失败', icon: 'none' })
}
})
} else {
uni.showToast({ title: '暂无发票', icon: 'none' })
}
} catch (e) {
console.error('发票信息解析失败:', e)
uni.showToast({ title: '发票信息解析失败', icon: 'none' })
}
previewAttachment(parseAttachmentJson(fileUrl), { title: '查看发票' })
}
</script>
......
......@@ -148,7 +148,7 @@ import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
// const config = require('@/config.js')
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
const loading = ref(false)
const form = ref({})
......@@ -159,57 +159,7 @@ onLoad((options) => {
}
})
function download(url) {
console.log(url)
const fileUrl = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(fileUrl)) {
uni.previewImage({
urls: [fileUrl],
success: function(res) {
}
})
} else {
goWebView(fileUrl)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title:`下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(url, { title: '查看附件' })
}
function getInstitutionInfo(memId) {
loading.value = true
......
......@@ -81,7 +81,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -234,63 +234,7 @@ function goGroupInfo(row) {
}
function showImg(n) {
const str = fillImgUrl(n)
if (isImageUrl(n) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function (res) {
console.log('success', res)
},
fail: function (res) {
console.log('fail', res)
},
complete: function (res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function (res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
uni.hideLoading();
},
fail: function (err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function (error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(n, { title: '查看附件' })
}
</script>
......
......@@ -150,7 +150,7 @@
<script setup>
import * as api from '@/common/api.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { fillImgUrl, isImageUrl, previewAttachment } from '@/common/utils.js'
import _ from 'underscore'
import {
......@@ -380,60 +380,10 @@ function parseImageList(value) {
}
function download(url) {
console.log(url)
const fileUrl = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(fileUrl)) {
uni.previewImage({
urls: [fileUrl],
success: function (res) {
}
})
} else {
goWebView(fileUrl)
}
previewAttachment(url, { title: '查看附件' })
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function (res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
uni.hideLoading();
},
fail: function (err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function (error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
function payTheFees() {
function payTheFees() {
if (!form.value.name) {
uni.showToast({
title: `请先完善单位信息`,
......
......@@ -34,11 +34,11 @@
ref
} from 'vue'
import * as api from '@/common/api.js';
import {
onLoad
} from '@dcloudio/uni-app';
import _ from 'underscore'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import {
onLoad
} from '@dcloudio/uni-app';
import _ from 'underscore'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
const form = ref({})
const attachmentFile = ref([])
const attachmentMp4 = ref([])
......@@ -66,74 +66,10 @@
})
}
function downLoad(url) {
console.log(url)
const str = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
console.log(err.errMsg)
uni.hideLoading();
let msg
if (err.errMsg.indexOf('not supported') > -1) {
msg = '不支持该文件类型'
} else {
msg = err.errMsg
}
uni.showToast({
title: msg,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
function downLoad(url) {
previewAttachment(url, { title: '附件预览' })
}
</script>
<style scoped lang="scss">
.mainbox {
......@@ -198,4 +134,4 @@
video {
width: 100%;
}
</style>
\ No newline at end of file
</style>
......
......@@ -23,27 +23,21 @@
</template>
<script setup>
import { ref, onUnmounted } from "vue";
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import config from "@/config.js";
import { previewAttachment } from '@/common/utils.js'
const pdfUrl = ref("");
const loading = ref(true);
const loading = ref(false);
const showError = ref(false);
const errorMsg = ref("");
const useWebView = ref(false); // 是否使用 web-view 降级方案
let timeoutTimer = null;
const currentUrl = ref('')
onLoad((option) => {
if (option.url) {
// 解码并拼接完整URL
let relativeUrl = decodeURIComponent(option.url);
let fullUrl = config.baseUrl_api + relativeUrl;
console.log("完整PDF地址:", fullUrl);
// 优先使用 openDocument 方式(兼容性最好)
openPdfWithDocument(fullUrl);
currentUrl.value = decodeURIComponent(option.url);
openAttachment(currentUrl.value);
} else {
loading.value = false;
showError.value = true;
......@@ -51,83 +45,11 @@ onLoad((option) => {
}
});
// 优先方案:使用 uni.openDocument(推荐,兼容性最好)
const openPdfWithDocument = (url) => {
// 设置超时
timeoutTimer = setTimeout(() => {
if (loading.value) {
loading.value = false;
showError.value = true;
errorMsg.value = "加载超时,请检查网络";
}
}, 15000);
// 先下载文件
uni.downloadFile({
url: url,
success: (res) => {
clearTimeout(timeoutTimer);
if (res.statusCode === 200) {
const filePath = res.tempFilePath;
// 打开文档
uni.openDocument({
filePath: filePath,
success: () => {
// 打开成功,关闭当前页面
loading.value = false;
setTimeout(() => {
uni.navigateBack();
}, 500);
},
fail: (err) => {
console.error("openDocument失败:", err);
// 降级到 web-view 方式
fallbackToWebView(url);
}
});
} else {
fallbackToWebView(url);
}
},
fail: (err) => {
console.error("下载失败:", err);
clearTimeout(timeoutTimer);
// 降级到 web-view 方式
fallbackToWebView(url);
}
});
};
// 降级方案:使用 web-view
const fallbackToWebView = (url) => {
console.log("降级使用 web-view 方式");
useWebView.value = true;
// 处理URL,确保是HTTPS
let webViewUrl = url;
if (webViewUrl.startsWith('http://')) {
webViewUrl = webViewUrl.replace('http://', 'https://');
}
// 添加时间戳避免缓存问题
webViewUrl = webViewUrl + (webViewUrl.includes('?') ? '&' : '?') + 't=' + Date.now();
pdfUrl.value = webViewUrl;
// 给 web-view 一些加载时间
setTimeout(() => {
if (loading.value) {
loading.value = false;
// 不立即显示错误,让 web-view 继续尝试
setTimeout(() => {
if (loading.value === false && !showError.value) {
// 如果还在加载状态,可能是真的有问题
// 但这里不做额外处理
}
}, 3000);
}
}, 2000);
const openAttachment = (url) => {
showError.value = false;
errorMsg.value = "";
loading.value = false;
previewAttachment(url, { title: '证书预览' })
};
// web-view 消息接收(可选)
......@@ -138,25 +60,11 @@ const onWebViewMessage = (e) => {
// 重试加载
const retryLoad = () => {
showError.value = false;
loading.value = true;
loading.value = false;
useWebView.value = false;
errorMsg.value = "";
// 重新获取URL
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const url = currentPage.$page.options.url;
if (url) {
let fullUrl = config.baseUrl_api + decodeURIComponent(url);
openPdfWithDocument(fullUrl);
}
if (currentUrl.value) openAttachment(currentUrl.value);
};
// 页面卸载时清除定时器
onUnmounted(() => {
if (timeoutTimer) clearTimeout(timeoutTimer);
});
</script>
<style lang="scss" scoped>
......
......@@ -65,11 +65,13 @@
<view v-if="item.fileUrl" class="item-row">
<text class="item-label">附件</text>
<image
v-if="isImageUrl(item.fileUrl)"
class="item-image"
:src="fillImgUrl(item.fileUrl)"
mode="aspectFill"
@click="previewImage(item.fileUrl)"
></image>
<text v-else class="item-value text-primary" @click="previewImage(item.fileUrl)">查看附件</text>
</view>
</view>
......@@ -88,7 +90,7 @@
import { ref } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import { memberAuditList } from '@/common/api'
import config from '@/config'
import { fillImgUrl, isImageUrl, previewAttachment } from '@/common/utils.js'
const tabs = [
{ label: '全部', value: '' },
......@@ -187,17 +189,8 @@ function formatDate(dateStr) {
return `${year}-${month}-${day}`
}
function fillImgUrl(url) {
if (!url) return ''
if (url.startsWith('http')) return url
return config.baseUrl + url
}
function previewImage(url) {
uni.previewImage({
urls: [fillImgUrl(url)],
current: fillImgUrl(url)
})
previewAttachment(url, { title: '查看附件' })
}
</script>
......
......@@ -166,6 +166,7 @@
<script setup>
import {
parseAttachmentJson,
szToHz
} from '@/common/utils.js'
import {
......@@ -208,7 +209,7 @@
api.infoMergeList(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl) || []
})
total.value = res.total
uni.hideLoading()
......@@ -270,68 +271,116 @@
})
}
function commitFN() {
async function commitFN() {
const flag = list.value.some(item => {
if (!item.fileUrl) {
if (!getPrimaryFile(item.fileUrl)) {
uni.showToast({
title: `请上传${item.personInfo?.name}的附件`,
icon: 'none'
})
return !item.fileUrl
return true
}
})
if (flag) return
if (form.value.rangeId == '') return
if (!queryParams.value.rangeId || queryParams.value.rangeId == '-1') return
uni.showModal({
title: '提示',
content: `确定提交吗`,
success: function(res) {
success: async function(res) {
if (res.confirm) {
api.commitMergeVip([queryParams.value.rangeId]).then(Response => {
try {
uni.showLoading({
title: '提交中',
mask: true
})
await syncMergeFiles()
// await api.commitMergeVip([queryParams.value.rangeId])
uni.showToast({
icon: "none",
title: '提交成功!'
})
uni.navigateBack()
})
} finally {
uni.hideLoading()
}
}
}
})
}
let selectFileValue = {}
function selectFile(row, e) {
async function selectFile(row, e) {
form.value = row
let file = e.tempFiles[0]
if (!file) {
return
}
api.uploadFile(e).then(data => {
uni.showLoading({
title: '上传中',
mask: true
})
try {
const data = await api.uploadFile(e)
const fileKey = data.data || data.msg
selectFileValue = {
url: data.msg,
url: fileKey,
name: file.name,
extname: file.extname
}
console.log(selectFileValue, row.fileUrl)
uni.showLoading({
title: '上传中'
})
debugger
api.editMergeByFile({
mergeId: form.value.id,
fileUrl: JSON.stringify([selectFileValue])
}).then(Response => {
uni.hideLoading()
getList()
row.fileUrl = [selectFileValue]
await saveMergeFile(row, row.fileUrl)
getList()
} catch (err) {
row.fileUrl = []
uni.showToast({
title: err?.message || '上传失败',
icon: 'none'
})
});
} finally {
uni.hideLoading()
}
}
function delSupplementFile(row) {
selectFileValue = {}
row.fileUrl = []
}
function getPrimaryFile(fileUrl) {
if (!fileUrl) return null
if (Array.isArray(fileUrl)) return fileUrl[0] || null
if (typeof fileUrl === 'object') return fileUrl
return fileUrl
}
function toSubmitFile(file) {
if (typeof file === 'string') {
return {
url: file
}
}
return {
url: file.rawUrl || file.url,
name: file.name,
extname: file.extname
}
}
function saveMergeFile(row, fileUrl) {
const file = getPrimaryFile(fileUrl)
if (!row?.id || !file) return Promise.resolve()
return api.editMergeByFile({
mergeId: row.id,
fileUrl: JSON.stringify([toSubmitFile(file)])
})
}
async function syncMergeFiles() {
for (const item of list.value) {
await saveMergeFile(item, item.fileUrl)
}
}
</script>
<style scoped lang="scss">
.flexbox {
......@@ -380,4 +429,4 @@
opacity: 0;
background-color: transparent;
}
</style>
\ No newline at end of file
</style>
......
......@@ -61,11 +61,11 @@
onLoad,
onShow
} from '@dcloudio/uni-app'
import {
fillImgUrl,
isImageUrl,
szToHz
} from '@/common/utils.js'
import {
parseAttachmentJson,
previewAttachment,
szToHz
} from '@/common/utils.js'
import * as api from '@/common/api.js'
const inputstyle = ref({
borderColor: '#fff',
......@@ -243,76 +243,20 @@
api.getLevelChangeAddList(queryParams.value).then(Response => {
list.value = Response.rows
for (var item of list.value) {
item.examPersonData = JSON.parse(item.examPersonData)
if (item.fileUrl) {
item.fileUrl = JSON.parse(item.fileUrl)
}
}
item.examPersonData = JSON.parse(item.examPersonData)
if (item.fileUrl) {
item.fileUrl = parseAttachmentJson(item.fileUrl)
}
}
total.value = Response.total
uni.hideLoading()
})
}
function showImg(n) {
const url = n.fileUrl[0]?.url
const str = fillImgUrl(url)
if(isImageUrl(url) || isImageUrl(str)){
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
}else{
goWebView(str)
}
}
function goWebView(url){
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
function showImg(n) {
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
.wBox {
......@@ -408,4 +352,4 @@
:deep(.file-picker__progress) {
opacity: 0;
}
</style>
\ No newline at end of file
</style>
......
......@@ -74,7 +74,7 @@
onLoad
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
const queryParams = ref({})
const total = ref(0)
const list = ref([])
......@@ -120,7 +120,7 @@
api.addInfoModeList(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl)
})
total.value = res.total
uni.hideLoading()
......@@ -150,67 +150,10 @@
})
}
function showImg(n) {
const url = n.fileUrl[0]?.url
const str = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
function showImg(n) {
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
.flexbox {
padding: 30rpx 30rpx 0
......@@ -244,4 +187,4 @@
background: #fff;
padding: 30rpx;
}
</style>
\ No newline at end of file
</style>
......
......@@ -83,7 +83,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -128,67 +128,8 @@ function handleUpdate(item) {
}
function downloadOrder(item) {
//下载凭证
var arr = JSON.parse(item.payEvidence) || []
showImg(arr[0]?.url)
}
function showImg(url) {
const str = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
const arr = parseAttachmentJson(item.payEvidence) || []
previewAttachment(arr[0] || arr, { title: '查看凭证' })
}
let selectFileValue = {}
......
......@@ -128,10 +128,11 @@
onLoad
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import {
szToHz
} from '@/common/utils.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import {
parseAttachmentJson,
previewAttachment,
szToHz
} from '@/common/utils.js'
const queryParams = ref({})
const total = ref(0)
const list = ref([])
......@@ -150,10 +151,10 @@
title: '加载中'
})
api.infoMergeList(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
})
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = parseAttachmentJson(item.fileUrl)
})
total.value = res.total
uni.hideLoading()
})
......@@ -182,67 +183,10 @@
})
}
function showImg(n) {
const url = n.fileUrl[0]?.url
const str = fillImgUrl(url)
if (isImageUrl(url) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
</script>
function showImg(n) {
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
.flexbox {
padding: 30rpx 30rpx 0
......@@ -277,4 +221,4 @@
background: #fff;
padding: 30rpx;
}
</style>
\ No newline at end of file
</style>
......
......@@ -82,7 +82,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, isImageUrl } from '@/common/utils.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -194,51 +194,12 @@ function circulation(id) {
api.queryProcess(id).then(res=>{
if (res.data.url) {
uni.hideLoading()
goWebView(fillImgUrl(res.data.url))
previewAttachment(res.data.url, { title: '缴费通知单' })
} else {
circulation(id)
}
})
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
}
function handleBack(row){
uni.showModal({
......@@ -263,30 +224,11 @@ function handleBack(row){
}
function viewSettleFile(item){
if(item.payEvidence){
let file = JSON.parse(item.payEvidence)
let file = parseAttachmentJson(item.payEvidence)
console.log(file)
showImg(file[0].url)
previewAttachment(file[0] || file, { title: '查看凭证' })
}
}
function showImg(n) {
const str = fillImgUrl(n)
if (isImageUrl(n) || isImageUrl(str)) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
</script>
<style scoped lang="scss">
......@@ -302,4 +244,4 @@ function viewSettleFile(item){
}
}
.func button.miniBtn{font-size: 28rpx;padding: 0 20rpx;}
</style>
\ No newline at end of file
</style>
......
......@@ -161,7 +161,7 @@ function getAuditResultText(result) {
}
function getIdcTypeText(type) {
const map = { 1: '身份证', 2: '护照', 3: '其他' }
const map = { 0: '身份证', 1: '护照', 2: '其他' }
return map[type] || '其他'
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!