Commit 04a80e11 by zhangzhen

文件预览功能优化

parent 57fecd32
......@@ -3,6 +3,7 @@ const CONFIG = {
development: {
// assetsPath: 'https://www.eis-paas.com', // 静态资源路径
assetsPath: 'http://129.211.46.84:8085', // 静态资源路径
// assetsPath: 'http://106.15.43.147:8000', // 静态资源路径
// baseUrl: 'http://10.24.1.97:8080/hp-smart', // 后台接口请求地址
// #ifdef MP
baseUrl:'http://129.211.46.84:8085',
......@@ -10,8 +11,9 @@ const CONFIG = {
// #ifndef MP
baseUrl:'/prod-api',
// #endif
// hostUrl: 'https://www.eis-paas.com', // H5地址(前端运行地址)
hostUrl: 'http://129.211.46.84:8086/file-preview', // H5地址(前端运行地址)
// hostUrl: 'https://www.eis-paas.com/file-preview', // H5地址(前端运行地址)
// hostUrl: 'http://129.211.46.84:8086/file-preview', // H5地址(前端运行地址)
hostUrl: 'http://139.224.202.156:8012',
websocketUrl: '', // websocket服务端地址
weixinAppId: '' ,// 微信公众号appid
codeHeadUrl:"",
......@@ -23,8 +25,8 @@ const CONFIG = {
// assetsPath: 'https://www.eis-paas.com', // 静态资源路径-正式服
// assetsPath: 'http://106.15.43.147:8000',
baseUrl: '/hggp', // 后台接口请求地址
hostUrl: 'http://129.211.46.84:8086/file-preview', // H5地址(前端运行地址)
// hostUrl: 'https://www.eis-paas.com/file-preview', // H5地址(前端运行地址)
// hostUrl: 'https://www.eis-paas.com', // H5地址(前端运行地址)
hostUrl: 'http://139.224.202.156:8012', // H5地址(前端运行地址)
// hostUrl: 'http://106.15.43.147:8000/file-preview',
websocketUrl: '', // websocket服务端地址
weixinAppId: '', // 微信公众号appid
......
......@@ -17,6 +17,7 @@
},
"dependencies": {
"echarts": "^5.5.0",
"html2canvas": "^1.4.1"
"html2canvas": "^1.4.1",
"js-base64": "^3.7.7"
}
}
......@@ -108,6 +108,7 @@
</template>
<script>
import {Base64} from "js-base64"
import config from "@/config/index.config";
import {
getDict
......@@ -169,35 +170,45 @@
},
islmage(filename) {
const extension = filename.split('.').pop().toLowerCase();
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg','mp4','3gp','avi','docx','pdf','txt','xlsx','xls']
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg','mp4','3gp','avi','docx','doc','pdf','txt','xlsx','xls']
return imageExtensions.includes(extension);
},
onNavToPreview() {
addPreview(this.orderInfo).then(res => {
if (res.data.__sys__.status === 1) {
if(this.islmage(this.orderInfo.docName)){
this.previewStatus = true;
if(['docx','pdf','txt','xlsx','xls'].includes(this.orderInfo.fileSuffix)){
let urlStr=`${this.hostUrl}/?docId=${this.orderInfo.docId}&fileSuffix=${this.orderInfo.fileSuffix}`
window.open(urlStr)
}
}else{
let urlStr = this.assetsPath + '/hggp/file/download/' + this.orderInfo.docId;
uni.downloadFile({
url: urlStr,
success: (res)=> {
console.log(res,999999)
let filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
success: (res) =>{
console.log('打开文档成功');
}
});
}
});
}
let urlStr = `${this.assetsPath}/hggp/file/download/preview/${this.orderInfo.docId}?fullfilename=${this.orderInfo.docName}`;
console.log(Base64.encode(urlStr))
let fullUrl = `${this.hostUrl}/preview/onlinePreview?url=${encodeURIComponent(Base64.encode(urlStr))}`;
console.log(urlStr)
console.log(fullUrl)
window.open(fullUrl)
// if(this.islmage(this.orderInfo.docName)){
// this.previewStatus = true;
// if(['docx','pdf','txt','xlsx','xls','doc'].includes(this.orderInfo.fileSuffix)){
// let urlStr=`${this.hostUrl}/?docId=${this.orderInfo.docId}&fileSuffix=${this.orderInfo.fileSuffix}`
// window.open(urlStr)
// }
// }else{
// let urlStr = this.assetsPath + '/hggp/file/download/' + this.orderInfo.docId;
// uni.downloadFile({
// url: urlStr,
// success: (res)=> {
// console.log(res,999999)
// let filePath = res.tempFilePath;
// uni.openDocument({
// filePath: filePath,
// showMenu: true,
// success: (res) =>{
// console.log('打开文档成功');
// }
// });
// }
// });
// }
}
this.onGetList();
})
......@@ -262,7 +273,7 @@
this.orderInfo = {
...list[0],
fileSuffix:list[0].docName.split('.').pop().toLowerCase(),
previewStatus: this.islmage(list[0].docName),
previewStatus: true,
releaseDate: updatedTime.length >= 13 ?
`${updatedTime[0]}${updatedTime[1]}${updatedTime[2]}${updatedTime[3]}/${updatedTime[4]}${updatedTime[5]}/${updatedTime[6]}${updatedTime[7]} ${updatedTime[8]}${updatedTime[9]}:${updatedTime[10]}${updatedTime[11]}:${updatedTime[12]}${updatedTime[13]}` :
''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment