pdfPreView.vue
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
<view class="material-detail">
<view class="nav-bar">
<view class="back" @click.stop="back">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
{{ title }}
</view>
<web-view v-if="fileUrltype === 'html'" :src="url"></web-view>
<view v-else-if="fileUrltype !== 'pdf'">
<lk-preview-office :url="url" :fileType="fileType"></lk-preview-office>
</view>
<view v-else>
<lk-preview-office :url="url" fileType="pdf"></lk-preview-office>
</view>
</view>
</template>
<script type="text/ecmascript-6">
import { report } from '@/mixin/index.js'
export default {
name: '',
mixins: [report],
data () {
return {
url: '',
title: '',
fileType: 'pdf',
Signature: true,
fileUrltype:'pdf'
}
},
onLoad (options) {
console.log(options)
this.fileUrltype = options.fileUrltype || 'pdf'
this.fileType = options.fileType || 'pdf'
this.Signature = options.Signature === 'false' ? false : (options.Signature || true);
if(this.fileType === 'docx') {
this.url = options.fileUrl
}else if(!this.Signature) {
this.url = options.fileUrl
}else {
this.url = options.fileUrl + '&OSSAccessKeyId='+ options.OSSAccessKeyId + '&Signature=' + options.Signature
}
this.title = options.fileName
console.log(this.url)
// else this.setWv()
},
mounted () {
},
methods: {
back () {
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 100
})
},
setWebviewStyle () {
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$scope.$getAppWebview()
let [wv] = currentWebview.children(),
wvFlag = false
if (wv) {
wv.setStyle({
left: '71.9%',
top: '17.18%',
height: '82.82%',
width: '28.3%'
})
wvFlag = true;
}
return wvFlag
}
const retrySetWebviewStyle = () => {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
setTimeout(retrySetWebviewStyle, 100);
}
}
}
</script>
<style scoped lang="scss">
.nav-bar {
position: fixed;
width: 100%;
height: toRpx(96);
left: 0;
top: toRpx(48);
z-index: 9;
text-align: center;
font-weight: 700;
font-size: toRpx(32);
color: #1a1a1a;
line-height: toRpx(96);
.back {
position: absolute;
left: 0;
top: 0;
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
}
}
.file-box {
position: fixed;
top: 5.2vh;
height: 94.8vh;
left: 0;
width: 100vw;
}
.has-ai {
width: 71.36vw;
}
.AI-window {
width: 28.3vw;
height: 90.63vh;
position: fixed;
top: 9.37vh;
right: 0;
background: #f5f9ff;
.AI-title {
height: 5.73vh;
padding-top: 2.08vh;
font-size: toRpx(34);
font-weight: 500;
justify-content: center;
color: #333333;
}
}
</style>