fix: 调整pdf预览

This commit is contained in:
杨航
2025-09-05 18:58:32 +08:00
parent 869736e6d2
commit 98fe07b635
394 changed files with 3715 additions and 78568 deletions
+97 -134
View File
@@ -1,142 +1,105 @@
<template>
<view class="popup-view">
<view class="body-title">
<uv-icon class="arrow-icon" name="arrow-left" @click="backRouter()" />
文件预览
</view>
<view class="popup-view-preview" v-if="showView">
<web-view
:src="showUrl"
:fullscreen="true"
:webview-styles="{
width: '100%',
height: '100%'
}"
></web-view>
</view>
</view>
<view class="popup-view">
<view class="body-title">
<uv-icon class="arrow-icon" name="arrow-left" @click="backRouter()" />
文件预览
</view>
<view class="popup-view-preview" v-if="showView">
<web-view
:src="showUrl"
:fullscreen="true"
:webview-styles="{
width: '100%',
height: '100%'
}"></web-view>
</view>
</view>
</template>
<script>
import {
getToken
} from "@/common/common.js"
import common from '@/common/common';
import {
downloadFile
} from "@/api/common.js"
import {
get_base_url
} from '@/api/request.js'
var wv
export default{
data(){
return {
fileId:'',
showUrl:'',
viewerUrl: '/static/pdf-view/web/viewer.html',
showView: false,
wv: null
}
},
onLoad(params){
this.fileId = params.fileId || '';
},
onShow(){
this.openPdfFn({
fileId: this.fileId
})
},
onReady(){
//#ifdef APP-PLUS
var currentWebview = this.$scope.$getAppWebview()
setTimeout(()=>{
wv = currentWebview.children()[0]
wv.setStyle({
top: 80
})
uni.onKeyboardHeightChange(setHeight)
},1000)
// #endif
},
methods:{
// setHeight(res){
// wv.setStyle({
// top: res.height + 20
// })
// },
backRouter(){
common.navigateBack()
},
openPdfFn(data){
const base_url = get_base_url('/traask/traFilePreview/')
const token = getToken();
const header = {};
let _id = data?.fileId
let fileUrl = base_url + '/traask/traFilePreview/' + _id
if (token)
header['summary'] = token
uni.downloadFile({
//需要预览的文件地址
url: fileUrl,
header: header,
success: (res) => {
//下载成功,得到文件临时地址
//条件编译,若为h5端则直接赋值文件地址
// #ifdef H5
let newUrl = res.tempFilePath
// #endif
//条件编译,若为App端,则需要将本地文件系统URL转换为平台绝对路径
// #ifdef APP-PLUS
console.log('getFileInfo', res);
uni.getFileInfo({
res.tempFilePath,
success: (ress) => {
console.log('success', ress);
},
fail: (ress) => {
console.log('fail', ress);
}
})
let newUrl = plus.io.convertLocalFileSystemURL(res.tempFilePath)
console.log('newUrl', newUrl);
// #endif
this.showUrl = this.viewerUrl + '?file=' + newUrl
this.showView = true
}
})
}
}
}
import { getToken } from '@/common/common.js'
import common from '@/common/common'
import { downloadFile } from '@/api/common.js'
import { get_base_url } from '@/api/request.js'
var wv
export default {
data() {
return {
fileId: '',
showUrl: '',
// viewerUrl: '/static/pdf-view/web/viewer.html',
viewerUrl: '/static/view-pdf/pdf.html',
showView: false,
wv: null
}
},
onLoad(params) {
this.fileId = params.fileId || ''
},
onShow() {
this.openPdfFn({
fileId: this.fileId
})
},
onReady() {
//#ifdef APP-PLUS
var currentWebview = this.$scope.$getAppWebview()
setTimeout(() => {
wv = currentWebview.children()[0]
wv.setStyle({
top: 80
})
// uni.onKeyboardHeightChange(setHeight)
}, 1000)
// #endif
},
methods: {
// setHeight(res){
// wv.setStyle({
// top: res.height + 20
// })
// },
backRouter() {
common.navigateBack()
},
openPdfFn(data) {
const base_url = get_base_url('/traask/traFilePreview/')
let _id = data?.fileId
let fileUrl = base_url + '/traask/traFilePreview/' + _id
this.showUrl = this.viewerUrl + '?url=' + fileUrl
this.showView = true
}
}
}
</script>
<style lang="scss" scoped>
.popup-view {
width: 100vw;
height: 100vh;
}
.body-title {
height: 90rpx;
text-align: center;
font-size: 33rpx;
padding-top: 10rpx;
line-height: 46rpx;
box-sizing: border-box;
font-weight: 500;
color: #000;
position: fixed;
top: var(--status-bar-height);
left: 0;
width: 100vw;
z-index: 10000;
// margin-bottom: 23rpx;
.arrow-icon {
position: absolute;
left: 21rpx;
top: 5rpx;
color: #000;
padding: 15rpx;
// background-color: red;
}
}
.popup-view {
width: 100vw;
height: 100vh;
}
.body-title {
height: 90rpx;
text-align: center;
font-size: 33rpx;
padding-top: 10rpx;
line-height: 46rpx;
box-sizing: border-box;
font-weight: 500;
color: #000;
position: fixed;
top: var(--status-bar-height);
left: 0;
width: 100vw;
z-index: 10000;
// margin-bottom: 23rpx;
.arrow-icon {
position: absolute;
left: 21rpx;
top: 5rpx;
color: #000;
padding: 15rpx;
// background-color: red;
}
}
</style>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
àRCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSEáCNS2-H
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
àRCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSEá ETen-B5-H` ^
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-4
View File
@@ -1,4 +0,0 @@
àRCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSE!!º]aX!!]`21> p z$]"Rd-Uƒ7*„␍4„%+ „Z „{/%…<9K…b1]†." ‰`]‡,"]ˆ
"]ˆh"]‰F"]Š$"]"]`"]Œ>"]"]z"]ŽX"]6"]"]r"]P"]."]“ "]“j"]”H"]•&"]"]b"]—@"]˜"]˜|"]™Z"]š8"]"]t"]œR"]0"]ž"]žl"]ŸJ"] ("]¡"]¡d"]¢B"]£ "X£~']¤W"]¥5"]¦"]¦q"]§O"]¨-"]© "]©i"]ªG"]«%"]¬"]¬a"]­?"]®"]®{"]¯Y"]°7"]±"]±s"]²Q"]³/"]´␍"]´k"]µI"]¶'"]·"]·c"]¸A"]¹"]¹}"]º["]»9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More