d7962027 by lttnew

上传图片

1 parent b6754440
...@@ -276,7 +276,7 @@ export function uploadImgCorpPhoto(tempFilePath) { ...@@ -276,7 +276,7 @@ export function uploadImgCorpPhoto(tempFilePath) {
276 title: '加载中' 276 title: '加载中'
277 }); 277 });
278 return uni.uploadFile({ 278 return uni.uploadFile({
279 url: config.baseUrl_api + '/upload/uploadImgToLocalServerCaiJian', 279 url: config.baseUrl_api + '/fileServer/uploadImgToMinioCaiJian',
280 header: { 280 header: {
281 'Authorization': uni.getStorageSync('token'), 281 'Authorization': uni.getStorageSync('token'),
282 }, 282 },
...@@ -479,7 +479,7 @@ export function uploadFile(e) { ...@@ -479,7 +479,7 @@ export function uploadFile(e) {
479 title: '加载中' 479 title: '加载中'
480 }); 480 });
481 return uni.uploadFile({ 481 return uni.uploadFile({
482 url: config.baseUrl_api + '/upload/uploadFileToLocalServer', 482 url: config.baseUrl_api + '/fileServer/uploadFile',
483 filePath: fileUrl, 483 filePath: fileUrl,
484 name: 'file', 484 name: 'file',
485 header: { 485 header: {
...@@ -487,6 +487,16 @@ export function uploadFile(e) { ...@@ -487,6 +487,16 @@ export function uploadFile(e) {
487 } 487 }
488 }).then(res => { 488 }).then(res => {
489 let data = JSON.parse(res.data); 489 let data = JSON.parse(res.data);
490 if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 300)) {
491 throw new Error(data.msg || '上传失败')
492 }
493 if (data.code && data.code !== 200) {
494 throw new Error(data.msg || '上传失败')
495 }
496 if (data.data) {
497 data.message = data.msg
498 data.msg = data.data
499 }
490 return data 500 return data
491 }).finally(() => { 501 }).finally(() => {
492 uni.hideLoading(); 502 uni.hideLoading();
...@@ -498,7 +508,7 @@ export function uploadFileList(path) { ...@@ -498,7 +508,7 @@ export function uploadFileList(path) {
498 title: '加载中' 508 title: '加载中'
499 }); 509 });
500 return uni.uploadFile({ 510 return uni.uploadFile({
501 url: config.baseUrl_api + '/upload/uploadFileToLocalServer', 511 url: config.baseUrl_api + '/fileServer/uploadFile',
502 filePath: path, 512 filePath: path,
503 name: 'file', 513 name: 'file',
504 header: { 514 header: {
...@@ -506,7 +516,13 @@ export function uploadFileList(path) { ...@@ -506,7 +516,13 @@ export function uploadFileList(path) {
506 } 516 }
507 }).then(res => { 517 }).then(res => {
508 let data = JSON.parse(res.data); 518 let data = JSON.parse(res.data);
509 return data.msg 519 if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 300)) {
520 throw new Error(data.msg || '上传失败')
521 }
522 if (data.code && data.code !== 200) {
523 throw new Error(data.msg || '上传失败')
524 }
525 return data.data || data.msg
510 }).finally(() => { 526 }).finally(() => {
511 uni.hideLoading(); 527 uni.hideLoading();
512 }); 528 });
......
1 import CryptoJS from 'crypto-js' 1 import CryptoJS from 'crypto-js'
2 import config from '@/config.js'
2 export function szToHz(num) { 3 export function szToHz(num) {
3 const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'] 4 const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
4 return hzArr[parseInt(num)] 5 return hzArr[parseInt(num)]
...@@ -39,3 +40,315 @@ export function AESDecrypt(str) { ...@@ -39,3 +40,315 @@ export function AESDecrypt(str) {
39 return aesStr 40 return aesStr
40 } 41 }
41 } 42 }
43
44 export function isDaoGuanRole() {
45 const app = getApp()
46 const deptType = app.globalData?.deptType
47 const userType = app.globalData?.userType
48 return deptType == null || deptType == 6 || deptType == '6' || userType == '4'
49 }
50
51 export function reLaunchHomeByRole() {
52 uni.reLaunch({
53 url: isDaoGuanRole() ? '/pages/index/daoGuanPerson' : '/pages/index/home'
54 })
55 }
56
57 export function fillImgUrl(url, prefix) {
58 if (!url) return ''
59 const trimmedUrl = String(url).trim()
60 if (!trimmedUrl) return ''
61 if (trimmedUrl === 'null' || trimmedUrl === 'undefined') return ''
62 if (trimmedUrl.startsWith('msr:')) {
63 return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${encodeURIComponent(trimmedUrl)}&downFlag=0`
64 }
65 if (/^(data:|https?:\/\/)/.test(trimmedUrl)) {
66 return trimmedUrl
67 }
68 const baseUrl = prefix
69 ? `${trimBaseUrl(config.baseUrl_api)}/${String(prefix).replace(/^\/+|\/+$/g, '')}`
70 : trimBaseUrl(config.baseUrl_api)
71 const path = trimmedUrl.startsWith('/') ? trimmedUrl : `/${trimmedUrl}`
72 return baseUrl + path
73 }
74
75 export function isImageUrl(url) {
76 const value = String(url || '').trim()
77 if (!value) return false
78 const decodedValue = safeDecodeURIComponent(value)
79 return /\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(decodedValue) ||
80 /[?&]file=[^&]*\.(png|jpe?g|gif|webp|bmp|svg)(&|$)/i.test(decodedValue)
81 }
82
83 export function getMemberPhotoValue(item = {}) {
84 return [item.photo, item.perPhoto, item.photo2, item.perPhoto2].find(isValidUrlValue) || ''
85 }
86
87 export function fillMemberPhoto(item = {}, fallback = '') {
88 const photo = getMemberPhotoValue(item)
89 return photo ? fillImgUrl(photo) : fallback
90 }
91
92 export async 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 const errorMsg = await checkAttachmentError(previewUrl)
105 if (errorMsg) {
106 uni.showToast({
107 title: errorMsg,
108 icon: 'none'
109 })
110 return
111 }
112 uni.previewImage({
113 urls: [previewUrl],
114 current: previewUrl,
115 fail: () => {
116 uni.showToast({
117 title: '图片预览失败',
118 icon: 'none'
119 })
120 }
121 })
122 return
123 }
124 if (getAttachmentExt(item) === 'zip') {
125 uni.showToast({
126 title: '压缩包暂不支持在线预览',
127 icon: 'none'
128 })
129 return
130 }
131 openDocumentAttachment(item, getAttachmentPreviewUrl(rawUrl, 0), false, options)
132 }
133
134 export function normalizeAttachment(file) {
135 if (Array.isArray(file)) return normalizeAttachment(file[0])
136 if (typeof file === 'string') {
137 const parsed = parseAttachmentJson(file)
138 if (parsed !== file) return normalizeAttachment(parsed)
139 return {
140 rawUrl: file,
141 url: file,
142 name: ''
143 }
144 }
145 if (file && typeof file === 'object') {
146 const rawUrl = file.rawUrl || file.url || file.fileUrl || file.path || ''
147 return {
148 ...file,
149 rawUrl,
150 url: rawUrl
151 }
152 }
153 return {}
154 }
155
156 export function parseAttachmentJson(value) {
157 if (!value || typeof value !== 'string') return value
158 try {
159 return JSON.parse(value)
160 } catch (e) {
161 return value
162 }
163 }
164
165 export function getAttachmentPreviewUrl(url, downFlag = 0) {
166 if (!url) return ''
167 const value = String(url).trim()
168 if (!value || value === 'null' || value === 'undefined') return ''
169 if (value.startsWith('msr:')) {
170 return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${encodeURIComponent(value)}&downFlag=${downFlag}`
171 }
172 return fillImgUrl(value)
173 }
174
175 function openDocumentAttachment(item, url, retried = false, options = {}) {
176 if (!url) {
177 uni.showToast({
178 title: '文件下载失败',
179 icon: 'none'
180 })
181 return
182 }
183 uni.showLoading({
184 title: '打开中',
185 mask: true
186 })
187 uni.downloadFile({
188 url,
189 header: {
190 Authorization: uni.getStorageSync('token')
191 },
192 success: res => {
193 if (res.statusCode && res.statusCode !== 200) {
194 if ((res.statusCode === 301 || res.statusCode === 302) && !retried) {
195 const redirectUrl = getRedirectUrl(res.header)
196 uni.hideLoading()
197 if (redirectUrl) {
198 openDocumentAttachment(item, redirectUrl, true, options)
199 } else {
200 uni.showToast({
201 title: '文件下载失败',
202 icon: 'none'
203 })
204 }
205 return
206 }
207 showAttachmentFailToast(url, '文件下载失败')
208 return
209 }
210 uni.openDocument({
211 filePath: res.tempFilePath,
212 fileType: getDocumentFileType(item),
213 showMenu: true,
214 fail: () => {
215 uni.showToast({
216 title: '文件暂不支持预览',
217 icon: 'none'
218 })
219 }
220 })
221 },
222 fail: () => {
223 showAttachmentFailToast(url, '文件下载失败')
224 },
225 complete: () => {
226 uni.hideLoading()
227 }
228 })
229 }
230
231 function openAttachmentWebView(url, title = '附件预览') {
232 if (!url) {
233 uni.showToast({
234 title: '文件下载失败',
235 icon: 'none'
236 })
237 return
238 }
239 uni.navigateTo({
240 url: `/pages/webview/webview?title=${encodeURIComponent(title)}&url=${encodeURIComponent(url)}`,
241 fail: () => {
242 uni.showToast({
243 title: '附件预览失败',
244 icon: 'none'
245 })
246 }
247 })
248 }
249
250 function getAttachmentExt(file) {
251 const name = `${file?.extname || file?.name || file?.rawUrl || file?.url || file || ''}`
252 const fileParam = getQueryParam(name, 'file')
253 const cleanName = safeDecodeURIComponent(fileParam || name).split('?')[0].split('#')[0]
254 const fileName = cleanName.split('/').pop() || cleanName
255 const ext = fileName.includes('.') ? fileName.split('.').pop() : fileName
256 return ext.toLowerCase()
257 }
258
259 function checkAttachmentError(url) {
260 if (!isFileDownloadUrl(url)) return Promise.resolve('')
261 return new Promise(resolve => {
262 uni.request({
263 url,
264 method: 'GET',
265 header: {
266 Authorization: uni.getStorageSync('token') || ''
267 },
268 success: res => {
269 const data = parseAttachmentResponse(res.data)
270 if (res.statusCode >= 400 || (data && data.code && data.code !== 200)) {
271 resolve(getAttachmentErrorMsg(data))
272 return
273 }
274 resolve('')
275 },
276 fail: () => resolve('')
277 })
278 })
279 }
280
281 async function showAttachmentFailToast(url, fallback) {
282 const errorMsg = await checkAttachmentError(url)
283 uni.showToast({
284 title: errorMsg || fallback,
285 icon: 'none'
286 })
287 }
288
289 function parseAttachmentResponse(data) {
290 if (!data) return null
291 if (typeof data === 'object') return data
292 if (typeof data === 'string') {
293 try {
294 return JSON.parse(data)
295 } catch (e) {
296 return null
297 }
298 }
299 return null
300 }
301
302 function getAttachmentErrorMsg(data) {
303 const msg = data?.msg || data?.message || ''
304 if (!msg) return '附件预览失败'
305 if (msg.includes('Hostname') || msg.includes('certificate')) {
306 return '附件服务证书异常,请稍后再试'
307 }
308 return msg.length > 40 ? msg.slice(0, 40) : msg
309 }
310
311 function isAttachmentImage(file) {
312 return ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'svg'].includes(getAttachmentExt(file))
313 }
314
315 function getDocumentFileType(file) {
316 const ext = getAttachmentExt(file)
317 const types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
318 return types.includes(ext) ? ext : undefined
319 }
320
321 function getRedirectUrl(header = {}) {
322 const location = header.Location || header.location
323 if (!location) return ''
324 if (/^https?:\/\//.test(location)) return location
325 return `${trimBaseUrl(config.baseUrl_api)}/${String(location).replace(/^\/+/, '')}`
326 }
327
328 function isFileDownloadUrl(url) {
329 const value = String(url || '')
330 return value.includes('/fileServer/download') || value.startsWith('fileServer/download')
331 }
332
333 function getQueryParam(url, key) {
334 const match = String(url || '').match(new RegExp(`[?&]${key}=([^&#]+)`))
335 return match ? safeDecodeURIComponent(match[1]) : ''
336 }
337
338 function isValidUrlValue(value) {
339 if (value === undefined || value === null) return false
340 const url = String(value).trim()
341 return url !== '' && url !== 'null' && url !== 'undefined'
342 }
343
344 function trimBaseUrl(url) {
345 return String(url || '').replace(/\/+$/, '')
346 }
347
348 function safeDecodeURIComponent(value) {
349 try {
350 return decodeURIComponent(value)
351 } catch (e) {
352 return value
353 }
354 }
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
7 // const baseUrl_api = "https://ztx.itechtop.cn:8443/stage-api"; 7 // const baseUrl_api = "https://ztx.itechtop.cn:8443/stage-api";
8 // const baseUrl_api = 'http://192.168.1.132:8787' 8 // const baseUrl_api = 'http://192.168.1.132:8787'
9 // const baseUrl_api = 'https://tkcn.19wk.cn:8443/stage-api' 9 // const baseUrl_api = 'https://tkcn.19wk.cn:8443/stage-api'
10 const baseUrl_api = 'https://tk001.wxjylt.com/stage-api' 10 const baseUrl_api = 'https://tk001.wxjylt.com/stage-api' //测试环境
11 // const baseUrl_api = 'https://system.taekwondo.org.cn/stage-api' //会员生产
11 // const baseUrl_api = 'https://system.taekwondo.org.cn/stage-api' 12 // const baseUrl_api = 'https://system.taekwondo.org.cn/stage-api'
12 export default { 13 export default {
13 baseUrl_api 14 baseUrl_api
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
111 <script setup> 111 <script setup>
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 { fillImgUrl } from '@/common/utils.js'
114 import { 115 import {
115 onMounted, 116 onMounted,
116 ref 117 ref
...@@ -310,11 +311,7 @@ ...@@ -310,11 +311,7 @@
310 } 311 }
311 function showImg(n) { 312 function showImg(n) {
312 var str = '' 313 var str = ''
313 if(n.indexOf('http')==-1){ 314 str = fillImgUrl(n)
314 str = config.baseUrl_api + n
315 } else {
316 str = n
317 }
318 315
319 if (n.indexOf('png') > -1 || n.indexOf('jpg') > -1 || n.indexOf( 316 if (n.indexOf('png') > -1 || n.indexOf('jpg') > -1 || n.indexOf(
320 'jpeg') > -1) { 317 'jpeg') > -1) {
......
...@@ -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 config from '@/config.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 var str = config.baseUrl_api + n.fileUrl[0]?.url 71 previewAttachment(n.fileUrl, { title: '查看附件' })
72 if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
73 'jpeg') > -1) {
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">
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
37 <script setup> 37 <script setup>
38 import * as api from '@/common/api.js' 38 import * as api from '@/common/api.js'
39 import config from '@/config.js' 39 import config from '@/config.js'
40 import { fillImgUrl } from '@/common/utils.js'
40 import { 41 import {
41 ref, 42 ref,
42 getCurrentInstance 43 getCurrentInstance
...@@ -72,9 +73,7 @@ ...@@ -72,9 +73,7 @@
72 paging.value.complete(res.rows) 73 paging.value.complete(res.rows)
73 list.value = res.rows 74 list.value = res.rows
74 for(var l of list.value){ 75 for(var l of list.value){
75 if(l.photo&&l.photo.indexOf('http')==-1){ 76 l.photo = fillImgUrl(l.photo)
76 l.photo = config.baseUrl_api + l.photo
77 }
78 } 77 }
79 }) 78 })
80 } 79 }
...@@ -87,9 +86,7 @@ ...@@ -87,9 +86,7 @@
87 paging.value.complete(res.rows); 86 paging.value.complete(res.rows);
88 list.value = res.rows 87 list.value = res.rows
89 for(var l of list.value){ 88 for(var l of list.value){
90 if(l.photo&&l.photo.indexOf('http')==-1){ 89 l.photo = fillImgUrl(l.photo)
91 l.photo = config.baseUrl_api + l.photo
92 }
93 } 90 }
94 total.value = res.total 91 total.value = res.total
95 }) 92 })
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
61 </view> 61 </view>
62 </view> 62 </view>
63 <view class="nodata" v-if="list.length==0"> 63 <view class="nodata" v-if="list.length==0">
64 <image mode="aspectFit" src="/static/nodata.png"></image> 64 <image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
65 <text>暂无数据</text> 65 <text>暂无数据</text>
66 </view> 66 </view>
67 67
...@@ -92,6 +92,7 @@ ...@@ -92,6 +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 { previewAttachment } from '@/common/utils.js'
95 import { 96 import {
96 onMounted, 97 onMounted,
97 ref 98 ref
...@@ -214,66 +215,7 @@ function goDetail(item) { ...@@ -214,66 +215,7 @@ function goDetail(item) {
214 215
215 function downloadOrder(item) { 216 function downloadOrder(item) {
216 //下载凭证 217 //下载凭证
217 showImg(item.payEvidence[0]?.url) 218 previewAttachment(item.payEvidence?.[0] || item.payEvidence, { title: '查看凭证' })
218 }
219 function showImg(url) {
220 var str = config.baseUrl_api + url
221 if (url.indexOf('png') > -1 || url.indexOf('jpg') > -1 || url.indexOf('jpeg') > -1) {
222 uni.previewImage({
223 urls: [str],
224 success: function(res) {
225 console.log('success', res)
226 },
227 fail: function(res) {
228 console.log('fail', res)
229 },
230 complete: function(res) {
231 console.log('complete', res)
232 }
233 })
234 } else {
235 goWebView(str)
236 }
237 }
238
239 function goWebView(url) {
240 url = url.replace("http://", "https://")
241 uni.showLoading({
242 title: '下载中'
243 });
244 uni.downloadFile({
245 url: url,
246 success: function(res) {
247 uni.hideLoading();
248 var filePath = res.tempFilePath;
249 uni.showLoading({
250 title: '正在打开'
251 });
252 uni.openDocument({
253 filePath: filePath,
254 showMenu: true,
255 success: function(res) {
256 uni.hideLoading();
257 },
258 fail: function(err) {
259 uni.hideLoading();
260 uni.showToast({
261 title: err,
262 icon: 'none',
263 duration: 2000
264 });
265 }
266 });
267 },
268 fail: function(error) {
269 uni.hideLoading();
270 uni.showToast({
271 title: `下载失败`,
272 icon: 'none',
273 duration: 2000
274 });
275 }
276 });
277 } 219 }
278 220
279 </script> 221 </script>
...@@ -293,3 +235,4 @@ function goWebView(url) { ...@@ -293,3 +235,4 @@ function goWebView(url) {
293 } 235 }
294 } 236 }
295 </style> 237 </style>
238
......
...@@ -101,8 +101,8 @@ ...@@ -101,8 +101,8 @@
101 101
102 <script setup> 102 <script setup>
103 import * as api from '@/common/api.js' 103 import * as api from '@/common/api.js'
104 import config from '@/config.js'
105 import _ from 'underscore' 104 import _ from 'underscore'
105 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
106 import { 106 import {
107 onMounted, 107 onMounted,
108 ref 108 ref
...@@ -153,6 +153,11 @@ ...@@ -153,6 +153,11 @@
153 }catch(e){ 153 }catch(e){
154 form.value.businessLicenseArr=[{url:form.value.businessLicense,name:'营业执照'}] 154 form.value.businessLicenseArr=[{url:form.value.businessLicense,name:'营业执照'}]
155 } 155 }
156 form.value.businessLicenseArr = form.value.businessLicenseArr.map(item => ({
157 ...item,
158 rawUrl: item.url,
159 url: fillImgUrl(item.url)
160 }))
156 console.log('营业执照',form.value.businessLicenseArr) 161 console.log('营业执照',form.value.businessLicenseArr)
157 } 162 }
158 if (form.value.certBusinessLicense) { 163 if (form.value.certBusinessLicense) {
...@@ -162,19 +167,18 @@ ...@@ -162,19 +167,18 @@
162 }catch(e){ 167 }catch(e){
163 form.value.businessLicenseArrR=[{url:form.value.certBusinessLicense,name:'营业执照'}] 168 form.value.businessLicenseArrR=[{url:form.value.certBusinessLicense,name:'营业执照'}]
164 } 169 }
170 form.value.businessLicenseArrR = form.value.businessLicenseArrR.map(item => ({
171 ...item,
172 rawUrl: item.url,
173 url: fillImgUrl(item.url)
174 }))
165 console.log('营业执照',form.value.businessLicenseArrR) 175 console.log('营业执照',form.value.businessLicenseArrR)
166 } 176 }
167 if (form.value.certLegalIdcPhoto && form.value.certLegalIdcPhoto!=null) { 177 if (form.value.certLegalIdcPhoto && form.value.certLegalIdcPhoto!=null) {
168 form.value.legalIdcPhotoArr = [] 178 form.value.legalIdcPhotoArr = []
169 var arr = form.value.certLegalIdcPhoto?.split(',') || [] 179 var arr = form.value.certLegalIdcPhoto?.split(',') || []
170 if (arr.length > 0) { 180 if (arr.length > 0) {
171 arr = _.map(arr, (p) => { 181 arr = _.map(arr, (p) => fillImgUrl(p))
172 if(p.indexOf('http')==-1){
173 console.log(p)
174 p = config.baseUrl_api + p
175 }
176 return p
177 })
178 form.value.legalIdcPhotoArr = arr 182 form.value.legalIdcPhotoArr = arr
179 } 183 }
180 } 184 }
...@@ -182,13 +186,7 @@ ...@@ -182,13 +186,7 @@
182 form.value.legalIdcPhotoArrR = [] 186 form.value.legalIdcPhotoArrR = []
183 var arr = form.value.legalIdcPhoto?.split(',') || [] 187 var arr = form.value.legalIdcPhoto?.split(',') || []
184 if (arr.length > 0) { 188 if (arr.length > 0) {
185 arr = _.map(arr, (p) => { 189 arr = _.map(arr, (p) => fillImgUrl(p))
186 if(p.indexOf('http')==-1){
187 console.log(p)
188 p = config.baseUrl_api + p
189 }
190 return p
191 })
192 form.value.legalIdcPhotoArrR = arr 190 form.value.legalIdcPhotoArrR = arr
193 } 191 }
194 } 192 }
...@@ -197,12 +195,7 @@ ...@@ -197,12 +195,7 @@
197 form.value.picturesArr = [] 195 form.value.picturesArr = []
198 var arr = form.value.certPictures.split(',') || [] 196 var arr = form.value.certPictures.split(',') || []
199 if (arr.length > 0) { 197 if (arr.length > 0) {
200 arr = _.map(arr, (p) => { 198 arr = _.map(arr, (p) => fillImgUrl(p))
201 if(p.indexOf('http')==-1){
202 p = config.baseUrl_api + p
203 }
204 return p
205 })
206 form.value.picturesArr = arr 199 form.value.picturesArr = arr
207 } 200 }
208 console.log(form.value.picturesArr) 201 console.log(form.value.picturesArr)
...@@ -211,12 +204,7 @@ ...@@ -211,12 +204,7 @@
211 form.value.picturesArrR = [] 204 form.value.picturesArrR = []
212 var arr = form.value.pictures.split(',') || [] 205 var arr = form.value.pictures.split(',') || []
213 if (arr.length > 0) { 206 if (arr.length > 0) {
214 arr = _.map(arr, (p) => { 207 arr = _.map(arr, (p) => fillImgUrl(p))
215 if(p.indexOf('http')==-1){
216 p = config.baseUrl_api + p
217 }
218 return p
219 })
220 form.value.picturesArrR = arr 208 form.value.picturesArrR = arr
221 } 209 }
222 console.log(form.value.picturesArrR) 210 console.log(form.value.picturesArrR)
...@@ -248,70 +236,7 @@ ...@@ -248,70 +236,7 @@
248 } 236 }
249 237
250 function download(url) { 238 function download(url) {
251 console.log(url) 239 previewAttachment(url, { title: '查看附件' })
252 if (url.indexOf('.png') > -1 || url.indexOf('.jpg') > -1) {
253 if(url.indexOf('http')>-1){
254 uni.previewImage({
255 urls: [url],
256 success: function(res) {
257 console.log(res,[url],'111')
258 }
259 })
260 } else {
261 uni.previewImage({
262 urls: [config.baseUrl_api + url],
263 success: function(res) {
264 console.log(url,'222')
265 }
266 })
267 }
268 } else {
269 if(url.indexOf('http')>-1){
270 goWebView(url)
271 } else {
272 goWebView(config.baseUrl_api + url)
273 }
274 }
275 }
276
277 function goWebView(url) {
278 url = url.replace("http://", "https://")
279 uni.showLoading({
280 title: '下载中'
281 });
282 uni.downloadFile({
283 url: url,
284 success: function(res) {
285 uni.hideLoading();
286 var filePath = res.tempFilePath;
287 uni.showLoading({
288 title: '正在打开'
289 });
290 uni.openDocument({
291 filePath: filePath,
292 showMenu: true,
293 success: function(res) {
294 uni.hideLoading();
295 },
296 fail: function(err) {
297 uni.hideLoading();
298 uni.showToast({
299 title: err,
300 icon: 'none',
301 duration: 2000
302 });
303 }
304 });
305 },
306 fail: function(error) {
307 uni.hideLoading();
308 uni.showToast({
309 title:`下载失败`,
310 icon: 'none',
311 duration: 2000
312 });
313 }
314 });
315 } 240 }
316 </script> 241 </script>
317 242
......
...@@ -173,6 +173,7 @@ ...@@ -173,6 +173,7 @@
173 onShow 173 onShow
174 } from '@dcloudio/uni-app'; 174 } from '@dcloudio/uni-app';
175 import config from '@/config.js' 175 import config from '@/config.js'
176 import { fillImgUrl } from '@/common/utils.js'
176 import dayjs from 'dayjs' 177 import dayjs from 'dayjs'
177 import _ from 'underscore' 178 import _ from 'underscore'
178 const app = getApp(); 179 const app = getApp();
...@@ -422,9 +423,7 @@ ...@@ -422,9 +423,7 @@
422 studentList.value = response.rows 423 studentList.value = response.rows
423 for (var s of studentList.value) { 424 for (var s of studentList.value) {
424 s.checked = false 425 s.checked = false
425 if (s.photo && s.photo.indexOf('http') == -1) { 426 s.photo = fillImgUrl(s.photo)
426 s.photo = config.baseUrl_api + s.photo
427 }
428 427
429 } 428 }
430 uni.hideLoading() 429 uni.hideLoading()
...@@ -485,9 +484,7 @@ ...@@ -485,9 +484,7 @@
485 if (!d.isPass) { 484 if (!d.isPass) {
486 d.isPass = '1' 485 d.isPass = '1'
487 } 486 }
488 if (d.photo && d.photo.indexOf('http') == -1) { 487 d.photo = fillImgUrl(d.photo)
489 d.photo = config.baseUrl_api + d.photo
490 }
491 }) 488 })
492 489
493 infoList.value = res.rows 490 infoList.value = res.rows
......
...@@ -112,8 +112,8 @@ ...@@ -112,8 +112,8 @@
112 infoList.value.push(item) 112 infoList.value.push(item)
113 }) 113 })
114 console.log(infoList.value) 114 console.log(infoList.value)
115 form.value.totalNum = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalNum || 0))) 115 form.value.totalNum = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalNum || 0), 0))
116 form.value.totalAmount = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalAmount || 0))) 116 form.value.totalAmount = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalAmount || 0), 0))
117 117
118 uni.hideLoading() 118 uni.hideLoading()
119 119
......
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
115 <script setup> 115 <script setup>
116 import * as api from '@/common/api.js' 116 import * as api from '@/common/api.js'
117 import config from '@/config.js' 117 import config from '@/config.js'
118 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
118 import * as loginServer from '@/common/login.js'; 119 import * as loginServer from '@/common/login.js';
119 120
120 import _ from 'underscore' 121 import _ from 'underscore'
...@@ -203,9 +204,17 @@ ...@@ -203,9 +204,17 @@
203 if (form.value.businessLicense) { 204 if (form.value.businessLicense) {
204 form.value.businessLicenseArr = [] 205 form.value.businessLicenseArr = []
205 try{ 206 try{
206 form.value.businessLicenseArr = JSON.parse(form.value.businessLicense) || [] 207 const parsed = JSON.parse(form.value.businessLicense) || []
208 form.value.businessLicenseArr = parsed.map(item => ({
209 ...item,
210 name: item.name || '营业执照',
211 url: fillImgUrl(item.url || item.rawUrl || form.value.businessLicense)
212 }))
207 }catch(e){ 213 }catch(e){
208 form.value.businessLicenseArr=[{url:form.value.businessLicense,name:'营业执照'}] 214 form.value.businessLicenseArr=[{
215 url: fillImgUrl(form.value.businessLicense),
216 name: '营业执照'
217 }]
209 } 218 }
210 console.log('营业执照',form.value.businessLicenseArr) 219 console.log('营业执照',form.value.businessLicenseArr)
211 } 220 }
...@@ -213,13 +222,7 @@ ...@@ -213,13 +222,7 @@
213 form.value.legalIdcPhotoArr = [] 222 form.value.legalIdcPhotoArr = []
214 var arr = form.value.certLegalIdcPhoto?.split(',') || [] 223 var arr = form.value.certLegalIdcPhoto?.split(',') || []
215 if (arr.length > 0) { 224 if (arr.length > 0) {
216 arr = _.map(arr, (p) => { 225 arr = _.map(arr, (p) => fillImgUrl(p))
217 if(p.indexOf('http')==-1){
218 console.log(p)
219 p = config.baseUrl_api + p
220 }
221 return p
222 })
223 form.value.legalIdcPhotoArr = arr 226 form.value.legalIdcPhotoArr = arr
224 } 227 }
225 console.log('法人身份证',form.value.legalIdcPhotoArr) 228 console.log('法人身份证',form.value.legalIdcPhotoArr)
...@@ -228,12 +231,7 @@ ...@@ -228,12 +231,7 @@
228 form.value.picturesArr = [] 231 form.value.picturesArr = []
229 var arr = form.value.certPictures.split(',') || [] 232 var arr = form.value.certPictures.split(',') || []
230 if (arr.length > 0) { 233 if (arr.length > 0) {
231 arr = _.map(arr, (p) => { 234 arr = _.map(arr, (p) => fillImgUrl(p))
232 if(p.indexOf('http')==-1){
233 p = config.baseUrl_api + p
234 }
235 return p
236 })
237 form.value.picturesArr = arr 235 form.value.picturesArr = arr
238 } 236 }
239 console.log(form.value.picturesArr) 237 console.log(form.value.picturesArr)
...@@ -258,29 +256,7 @@ ...@@ -258,29 +256,7 @@
258 } 256 }
259 257
260 function download(url) { 258 function download(url) {
261 console.log(url) 259 previewAttachment(url, { title: '查看营业执照' })
262 if (url.indexOf('.png') > -1 || url.indexOf('.jpg') > -1) {
263 if(url.indexOf('http')>-1){
264 uni.previewImage({
265 urls: [url],
266 success: function(res) {
267
268 }
269 })
270 } else {
271 uni.previewImage({
272 urls: [config.baseUrl_api + url],
273 success: function(res) {
274 }
275 })
276 }
277 } else {
278 if(url.indexOf('http')>-1){
279 goWebView(url)
280 } else {
281 goWebView(config.baseUrl_api + url)
282 }
283 }
284 } 260 }
285 261
286 function goWebView(url) { 262 function goWebView(url) {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
37 import * as api from '@/common/api.js'; 37 import * as api from '@/common/api.js';
38 import * as loginServer from '@/common/login.js'; 38 import * as loginServer from '@/common/login.js';
39 import config from '@/config.js' 39 import config from '@/config.js'
40 import { fillImgUrl } from '@/common/utils.js'
40 import { 41 import {
41 onLoad, 42 onLoad,
42 onShow, 43 onShow,
...@@ -107,9 +108,7 @@ function loginOut() { ...@@ -107,9 +108,7 @@ function loginOut() {
107 function getUser() { 108 function getUser() {
108 api.getUserProfile().then((response) => { 109 api.getUserProfile().then((response) => {
109 state.user = response.data.user 110 state.user = response.data.user
110 if(state.user.avatar&&state.user.avatar.indexOf('http')==-1){ 111 state.user.avatar = fillImgUrl(state.user.avatar)
111 state.user.avatar = config.baseUrl_api+state.user.avatar
112 }
113 state.roleGroup = response.data.roleGroup 112 state.roleGroup = response.data.roleGroup
114 state.postGroup = response.data.postGroup 113 state.postGroup = response.data.postGroup
115 uni.hideLoading(); 114 uni.hideLoading();
......
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
103 onShow 103 onShow
104 } from '@dcloudio/uni-app'; 104 } from '@dcloudio/uni-app';
105 import config from '@/config.js' 105 import config from '@/config.js'
106 import { fillImgUrl } from '@/common/utils.js'
106 const app = getApp(); 107 const app = getApp();
107 const form = ref({ 108 const form = ref({
108 type: '1', 109 type: '1',
...@@ -242,12 +243,8 @@ ...@@ -242,12 +243,8 @@
242 if(form.value.legalIdcPhoto){ 243 if(form.value.legalIdcPhoto){
243 legalIdcPhoto1.value = form.value.legalIdcPhoto.split(',')?.[0] || '' 244 legalIdcPhoto1.value = form.value.legalIdcPhoto.split(',')?.[0] || ''
244 legalIdcPhoto2.value = form.value.legalIdcPhoto.split(',')?.[1] || '' 245 legalIdcPhoto2.value = form.value.legalIdcPhoto.split(',')?.[1] || ''
245 if(legalIdcPhoto1.value.indexOf('http')==-1){ 246 legalIdcPhoto1.value = fillImgUrl(legalIdcPhoto1.value)
246 legalIdcPhoto1.value = config.baseUrl_api + legalIdcPhoto1.value 247 legalIdcPhoto2.value = fillImgUrl(legalIdcPhoto2.value)
247 }
248 if(legalIdcPhoto2.value.indexOf('http')==-1){
249 legalIdcPhoto2.value = config.baseUrl_api + legalIdcPhoto2.value
250 }
251 imgfront.value = { 248 imgfront.value = {
252 url: legalIdcPhoto1.value, 249 url: legalIdcPhoto1.value,
253 name: '身份证正面', 250 name: '身份证正面',
...@@ -265,9 +262,7 @@ ...@@ -265,9 +262,7 @@
265 var arr = form.value.pictures.split(',') || [] 262 var arr = form.value.pictures.split(',') || []
266 if (arr.length > 0) { 263 if (arr.length > 0) {
267 arr = _.map(arr, (p) => { 264 arr = _.map(arr, (p) => {
268 if(p.indexOf('http')==-1){ 265 p = fillImgUrl(p)
269 p = config.baseUrl_api + p
270 }
271 var obj = { 266 var obj = {
272 url: p, 267 url: p,
273 name: '图片', 268 name: '图片',
...@@ -482,10 +477,17 @@ ...@@ -482,10 +477,17 @@
482 return 477 return
483 } 478 }
484 uni.showLoading({ 479 uni.showLoading({
485 title: '加载中' 480 title: '上传中'
481 })
482 uploadMinioImage(imgUrl).then(url => {
483 legalIdcPhoto1.value = url
484 uni.hideLoading()
485 }).catch(err => {
486 uni.hideLoading()
487 uni.showToast({
488 title: '上传失败',
489 icon: 'none'
486 }) 490 })
487 api.uploadImg(e).then(data => {
488 legalIdcPhoto1.value = data.msg
489 }) 491 })
490 } 492 }
491 493
...@@ -496,10 +498,17 @@ ...@@ -496,10 +498,17 @@
496 return 498 return
497 } 499 }
498 uni.showLoading({ 500 uni.showLoading({
499 title: '加载中' 501 title: '上传中'
502 })
503 uploadMinioImage(imgUrl).then(url => {
504 legalIdcPhoto2.value = url
505 uni.hideLoading()
506 }).catch(err => {
507 uni.hideLoading()
508 uni.showToast({
509 title: '上传失败',
510 icon: 'none'
500 }) 511 })
501 api.uploadImg(e).then(data => {
502 legalIdcPhoto2.value = data.msg
503 }) 512 })
504 } 513 }
505 514
...@@ -521,19 +530,31 @@ ...@@ -521,19 +530,31 @@
521 if (!file) { 530 if (!file) {
522 return 531 return
523 } 532 }
524 api.uploadFile(e).then(data => { 533 const filePath = file.url || file.path || e.tempFilePaths?.[0]
534 uni.showLoading({
535 title: '上传中'
536 })
537 uploadMinioImage(filePath).then(url => {
525 selectFileValue = { 538 selectFileValue = {
526 url: data.msg, 539 url: url,
527 name: file.name, 540 name: file.name,
528 extname: file.extname 541 extname: file.extname
529 } 542 }
530 form.value.businessLicense = JSON.stringify([selectFileValue]) 543 form.value.businessLicense = JSON.stringify([selectFileValue])
531 console.log(selectFileValue,form.value.businessLicense) 544 console.log(selectFileValue,form.value.businessLicense)
545 uni.hideLoading()
546 }).catch(err => {
547 uni.hideLoading()
548 uni.showToast({
549 title: '上传失败',
550 icon: 'none'
551 })
532 }) 552 })
533 } 553 }
534 554
535 function delSupplementFile() { 555 function delSupplementFile() {
536 selectFileValue = {} 556 selectFileValue = {}
557 form.value.businessLicense = ''
537 } 558 }
538 559
539 function upPicArr(e) { 560 function upPicArr(e) {
...@@ -543,20 +564,58 @@ ...@@ -543,20 +564,58 @@
543 return 564 return
544 } 565 }
545 uni.showLoading({ 566 uni.showLoading({
546 title: '加载中' 567 title: '上传中'
568 })
569 Promise.all(tempFilePaths.slice(0, 3).map(path => uploadMinioImage(path))).then(urls => {
570 picArr.value.push(...urls.filter(Boolean))
571 form.value.pictures = picArr.value.join(',')
572 uni.hideLoading()
573 }).catch(err => {
574 uni.hideLoading()
575 uni.showToast({
576 title: '上传失败',
577 icon: 'none'
547 }) 578 })
548 api.uploadImg(e).then(data => {
549 picArr.value.push(data.msg)
550 // form.value.pictures
551 console.log(picArr.value)
552 }) 579 })
553 } 580 }
554 581
555 function delpicArr(e) { 582 function delpicArr(e) {
556 picArr.value.splice(e.index, 1) 583 picArr.value.splice(e.index, 1)
584 form.value.pictures = picArr.value.join(',')
557 console.log(picArr.value, picArrR.value) 585 console.log(picArr.value, picArrR.value)
558 } 586 }
559 587
588 function uploadMinioImage(filePath) {
589 return new Promise((resolve, reject) => {
590 if (!filePath) return reject(new Error('请选择图片'))
591 uni.uploadFile({
592 url: config.baseUrl_api + '/fileServer/uploadImg',
593 filePath,
594 name: 'image',
595 header: {
596 'Authorization': uni.getStorageSync('token')
597 },
598 success: (res) => {
599 try {
600 const data = JSON.parse(res.data || '{}')
601 const url = getUploadUrl(data)
602 if (!url) return reject(new Error('上传返回数据异常'))
603 resolve(url)
604 } catch (e) {
605 reject(e)
606 }
607 },
608 fail: reject
609 })
610 })
611 }
612
613 function getUploadUrl(res) {
614 const data = res?.data
615 if (typeof data === 'string') return data
616 return data?.ms || data?.url || data?.fang || res?.msg || ''
617 }
618
560 619
561 function bindChange(e) { 620 function bindChange(e) {
562 console.log(e) 621 console.log(e)
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
10 <view v-html="form.content"></view> 10 <view v-html="form.content"></view>
11 11
12 <view v-if="attachmentMp4.length>0"> 12 <view v-if="attachmentMp4.length>0">
13 <video v-for="(f,index) in attachmentMp4" :key="index" controls :src="config.baseUrl_api + f.url"></video> 13 <video v-for="(f,index) in attachmentMp4" :key="index" controls
14 :src="fillImgUrl(f.url)"></video>
14 </view> 15 </view>
15 <view v-if="attachmentFile.length>0" class="mt20"> 16 <view v-if="attachmentFile.length>0" class="mt20">
16 <!-- 附件--> 17 <!-- 附件-->
...@@ -37,10 +38,10 @@ ...@@ -37,10 +38,10 @@
37 onLoad 38 onLoad
38 } from '@dcloudio/uni-app'; 39 } from '@dcloudio/uni-app';
39 import _ from 'underscore' 40 import _ from 'underscore'
40 import config from '@/config.js' 41 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
41 const form = ref({}) 42 const form = ref({})
42 const attachmentFile = ref([]) 43 const attachmentFile = ref([])
43 const attachmentMp4 = ref([]) 44 const attachmentMp4 = ref([])
44 45
45 onLoad((option) => { 46 onLoad((option) => {
46 getData(option.noteId) 47 getData(option.noteId)
...@@ -58,78 +59,15 @@ const attachmentMp4 = ref([]) ...@@ -58,78 +59,15 @@ const attachmentMp4 = ref([])
58 59
59 if (form.value.attacthJson) { 60 if (form.value.attacthJson) {
60 const attachment = JSON.parse(form.value.attacthJson) 61 const attachment = JSON.parse(form.value.attacthJson)
61 attachmentFile.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') === -1) || [] 62 attachmentFile.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') === -1) ||
63 []
62 attachmentMp4.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') !== -1) || [] 64 attachmentMp4.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') !== -1) || []
63 } 65 }
64 }) 66 })
65 } 67 }
66 function downLoad(url){ 68
67 console.log(url) 69 function downLoad(url) {
68 var str = config.baseUrl_api + url 70 previewAttachment(url, { title: '附件预览' })
69 if (url.indexOf('png') > -1 ||url.indexOf('jpg') > -1 ||url.indexOf('jpeg') > -1) {
70 uni.previewImage({
71 urls: [str],
72 success: function(res) {
73 console.log('success', res)
74 },
75 fail: function(res) {
76 console.log('fail', res)
77 },
78 complete: function(res) {
79 console.log('complete', res)
80 }
81 })
82 } else {
83 goWebView(str)
84 }
85 }
86 function goWebView(url) {
87 url = url.replace("http://", "https://")
88 uni.showLoading({
89 title: '下载中'
90 });
91 uni.downloadFile({
92 url: url,
93 success: function(res) {
94 console.log('111')
95 uni.hideLoading();
96 var filePath = res.tempFilePath;
97 uni.showLoading({
98 title: '正在打开'
99 });
100 uni.openDocument({
101 filePath: filePath,
102 showMenu: true,
103 success: function(res) {
104 console.log('222')
105 uni.hideLoading();
106 },
107 fail: function(err) {
108 console.log(err.errMsg)
109 uni.hideLoading();
110 let msg
111 if(err.errMsg.indexOf('not supported')>-1){
112 msg = '不支持该文件类型'
113 } else {
114 msg = err.errMsg
115 }
116 uni.showToast({
117 title: msg,
118 icon: 'none',
119 duration: 2000
120 });
121 }
122 });
123 },
124 fail: function(error) {
125 uni.hideLoading();
126 uni.showToast({
127 title: `下载失败`,
128 icon: 'none',
129 duration: 2000
130 });
131 }
132 });
133 } 71 }
134 </script> 72 </script>
135 73
...@@ -178,7 +116,9 @@ const attachmentMp4 = ref([]) ...@@ -178,7 +116,9 @@ const attachmentMp4 = ref([])
178 word-wrap: break-word !important; 116 word-wrap: break-word !important;
179 white-space: normal !important; 117 white-space: normal !important;
180 } 118 }
181 .content rich-text img{max-width: 100%;} 119 .content rich-text img {
120 max-width: 100%;
121 }
182 122
183 image { 123 image {
184 max-width: 100%; 124 max-width: 100%;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
25 </view> 25 </view>
26 <view class="ddd" v-if="userType=='2'||userType=='1'"> 26 <view class="ddd" v-if="userType=='2'||userType=='1'">
27 <text class="lab">总金额:</text> 27 <text class="lab">总金额:</text>
28 <text class="text-danger">¥{{(form.totalAmount*1).toFixed(2) }}</text> 28 <text class="text-danger">¥{{ form.totalAmount? (form.totalAmount*1).toFixed(2) : '0' }}</text>
29 </view> 29 </view>
30 </view> 30 </view>
31 <view class="wBox"> 31 <view class="wBox">
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
64 <uni-forms-item label="头像" required> 64 <uni-forms-item label="头像" required>
65 <uni-file-picker v-model="photoArr" @delete="delPhoto" return-type="object" limit="1" 65 <uni-file-picker v-model="photoArr" @delete="delPhoto" return-type="object" limit="1"
66 @select="upPhoto" :del-ico="false" :image-styles="imageStylesTx"></uni-file-picker> 66 @select="upPhoto" :del-ico="false" :image-styles="imageStylesTx"></uni-file-picker>
67 <image mode="aspectFill" v-if="baseFormData.photo2" style="height:200rpx;width:200rpx;" :src="config.baseUrl_api + baseFormData.photo2"/> 67 <!-- <image mode="aspectFill" v-if="baseFormData.photo2" style="height:200rpx;width:200rpx;" :src="fillImgUrl(baseFormData.photo2)"/> -->
68 </uni-forms-item> 68 </uni-forms-item>
69 </view> 69 </view>
70 70
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
130 } from '@dcloudio/uni-app' 130 } from '@dcloudio/uni-app'
131 import config from '@/config.js' 131 import config from '@/config.js'
132 import * as aes2 from '@/common/utils.js' 132 import * as aes2 from '@/common/utils.js'
133 import { fillImgUrl, fillMemberPhoto } from '@/common/utils.js'
133 const current = ref(0) 134 const current = ref(0)
134 const popup = ref(null) 135 const popup = ref(null)
135 const infoConfirm = ref(null) 136 const infoConfirm = ref(null)
...@@ -301,7 +302,7 @@ ...@@ -301,7 +302,7 @@
301 baseFormData.value.photo = data.data.fang; 302 baseFormData.value.photo = data.data.fang;
302 baseFormData.value.photo2 = data.data.yuan; 303 baseFormData.value.photo2 = data.data.yuan;
303 photoArr.value = { 304 photoArr.value = {
304 url: config.baseUrl_api+baseFormData.value.photo, 305 url: fillImgUrl(baseFormData.value.photo),
305 name: '头像', 306 name: '头像',
306 extname: 'jpg' 307 extname: 'jpg'
307 } 308 }
...@@ -358,26 +359,17 @@ ...@@ -358,26 +359,17 @@
358 baseFormData.value.phone = res.data.phone 359 baseFormData.value.phone = res.data.phone
359 baseFormData.value.cityId = res.data.cityId 360 baseFormData.value.cityId = res.data.cityId
360 baseFormData.value.address = res.data.address 361 baseFormData.value.address = res.data.address
361 if (res.data.photo) { 362 const photoUrl = fillMemberPhoto(res.data)
362 console.log(res.data.photo) 363 if (photoUrl) {
363 if (res.data.photo.indexOf('http') == -1) { 364 console.log(res.data.photo || res.data.perPhoto)
364 baseFormData.value.photo = res.data.photo 365 baseFormData.value.photo = res.data.photo || res.data.perPhoto || ''
366 baseFormData.value.photo2 = res.data.photo2 || res.data.perPhoto2 || ''
365 let obj = { 367 let obj = {
366 url: config.baseUrl_api + res.data.photo, 368 url: photoUrl,
367 name: '头像', 369 name: '头像',
368 extname: 'jpg' 370 extname: 'jpg'
369 } 371 }
370 photoArr.value = obj 372 photoArr.value = obj
371 } else {
372 baseFormData.value.photo = res.data.photo
373 let obj = {
374 url: res.data.photo,
375 name: '头像',
376 extname: 'jpg'
377 }
378 photoArr.value = obj
379 }
380
381 } 373 }
382 // baseFormData.value.name = res.data.name 374 // baseFormData.value.name = res.data.name
383 baseFormData.value.perId = res.data.perId 375 baseFormData.value.perId = res.data.perId
......
...@@ -62,10 +62,11 @@ ...@@ -62,10 +62,11 @@
62 onShow 62 onShow
63 } from '@dcloudio/uni-app' 63 } from '@dcloudio/uni-app'
64 import { 64 import {
65 parseAttachmentJson,
66 previewAttachment,
65 szToHz 67 szToHz
66 } from '@/common/utils.js' 68 } from '@/common/utils.js'
67 import * as api from '@/common/api.js' 69 import * as api from '@/common/api.js'
68 import config from '../config';
69 const inputstyle = ref({ 70 const inputstyle = ref({
70 borderColor: '#fff', 71 borderColor: '#fff',
71 fontSize: '30rpx' 72 fontSize: '30rpx'
...@@ -244,7 +245,7 @@ import config from '../config'; ...@@ -244,7 +245,7 @@ import config from '../config';
244 for (var item of list.value) { 245 for (var item of list.value) {
245 item.examPersonData = JSON.parse(item.examPersonData) 246 item.examPersonData = JSON.parse(item.examPersonData)
246 if (item.fileUrl) { 247 if (item.fileUrl) {
247 item.fileUrl = JSON.parse(item.fileUrl) 248 item.fileUrl = parseAttachmentJson(item.fileUrl)
248 } 249 }
249 } 250 }
250 total.value = Response.total 251 total.value = Response.total
...@@ -253,62 +254,7 @@ import config from '../config'; ...@@ -253,62 +254,7 @@ import config from '../config';
253 } 254 }
254 255
255 function showImg(n) { 256 function showImg(n) {
256 var str= config.baseUrl_api + n.fileUrl[0]?.url 257 previewAttachment(n.fileUrl, { title: '查看附件' })
257 if(n.fileUrl[0]?.url.indexOf('png')>-1||n.fileUrl[0]?.url.indexOf('jpg')>-1||n.fileUrl[0]?.url.indexOf('jpeg')>-1){
258 uni.previewImage({
259 urls: [str],
260 success: function(res) {
261 console.log('success', res)
262 },
263 fail: function(res) {
264 console.log('fail', res)
265 },
266 complete: function(res) {
267 console.log('complete', res)
268 }
269 })
270 }else{
271 goWebView(str)
272 }
273 }
274 function goWebView(url){
275 url = url.replace("http://", "https://")
276 uni.showLoading({
277 title: '下载中'
278 });
279 uni.downloadFile({
280 url: url,
281 success: function(res) {
282 uni.hideLoading();
283 var filePath = res.tempFilePath;
284 uni.showLoading({
285 title: '正在打开'
286 });
287 uni.openDocument({
288 filePath: filePath,
289 showMenu: true,
290 success: function(res) {
291 uni.hideLoading();
292 },
293 fail: function(err) {
294 uni.hideLoading();
295 uni.showToast({
296 title: err,
297 icon: 'none',
298 duration: 2000
299 });
300 }
301 });
302 },
303 fail: function(error) {
304 uni.hideLoading();
305 uni.showToast({
306 title: `下载失败`,
307 icon: 'none',
308 duration: 2000
309 });
310 }
311 });
312 } 258 }
313 </script> 259 </script>
314 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 config from '@/config.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 var str = config.baseUrl_api + n.fileUrl[0]?.url 154 previewAttachment(n.fileUrl, { title: '查看附件' })
155 if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
156 'jpeg') > -1) {
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">
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
65 <script setup> 65 <script setup>
66 import * as api from '@/common/api.js' 66 import * as api from '@/common/api.js'
67 import config from '@/config.js' 67 import config from '@/config.js'
68 import { fillImgUrl } from '@/common/utils.js'
68 import { 69 import {
69 onLoad, 70 onLoad,
70 onShow 71 onShow
...@@ -111,9 +112,7 @@ ...@@ -111,9 +112,7 @@
111 if (form.value.cityId) { 112 if (form.value.cityId) {
112 getRegionsList(form.value.cityId) 113 getRegionsList(form.value.cityId)
113 } 114 }
114 if (form.value.photo && form.value.photo.indexOf('http') == -1) { 115 form.value.photo = fillImgUrl(form.value.photo)
115 form.value.photo = config.baseUrl_api + form.value.photo
116 }
117 }) 116 })
118 }) 117 })
119 118
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
52 </view> 52 </view>
53 </view> 53 </view>
54 <view class="nodata" v-if="list.length==0"> 54 <view class="nodata" v-if="list.length==0">
55 <image mode="aspectFit" src="/static/nodata.png"></image> 55 <image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
56 <text>暂无数据</text> 56 <text>暂无数据</text>
57 </view> 57 </view>
58 58
...@@ -83,6 +83,7 @@ ...@@ -83,6 +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 { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
86 import { 87 import {
87 onMounted, 88 onMounted,
88 ref 89 ref
...@@ -127,67 +128,8 @@ function handleUpdate(item) { ...@@ -127,67 +128,8 @@ function handleUpdate(item) {
127 } 128 }
128 function downloadOrder(item) { 129 function downloadOrder(item) {
129 //下载凭证 130 //下载凭证
130 var arr = JSON.parse(item.payEvidence) || [] 131 const arr = parseAttachmentJson(item.payEvidence) || []
131 showImg(arr[0]?.url) 132 previewAttachment(arr[0] || arr, { title: '查看凭证' })
132 }
133 function showImg(url) {
134 var str = config.baseUrl_api + url
135 if (url.indexOf('png') > -1 || url.indexOf('jpg') > -1 || url.indexOf('jpeg') > -1) {
136 uni.previewImage({
137 urls: [str],
138 success: function(res) {
139 console.log('success', res)
140 },
141 fail: function(res) {
142 console.log('fail', res)
143 },
144 complete: function(res) {
145 console.log('complete', res)
146 }
147 })
148 } else {
149 goWebView(str)
150 }
151 }
152
153 function goWebView(url) {
154 url = url.replace("http://", "https://")
155 uni.showLoading({
156 title: '下载中'
157 });
158 uni.downloadFile({
159 url: url,
160 success: function(res) {
161 uni.hideLoading();
162 var filePath = res.tempFilePath;
163 uni.showLoading({
164 title: '正在打开'
165 });
166 uni.openDocument({
167 filePath: filePath,
168 showMenu: true,
169 success: function(res) {
170 uni.hideLoading();
171 },
172 fail: function(err) {
173 uni.hideLoading();
174 uni.showToast({
175 title: err,
176 icon: 'none',
177 duration: 2000
178 });
179 }
180 });
181 },
182 fail: function(error) {
183 uni.hideLoading();
184 uni.showToast({
185 title: `下载失败`,
186 icon: 'none',
187 duration: 2000
188 });
189 }
190 });
191 } 133 }
192 134
193 let selectFileValue = {} 135 let selectFileValue = {}
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
69 69
70 <script setup> 70 <script setup>
71 import * as api from '@/common/api.js' 71 import * as api from '@/common/api.js'
72 import { fillImgUrl, previewAttachment } from '@/common/utils.js'
72 import config from '@/config.js' 73 import config from '@/config.js'
73 import { 74 import {
74 onMounted, 75 onMounted,
...@@ -106,9 +107,7 @@ ...@@ -106,9 +107,7 @@
106 } 107 }
107 api.selectPageList(query.value).then(res => { 108 api.selectPageList(query.value).then(res => {
108 for (var l of res.rows) { 109 for (var l of res.rows) {
109 if (l.photo && l.photo.indexOf('http') == -1) { 110 l.photo = fillImgUrl(l.photo)
110 l.photo = config.baseUrl_api + l.photo
111 }
112 } 111 }
113 list.value = res.rows 112 list.value = res.rows
114 paging.value.complete(res.rows) 113 paging.value.complete(res.rows)
...@@ -126,9 +125,7 @@ ...@@ -126,9 +125,7 @@
126 } 125 }
127 api.selectPageList(query.value).then(res => { 126 api.selectPageList(query.value).then(res => {
128 for (var l of res.rows) { 127 for (var l of res.rows) {
129 if (l.photo && l.photo.indexOf('http') == -1) { 128 l.photo = fillImgUrl(l.photo)
130 l.photo = config.baseUrl_api + l.photo
131 }
132 } 129 }
133 list.value = res.rows 130 list.value = res.rows
134 paging.value.complete(res.rows) 131 paging.value.complete(res.rows)
......
...@@ -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 config from '@/config.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 var str = config.baseUrl_api + n.fileUrl[0]?.url 187 previewAttachment(n.fileUrl, { title: '查看附件' })
187 if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
188 'jpeg') > -1) {
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,6 +82,7 @@ ...@@ -82,6 +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, previewAttachment } from '@/common/utils.js'
85 import { 86 import {
86 onMounted, 87 onMounted,
87 ref 88 ref
...@@ -193,7 +194,7 @@ function circulation(id) { ...@@ -193,7 +194,7 @@ function circulation(id) {
193 api.queryProcess(id).then(res=>{ 194 api.queryProcess(id).then(res=>{
194 if (res.data.url) { 195 if (res.data.url) {
195 uni.hideLoading() 196 uni.hideLoading()
196 goWebView(config.baseUrl_api + res.data.url) 197 previewAttachment(res.data.url, { title: '查看附件' })
197 } else { 198 } else {
198 circulation(id) 199 circulation(id)
199 } 200 }
...@@ -269,11 +270,7 @@ function viewSettleFile(item){ ...@@ -269,11 +270,7 @@ function viewSettleFile(item){
269 } 270 }
270 function showImg(n) { 271 function showImg(n) {
271 var str = '' 272 var str = ''
272 if(n.indexOf('http')==-1){ 273 str = fillImgUrl(n)
273 str = config.baseUrl_api + n
274 } else {
275 str = n
276 }
277 274
278 if (n.indexOf('png') > -1 || n.indexOf('jpg') > -1 || n.indexOf( 275 if (n.indexOf('png') > -1 || n.indexOf('jpg') > -1 || n.indexOf(
279 'jpeg') > -1) { 276 'jpeg') > -1) {
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
45 <script setup> 45 <script setup>
46 import * as api from '@/common/api.js' 46 import * as api from '@/common/api.js'
47 import config from '@/config.js' 47 import config from '@/config.js'
48 import { fillImgUrl } from '@/common/utils.js'
48 import { 49 import {
49 onMounted, 50 onMounted,
50 ref 51 ref
...@@ -74,9 +75,7 @@ ...@@ -74,9 +75,7 @@
74 api.addSelectPageList(queryParams.value).then(res => { 75 api.addSelectPageList(queryParams.value).then(res => {
75 list.value = res.pageData.rows 76 list.value = res.pageData.rows
76 for (var l of list.value) { 77 for (var l of list.value) {
77 if (l.photo && l.photo.indexOf('http') == -1) { 78 l.photo = fillImgUrl(l.photo)
78 l.photo = config.baseUrl_api + l.photo
79 }
80 } 79 }
81 }) 80 })
82 } 81 }
......
...@@ -110,8 +110,8 @@ ...@@ -110,8 +110,8 @@
110 item.recordId = r.recordId 110 item.recordId = r.recordId
111 infoList.value.push(item) 111 infoList.value.push(item)
112 }) 112 })
113 form.value.totalNum = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalNum || 0))) 113 form.value.totalNum = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalNum || 0), 0))
114 form.value.totalAmount = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalAmount || 0))) 114 form.value.totalAmount = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalAmount || 0), 0))
115 115
116 uni.hideLoading() 116 uni.hideLoading()
117 117
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
60 <script setup> 60 <script setup>
61 import * as api from '@/common/api.js' 61 import * as api from '@/common/api.js'
62 import config from '@/config.js' 62 import config from '@/config.js'
63 import { fillImgUrl } from '@/common/utils.js'
63 import { 64 import {
64 ref, 65 ref,
65 getCurrentInstance 66 getCurrentInstance
...@@ -89,9 +90,7 @@ ...@@ -89,9 +90,7 @@
89 api.selectPageList(queryParams.value).then(res => { 90 api.selectPageList(queryParams.value).then(res => {
90 list.value = res.rows 91 list.value = res.rows
91 for(var l of list.value){ 92 for(var l of list.value){
92 if(l.photo&&l.photo.indexOf('http')==-1){ 93 l.photo = fillImgUrl(l.photo)
93 l.photo = config.baseUrl_api + l.photo
94 }
95 } 94 }
96 total.value = res.total 95 total.value = res.total
97 }) 96 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!