12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <template>
- <view>
- <web-view v-if="pdfUrl" :src="pdfUrl" @message="getPostMessage"></web-view>
-
- <ssDownload ref="ssRef"></ssDownload>
- </view>
- </template>
- <script setup>
- import {ref} from "vue"
- import {onLoad} from "@dcloudio/uni-app"
- import ssDownload from "./ssDownload.vue"
- import * as httpApi from "@/apis/pdf.js"
- const pdfUrl = ref('');
- const httpUrl = ref('');
- const ssRef = ref(null)
-
- function updatePdfUrl({banben,nianji}) {
- httpApi.getPDFUrl({
- banben,
- nianji,
- }).then(url => {
- httpUrl.value = url;
- pdfUrl.value = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url);
- })
- }
-
- function getPostMessage() {
- // console.log('执行下载操作')
- ssRef.value.toDownload({
- type:2,
- src: httpUrl.value
- })
- }
-
-
- onLoad(({banben, nianji}) => {
- updatePdfUrl({banben, nianji});
- })
-
- </script>
- <style>
- </style>
|