a5474b95 by lttnew

查看图片

1 parent 67a6778f
...@@ -89,6 +89,199 @@ export function fillMemberPhoto(item = {}, fallback = '') { ...@@ -89,6 +89,199 @@ export function fillMemberPhoto(item = {}, fallback = '') {
89 return photo ? fillImgUrl(photo) : fallback 89 return photo ? fillImgUrl(photo) : fallback
90 } 90 }
91 91
92 export function previewAttachment(file, options = {}) {
93 const item = normalizeAttachment(file)
94 const rawUrl = item.rawUrl || item.url
95 const previewUrl = getAttachmentPreviewUrl(rawUrl, 0)
96 if (!previewUrl) {
97 uni.showToast({
98 title: '暂无可预览附件',
99 icon: 'none'
100 })
101 return
102 }
103 if (isAttachmentImage(item) || isImageUrl(rawUrl) || isImageUrl(previewUrl)) {
104 uni.previewImage({
105 urls: [previewUrl],
106 current: previewUrl,
107 fail: () => {
108 uni.showToast({
109 title: '图片预览失败',
110 icon: 'none'
111 })
112 }
113 })
114 return
115 }
116 if (getAttachmentExt(item) === 'zip') {
117 uni.showToast({
118 title: '压缩包暂不支持在线预览',
119 icon: 'none'
120 })
121 return
122 }
123 if (getAttachmentExt(item) === 'pdf' && options.preferWebView !== false) {
124 openAttachmentWebView(previewUrl, options.title || '附件预览')
125 return
126 }
127 openDocumentAttachment(item, getAttachmentPreviewUrl(rawUrl, 1), false, options)
128 }
129
130 export function normalizeAttachment(file) {
131 if (Array.isArray(file)) return normalizeAttachment(file[0])
132 if (typeof file === 'string') {
133 const parsed = parseAttachmentJson(file)
134 if (parsed !== file) return normalizeAttachment(parsed)
135 return {
136 rawUrl: file,
137 url: file,
138 name: ''
139 }
140 }
141 if (file && typeof file === 'object') {
142 const rawUrl = file.rawUrl || file.url || file.fileUrl || file.path || ''
143 return {
144 ...file,
145 rawUrl,
146 url: rawUrl
147 }
148 }
149 return {}
150 }
151
152 export function parseAttachmentJson(value) {
153 if (!value || typeof value !== 'string') return value
154 try {
155 return JSON.parse(value)
156 } catch (e) {
157 return value
158 }
159 }
160
161 export function getAttachmentPreviewUrl(url, downFlag = 0) {
162 if (!url) return ''
163 const value = String(url).trim()
164 if (!value || value === 'null' || value === 'undefined') return ''
165 if (value.startsWith('msr:')) {
166 return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${value}&downFlag=${downFlag}`
167 }
168 return fillImgUrl(value)
169 }
170
171 function openDocumentAttachment(item, url, retried = false, options = {}) {
172 if (!url) {
173 uni.showToast({
174 title: '文件下载失败',
175 icon: 'none'
176 })
177 return
178 }
179 uni.showLoading({
180 title: '打开中',
181 mask: true
182 })
183 uni.downloadFile({
184 url,
185 header: {
186 Authorization: uni.getStorageSync('token')
187 },
188 success: res => {
189 if (res.statusCode && res.statusCode !== 200) {
190 if ((res.statusCode === 301 || res.statusCode === 302) && !retried) {
191 const redirectUrl = getRedirectUrl(res.header)
192 uni.hideLoading()
193 if (redirectUrl) {
194 openDocumentAttachment(item, redirectUrl, true, options)
195 } else if (getAttachmentExt(item) === 'pdf') {
196 openAttachmentWebView(getAttachmentPreviewUrl(item.rawUrl || item.url, 0), options.title || '附件预览')
197 } else {
198 uni.showToast({
199 title: '文件下载失败',
200 icon: 'none'
201 })
202 }
203 return
204 }
205 uni.showToast({
206 title: '文件下载失败',
207 icon: 'none'
208 })
209 return
210 }
211 uni.openDocument({
212 filePath: res.tempFilePath,
213 fileType: getDocumentFileType(item),
214 showMenu: true,
215 fail: () => {
216 if (getAttachmentExt(item) === 'pdf') {
217 openAttachmentWebView(getAttachmentPreviewUrl(item.rawUrl || item.url, 0), options.title || '附件预览')
218 return
219 }
220 uni.showToast({
221 title: '文件暂不支持预览',
222 icon: 'none'
223 })
224 }
225 })
226 },
227 fail: () => {
228 if (getAttachmentExt(item) === 'pdf') {
229 openAttachmentWebView(getAttachmentPreviewUrl(item.rawUrl || item.url, 0), options.title || '附件预览')
230 return
231 }
232 uni.showToast({
233 title: '文件下载失败',
234 icon: 'none'
235 })
236 },
237 complete: () => {
238 uni.hideLoading()
239 }
240 })
241 }
242
243 function openAttachmentWebView(url, title = '附件预览') {
244 if (!url) {
245 uni.showToast({
246 title: '文件下载失败',
247 icon: 'none'
248 })
249 return
250 }
251 uni.navigateTo({
252 url: `/pages/webview/webview?title=${encodeURIComponent(title)}&url=${encodeURIComponent(url)}`,
253 fail: () => {
254 uni.showToast({
255 title: '附件预览失败',
256 icon: 'none'
257 })
258 }
259 })
260 }
261
262 function getAttachmentExt(file) {
263 const name = `${file?.extname || file?.name || file?.rawUrl || file?.url || ''}`
264 const ext = name.includes('.') ? name.split('.').pop() : name
265 return ext.split('?')[0].toLowerCase()
266 }
267
268 function isAttachmentImage(file) {
269 return ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'svg'].includes(getAttachmentExt(file))
270 }
271
272 function getDocumentFileType(file) {
273 const ext = getAttachmentExt(file)
274 const types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
275 return types.includes(ext) ? ext : undefined
276 }
277
278 function getRedirectUrl(header = {}) {
279 const location = header.Location || header.location
280 if (!location) return ''
281 if (/^https?:\/\//.test(location)) return location
282 return `${trimBaseUrl(config.baseUrl_api)}/${String(location).replace(/^\/+/, '')}`
283 }
284
92 function isValidUrlValue(value) { 285 function isValidUrlValue(value) {
93 if (value === undefined || value === null) return false 286 if (value === undefined || value === null) return false
94 const url = String(value).trim() 287 const url = String(value).trim()
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
80 <script setup> 80 <script setup>
81 import * as api from '@/common/api.js' 81 import * as api from '@/common/api.js'
82 import config from '@/config.js' 82 import config from '@/config.js'
83 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 83 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
84 import { 84 import {
85 onMounted, 85 onMounted,
86 ref 86 ref
...@@ -266,74 +266,14 @@ function goGroupInfo(row) { ...@@ -266,74 +266,14 @@ function goGroupInfo(row) {
266 } 266 }
267 267
268 function viewSettleFile(doc) { 268 function viewSettleFile(doc) {
269 let url
270 if (doc.payEvidence) { 269 if (doc.payEvidence) {
271 url = JSON.parse(doc.payEvidence)[0].url || null 270 const file = parseAttachmentJson(doc.payEvidence)
272 console.log(url) 271 previewAttachment(file?.[0] || file, { title: '查看凭证' })
273 if (url) {
274 showImg(url)
275 }
276 } 272 }
277 } 273 }
278 274
279 function showImg(n) { 275 function showImg(n) {
280 const str = fillImgUrl(n) 276 previewAttachment(n, { title: '查看附件' })
281 if (isImageUrl(n) || isImageUrl(str)) {
282 uni.previewImage({
283 urls: [str],
284 success: function (res) {
285 console.log('success', res)
286 },
287 fail: function (res) {
288 console.log('fail', res)
289 },
290 complete: function (res) {
291 console.log('complete', res)
292 }
293 })
294 } else {
295 goWebView(str)
296 }
297 }
298
299 function goWebView(url) {
300 url = url.replace("http://", "https://")
301 uni.showLoading({
302 title: '下载中'
303 });
304 uni.downloadFile({
305 url: url,
306 success: function (res) {
307 uni.hideLoading();
308 var filePath = res.tempFilePath;
309 uni.showLoading({
310 title: '正在打开'
311 });
312 uni.openDocument({
313 filePath: filePath,
314 showMenu: true,
315 success: function (res) {
316 uni.hideLoading();
317 },
318 fail: function (err) {
319 uni.hideLoading();
320 uni.showToast({
321 title: err,
322 icon: 'none',
323 duration: 2000
324 });
325 }
326 });
327 },
328 fail: function (error) {
329 uni.hideLoading();
330 uni.showToast({
331 title: `下载失败`,
332 icon: 'none',
333 duration: 2000
334 });
335 }
336 });
337 } 277 }
338 </script> 278 </script>
339 279
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
39 onLoad 39 onLoad
40 } from '@dcloudio/uni-app' 40 } from '@dcloudio/uni-app'
41 import * as api from '@/common/api.js' 41 import * as api from '@/common/api.js'
42 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 42 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
43 const queryParams = ref({}) 43 const queryParams = ref({})
44 const total = ref(0) 44 const total = ref(0)
45 const list = ref([]) 45 const list = ref([])
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
60 api.getChangeGroupByRangeId(queryParams.value).then(res => { 60 api.getChangeGroupByRangeId(queryParams.value).then(res => {
61 list.value = res.rows 61 list.value = res.rows
62 list.value.forEach(item => { 62 list.value.forEach(item => {
63 item.fileUrl = JSON.parse(item.fileUrl) 63 item.fileUrl = parseAttachmentJson(item.fileUrl)
64 }) 64 })
65 total.value = res.total 65 total.value = res.total
66 uni.hideLoading() 66 uni.hideLoading()
...@@ -68,64 +68,7 @@ ...@@ -68,64 +68,7 @@
68 } 68 }
69 69
70 function showImg(n) { 70 function showImg(n) {
71 const url = n.fileUrl[0]?.url 71 previewAttachment(n.fileUrl, { title: '查看附件' })
72 const str = fillImgUrl(url)
73 if (isImageUrl(url) || isImageUrl(str)) {
74 uni.previewImage({
75 urls: [str],
76 success: function(res) {
77 console.log('success', res)
78 },
79 fail: function(res) {
80 console.log('fail', res)
81 },
82 complete: function(res) {
83 console.log('complete', res)
84 }
85 })
86 } else {
87 goWebView(str)
88 }
89 }
90
91 function goWebView(url) {
92 url = url.replace("http://", "https://")
93 uni.showLoading({
94 title: '下载中'
95 });
96 uni.downloadFile({
97 url: url,
98 success: function(res) {
99 uni.hideLoading();
100 var filePath = res.tempFilePath;
101 uni.showLoading({
102 title: '正在打开'
103 });
104 uni.openDocument({
105 filePath: filePath,
106 showMenu: true,
107 success: function(res) {
108 uni.hideLoading();
109 },
110 fail: function(err) {
111 uni.hideLoading();
112 uni.showToast({
113 title: err,
114 icon: 'none',
115 duration: 2000
116 });
117 }
118 });
119 },
120 fail: function(error) {
121 uni.hideLoading();
122 uni.showToast({
123 title: `下载失败`,
124 icon: 'none',
125 duration: 2000
126 });
127 }
128 });
129 } 72 }
130 </script> 73 </script>
131 <style scoped lang="scss"> 74 <style scoped lang="scss">
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
92 <script setup> 92 <script setup>
93 import * as api from '@/common/api.js' 93 import * as api from '@/common/api.js'
94 import config from '@/config.js' 94 import config from '@/config.js'
95 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 95 import { previewAttachment } from '@/common/utils.js'
96 import { 96 import {
97 onMounted, 97 onMounted,
98 ref 98 ref
...@@ -215,66 +215,7 @@ function goDetail(item) { ...@@ -215,66 +215,7 @@ function goDetail(item) {
215 215
216 function downloadOrder(item) { 216 function downloadOrder(item) {
217 //下载凭证 217 //下载凭证
218 showImg(item.payEvidence[0]?.url) 218 previewAttachment(item.payEvidence?.[0] || item.payEvidence, { title: '查看凭证' })
219 }
220 function showImg(url) {
221 const str = fillImgUrl(url)
222 if (isImageUrl(url) || isImageUrl(str)) {
223 uni.previewImage({
224 urls: [str],
225 success: function(res) {
226 console.log('success', res)
227 },
228 fail: function(res) {
229 console.log('fail', res)
230 },
231 complete: function(res) {
232 console.log('complete', res)
233 }
234 })
235 } else {
236 goWebView(str)
237 }
238 }
239
240 function goWebView(url) {
241 url = url.replace("http://", "https://")
242 uni.showLoading({
243 title: '下载中'
244 });
245 uni.downloadFile({
246 url: url,
247 success: function(res) {
248 uni.hideLoading();
249 var filePath = res.tempFilePath;
250 uni.showLoading({
251 title: '正在打开'
252 });
253 uni.openDocument({
254 filePath: filePath,
255 showMenu: true,
256 success: function(res) {
257 uni.hideLoading();
258 },
259 fail: function(err) {
260 uni.hideLoading();
261 uni.showToast({
262 title: err,
263 icon: 'none',
264 duration: 2000
265 });
266 }
267 });
268 },
269 fail: function(error) {
270 uni.hideLoading();
271 uni.showToast({
272 title: `下载失败`,
273 icon: 'none',
274 duration: 2000
275 });
276 }
277 });
278 } 219 }
279 220
280 </script> 221 </script>
......
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
102 <script setup> 102 <script setup>
103 import * as api from '@/common/api.js' 103 import * as api from '@/common/api.js'
104 import _ from 'underscore' 104 import _ from 'underscore'
105 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 105 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
106 import { 106 import {
107 onMounted, 107 onMounted,
108 ref 108 ref
...@@ -236,57 +236,7 @@ ...@@ -236,57 +236,7 @@
236 } 236 }
237 237
238 function download(url) { 238 function download(url) {
239 console.log(url) 239 previewAttachment(url, { title: '查看附件' })
240 const fileUrl = fillImgUrl(url)
241 if (isImageUrl(url) || isImageUrl(fileUrl)) {
242 uni.previewImage({
243 urls: [fileUrl],
244 success: function(res) {
245 }
246 })
247 } else {
248 goWebView(fileUrl)
249 }
250 }
251
252 function goWebView(url) {
253 url = url.replace("http://", "https://")
254 uni.showLoading({
255 title: '下载中'
256 });
257 uni.downloadFile({
258 url: url,
259 success: function(res) {
260 uni.hideLoading();
261 var filePath = res.tempFilePath;
262 uni.showLoading({
263 title: '正在打开'
264 });
265 uni.openDocument({
266 filePath: filePath,
267 showMenu: true,
268 success: function(res) {
269 uni.hideLoading();
270 },
271 fail: function(err) {
272 uni.hideLoading();
273 uni.showToast({
274 title: err,
275 icon: 'none',
276 duration: 2000
277 });
278 }
279 });
280 },
281 fail: function(error) {
282 uni.hideLoading();
283 uni.showToast({
284 title:`下载失败`,
285 icon: 'none',
286 duration: 2000
287 });
288 }
289 });
290 } 240 }
291 </script> 241 </script>
292 242
......
...@@ -151,7 +151,7 @@ import { ...@@ -151,7 +151,7 @@ import {
151 onShow 151 onShow
152 } from '@dcloudio/uni-app' 152 } from '@dcloudio/uni-app'
153 import * as api from '@/common/api.js' 153 import * as api from '@/common/api.js'
154 import { fillImgUrl } from '@/common/utils.js' 154 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
155 import config from '/config.js' 155 import config from '/config.js'
156 const queryParams = ref({}) 156 const queryParams = ref({})
157 const query = ref({}) 157 const query = ref({})
...@@ -412,150 +412,7 @@ function isImageFile(file) { ...@@ -412,150 +412,7 @@ function isImageFile(file) {
412 } 412 }
413 413
414 function previewFile(file) { 414 function previewFile(file) {
415 const url = isImageFile(file) ? getPreviewUrl(file, 0) : getPreviewUrl(file, 1) 415 previewAttachment(file, { title: '查看附件' })
416 if (!url) {
417 uni.showToast({
418 title: '暂无可预览附件',
419 icon: 'none'
420 })
421 return
422 }
423 if (getFileExt(file) === 'zip') {
424 uni.showToast({
425 title: '压缩包暂不支持在线预览',
426 icon: 'none'
427 })
428 return
429 }
430 if (isImageFile(file)) {
431 uni.previewImage({
432 urls: [url],
433 current: url,
434 fail: () => {
435 uni.showToast({
436 title: '图片预览失败',
437 icon: 'none'
438 })
439 }
440 })
441 return
442 }
443 if (getDocumentFileType(file) === 'pdf') {
444 openPdfWebView(getPreviewUrl(file, 0))
445 return
446 }
447 openDocumentFile(file, url)
448 }
449
450 function openDocumentFile(file, url, retried = false) {
451 uni.showLoading({
452 title: '打开中',
453 mask: true
454 })
455 uni.downloadFile({
456 url,
457 header: {
458 Authorization: uni.getStorageSync('token')
459 },
460 success: res => {
461 if (res.statusCode && res.statusCode !== 200) {
462 if ((res.statusCode === 301 || res.statusCode === 302) && !retried) {
463 const redirectUrl = getRedirectUrl(res.header)
464 const fallbackUrl = redirectUrl || getPreviewUrl(file, 0)
465 uni.hideLoading()
466 if (redirectUrl) {
467 openDocumentFile(file, redirectUrl, true)
468 } else if (getDocumentFileType(file) === 'pdf') {
469 openPdfWebView(fallbackUrl)
470 } else {
471 openDocumentFile(file, fallbackUrl, true)
472 }
473 return
474 }
475 if (getDocumentFileType(file) === 'pdf') {
476 uni.hideLoading()
477 openPdfWebView(getPreviewUrl(file, 0))
478 return
479 }
480 uni.showToast({
481 title: '文件下载失败',
482 icon: 'none'
483 })
484 return
485 }
486 const filePath = res.tempFilePath
487 uni.openDocument({
488 filePath,
489 fileType: getDocumentFileType(file),
490 showMenu: true,
491 fail: () => {
492 if (getDocumentFileType(file) === 'pdf') {
493 openPdfWebView(getPreviewUrl(file, 0))
494 return
495 }
496 uni.showToast({
497 title: '文件暂不支持预览',
498 icon: 'none'
499 })
500 }
501 })
502 },
503 fail: () => {
504 if (getDocumentFileType(file) === 'pdf') {
505 openPdfWebView(getPreviewUrl(file, 0))
506 return
507 }
508 uni.showToast({
509 title: '文件下载失败',
510 icon: 'none'
511 })
512 },
513 complete: () => {
514 uni.hideLoading()
515 }
516 })
517 }
518
519 function getRedirectUrl(header = {}) {
520 const location = header.Location || header.location
521 if (!location) return ''
522 if (/^https?:\/\//.test(location)) return location
523 return `${config.baseUrl_api.replace(/\/+$/, '')}/${String(location).replace(/^\/+/, '')}`
524 }
525
526 function openPdfWebView(url) {
527 if (!url) {
528 uni.showToast({
529 title: '文件下载失败',
530 icon: 'none'
531 })
532 return
533 }
534 uni.navigateTo({
535 url: `/pages/webview/webview?title=${encodeURIComponent('PDF预览')}&url=${encodeURIComponent(url)}`,
536 fail: () => {
537 uni.showToast({
538 title: 'PDF预览失败',
539 icon: 'none'
540 })
541 }
542 })
543 }
544
545 function getPreviewUrl(file, downFlag = 0) {
546 const rawUrl = file?.rawUrl || file?.url
547 if (!rawUrl) return ''
548 const value = String(rawUrl).trim()
549 if (value.startsWith('msr:')) {
550 return `${config.baseUrl_api.replace(/\/+$/, '')}/fileServer/download?file=${value}&downFlag=${downFlag}`
551 }
552 return file?.url || fillImgUrl(value)
553 }
554
555 function getDocumentFileType(file) {
556 const ext = getFileExt(file)
557 const types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
558 return types.includes(ext) ? ext : undefined
559 } 416 }
560 </script> 417 </script>
561 <style scoped lang="scss"> 418 <style scoped lang="scss">
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
230 <view class="form-label">证件类型</view> 230 <view class="form-label">证件类型</view>
231 <view class="form-input"> 231 <view class="form-input">
232 <picker :value="idcTypeIndex" :range="idcTypeList" range-key="text" @change="onIdcTypeChange"> 232 <picker :value="idcTypeIndex" :range="idcTypeList" range-key="text" @change="onIdcTypeChange">
233 <view class="picker-value">{{ idcTypeList[idcTypeIndex]?.text || '请选择证件类型' }}</view> 233 <view class="picker-value">{{ getSelectedIdcTypeText() }}</view>
234 </picker> 234 </picker>
235 </view> 235 </view>
236 </view> 236 </view>
...@@ -347,13 +347,19 @@ const addForm = ref({ ...@@ -347,13 +347,19 @@ const addForm = ref({
347 }) 347 })
348 const idcTypeList = ref([ 348 const idcTypeList = ref([
349 { value: '0', text: '身份证' }, 349 { value: '0', text: '身份证' },
350 { value: '1', text: '护照' }, 350 { value: '1', text: '来往大陆(内地)通行证' },
351 { value: '2', text: '军官证' } 351 { value: '3', text: '护照' },
352 { value: '5', text: '香港身份证' }
352 ]) 353 ])
353 const idcTypeIndex = ref(0) 354 const idcTypeIndex = ref(0)
354 355
355 let examId 356 let examId
356 357
358 function getSelectedIdcTypeText() {
359 const current = idcTypeList.value[idcTypeIndex.value]
360 return current && current.text ? current.text : '请选择证件类型'
361 }
362
357 function openConfirmModal(options = {}) { 363 function openConfirmModal(options = {}) {
358 confirmModal.value = { 364 confirmModal.value = {
359 title: options.title || '提示', 365 title: options.title || '提示',
......
...@@ -24,64 +24,45 @@ ...@@ -24,64 +24,45 @@
24 <view class="order-list"> 24 <view class="order-list">
25 <view v-if="list.length > 0"> 25 <view v-if="list.length > 0">
26 <view 26 <view
27 class="order-card" 27 class="order-card-new"
28 v-for="(item, index) in list" 28 v-for="(item, index) in list"
29 :key="index" 29 :key="index"
30 > 30 >
31 <!-- 卡片头部:日期 + 状态 -->
32 <view class="card-header"> 31 <view class="card-header">
33 <view class="date"> 32 <view class="date">
34 <image :src="config.baseUrl_api + '/fs/static/calendar@2x.png'" v-if="item.commitTime" mode="widthFix" style="width:30rpx;height:30rpx;"/> 33 <view class="data-header">
35 <text class="date-text" v-if="item.commitTime">{{ item.commitTime }}</text> 34 <text class="member-label">{{ item.examCode || '--' }}</text>
35 <!-- <text class="value ml10">{{ item.examCode || '--' }}</text> -->
36 </view> 36 </view>
37 <view class="status-tags"> 37 <text class="status-tag" :class="getStatusClass(item.status)">
38 <view class="status-tag" :class="getStatusClass(item.status)">
39 {{ item.statusStr || '待提交' }} 38 {{ item.statusStr || '待提交' }}
40 </view> 39 </text>
41 </view> 40 </view>
42 </view> 41 </view>
43 42
44 <!-- 基本信息 --> 43 <view class="member-time">
45 <view class="info-row"> 44 <view class="label">
46 <text class="label">缴费编号:</text> 45 <text class="star"></text>
47 <text class="value">{{ item.examCode || '--' }}</text> 46 {{ item.name || '--' }}
48 </view> 47 </view>
49 <view class="info-row"> 48 <view class="price">
50 <text class="label">缴费名称:</text> 49 <view>{{ (Number(item.price) || 0).toFixed(2) }}</view>
51 <text class="value">{{ item.name || '--' }}</text> 50 <view class="person">{{ item.totalNum || 0 }}</view>
52 </view> 51 </view>
53 <view class="info-row">
54 <text class="label">上报单位:</text>
55 <text class="value">{{ item.memberName || '--' }}</text>
56 </view> 52 </view>
57 53
58 <!-- 费用信息区 --> 54 <view class="detail-section">
59 <view class="info-section"> 55 <view class="detail-row">
60 <view class="info-item"> 56 <text class="detail-label">上报单位</text>
61 <text class="item-label">考试人数</text> 57 <text class="detail-value">{{ item.memberName || '--' }}</text>
62 <text class="item-value">{{ item.totalNum || 0 }}</text>
63 </view>
64 <view class="info-line"></view>
65 <view class="info-item">
66 <text class="item-label">总金额</text>
67 <text class="item-value">¥{{ (Number(item.price) || 0).toFixed(2) }}</text>
68 </view>
69 <view class="info-line"></view>
70 <view class="info-item">
71 <text class="item-label">支付方式</text>
72 <text class="item-value">{{ String(item.payType) === '3' ? '对公转账' : '民生付' }}</text>
73 </view> 58 </view>
59 <view class="detail-row">
60 <text class="detail-label">提交日期</text>
61 <text class="detail-value">{{ item.commitTime || '--' }}</text>
74 </view> 62 </view>
75 63 <view class="detail-row">
76 <!-- 审核信息 --> 64 <text class="detail-label">审核日期</text>
77 <view class="price-section"> 65 <text class="detail-value">{{ item.handleDate || '--' }}</text>
78 <view class="price-row">
79 <text class="price-label">提交日期</text>
80 <text class="price-value">{{ item.commitTime || '--' }}</text>
81 </view>
82 <view class="price-row">
83 <text class="price-label">审核日期</text>
84 <text class="price-value">{{ item.handleDate || '--' }}</text>
85 </view> 66 </view>
86 </view> 67 </view>
87 </view> 68 </view>
...@@ -189,7 +170,7 @@ ...@@ -189,7 +170,7 @@
189 <style lang="scss" scoped> 170 <style lang="scss" scoped>
190 .order-page { 171 .order-page {
191 height: 100vh; 172 height: 100vh;
192 background: #f5f7fa; 173 background: #ededf0;
193 display: flex; 174 display: flex;
194 flex-direction: column; 175 flex-direction: column;
195 } 176 }
...@@ -197,21 +178,22 @@ ...@@ -197,21 +178,22 @@
197 // Tab 178 // Tab
198 .tab-bar { 179 .tab-bar {
199 display: flex; 180 display: flex;
200 background: #fff;
201 border-bottom: 1rpx solid #eee;
202 flex-shrink: 0; 181 flex-shrink: 0;
182 padding: 22rpx 32rpx 4rpx;
183 background: #ededf0;
203 184
204 .tab-item { 185 .tab-item {
205 flex: 1; 186 flex: 1;
206 text-align: center; 187 text-align: center;
207 padding: 24rpx 0; 188 padding: 0 0 14rpx;
208 font-size: 28rpx; 189 font-size: 30rpx;
209 color: #666; 190 color: #666;
210 position: relative; 191 position: relative;
192 font-weight: bold;
211 193
212 &.active { 194 &.active {
213 color: #e4393c; 195 color: #c30d23;
214 font-weight: 500; 196 font-weight: bold;
215 197
216 &::after { 198 &::after {
217 content: ''; 199 content: '';
...@@ -219,9 +201,9 @@ ...@@ -219,9 +201,9 @@
219 bottom: 0; 201 bottom: 0;
220 left: 50%; 202 left: 50%;
221 transform: translateX(-50%); 203 transform: translateX(-50%);
222 width: 60rpx; 204 width: 72rpx;
223 height: 4rpx; 205 height: 4rpx;
224 background: linear-gradient(90deg, #FF755A, #F51722); 206 background: #c30d23;
225 border-radius: 2rpx; 207 border-radius: 2rpx;
226 } 208 }
227 } 209 }
...@@ -231,149 +213,173 @@ ...@@ -231,149 +213,173 @@
231 // 滚动列表容器 —— 这里是关键修复 213 // 滚动列表容器 —— 这里是关键修复
232 .order-list-scroll { 214 .order-list-scroll {
233 flex: 1; 215 flex: 1;
234 height: auto; 216 height: 0;
235 overflow: auto; 217 min-height: 0;
218 overflow: hidden;
219 background: #ededf0;
236 } 220 }
237 221
238 .order-list { 222 .order-list {
239 padding: 20rpx; 223 min-height: 100%;
224 box-sizing: border-box;
225 padding: 0 24rpx calc(120rpx + env(safe-area-inset-bottom));
240 } 226 }
241 227
242 .order-card { 228 .order-card-new {
243 background: #fff; 229 background: #fff;
244 margin-bottom: 20rpx; 230 margin-bottom: 22rpx;
245 padding: 24rpx; 231 padding: 22rpx 18rpx 18rpx;
246 border-radius: 12rpx; 232 border-radius: 18rpx;
247 box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04); 233 box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
248 border-top: 6rpx solid transparent; 234 display: flex;
249 background-clip: padding-box, border-box; 235 flex-direction: column;
250 background-origin: padding-box, border-box;
251 background-image: linear-gradient(#fff, #fff), linear-gradient(90deg, #FF755A, #F51722);
252 }
253 236
254 .card-header { 237 .card-header {
255 display: flex; 238 display: flex;
256 justify-content: space-between; 239 justify-content: space-between;
257 align-items: center; 240 align-items: center;
258 padding-bottom: 20rpx; 241 padding-bottom: 10rpx;
259 margin-bottom: 20rpx;
260 border-bottom: 1rpx dashed #eee;
261 242
262 .date { 243 .date {
244 width: 100%;
263 display: flex; 245 display: flex;
264 align-items: center; 246 align-items: center;
247 justify-content: space-between;
265 gap: 8rpx; 248 gap: 8rpx;
266
267 .date-text {
268 font-size: 26rpx; 249 font-size: 26rpx;
269 color: #666;
270 }
271 } 250 }
272 251
273 .status-tags { 252 .data-header {
274 display: flex; 253 display: flex;
275 gap: 10rpx; 254 align-items: center;
255 min-width: 0;
256 }
257
258 .member-label {
259 color: #c30d23;
260 font-size: 28rpx;
261 font-weight: bold;
262 flex-shrink: 0;
263 }
264
265 .value {
266 color: #000;
267 font-size: 27rpx;
268 font-weight: bold;
269 max-width: 360rpx;
270 overflow: hidden;
271 white-space: nowrap;
272 text-overflow: ellipsis;
273 }
274
275 .ml10 {
276 margin-left: 10rpx;
276 } 277 }
277 278
278 .status-tag { 279 .status-tag {
279 font-size: 22rpx; 280 font-size: 24rpx;
280 padding: 6rpx 16rpx; 281 color: #999;
281 border-radius: 20rpx; 282 flex-shrink: 0;
282 283
283 &.success { 284 &.success {
284 background: #e6f7ef;
285 color: #52c41a; 285 color: #52c41a;
286 } 286 }
287 287
288 &.danger { 288 &.danger {
289 background: #fff1f0;
290 color: #ff4d4f; 289 color: #ff4d4f;
291 } 290 }
292 291
293 &.pending { 292 &.pending {
294 background: #f5f5f5; 293 color: #faad14;
295 color: #999;
296 } 294 }
297 295
298 &.warning { 296 &.warning {
299 background: #fff7e6; 297 color: #999;
300 color: #faad14; 298 }
301 } 299 }
302 } 300 }
303 }
304 301
305 .info-row { 302 .member-time {
303 width: 100%;
306 display: flex; 304 display: flex;
307 align-items: center; 305 justify-content: space-between;
308 margin-bottom: 16rpx; 306 padding-bottom: 8rpx;
309 font-size: 26rpx;
310 307
311 .label { 308 .label {
312 color: #999; 309 max-width: 480rpx;
313 flex-shrink: 0; 310 color: #555;
314 min-width: 140rpx; 311 font-size: 26rpx;
315 } 312 font-weight: 700;
316 313 line-height: 1.4;
317 .value {
318 color: #333;
319 word-break: break-all; 314 word-break: break-all;
320 } 315 }
321 }
322 316
323 .info-section { 317 .star {
324 display: flex; 318 color: #777;
325 align-items: center; 319 font-size: 26rpx;
326 background: #f3f6fc; 320 }
327 padding: 16rpx 20rpx;
328 margin: 16rpx 0;
329 border-radius: 8rpx;
330 321
331 .info-item { 322 .price {
332 flex: 1; 323 min-width: 150rpx;
333 display: flex; 324 color: #333;
334 flex-direction: column; 325 font-size: 26rpx;
335 align-items: center; 326 font-weight: 500;
327 text-align: right;
328 margin-left: 20rpx;
336 329
337 .item-label { 330 .person {
338 font-size: 24rpx; 331 font-size: 24rpx;
339 color: #999; 332 color: #999;
333 text-align: right;
334 margin-top: 4rpx;
340 } 335 }
341
342 .item-value {
343 font-size: 28rpx;
344 color: #333;
345 font-weight: 500;
346 margin-top: 8rpx;
347 } 336 }
348 } 337 }
349 338
350 .info-line { 339 .detail-section {
351 width: 1rpx; 340 background: #f3f6fc;
352 height: 60rpx; 341 border-radius: 18rpx;
353 background: #ddd; 342 padding: 10rpx 18rpx;
343 margin-top: 10rpx;
354 } 344 }
355 }
356
357 .price-section {
358 border-top: 1rpx dashed #eee;
359 padding-top: 16rpx;
360 margin-top: 8rpx;
361 345
362 .price-row { 346 .detail-row {
363 display: flex; 347 display: flex;
364 justify-content: space-between; 348 justify-content: space-between;
365 align-items: center; 349 align-items: flex-start;
366 padding: 8rpx 0; 350 padding: 8rpx 0;
351 gap: 24rpx;
352 }
367 353
368 .price-label { 354 .detail-label {
369 font-size: 26rpx; 355 font-size: 26rpx;
370 color: #333; 356 color: #666;
357 flex-shrink: 0;
371 } 358 }
372 359
373 .price-value { 360 .detail-value {
374 font-size: 26rpx; 361 font-size: 26rpx;
375 color: #666; 362 color: #333;
363 text-align: right;
364 word-break: break-all;
376 } 365 }
366 }
367
368 .empty {
369 padding: 160rpx 0 80rpx;
370 display: flex;
371 flex-direction: column;
372 align-items: center;
373
374 .empty-img {
375 width: 240rpx;
376 height: 180rpx;
377 }
378
379 .empty-text {
380 margin-top: 20rpx;
381 color: #999;
382 font-size: 28rpx;
377 } 383 }
378 } 384 }
379 385
......
...@@ -112,7 +112,7 @@ import {onShow} from '@dcloudio/uni-app' ...@@ -112,7 +112,7 @@ import {onShow} from '@dcloudio/uni-app'
112 import * as api from '@/common/api.js' 112 import * as api from '@/common/api.js'
113 import config from '@/config.js' 113 import config from '@/config.js'
114 import _ from 'underscore' 114 import _ from 'underscore'
115 import { fillImgUrl } from '@/common/utils.js' 115 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
116 116
117 const tabs = ref([ 117 const tabs = ref([
118 { value: '', text: '全部' }, 118 { value: '', text: '全部' },
...@@ -249,30 +249,7 @@ function downloadInvoice(item) { ...@@ -249,30 +249,7 @@ function downloadInvoice(item) {
249 uni.showToast({ title: '暂无发票', icon: 'none' }) 249 uni.showToast({ title: '暂无发票', icon: 'none' })
250 return 250 return
251 } 251 }
252 try { 252 previewAttachment(parseAttachmentJson(item.fileUrl), { title: '查看发票' })
253 const invoice = JSON.parse(item.fileUrl)
254 if (invoice && invoice[0]?.url) {
255 let fileUrl = invoice[0].url
256 fileUrl = fillImgUrl(fileUrl)
257
258 // 小程序中使用 previewImage 预览,让用户长按保存
259 uni.previewImage({
260 urls: [fileUrl],
261 success: () => {
262 console.log('previewImage success')
263 },
264 fail: (err) => {
265 console.error('previewImage fail:', err)
266 uni.showToast({ title: '打开图片失败', icon: 'none' })
267 }
268 })
269 } else {
270 uni.showToast({ title: '发票文件不存在', icon: 'none' })
271 }
272 } catch (e) {
273 console.error('解析发票数据失败', e)
274 uni.showToast({ title: '解析发票数据失败', icon: 'none' })
275 }
276 } 253 }
277 254
278 // 打开结算审核 - 跳转到审核页面 255 // 打开结算审核 - 跳转到审核页面
......
...@@ -119,7 +119,7 @@ import { ref, onMounted } from 'vue' ...@@ -119,7 +119,7 @@ import { ref, onMounted } from 'vue'
119 import { onLoad } from '@dcloudio/uni-app' 119 import { onLoad } from '@dcloudio/uni-app'
120 import * as api from '@/common/api.js' 120 import * as api from '@/common/api.js'
121 import config from '@/config.js' 121 import config from '@/config.js'
122 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 122 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
123 123
124 const loading = ref(false) 124 const loading = ref(false)
125 const loadingPayment = ref(false) 125 const loadingPayment = ref(false)
...@@ -188,56 +188,7 @@ function downloadInvoice() { ...@@ -188,56 +188,7 @@ function downloadInvoice() {
188 uni.showToast({ title: '暂无发票', icon: 'none' }) 188 uni.showToast({ title: '暂无发票', icon: 'none' })
189 return 189 return
190 } 190 }
191 try { 191 previewAttachment(parseAttachmentJson(form.value.fileUrl), { title: '查看发票' })
192 const invoice = JSON.parse(form.value.fileUrl)
193 if (invoice && invoice[0]?.url) {
194 let url = invoice[0].url
195 url = fillImgUrl(url)
196 const isImage = isImageUrl(url)
197
198 uni.showLoading({ title: '加载中' })
199 uni.downloadFile({
200 url: url,
201 success: (res) => {
202 uni.hideLoading()
203 if (res.statusCode === 200) {
204 if (isImage) {
205 // 图片预览
206 uni.previewImage({
207 urls: [res.tempFilePath]
208 })
209 } else {
210 // 文件下载后打开
211 uni.saveFile({
212 tempFilePath: res.tempFilePath,
213 success: (saveRes) => {
214 uni.openDocument({
215 filePath: saveRes.savedFilePath,
216 showMenu: true,
217 fail: () => {
218 uni.showToast({ title: '打开失败', icon: 'none' })
219 }
220 })
221 },
222 fail: () => {
223 uni.showToast({ title: '保存失败', icon: 'none' })
224 }
225 })
226 }
227 } else {
228 uni.showToast({ title: '下载失败', icon: 'none' })
229 }
230 },
231 fail: () => {
232 uni.hideLoading()
233 uni.showToast({ title: '下载失败', icon: 'none' })
234 }
235 })
236 }
237 } catch (e) {
238 console.error('解析发票数据失败', e)
239 uni.showToast({ title: '解析发票数据失败', icon: 'none' })
240 }
241 } 192 }
242 </script> 193 </script>
243 194
......
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
153 <script setup> 153 <script setup>
154 import * as api from '@/common/api_exam.js' 154 import * as api from '@/common/api_exam.js'
155 import config from '@/config.js' 155 import config from '@/config.js'
156 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 156 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
157 import { ref, reactive, computed } from 'vue' 157 import { ref, reactive, computed } from 'vue'
158 import { onLoad, onReachBottom } from '@dcloudio/uni-app' 158 import { onLoad, onReachBottom } from '@dcloudio/uni-app'
159 159
...@@ -271,62 +271,7 @@ function handelInvoice(fileUrl) { ...@@ -271,62 +271,7 @@ function handelInvoice(fileUrl) {
271 uni.showToast({ title: '暂无发票', icon: 'none' }) 271 uni.showToast({ title: '暂无发票', icon: 'none' })
272 return 272 return
273 } 273 }
274 try { 274 previewAttachment(parseAttachmentJson(fileUrl), { title: '查看发票' })
275 const invoice = JSON.parse(fileUrl)
276 if (invoice && invoice.length > 0) {
277 let url = invoice[0].url || ''
278 if (!url) {
279 uni.showToast({ title: '暂无发票', icon: 'none' })
280 return
281 }
282 url = fillImgUrl(url)
283 const isImage = isImageUrl(url)
284
285 uni.showLoading({ title: '加载中' })
286 uni.downloadFile({
287 url: url,
288 success: (res) => {
289 uni.hideLoading()
290 if (res.statusCode === 200) {
291 if (isImage) {
292 // 图片预览
293 uni.previewImage({
294 urls: [res.tempFilePath]
295 })
296 } else {
297 // 文件下载后打开
298 uni.saveFile({
299 tempFilePath: res.tempFilePath,
300 success: (saveRes) => {
301 uni.openDocument({
302 filePath: saveRes.savedFilePath,
303 showMenu: true,
304 fail: () => {
305 uni.showToast({ title: '打开失败', icon: 'none' })
306 }
307 })
308 },
309 fail: () => {
310 uni.showToast({ title: '保存失败', icon: 'none' })
311 }
312 })
313 }
314 } else {
315 uni.showToast({ title: '下载失败', icon: 'none' })
316 }
317 },
318 fail: () => {
319 uni.hideLoading()
320 uni.showToast({ title: '下载失败', icon: 'none' })
321 }
322 })
323 } else {
324 uni.showToast({ title: '暂无发票', icon: 'none' })
325 }
326 } catch (e) {
327 console.error('发票信息解析失败:', e)
328 uni.showToast({ title: '发票信息解析失败', icon: 'none' })
329 }
330 } 275 }
331 </script> 276 </script>
332 277
......
...@@ -148,7 +148,7 @@ import { ref } from 'vue' ...@@ -148,7 +148,7 @@ import { ref } from 'vue'
148 import { onLoad } from '@dcloudio/uni-app' 148 import { onLoad } from '@dcloudio/uni-app'
149 149
150 // const config = require('@/config.js') 150 // const config = require('@/config.js')
151 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 151 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
152 152
153 const loading = ref(false) 153 const loading = ref(false)
154 const form = ref({}) 154 const form = ref({})
...@@ -159,57 +159,7 @@ onLoad((options) => { ...@@ -159,57 +159,7 @@ onLoad((options) => {
159 } 159 }
160 }) 160 })
161 function download(url) { 161 function download(url) {
162 console.log(url) 162 previewAttachment(url, { title: '查看附件' })
163 const fileUrl = fillImgUrl(url)
164 if (isImageUrl(url) || isImageUrl(fileUrl)) {
165 uni.previewImage({
166 urls: [fileUrl],
167 success: function(res) {
168 }
169 })
170 } else {
171 goWebView(fileUrl)
172 }
173 }
174
175 function goWebView(url) {
176 url = url.replace("http://", "https://")
177 uni.showLoading({
178 title: '下载中'
179 });
180 uni.downloadFile({
181 url: url,
182 success: function(res) {
183 uni.hideLoading();
184 var filePath = res.tempFilePath;
185 uni.showLoading({
186 title: '正在打开'
187 });
188 uni.openDocument({
189 filePath: filePath,
190 showMenu: true,
191 success: function(res) {
192 uni.hideLoading();
193 },
194 fail: function(err) {
195 uni.hideLoading();
196 uni.showToast({
197 title: err,
198 icon: 'none',
199 duration: 2000
200 });
201 }
202 });
203 },
204 fail: function(error) {
205 uni.hideLoading();
206 uni.showToast({
207 title:`下载失败`,
208 icon: 'none',
209 duration: 2000
210 });
211 }
212 });
213 } 163 }
214 function getInstitutionInfo(memId) { 164 function getInstitutionInfo(memId) {
215 loading.value = true 165 loading.value = true
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
81 <script setup> 81 <script setup>
82 import * as api from '@/common/api.js' 82 import * as api from '@/common/api.js'
83 import config from '@/config.js' 83 import config from '@/config.js'
84 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 84 import { previewAttachment } from '@/common/utils.js'
85 import { 85 import {
86 onMounted, 86 onMounted,
87 ref 87 ref
...@@ -234,63 +234,7 @@ function goGroupInfo(row) { ...@@ -234,63 +234,7 @@ function goGroupInfo(row) {
234 } 234 }
235 235
236 function showImg(n) { 236 function showImg(n) {
237 const str = fillImgUrl(n) 237 previewAttachment(n, { title: '查看附件' })
238 if (isImageUrl(n) || isImageUrl(str)) {
239 uni.previewImage({
240 urls: [str],
241 success: function (res) {
242 console.log('success', res)
243 },
244 fail: function (res) {
245 console.log('fail', res)
246 },
247 complete: function (res) {
248 console.log('complete', res)
249 }
250 })
251 } else {
252 goWebView(str)
253 }
254 }
255
256 function goWebView(url) {
257 url = url.replace("http://", "https://")
258 uni.showLoading({
259 title: '下载中'
260 });
261 uni.downloadFile({
262 url: url,
263 success: function (res) {
264 uni.hideLoading();
265 var filePath = res.tempFilePath;
266 uni.showLoading({
267 title: '正在打开'
268 });
269 uni.openDocument({
270 filePath: filePath,
271 showMenu: true,
272 success: function (res) {
273 uni.hideLoading();
274 },
275 fail: function (err) {
276 uni.hideLoading();
277 uni.showToast({
278 title: err,
279 icon: 'none',
280 duration: 2000
281 });
282 }
283 });
284 },
285 fail: function (error) {
286 uni.hideLoading();
287 uni.showToast({
288 title: `下载失败`,
289 icon: 'none',
290 duration: 2000
291 });
292 }
293 });
294 } 238 }
295 </script> 239 </script>
296 240
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
150 150
151 <script setup> 151 <script setup>
152 import * as api from '@/common/api.js' 152 import * as api from '@/common/api.js'
153 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 153 import { fillImgUrl, isImageUrl, previewAttachment } from '@/common/utils.js'
154 154
155 import _ from 'underscore' 155 import _ from 'underscore'
156 import { 156 import {
...@@ -380,57 +380,7 @@ function parseImageList(value) { ...@@ -380,57 +380,7 @@ function parseImageList(value) {
380 } 380 }
381 381
382 function download(url) { 382 function download(url) {
383 console.log(url) 383 previewAttachment(url, { title: '查看附件' })
384 const fileUrl = fillImgUrl(url)
385 if (isImageUrl(url) || isImageUrl(fileUrl)) {
386 uni.previewImage({
387 urls: [fileUrl],
388 success: function (res) {
389 }
390 })
391 } else {
392 goWebView(fileUrl)
393 }
394 }
395
396 function goWebView(url) {
397 url = url.replace("http://", "https://")
398 uni.showLoading({
399 title: '下载中'
400 });
401 uni.downloadFile({
402 url: url,
403 success: function (res) {
404 uni.hideLoading();
405 var filePath = res.tempFilePath;
406 uni.showLoading({
407 title: '正在打开'
408 });
409 uni.openDocument({
410 filePath: filePath,
411 showMenu: true,
412 success: function (res) {
413 uni.hideLoading();
414 },
415 fail: function (err) {
416 uni.hideLoading();
417 uni.showToast({
418 title: err,
419 icon: 'none',
420 duration: 2000
421 });
422 }
423 });
424 },
425 fail: function (error) {
426 uni.hideLoading();
427 uni.showToast({
428 title: `下载失败`,
429 icon: 'none',
430 duration: 2000
431 });
432 }
433 });
434 } 384 }
435 385
436 function payTheFees() { 386 function payTheFees() {
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
38 onLoad 38 onLoad
39 } from '@dcloudio/uni-app'; 39 } from '@dcloudio/uni-app';
40 import _ from 'underscore' 40 import _ from 'underscore'
41 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 41 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
42 const form = ref({}) 42 const form = ref({})
43 const attachmentFile = ref([]) 43 const attachmentFile = ref([])
44 const attachmentMp4 = ref([]) 44 const attachmentMp4 = ref([])
...@@ -67,71 +67,7 @@ ...@@ -67,71 +67,7 @@
67 } 67 }
68 68
69 function downLoad(url) { 69 function downLoad(url) {
70 console.log(url) 70 previewAttachment(url, { title: '附件预览' })
71 const str = fillImgUrl(url)
72 if (isImageUrl(url) || isImageUrl(str)) {
73 uni.previewImage({
74 urls: [str],
75 success: function(res) {
76 console.log('success', res)
77 },
78 fail: function(res) {
79 console.log('fail', res)
80 },
81 complete: function(res) {
82 console.log('complete', res)
83 }
84 })
85 } else {
86 goWebView(str)
87 }
88 }
89
90 function goWebView(url) {
91 url = url.replace("http://", "https://")
92 uni.showLoading({
93 title: '下载中'
94 });
95 uni.downloadFile({
96 url: url,
97 success: function(res) {
98 uni.hideLoading();
99 var filePath = res.tempFilePath;
100 uni.showLoading({
101 title: '正在打开'
102 });
103 uni.openDocument({
104 filePath: filePath,
105 showMenu: true,
106 success: function(res) {
107 uni.hideLoading();
108 },
109 fail: function(err) {
110 console.log(err.errMsg)
111 uni.hideLoading();
112 let msg
113 if (err.errMsg.indexOf('not supported') > -1) {
114 msg = '不支持该文件类型'
115 } else {
116 msg = err.errMsg
117 }
118 uni.showToast({
119 title: msg,
120 icon: 'none',
121 duration: 2000
122 });
123 }
124 });
125 },
126 fail: function(error) {
127 uni.hideLoading();
128 uni.showToast({
129 title: `下载失败`,
130 icon: 'none',
131 duration: 2000
132 });
133 }
134 });
135 } 71 }
136 </script> 72 </script>
137 73
......
...@@ -23,27 +23,21 @@ ...@@ -23,27 +23,21 @@
23 </template> 23 </template>
24 24
25 <script setup> 25 <script setup>
26 import { ref, onUnmounted } from "vue"; 26 import { ref } from "vue";
27 import { onLoad } from "@dcloudio/uni-app"; 27 import { onLoad } from "@dcloudio/uni-app";
28 import config from "@/config.js"; 28 import { previewAttachment } from '@/common/utils.js'
29 29
30 const pdfUrl = ref(""); 30 const pdfUrl = ref("");
31 const loading = ref(true); 31 const loading = ref(false);
32 const showError = ref(false); 32 const showError = ref(false);
33 const errorMsg = ref(""); 33 const errorMsg = ref("");
34 const useWebView = ref(false); // 是否使用 web-view 降级方案 34 const useWebView = ref(false); // 是否使用 web-view 降级方案
35 let timeoutTimer = null; 35 const currentUrl = ref('')
36 36
37 onLoad((option) => { 37 onLoad((option) => {
38 if (option.url) { 38 if (option.url) {
39 // 解码并拼接完整URL 39 currentUrl.value = decodeURIComponent(option.url);
40 let relativeUrl = decodeURIComponent(option.url); 40 openAttachment(currentUrl.value);
41 let fullUrl = config.baseUrl_api + relativeUrl;
42
43 console.log("完整PDF地址:", fullUrl);
44
45 // 优先使用 openDocument 方式(兼容性最好)
46 openPdfWithDocument(fullUrl);
47 } else { 41 } else {
48 loading.value = false; 42 loading.value = false;
49 showError.value = true; 43 showError.value = true;
...@@ -51,83 +45,11 @@ onLoad((option) => { ...@@ -51,83 +45,11 @@ onLoad((option) => {
51 } 45 }
52 }); 46 });
53 47
54 // 优先方案:使用 uni.openDocument(推荐,兼容性最好) 48 const openAttachment = (url) => {
55 const openPdfWithDocument = (url) => { 49 showError.value = false;
56 // 设置超时 50 errorMsg.value = "";
57 timeoutTimer = setTimeout(() => {
58 if (loading.value) {
59 loading.value = false;
60 showError.value = true;
61 errorMsg.value = "加载超时,请检查网络";
62 }
63 }, 15000);
64
65 // 先下载文件
66 uni.downloadFile({
67 url: url,
68 success: (res) => {
69 clearTimeout(timeoutTimer);
70
71 if (res.statusCode === 200) {
72 const filePath = res.tempFilePath;
73 // 打开文档
74 uni.openDocument({
75 filePath: filePath,
76 success: () => {
77 // 打开成功,关闭当前页面
78 loading.value = false;
79 setTimeout(() => {
80 uni.navigateBack();
81 }, 500);
82 },
83 fail: (err) => {
84 console.error("openDocument失败:", err);
85 // 降级到 web-view 方式
86 fallbackToWebView(url);
87 }
88 });
89 } else {
90 fallbackToWebView(url);
91 }
92 },
93 fail: (err) => {
94 console.error("下载失败:", err);
95 clearTimeout(timeoutTimer);
96 // 降级到 web-view 方式
97 fallbackToWebView(url);
98 }
99 });
100 };
101
102 // 降级方案:使用 web-view
103 const fallbackToWebView = (url) => {
104 console.log("降级使用 web-view 方式");
105 useWebView.value = true;
106
107 // 处理URL,确保是HTTPS
108 let webViewUrl = url;
109 if (webViewUrl.startsWith('http://')) {
110 webViewUrl = webViewUrl.replace('http://', 'https://');
111 }
112
113 // 添加时间戳避免缓存问题
114 webViewUrl = webViewUrl + (webViewUrl.includes('?') ? '&' : '?') + 't=' + Date.now();
115
116 pdfUrl.value = webViewUrl;
117
118 // 给 web-view 一些加载时间
119 setTimeout(() => {
120 if (loading.value) {
121 loading.value = false; 51 loading.value = false;
122 // 不立即显示错误,让 web-view 继续尝试 52 previewAttachment(url, { title: '证书预览' })
123 setTimeout(() => {
124 if (loading.value === false && !showError.value) {
125 // 如果还在加载状态,可能是真的有问题
126 // 但这里不做额外处理
127 }
128 }, 3000);
129 }
130 }, 2000);
131 }; 53 };
132 54
133 // web-view 消息接收(可选) 55 // web-view 消息接收(可选)
...@@ -138,25 +60,11 @@ const onWebViewMessage = (e) => { ...@@ -138,25 +60,11 @@ const onWebViewMessage = (e) => {
138 // 重试加载 60 // 重试加载
139 const retryLoad = () => { 61 const retryLoad = () => {
140 showError.value = false; 62 showError.value = false;
141 loading.value = true; 63 loading.value = false;
142 useWebView.value = false; 64 useWebView.value = false;
143 errorMsg.value = ""; 65 errorMsg.value = "";
144 66 if (currentUrl.value) openAttachment(currentUrl.value);
145 // 重新获取URL
146 const pages = getCurrentPages();
147 const currentPage = pages[pages.length - 1];
148 const url = currentPage.$page.options.url;
149
150 if (url) {
151 let fullUrl = config.baseUrl_api + decodeURIComponent(url);
152 openPdfWithDocument(fullUrl);
153 }
154 }; 67 };
155
156 // 页面卸载时清除定时器
157 onUnmounted(() => {
158 if (timeoutTimer) clearTimeout(timeoutTimer);
159 });
160 </script> 68 </script>
161 69
162 <style lang="scss" scoped> 70 <style lang="scss" scoped>
......
...@@ -65,11 +65,13 @@ ...@@ -65,11 +65,13 @@
65 <view v-if="item.fileUrl" class="item-row"> 65 <view v-if="item.fileUrl" class="item-row">
66 <text class="item-label">附件</text> 66 <text class="item-label">附件</text>
67 <image 67 <image
68 v-if="isImageUrl(item.fileUrl)"
68 class="item-image" 69 class="item-image"
69 :src="fillImgUrl(item.fileUrl)" 70 :src="fillImgUrl(item.fileUrl)"
70 mode="aspectFill" 71 mode="aspectFill"
71 @click="previewImage(item.fileUrl)" 72 @click="previewImage(item.fileUrl)"
72 ></image> 73 ></image>
74 <text v-else class="item-value text-primary" @click="previewImage(item.fileUrl)">查看附件</text>
73 </view> 75 </view>
74 </view> 76 </view>
75 77
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
88 import { ref } from 'vue' 90 import { ref } from 'vue'
89 import { onLoad, onReachBottom } from '@dcloudio/uni-app' 91 import { onLoad, onReachBottom } from '@dcloudio/uni-app'
90 import { memberAuditList } from '@/common/api' 92 import { memberAuditList } from '@/common/api'
91 import config from '@/config' 93 import { fillImgUrl, isImageUrl, previewAttachment } from '@/common/utils.js'
92 94
93 const tabs = [ 95 const tabs = [
94 { label: '全部', value: '' }, 96 { label: '全部', value: '' },
...@@ -187,17 +189,8 @@ function formatDate(dateStr) { ...@@ -187,17 +189,8 @@ function formatDate(dateStr) {
187 return `${year}-${month}-${day}` 189 return `${year}-${month}-${day}`
188 } 190 }
189 191
190 function fillImgUrl(url) {
191 if (!url) return ''
192 if (url.startsWith('http')) return url
193 return config.baseUrl + url
194 }
195
196 function previewImage(url) { 192 function previewImage(url) {
197 uni.previewImage({ 193 previewAttachment(url, { title: '查看附件' })
198 urls: [fillImgUrl(url)],
199 current: fillImgUrl(url)
200 })
201 } 194 }
202 </script> 195 </script>
203 196
......
...@@ -166,6 +166,7 @@ ...@@ -166,6 +166,7 @@
166 166
167 <script setup> 167 <script setup>
168 import { 168 import {
169 parseAttachmentJson,
169 szToHz 170 szToHz
170 } from '@/common/utils.js' 171 } from '@/common/utils.js'
171 import { 172 import {
...@@ -208,7 +209,7 @@ ...@@ -208,7 +209,7 @@
208 api.infoMergeList(queryParams.value).then(res => { 209 api.infoMergeList(queryParams.value).then(res => {
209 list.value = res.rows 210 list.value = res.rows
210 list.value.forEach(item => { 211 list.value.forEach(item => {
211 item.fileUrl = JSON.parse(item.fileUrl) 212 item.fileUrl = parseAttachmentJson(item.fileUrl) || []
212 }) 213 })
213 total.value = res.total 214 total.value = res.total
214 uni.hideLoading() 215 uni.hideLoading()
...@@ -270,68 +271,116 @@ ...@@ -270,68 +271,116 @@
270 }) 271 })
271 } 272 }
272 273
273 function commitFN() { 274 async function commitFN() {
274 const flag = list.value.some(item => { 275 const flag = list.value.some(item => {
275 if (!item.fileUrl) { 276 if (!getPrimaryFile(item.fileUrl)) {
276 uni.showToast({ 277 uni.showToast({
277 title: `请上传${item.personInfo?.name}的附件`, 278 title: `请上传${item.personInfo?.name}的附件`,
278 icon: 'none' 279 icon: 'none'
279 }) 280 })
280 return !item.fileUrl 281 return true
281 } 282 }
282 }) 283 })
283 if (flag) return 284 if (flag) return
284 if (form.value.rangeId == '') return 285 if (!queryParams.value.rangeId || queryParams.value.rangeId == '-1') return
285 286
286 uni.showModal({ 287 uni.showModal({
287 title: '提示', 288 title: '提示',
288 content: `确定提交吗`, 289 content: `确定提交吗`,
289 success: function(res) { 290 success: async function(res) {
290 if (res.confirm) { 291 if (res.confirm) {
291 api.commitMergeVip([queryParams.value.rangeId]).then(Response => { 292 try {
293 uni.showLoading({
294 title: '提交中',
295 mask: true
296 })
297 await syncMergeFiles()
298 // await api.commitMergeVip([queryParams.value.rangeId])
292 uni.showToast({ 299 uni.showToast({
293 icon: "none", 300 icon: "none",
294 title: '提交成功!' 301 title: '提交成功!'
295 }) 302 })
296 uni.navigateBack() 303 uni.navigateBack()
297 }) 304 } finally {
305 uni.hideLoading()
306 }
298 } 307 }
299 } 308 }
300 }) 309 })
301 } 310 }
302 let selectFileValue = {} 311 let selectFileValue = {}
303 312
304 function selectFile(row, e) { 313 async function selectFile(row, e) {
305 form.value = row 314 form.value = row
306 let file = e.tempFiles[0] 315 let file = e.tempFiles[0]
307 if (!file) { 316 if (!file) {
308 return 317 return
309 } 318 }
310 api.uploadFile(e).then(data => { 319 uni.showLoading({
320 title: '上传中',
321 mask: true
322 })
323 try {
324 const data = await api.uploadFile(e)
325 const fileKey = data.data || data.msg
311 selectFileValue = { 326 selectFileValue = {
312 url: data.msg, 327 url: fileKey,
313 name: file.name, 328 name: file.name,
314 extname: file.extname 329 extname: file.extname
315 } 330 }
316 console.log(selectFileValue, row.fileUrl) 331 row.fileUrl = [selectFileValue]
317 uni.showLoading({ 332 await saveMergeFile(row, row.fileUrl)
318 title: '上传中'
319 })
320 debugger
321 api.editMergeByFile({
322 mergeId: form.value.id,
323 fileUrl: JSON.stringify([selectFileValue])
324 }).then(Response => {
325 uni.hideLoading()
326 getList() 333 getList()
334 } catch (err) {
335 row.fileUrl = []
336 uni.showToast({
337 title: err?.message || '上传失败',
338 icon: 'none'
327 }) 339 })
328 }); 340 } finally {
341 uni.hideLoading()
342 }
329 } 343 }
330 344
331 function delSupplementFile(row) { 345 function delSupplementFile(row) {
332 selectFileValue = {} 346 selectFileValue = {}
333 row.fileUrl = [] 347 row.fileUrl = []
334 } 348 }
349
350 function getPrimaryFile(fileUrl) {
351 if (!fileUrl) return null
352 if (Array.isArray(fileUrl)) return fileUrl[0] || null
353 if (typeof fileUrl === 'object') return fileUrl
354 return fileUrl
355 }
356
357 function toSubmitFile(file) {
358 if (typeof file === 'string') {
359 return {
360 url: file
361 }
362 }
363 return {
364 url: file.rawUrl || file.url,
365 name: file.name,
366 extname: file.extname
367 }
368 }
369
370 function saveMergeFile(row, fileUrl) {
371 const file = getPrimaryFile(fileUrl)
372 if (!row?.id || !file) return Promise.resolve()
373 return api.editMergeByFile({
374 mergeId: row.id,
375 fileUrl: JSON.stringify([toSubmitFile(file)])
376 })
377 }
378
379 async function syncMergeFiles() {
380 for (const item of list.value) {
381 await saveMergeFile(item, item.fileUrl)
382 }
383 }
335 </script> 384 </script>
336 <style scoped lang="scss"> 385 <style scoped lang="scss">
337 .flexbox { 386 .flexbox {
......
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
62 onShow 62 onShow
63 } from '@dcloudio/uni-app' 63 } from '@dcloudio/uni-app'
64 import { 64 import {
65 fillImgUrl, 65 parseAttachmentJson,
66 isImageUrl, 66 previewAttachment,
67 szToHz 67 szToHz
68 } from '@/common/utils.js' 68 } from '@/common/utils.js'
69 import * as api from '@/common/api.js' 69 import * as api from '@/common/api.js'
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
245 for (var item of list.value) { 245 for (var item of list.value) {
246 item.examPersonData = JSON.parse(item.examPersonData) 246 item.examPersonData = JSON.parse(item.examPersonData)
247 if (item.fileUrl) { 247 if (item.fileUrl) {
248 item.fileUrl = JSON.parse(item.fileUrl) 248 item.fileUrl = parseAttachmentJson(item.fileUrl)
249 } 249 }
250 } 250 }
251 total.value = Response.total 251 total.value = Response.total
...@@ -254,63 +254,7 @@ ...@@ -254,63 +254,7 @@
254 } 254 }
255 255
256 function showImg(n) { 256 function showImg(n) {
257 const url = n.fileUrl[0]?.url 257 previewAttachment(n.fileUrl, { title: '查看附件' })
258 const str = fillImgUrl(url)
259 if(isImageUrl(url) || isImageUrl(str)){
260 uni.previewImage({
261 urls: [str],
262 success: function(res) {
263 console.log('success', res)
264 },
265 fail: function(res) {
266 console.log('fail', res)
267 },
268 complete: function(res) {
269 console.log('complete', res)
270 }
271 })
272 }else{
273 goWebView(str)
274 }
275 }
276 function goWebView(url){
277 url = url.replace("http://", "https://")
278 uni.showLoading({
279 title: '下载中'
280 });
281 uni.downloadFile({
282 url: url,
283 success: function(res) {
284 uni.hideLoading();
285 var filePath = res.tempFilePath;
286 uni.showLoading({
287 title: '正在打开'
288 });
289 uni.openDocument({
290 filePath: filePath,
291 showMenu: true,
292 success: function(res) {
293 uni.hideLoading();
294 },
295 fail: function(err) {
296 uni.hideLoading();
297 uni.showToast({
298 title: err,
299 icon: 'none',
300 duration: 2000
301 });
302 }
303 });
304 },
305 fail: function(error) {
306 uni.hideLoading();
307 uni.showToast({
308 title: `下载失败`,
309 icon: 'none',
310 duration: 2000
311 });
312 }
313 });
314 } 258 }
315 </script> 259 </script>
316 260
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
74 onLoad 74 onLoad
75 } from '@dcloudio/uni-app' 75 } from '@dcloudio/uni-app'
76 import * as api from '@/common/api.js' 76 import * as api from '@/common/api.js'
77 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 77 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
78 const queryParams = ref({}) 78 const queryParams = ref({})
79 const total = ref(0) 79 const total = ref(0)
80 const list = ref([]) 80 const list = ref([])
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
120 api.addInfoModeList(queryParams.value).then(res => { 120 api.addInfoModeList(queryParams.value).then(res => {
121 list.value = res.rows 121 list.value = res.rows
122 list.value.forEach(item => { 122 list.value.forEach(item => {
123 item.fileUrl = JSON.parse(item.fileUrl) 123 item.fileUrl = parseAttachmentJson(item.fileUrl)
124 }) 124 })
125 total.value = res.total 125 total.value = res.total
126 uni.hideLoading() 126 uni.hideLoading()
...@@ -151,64 +151,7 @@ ...@@ -151,64 +151,7 @@
151 } 151 }
152 152
153 function showImg(n) { 153 function showImg(n) {
154 const url = n.fileUrl[0]?.url 154 previewAttachment(n.fileUrl, { title: '查看附件' })
155 const str = fillImgUrl(url)
156 if (isImageUrl(url) || isImageUrl(str)) {
157 uni.previewImage({
158 urls: [str],
159 success: function(res) {
160 console.log('success', res)
161 },
162 fail: function(res) {
163 console.log('fail', res)
164 },
165 complete: function(res) {
166 console.log('complete', res)
167 }
168 })
169 } else {
170 goWebView(str)
171 }
172 }
173
174 function goWebView(url) {
175 url = url.replace("http://", "https://")
176 uni.showLoading({
177 title: '下载中'
178 });
179 uni.downloadFile({
180 url: url,
181 success: function(res) {
182 uni.hideLoading();
183 var filePath = res.tempFilePath;
184 uni.showLoading({
185 title: '正在打开'
186 });
187 uni.openDocument({
188 filePath: filePath,
189 showMenu: true,
190 success: function(res) {
191 uni.hideLoading();
192 },
193 fail: function(err) {
194 uni.hideLoading();
195 uni.showToast({
196 title: err,
197 icon: 'none',
198 duration: 2000
199 });
200 }
201 });
202 },
203 fail: function(error) {
204 uni.hideLoading();
205 uni.showToast({
206 title: `下载失败`,
207 icon: 'none',
208 duration: 2000
209 });
210 }
211 });
212 } 155 }
213 </script> 156 </script>
214 <style scoped lang="scss"> 157 <style scoped lang="scss">
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
83 <script setup> 83 <script setup>
84 import * as api from '@/common/api.js' 84 import * as api from '@/common/api.js'
85 import config from '@/config.js' 85 import config from '@/config.js'
86 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 86 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
87 import { 87 import {
88 onMounted, 88 onMounted,
89 ref 89 ref
...@@ -128,67 +128,8 @@ function handleUpdate(item) { ...@@ -128,67 +128,8 @@ function handleUpdate(item) {
128 } 128 }
129 function downloadOrder(item) { 129 function downloadOrder(item) {
130 //下载凭证 130 //下载凭证
131 var arr = JSON.parse(item.payEvidence) || [] 131 const arr = parseAttachmentJson(item.payEvidence) || []
132 showImg(arr[0]?.url) 132 previewAttachment(arr[0] || arr, { title: '查看凭证' })
133 }
134 function showImg(url) {
135 const str = fillImgUrl(url)
136 if (isImageUrl(url) || isImageUrl(str)) {
137 uni.previewImage({
138 urls: [str],
139 success: function(res) {
140 console.log('success', res)
141 },
142 fail: function(res) {
143 console.log('fail', res)
144 },
145 complete: function(res) {
146 console.log('complete', res)
147 }
148 })
149 } else {
150 goWebView(str)
151 }
152 }
153
154 function goWebView(url) {
155 url = url.replace("http://", "https://")
156 uni.showLoading({
157 title: '下载中'
158 });
159 uni.downloadFile({
160 url: url,
161 success: function(res) {
162 uni.hideLoading();
163 var filePath = res.tempFilePath;
164 uni.showLoading({
165 title: '正在打开'
166 });
167 uni.openDocument({
168 filePath: filePath,
169 showMenu: true,
170 success: function(res) {
171 uni.hideLoading();
172 },
173 fail: function(err) {
174 uni.hideLoading();
175 uni.showToast({
176 title: err,
177 icon: 'none',
178 duration: 2000
179 });
180 }
181 });
182 },
183 fail: function(error) {
184 uni.hideLoading();
185 uni.showToast({
186 title: `下载失败`,
187 icon: 'none',
188 duration: 2000
189 });
190 }
191 });
192 } 133 }
193 134
194 let selectFileValue = {} 135 let selectFileValue = {}
......
...@@ -129,9 +129,10 @@ ...@@ -129,9 +129,10 @@
129 } from '@dcloudio/uni-app' 129 } from '@dcloudio/uni-app'
130 import * as api from '@/common/api.js' 130 import * as api from '@/common/api.js'
131 import { 131 import {
132 parseAttachmentJson,
133 previewAttachment,
132 szToHz 134 szToHz
133 } from '@/common/utils.js' 135 } from '@/common/utils.js'
134 import { fillImgUrl, isImageUrl } from '@/common/utils.js'
135 const queryParams = ref({}) 136 const queryParams = ref({})
136 const total = ref(0) 137 const total = ref(0)
137 const list = ref([]) 138 const list = ref([])
...@@ -152,7 +153,7 @@ ...@@ -152,7 +153,7 @@
152 api.infoMergeList(queryParams.value).then(res => { 153 api.infoMergeList(queryParams.value).then(res => {
153 list.value = res.rows 154 list.value = res.rows
154 list.value.forEach(item => { 155 list.value.forEach(item => {
155 item.fileUrl = JSON.parse(item.fileUrl) 156 item.fileUrl = parseAttachmentJson(item.fileUrl)
156 }) 157 })
157 total.value = res.total 158 total.value = res.total
158 uni.hideLoading() 159 uni.hideLoading()
...@@ -183,64 +184,7 @@ ...@@ -183,64 +184,7 @@
183 } 184 }
184 185
185 function showImg(n) { 186 function showImg(n) {
186 const url = n.fileUrl[0]?.url 187 previewAttachment(n.fileUrl, { title: '查看附件' })
187 const str = fillImgUrl(url)
188 if (isImageUrl(url) || isImageUrl(str)) {
189 uni.previewImage({
190 urls: [str],
191 success: function(res) {
192 console.log('success', res)
193 },
194 fail: function(res) {
195 console.log('fail', res)
196 },
197 complete: function(res) {
198 console.log('complete', res)
199 }
200 })
201 } else {
202 goWebView(str)
203 }
204 }
205
206 function goWebView(url) {
207 url = url.replace("http://", "https://")
208 uni.showLoading({
209 title: '下载中'
210 });
211 uni.downloadFile({
212 url: url,
213 success: function(res) {
214 uni.hideLoading();
215 var filePath = res.tempFilePath;
216 uni.showLoading({
217 title: '正在打开'
218 });
219 uni.openDocument({
220 filePath: filePath,
221 showMenu: true,
222 success: function(res) {
223 uni.hideLoading();
224 },
225 fail: function(err) {
226 uni.hideLoading();
227 uni.showToast({
228 title: err,
229 icon: 'none',
230 duration: 2000
231 });
232 }
233 });
234 },
235 fail: function(error) {
236 uni.hideLoading();
237 uni.showToast({
238 title: `下载失败`,
239 icon: 'none',
240 duration: 2000
241 });
242 }
243 });
244 } 188 }
245 </script> 189 </script>
246 <style scoped lang="scss"> 190 <style scoped lang="scss">
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
82 <script setup> 82 <script setup>
83 import * as api from '@/common/api.js' 83 import * as api from '@/common/api.js'
84 import config from '@/config.js' 84 import config from '@/config.js'
85 import { fillImgUrl, isImageUrl } from '@/common/utils.js' 85 import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
86 import { 86 import {
87 onMounted, 87 onMounted,
88 ref 88 ref
...@@ -194,51 +194,12 @@ function circulation(id) { ...@@ -194,51 +194,12 @@ function circulation(id) {
194 api.queryProcess(id).then(res=>{ 194 api.queryProcess(id).then(res=>{
195 if (res.data.url) { 195 if (res.data.url) {
196 uni.hideLoading() 196 uni.hideLoading()
197 goWebView(fillImgUrl(res.data.url)) 197 previewAttachment(res.data.url, { title: '缴费通知单' })
198 } else { 198 } else {
199 circulation(id) 199 circulation(id)
200 } 200 }
201 }) 201 })
202 } 202 }
203 function goWebView(url) {
204 url = url.replace("http://", "https://")
205 uni.showLoading({
206 title: '下载中'
207 });
208 uni.downloadFile({
209 url: url,
210 success: function(res) {
211 uni.hideLoading();
212 var filePath = res.tempFilePath;
213 uni.showLoading({
214 title: '正在打开'
215 });
216 uni.openDocument({
217 filePath: filePath,
218 showMenu: true,
219 success: function(res) {
220 uni.hideLoading();
221 },
222 fail: function(err) {
223 uni.hideLoading();
224 uni.showToast({
225 title: err,
226 icon: 'none',
227 duration: 2000
228 });
229 }
230 });
231 },
232 fail: function(error) {
233 uni.hideLoading();
234 uni.showToast({
235 title: `下载失败`,
236 icon: 'none',
237 duration: 2000
238 });
239 }
240 });
241 }
242 203
243 function handleBack(row){ 204 function handleBack(row){
244 uni.showModal({ 205 uni.showModal({
...@@ -263,30 +224,11 @@ function handleBack(row){ ...@@ -263,30 +224,11 @@ function handleBack(row){
263 } 224 }
264 function viewSettleFile(item){ 225 function viewSettleFile(item){
265 if(item.payEvidence){ 226 if(item.payEvidence){
266 let file = JSON.parse(item.payEvidence) 227 let file = parseAttachmentJson(item.payEvidence)
267 console.log(file) 228 console.log(file)
268 showImg(file[0].url) 229 previewAttachment(file[0] || file, { title: '查看凭证' })
269 } 230 }
270 } 231 }
271 function showImg(n) {
272 const str = fillImgUrl(n)
273 if (isImageUrl(n) || isImageUrl(str)) {
274 uni.previewImage({
275 urls: [str],
276 success: function(res) {
277 console.log('success', res)
278 },
279 fail: function(res) {
280 console.log('fail', res)
281 },
282 complete: function(res) {
283 console.log('complete', res)
284 }
285 })
286 } else {
287 goWebView(str)
288 }
289 }
290 </script> 232 </script>
291 233
292 <style scoped lang="scss"> 234 <style scoped lang="scss">
......
...@@ -161,7 +161,7 @@ function getAuditResultText(result) { ...@@ -161,7 +161,7 @@ function getAuditResultText(result) {
161 } 161 }
162 162
163 function getIdcTypeText(type) { 163 function getIdcTypeText(type) {
164 const map = { 1: '身份证', 2: '护照', 3: '其他' } 164 const map = { 0: '身份证', 1: '护照', 2: '其他' }
165 return map[type] || '其他' 165 return map[type] || '其他'
166 } 166 }
167 167
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!