d7962027 by lttnew

上传图片

1 parent b6754440
......@@ -276,7 +276,7 @@ export function uploadImgCorpPhoto(tempFilePath) {
title: '加载中'
});
return uni.uploadFile({
url: config.baseUrl_api + '/upload/uploadImgToLocalServerCaiJian',
url: config.baseUrl_api + '/fileServer/uploadImgToMinioCaiJian',
header: {
'Authorization': uni.getStorageSync('token'),
},
......@@ -479,7 +479,7 @@ export function uploadFile(e) {
title: '加载中'
});
return uni.uploadFile({
url: config.baseUrl_api + '/upload/uploadFileToLocalServer',
url: config.baseUrl_api + '/fileServer/uploadFile',
filePath: fileUrl,
name: 'file',
header: {
......@@ -487,6 +487,16 @@ export function uploadFile(e) {
}
}).then(res => {
let data = JSON.parse(res.data);
if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 300)) {
throw new Error(data.msg || '上传失败')
}
if (data.code && data.code !== 200) {
throw new Error(data.msg || '上传失败')
}
if (data.data) {
data.message = data.msg
data.msg = data.data
}
return data
}).finally(() => {
uni.hideLoading();
......@@ -498,7 +508,7 @@ export function uploadFileList(path) {
title: '加载中'
});
return uni.uploadFile({
url: config.baseUrl_api + '/upload/uploadFileToLocalServer',
url: config.baseUrl_api + '/fileServer/uploadFile',
filePath: path,
name: 'file',
header: {
......@@ -506,7 +516,13 @@ export function uploadFileList(path) {
}
}).then(res => {
let data = JSON.parse(res.data);
return data.msg
if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 300)) {
throw new Error(data.msg || '上传失败')
}
if (data.code && data.code !== 200) {
throw new Error(data.msg || '上传失败')
}
return data.data || data.msg
}).finally(() => {
uni.hideLoading();
});
......
import CryptoJS from 'crypto-js'
import config from '@/config.js'
export function szToHz(num) {
const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
return hzArr[parseInt(num)]
......@@ -39,3 +40,315 @@ export function AESDecrypt(str) {
return aesStr
}
}
export function isDaoGuanRole() {
const app = getApp()
const deptType = app.globalData?.deptType
const userType = app.globalData?.userType
return deptType == null || deptType == 6 || deptType == '6' || userType == '4'
}
export function reLaunchHomeByRole() {
uni.reLaunch({
url: isDaoGuanRole() ? '/pages/index/daoGuanPerson' : '/pages/index/home'
})
}
export function fillImgUrl(url, prefix) {
if (!url) return ''
const trimmedUrl = String(url).trim()
if (!trimmedUrl) return ''
if (trimmedUrl === 'null' || trimmedUrl === 'undefined') return ''
if (trimmedUrl.startsWith('msr:')) {
return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${encodeURIComponent(trimmedUrl)}&downFlag=0`
}
if (/^(data:|https?:\/\/)/.test(trimmedUrl)) {
return trimmedUrl
}
const baseUrl = prefix
? `${trimBaseUrl(config.baseUrl_api)}/${String(prefix).replace(/^\/+|\/+$/g, '')}`
: trimBaseUrl(config.baseUrl_api)
const path = trimmedUrl.startsWith('/') ? trimmedUrl : `/${trimmedUrl}`
return baseUrl + path
}
export function isImageUrl(url) {
const value = String(url || '').trim()
if (!value) return false
const decodedValue = safeDecodeURIComponent(value)
return /\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(decodedValue) ||
/[?&]file=[^&]*\.(png|jpe?g|gif|webp|bmp|svg)(&|$)/i.test(decodedValue)
}
export function getMemberPhotoValue(item = {}) {
return [item.photo, item.perPhoto, item.photo2, item.perPhoto2].find(isValidUrlValue) || ''
}
export function fillMemberPhoto(item = {}, fallback = '') {
const photo = getMemberPhotoValue(item)
return photo ? fillImgUrl(photo) : fallback
}
export async function previewAttachment(file, options = {}) {
const item = normalizeAttachment(file)
const rawUrl = item.rawUrl || item.url
const previewUrl = getAttachmentPreviewUrl(rawUrl, 0)
if (!previewUrl) {
uni.showToast({
title: '暂无可预览附件',
icon: 'none'
})
return
}
if (isAttachmentImage(item) || isImageUrl(rawUrl) || isImageUrl(previewUrl)) {
const errorMsg = await checkAttachmentError(previewUrl)
if (errorMsg) {
uni.showToast({
title: errorMsg,
icon: 'none'
})
return
}
uni.previewImage({
urls: [previewUrl],
current: previewUrl,
fail: () => {
uni.showToast({
title: '图片预览失败',
icon: 'none'
})
}
})
return
}
if (getAttachmentExt(item) === 'zip') {
uni.showToast({
title: '压缩包暂不支持在线预览',
icon: 'none'
})
return
}
openDocumentAttachment(item, getAttachmentPreviewUrl(rawUrl, 0), false, options)
}
export function normalizeAttachment(file) {
if (Array.isArray(file)) return normalizeAttachment(file[0])
if (typeof file === 'string') {
const parsed = parseAttachmentJson(file)
if (parsed !== file) return normalizeAttachment(parsed)
return {
rawUrl: file,
url: file,
name: ''
}
}
if (file && typeof file === 'object') {
const rawUrl = file.rawUrl || file.url || file.fileUrl || file.path || ''
return {
...file,
rawUrl,
url: rawUrl
}
}
return {}
}
export function parseAttachmentJson(value) {
if (!value || typeof value !== 'string') return value
try {
return JSON.parse(value)
} catch (e) {
return value
}
}
export function getAttachmentPreviewUrl(url, downFlag = 0) {
if (!url) return ''
const value = String(url).trim()
if (!value || value === 'null' || value === 'undefined') return ''
if (value.startsWith('msr:')) {
return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${encodeURIComponent(value)}&downFlag=${downFlag}`
}
return fillImgUrl(value)
}
function openDocumentAttachment(item, url, retried = false, options = {}) {
if (!url) {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
uni.showLoading({
title: '打开中',
mask: true
})
uni.downloadFile({
url,
header: {
Authorization: uni.getStorageSync('token')
},
success: res => {
if (res.statusCode && res.statusCode !== 200) {
if ((res.statusCode === 301 || res.statusCode === 302) && !retried) {
const redirectUrl = getRedirectUrl(res.header)
uni.hideLoading()
if (redirectUrl) {
openDocumentAttachment(item, redirectUrl, true, options)
} else {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
}
return
}
showAttachmentFailToast(url, '文件下载失败')
return
}
uni.openDocument({
filePath: res.tempFilePath,
fileType: getDocumentFileType(item),
showMenu: true,
fail: () => {
uni.showToast({
title: '文件暂不支持预览',
icon: 'none'
})
}
})
},
fail: () => {
showAttachmentFailToast(url, '文件下载失败')
},
complete: () => {
uni.hideLoading()
}
})
}
function openAttachmentWebView(url, title = '附件预览') {
if (!url) {
uni.showToast({
title: '文件下载失败',
icon: 'none'
})
return
}
uni.navigateTo({
url: `/pages/webview/webview?title=${encodeURIComponent(title)}&url=${encodeURIComponent(url)}`,
fail: () => {
uni.showToast({
title: '附件预览失败',
icon: 'none'
})
}
})
}
function getAttachmentExt(file) {
const name = `${file?.extname || file?.name || file?.rawUrl || file?.url || file || ''}`
const fileParam = getQueryParam(name, 'file')
const cleanName = safeDecodeURIComponent(fileParam || name).split('?')[0].split('#')[0]
const fileName = cleanName.split('/').pop() || cleanName
const ext = fileName.includes('.') ? fileName.split('.').pop() : fileName
return ext.toLowerCase()
}
function checkAttachmentError(url) {
if (!isFileDownloadUrl(url)) return Promise.resolve('')
return new Promise(resolve => {
uni.request({
url,
method: 'GET',
header: {
Authorization: uni.getStorageSync('token') || ''
},
success: res => {
const data = parseAttachmentResponse(res.data)
if (res.statusCode >= 400 || (data && data.code && data.code !== 200)) {
resolve(getAttachmentErrorMsg(data))
return
}
resolve('')
},
fail: () => resolve('')
})
})
}
async function showAttachmentFailToast(url, fallback) {
const errorMsg = await checkAttachmentError(url)
uni.showToast({
title: errorMsg || fallback,
icon: 'none'
})
}
function parseAttachmentResponse(data) {
if (!data) return null
if (typeof data === 'object') return data
if (typeof data === 'string') {
try {
return JSON.parse(data)
} catch (e) {
return null
}
}
return null
}
function getAttachmentErrorMsg(data) {
const msg = data?.msg || data?.message || ''
if (!msg) return '附件预览失败'
if (msg.includes('Hostname') || msg.includes('certificate')) {
return '附件服务证书异常,请稍后再试'
}
return msg.length > 40 ? msg.slice(0, 40) : msg
}
function isAttachmentImage(file) {
return ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'svg'].includes(getAttachmentExt(file))
}
function getDocumentFileType(file) {
const ext = getAttachmentExt(file)
const types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
return types.includes(ext) ? ext : undefined
}
function getRedirectUrl(header = {}) {
const location = header.Location || header.location
if (!location) return ''
if (/^https?:\/\//.test(location)) return location
return `${trimBaseUrl(config.baseUrl_api)}/${String(location).replace(/^\/+/, '')}`
}
function isFileDownloadUrl(url) {
const value = String(url || '')
return value.includes('/fileServer/download') || value.startsWith('fileServer/download')
}
function getQueryParam(url, key) {
const match = String(url || '').match(new RegExp(`[?&]${key}=([^&#]+)`))
return match ? safeDecodeURIComponent(match[1]) : ''
}
function isValidUrlValue(value) {
if (value === undefined || value === null) return false
const url = String(value).trim()
return url !== '' && url !== 'null' && url !== 'undefined'
}
function trimBaseUrl(url) {
return String(url || '').replace(/\/+$/, '')
}
function safeDecodeURIComponent(value) {
try {
return decodeURIComponent(value)
} catch (e) {
return value
}
}
......
......@@ -7,7 +7,8 @@
// const baseUrl_api = "https://ztx.itechtop.cn:8443/stage-api";
// const baseUrl_api = 'http://192.168.1.132:8787'
// const baseUrl_api = 'https://tkcn.19wk.cn:8443/stage-api'
const baseUrl_api = 'https://tk001.wxjylt.com/stage-api'
const baseUrl_api = 'https://tk001.wxjylt.com/stage-api' //测试环境
// const baseUrl_api = 'https://system.taekwondo.org.cn/stage-api' //会员生产
// const baseUrl_api = 'https://system.taekwondo.org.cn/stage-api'
export default {
baseUrl_api
......
......@@ -111,6 +111,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -310,11 +311,7 @@
}
function showImg(n) {
var str = ''
if(n.indexOf('http')==-1){
str = config.baseUrl_api + n
} else {
str = n
}
str = fillImgUrl(n)
if (n.indexOf('png') > -1 || n.indexOf('jpg') > -1 || n.indexOf(
'jpeg') > -1) {
......
......@@ -39,7 +39,7 @@
onLoad
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import config from '@/config.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
const queryParams = ref({})
const total = ref(0)
const list = ref([])
......@@ -60,7 +60,7 @@
api.getChangeGroupByRangeId(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl)
})
total.value = res.total
uni.hideLoading()
......@@ -68,64 +68,7 @@
}
function showImg(n) {
var str = config.baseUrl_api + n.fileUrl[0]?.url
if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
'jpeg') > -1) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
......
......@@ -37,6 +37,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import {
ref,
getCurrentInstance
......@@ -72,9 +73,7 @@
paging.value.complete(res.rows)
list.value = res.rows
for(var l of list.value){
if(l.photo&&l.photo.indexOf('http')==-1){
l.photo = config.baseUrl_api + l.photo
}
l.photo = fillImgUrl(l.photo)
}
})
}
......@@ -87,9 +86,7 @@
paging.value.complete(res.rows);
list.value = res.rows
for(var l of list.value){
if(l.photo&&l.photo.indexOf('http')==-1){
l.photo = config.baseUrl_api + l.photo
}
l.photo = fillImgUrl(l.photo)
}
total.value = res.total
})
......
......@@ -61,7 +61,7 @@
</view>
</view>
<view class="nodata" v-if="list.length==0">
<image mode="aspectFit" src="/static/nodata.png"></image>
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>暂无数据</text>
</view>
......@@ -92,6 +92,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -214,66 +215,7 @@ function goDetail(item) {
function downloadOrder(item) {
//下载凭证
showImg(item.payEvidence[0]?.url)
}
function showImg(url) {
var str = config.baseUrl_api + url
if (url.indexOf('png') > -1 || url.indexOf('jpg') > -1 || url.indexOf('jpeg') > -1) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(item.payEvidence?.[0] || item.payEvidence, { title: '查看凭证' })
}
</script>
......@@ -293,3 +235,4 @@ function goWebView(url) {
}
}
</style>
......
......@@ -101,8 +101,8 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import _ from 'underscore'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -153,6 +153,11 @@
}catch(e){
form.value.businessLicenseArr=[{url:form.value.businessLicense,name:'营业执照'}]
}
form.value.businessLicenseArr = form.value.businessLicenseArr.map(item => ({
...item,
rawUrl: item.url,
url: fillImgUrl(item.url)
}))
console.log('营业执照',form.value.businessLicenseArr)
}
if (form.value.certBusinessLicense) {
......@@ -162,19 +167,18 @@
}catch(e){
form.value.businessLicenseArrR=[{url:form.value.certBusinessLicense,name:'营业执照'}]
}
form.value.businessLicenseArrR = form.value.businessLicenseArrR.map(item => ({
...item,
rawUrl: item.url,
url: fillImgUrl(item.url)
}))
console.log('营业执照',form.value.businessLicenseArrR)
}
if (form.value.certLegalIdcPhoto && form.value.certLegalIdcPhoto!=null) {
form.value.legalIdcPhotoArr = []
var arr = form.value.certLegalIdcPhoto?.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
console.log(p)
p = config.baseUrl_api + p
}
return p
})
arr = _.map(arr, (p) => fillImgUrl(p))
form.value.legalIdcPhotoArr = arr
}
}
......@@ -182,13 +186,7 @@
form.value.legalIdcPhotoArrR = []
var arr = form.value.legalIdcPhoto?.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
console.log(p)
p = config.baseUrl_api + p
}
return p
})
arr = _.map(arr, (p) => fillImgUrl(p))
form.value.legalIdcPhotoArrR = arr
}
}
......@@ -197,12 +195,7 @@
form.value.picturesArr = []
var arr = form.value.certPictures.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
p = config.baseUrl_api + p
}
return p
})
arr = _.map(arr, (p) => fillImgUrl(p))
form.value.picturesArr = arr
}
console.log(form.value.picturesArr)
......@@ -211,12 +204,7 @@
form.value.picturesArrR = []
var arr = form.value.pictures.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
p = config.baseUrl_api + p
}
return p
})
arr = _.map(arr, (p) => fillImgUrl(p))
form.value.picturesArrR = arr
}
console.log(form.value.picturesArrR)
......@@ -248,70 +236,7 @@
}
function download(url) {
console.log(url)
if (url.indexOf('.png') > -1 || url.indexOf('.jpg') > -1) {
if(url.indexOf('http')>-1){
uni.previewImage({
urls: [url],
success: function(res) {
console.log(res,[url],'111')
}
})
} else {
uni.previewImage({
urls: [config.baseUrl_api + url],
success: function(res) {
console.log(url,'222')
}
})
}
} else {
if(url.indexOf('http')>-1){
goWebView(url)
} else {
goWebView(config.baseUrl_api + url)
}
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title:`下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(url, { title: '查看附件' })
}
</script>
......
......@@ -173,6 +173,7 @@
onShow
} from '@dcloudio/uni-app';
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import dayjs from 'dayjs'
import _ from 'underscore'
const app = getApp();
......@@ -422,9 +423,7 @@
studentList.value = response.rows
for (var s of studentList.value) {
s.checked = false
if (s.photo && s.photo.indexOf('http') == -1) {
s.photo = config.baseUrl_api + s.photo
}
s.photo = fillImgUrl(s.photo)
}
uni.hideLoading()
......@@ -485,9 +484,7 @@
if (!d.isPass) {
d.isPass = '1'
}
if (d.photo && d.photo.indexOf('http') == -1) {
d.photo = config.baseUrl_api + d.photo
}
d.photo = fillImgUrl(d.photo)
})
infoList.value = res.rows
......
......@@ -112,8 +112,8 @@
infoList.value.push(item)
})
console.log(infoList.value)
form.value.totalNum = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalNum || 0)))
form.value.totalAmount = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalAmount || 0)))
form.value.totalNum = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalNum || 0), 0))
form.value.totalAmount = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalAmount || 0), 0))
uni.hideLoading()
......
......@@ -115,6 +115,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
import * as loginServer from '@/common/login.js';
import _ from 'underscore'
......@@ -203,9 +204,17 @@
if (form.value.businessLicense) {
form.value.businessLicenseArr = []
try{
form.value.businessLicenseArr = JSON.parse(form.value.businessLicense) || []
const parsed = JSON.parse(form.value.businessLicense) || []
form.value.businessLicenseArr = parsed.map(item => ({
...item,
name: item.name || '营业执照',
url: fillImgUrl(item.url || item.rawUrl || form.value.businessLicense)
}))
}catch(e){
form.value.businessLicenseArr=[{url:form.value.businessLicense,name:'营业执照'}]
form.value.businessLicenseArr=[{
url: fillImgUrl(form.value.businessLicense),
name: '营业执照'
}]
}
console.log('营业执照',form.value.businessLicenseArr)
}
......@@ -213,13 +222,7 @@
form.value.legalIdcPhotoArr = []
var arr = form.value.certLegalIdcPhoto?.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
console.log(p)
p = config.baseUrl_api + p
}
return p
})
arr = _.map(arr, (p) => fillImgUrl(p))
form.value.legalIdcPhotoArr = arr
}
console.log('法人身份证',form.value.legalIdcPhotoArr)
......@@ -228,12 +231,7 @@
form.value.picturesArr = []
var arr = form.value.certPictures.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
p = config.baseUrl_api + p
}
return p
})
arr = _.map(arr, (p) => fillImgUrl(p))
form.value.picturesArr = arr
}
console.log(form.value.picturesArr)
......@@ -258,29 +256,7 @@
}
function download(url) {
console.log(url)
if (url.indexOf('.png') > -1 || url.indexOf('.jpg') > -1) {
if(url.indexOf('http')>-1){
uni.previewImage({
urls: [url],
success: function(res) {
}
})
} else {
uni.previewImage({
urls: [config.baseUrl_api + url],
success: function(res) {
}
})
}
} else {
if(url.indexOf('http')>-1){
goWebView(url)
} else {
goWebView(config.baseUrl_api + url)
}
}
previewAttachment(url, { title: '查看营业执照' })
}
function goWebView(url) {
......
......@@ -37,6 +37,7 @@
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import {
onLoad,
onShow,
......@@ -107,9 +108,7 @@ function loginOut() {
function getUser() {
api.getUserProfile().then((response) => {
state.user = response.data.user
if(state.user.avatar&&state.user.avatar.indexOf('http')==-1){
state.user.avatar = config.baseUrl_api+state.user.avatar
}
state.user.avatar = fillImgUrl(state.user.avatar)
state.roleGroup = response.data.roleGroup
state.postGroup = response.data.postGroup
uni.hideLoading();
......
......@@ -103,6 +103,7 @@
onShow
} from '@dcloudio/uni-app';
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
const app = getApp();
const form = ref({
type: '1',
......@@ -242,12 +243,8 @@
if(form.value.legalIdcPhoto){
legalIdcPhoto1.value = form.value.legalIdcPhoto.split(',')?.[0] || ''
legalIdcPhoto2.value = form.value.legalIdcPhoto.split(',')?.[1] || ''
if(legalIdcPhoto1.value.indexOf('http')==-1){
legalIdcPhoto1.value = config.baseUrl_api + legalIdcPhoto1.value
}
if(legalIdcPhoto2.value.indexOf('http')==-1){
legalIdcPhoto2.value = config.baseUrl_api + legalIdcPhoto2.value
}
legalIdcPhoto1.value = fillImgUrl(legalIdcPhoto1.value)
legalIdcPhoto2.value = fillImgUrl(legalIdcPhoto2.value)
imgfront.value = {
url: legalIdcPhoto1.value,
name: '身份证正面',
......@@ -265,9 +262,7 @@
var arr = form.value.pictures.split(',') || []
if (arr.length > 0) {
arr = _.map(arr, (p) => {
if(p.indexOf('http')==-1){
p = config.baseUrl_api + p
}
p = fillImgUrl(p)
var obj = {
url: p,
name: '图片',
......@@ -482,10 +477,17 @@
return
}
uni.showLoading({
title: '加载中'
title: '上传中'
})
uploadMinioImage(imgUrl).then(url => {
legalIdcPhoto1.value = url
uni.hideLoading()
}).catch(err => {
uni.hideLoading()
uni.showToast({
title: '上传失败',
icon: 'none'
})
api.uploadImg(e).then(data => {
legalIdcPhoto1.value = data.msg
})
}
......@@ -496,10 +498,17 @@
return
}
uni.showLoading({
title: '加载中'
title: '上传中'
})
uploadMinioImage(imgUrl).then(url => {
legalIdcPhoto2.value = url
uni.hideLoading()
}).catch(err => {
uni.hideLoading()
uni.showToast({
title: '上传失败',
icon: 'none'
})
api.uploadImg(e).then(data => {
legalIdcPhoto2.value = data.msg
})
}
......@@ -521,19 +530,31 @@
if (!file) {
return
}
api.uploadFile(e).then(data => {
const filePath = file.url || file.path || e.tempFilePaths?.[0]
uni.showLoading({
title: '上传中'
})
uploadMinioImage(filePath).then(url => {
selectFileValue = {
url: data.msg,
url: url,
name: file.name,
extname: file.extname
}
form.value.businessLicense = JSON.stringify([selectFileValue])
console.log(selectFileValue,form.value.businessLicense)
uni.hideLoading()
}).catch(err => {
uni.hideLoading()
uni.showToast({
title: '上传失败',
icon: 'none'
})
})
}
function delSupplementFile() {
selectFileValue = {}
form.value.businessLicense = ''
}
function upPicArr(e) {
......@@ -543,20 +564,58 @@
return
}
uni.showLoading({
title: '加载中'
title: '上传中'
})
Promise.all(tempFilePaths.slice(0, 3).map(path => uploadMinioImage(path))).then(urls => {
picArr.value.push(...urls.filter(Boolean))
form.value.pictures = picArr.value.join(',')
uni.hideLoading()
}).catch(err => {
uni.hideLoading()
uni.showToast({
title: '上传失败',
icon: 'none'
})
api.uploadImg(e).then(data => {
picArr.value.push(data.msg)
// form.value.pictures
console.log(picArr.value)
})
}
function delpicArr(e) {
picArr.value.splice(e.index, 1)
form.value.pictures = picArr.value.join(',')
console.log(picArr.value, picArrR.value)
}
function uploadMinioImage(filePath) {
return new Promise((resolve, reject) => {
if (!filePath) return reject(new Error('请选择图片'))
uni.uploadFile({
url: config.baseUrl_api + '/fileServer/uploadImg',
filePath,
name: 'image',
header: {
'Authorization': uni.getStorageSync('token')
},
success: (res) => {
try {
const data = JSON.parse(res.data || '{}')
const url = getUploadUrl(data)
if (!url) return reject(new Error('上传返回数据异常'))
resolve(url)
} catch (e) {
reject(e)
}
},
fail: reject
})
})
}
function getUploadUrl(res) {
const data = res?.data
if (typeof data === 'string') return data
return data?.ms || data?.url || data?.fang || res?.msg || ''
}
function bindChange(e) {
console.log(e)
......
......@@ -10,7 +10,8 @@
<view v-html="form.content"></view>
<view v-if="attachmentMp4.length>0">
<video v-for="(f,index) in attachmentMp4" :key="index" controls :src="config.baseUrl_api + f.url"></video>
<video v-for="(f,index) in attachmentMp4" :key="index" controls
:src="fillImgUrl(f.url)"></video>
</view>
<view v-if="attachmentFile.length>0" class="mt20">
<!-- 附件-->
......@@ -37,10 +38,10 @@
onLoad
} from '@dcloudio/uni-app';
import _ from 'underscore'
import config from '@/config.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
const form = ref({})
const attachmentFile = ref([])
const attachmentMp4 = ref([])
const attachmentFile = ref([])
const attachmentMp4 = ref([])
onLoad((option) => {
getData(option.noteId)
......@@ -58,78 +59,15 @@ const attachmentMp4 = ref([])
if (form.value.attacthJson) {
const attachment = JSON.parse(form.value.attacthJson)
attachmentFile.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') === -1) || []
attachmentFile.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') === -1) ||
[]
attachmentMp4.value = _.filter(attachment, (a) => a.url.toLowerCase().indexOf('.mp4') !== -1) || []
}
})
}
function downLoad(url){
console.log(url)
var str = config.baseUrl_api + url
if (url.indexOf('png') > -1 ||url.indexOf('jpg') > -1 ||url.indexOf('jpeg') > -1) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
console.log('111')
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
console.log('222')
uni.hideLoading();
},
fail: function(err) {
console.log(err.errMsg)
uni.hideLoading();
let msg
if(err.errMsg.indexOf('not supported')>-1){
msg = '不支持该文件类型'
} else {
msg = err.errMsg
}
uni.showToast({
title: msg,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
function downLoad(url) {
previewAttachment(url, { title: '附件预览' })
}
</script>
......@@ -178,7 +116,9 @@ const attachmentMp4 = ref([])
word-wrap: break-word !important;
white-space: normal !important;
}
.content rich-text img{max-width: 100%;}
.content rich-text img {
max-width: 100%;
}
image {
max-width: 100%;
......
......@@ -25,7 +25,7 @@
</view>
<view class="ddd" v-if="userType=='2'||userType=='1'">
<text class="lab">总金额:</text>
<text class="text-danger">¥{{(form.totalAmount*1).toFixed(2) }}</text>
<text class="text-danger">¥{{ form.totalAmount? (form.totalAmount*1).toFixed(2) : '0' }}</text>
</view>
</view>
<view class="wBox">
......
......@@ -64,7 +64,7 @@
<uni-forms-item label="头像" required>
<uni-file-picker v-model="photoArr" @delete="delPhoto" return-type="object" limit="1"
@select="upPhoto" :del-ico="false" :image-styles="imageStylesTx"></uni-file-picker>
<image mode="aspectFill" v-if="baseFormData.photo2" style="height:200rpx;width:200rpx;" :src="config.baseUrl_api + baseFormData.photo2"/>
<!-- <image mode="aspectFill" v-if="baseFormData.photo2" style="height:200rpx;width:200rpx;" :src="fillImgUrl(baseFormData.photo2)"/> -->
</uni-forms-item>
</view>
......@@ -130,6 +130,7 @@
} from '@dcloudio/uni-app'
import config from '@/config.js'
import * as aes2 from '@/common/utils.js'
import { fillImgUrl, fillMemberPhoto } from '@/common/utils.js'
const current = ref(0)
const popup = ref(null)
const infoConfirm = ref(null)
......@@ -301,7 +302,7 @@
baseFormData.value.photo = data.data.fang;
baseFormData.value.photo2 = data.data.yuan;
photoArr.value = {
url: config.baseUrl_api+baseFormData.value.photo,
url: fillImgUrl(baseFormData.value.photo),
name: '头像',
extname: 'jpg'
}
......@@ -358,26 +359,17 @@
baseFormData.value.phone = res.data.phone
baseFormData.value.cityId = res.data.cityId
baseFormData.value.address = res.data.address
if (res.data.photo) {
console.log(res.data.photo)
if (res.data.photo.indexOf('http') == -1) {
baseFormData.value.photo = res.data.photo
const photoUrl = fillMemberPhoto(res.data)
if (photoUrl) {
console.log(res.data.photo || res.data.perPhoto)
baseFormData.value.photo = res.data.photo || res.data.perPhoto || ''
baseFormData.value.photo2 = res.data.photo2 || res.data.perPhoto2 || ''
let obj = {
url: config.baseUrl_api + res.data.photo,
url: photoUrl,
name: '头像',
extname: 'jpg'
}
photoArr.value = obj
} else {
baseFormData.value.photo = res.data.photo
let obj = {
url: res.data.photo,
name: '头像',
extname: 'jpg'
}
photoArr.value = obj
}
}
// baseFormData.value.name = res.data.name
baseFormData.value.perId = res.data.perId
......
......@@ -62,10 +62,11 @@
onShow
} from '@dcloudio/uni-app'
import {
parseAttachmentJson,
previewAttachment,
szToHz
} from '@/common/utils.js'
import * as api from '@/common/api.js'
import config from '../config';
const inputstyle = ref({
borderColor: '#fff',
fontSize: '30rpx'
......@@ -244,7 +245,7 @@ import config from '../config';
for (var item of list.value) {
item.examPersonData = JSON.parse(item.examPersonData)
if (item.fileUrl) {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl)
}
}
total.value = Response.total
......@@ -253,62 +254,7 @@ import config from '../config';
}
function showImg(n) {
var str= config.baseUrl_api + n.fileUrl[0]?.url
if(n.fileUrl[0]?.url.indexOf('png')>-1||n.fileUrl[0]?.url.indexOf('jpg')>-1||n.fileUrl[0]?.url.indexOf('jpeg')>-1){
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
}else{
goWebView(str)
}
}
function goWebView(url){
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
......
......@@ -74,7 +74,7 @@
onLoad
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import config from '@/config.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
const queryParams = ref({})
const total = ref(0)
const list = ref([])
......@@ -120,7 +120,7 @@
api.addInfoModeList(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl)
})
total.value = res.total
uni.hideLoading()
......@@ -151,64 +151,7 @@
}
function showImg(n) {
var str = config.baseUrl_api + n.fileUrl[0]?.url
if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
'jpeg') > -1) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
......
......@@ -65,6 +65,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import {
onLoad,
onShow
......@@ -111,9 +112,7 @@
if (form.value.cityId) {
getRegionsList(form.value.cityId)
}
if (form.value.photo && form.value.photo.indexOf('http') == -1) {
form.value.photo = config.baseUrl_api + form.value.photo
}
form.value.photo = fillImgUrl(form.value.photo)
})
})
......
......@@ -52,7 +52,7 @@
</view>
</view>
<view class="nodata" v-if="list.length==0">
<image mode="aspectFit" src="/static/nodata.png"></image>
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>暂无数据</text>
</view>
......@@ -83,6 +83,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { parseAttachmentJson, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -127,67 +128,8 @@ function handleUpdate(item) {
}
function downloadOrder(item) {
//下载凭证
var arr = JSON.parse(item.payEvidence) || []
showImg(arr[0]?.url)
}
function showImg(url) {
var str = config.baseUrl_api + url
if (url.indexOf('png') > -1 || url.indexOf('jpg') > -1 || url.indexOf('jpeg') > -1) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
const arr = parseAttachmentJson(item.payEvidence) || []
previewAttachment(arr[0] || arr, { title: '查看凭证' })
}
let selectFileValue = {}
......
......@@ -69,6 +69,7 @@
<script setup>
import * as api from '@/common/api.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
import config from '@/config.js'
import {
onMounted,
......@@ -106,9 +107,7 @@
}
api.selectPageList(query.value).then(res => {
for (var l of res.rows) {
if (l.photo && l.photo.indexOf('http') == -1) {
l.photo = config.baseUrl_api + l.photo
}
l.photo = fillImgUrl(l.photo)
}
list.value = res.rows
paging.value.complete(res.rows)
......@@ -126,9 +125,7 @@
}
api.selectPageList(query.value).then(res => {
for (var l of res.rows) {
if (l.photo && l.photo.indexOf('http') == -1) {
l.photo = config.baseUrl_api + l.photo
}
l.photo = fillImgUrl(l.photo)
}
list.value = res.rows
paging.value.complete(res.rows)
......
......@@ -129,9 +129,10 @@
} from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import {
parseAttachmentJson,
previewAttachment,
szToHz
} from '@/common/utils.js'
import config from '@/config.js'
const queryParams = ref({})
const total = ref(0)
const list = ref([])
......@@ -152,7 +153,7 @@
api.infoMergeList(queryParams.value).then(res => {
list.value = res.rows
list.value.forEach(item => {
item.fileUrl = JSON.parse(item.fileUrl)
item.fileUrl = parseAttachmentJson(item.fileUrl)
})
total.value = res.total
uni.hideLoading()
......@@ -183,64 +184,7 @@
}
function showImg(n) {
var str = config.baseUrl_api + n.fileUrl[0]?.url
if (n.fileUrl[0]?.url.indexOf('png') > -1 || n.fileUrl[0]?.url.indexOf('jpg') > -1 || n.fileUrl[0]?.url.indexOf(
'jpeg') > -1) {
uni.previewImage({
urls: [str],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
} else {
goWebView(str)
}
}
function goWebView(url) {
url = url.replace("http://", "https://")
uni.showLoading({
title: '下载中'
});
uni.downloadFile({
url: url,
success: function(res) {
uni.hideLoading();
var filePath = res.tempFilePath;
uni.showLoading({
title: '正在打开'
});
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
uni.showToast({
title: err,
icon: 'none',
duration: 2000
});
}
});
},
fail: function(error) {
uni.hideLoading();
uni.showToast({
title: `下载失败`,
icon: 'none',
duration: 2000
});
}
});
previewAttachment(n.fileUrl, { title: '查看附件' })
}
</script>
<style scoped lang="scss">
......
......@@ -82,6 +82,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl, previewAttachment } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -193,7 +194,7 @@ function circulation(id) {
api.queryProcess(id).then(res=>{
if (res.data.url) {
uni.hideLoading()
goWebView(config.baseUrl_api + res.data.url)
previewAttachment(res.data.url, { title: '查看附件' })
} else {
circulation(id)
}
......@@ -269,11 +270,7 @@ function viewSettleFile(item){
}
function showImg(n) {
var str = ''
if(n.indexOf('http')==-1){
str = config.baseUrl_api + n
} else {
str = n
}
str = fillImgUrl(n)
if (n.indexOf('png') > -1 || n.indexOf('jpg') > -1 || n.indexOf(
'jpeg') > -1) {
......
......@@ -45,6 +45,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import {
onMounted,
ref
......@@ -74,9 +75,7 @@
api.addSelectPageList(queryParams.value).then(res => {
list.value = res.pageData.rows
for (var l of list.value) {
if (l.photo && l.photo.indexOf('http') == -1) {
l.photo = config.baseUrl_api + l.photo
}
l.photo = fillImgUrl(l.photo)
}
})
}
......
......@@ -110,8 +110,8 @@
item.recordId = r.recordId
infoList.value.push(item)
})
form.value.totalNum = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalNum || 0)))
form.value.totalAmount = Math.floor(_.sumBy(infoList.value, (o) => parseFloat(o.totalAmount || 0)))
form.value.totalNum = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalNum || 0), 0))
form.value.totalAmount = Math.floor(infoList.value.reduce((sum, o) => sum + parseFloat(o.totalAmount || 0), 0))
uni.hideLoading()
......
......@@ -60,6 +60,7 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { fillImgUrl } from '@/common/utils.js'
import {
ref,
getCurrentInstance
......@@ -89,9 +90,7 @@
api.selectPageList(queryParams.value).then(res => {
list.value = res.rows
for(var l of list.value){
if(l.photo&&l.photo.indexOf('http')==-1){
l.photo = config.baseUrl_api + l.photo
}
l.photo = fillImgUrl(l.photo)
}
total.value = res.total
})
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!