1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <template>
- <view>
- <!-- <web-view v-if="pdfUrl" :src="pdfUrl" @message="getPostMessage"></web-view> -->
- <u-pdf :url="httpUrl" v-if="httpUrl" style="height:100vh" :show-timer="false" :disabled="false"></u-pdf>
- <ssDownload ref="ssRef"></ssDownload>
- </view>
- </template>
- <script setup>
- import {ref} from "vue"
- import {onLoad, onBackPress} from "@dcloudio/uni-app"
- import ssDownload from "./ssDownload.vue"
- import * as httpApi from "@/api/pdf.js"
- import uPdf from "@/components/u-pdf/u-pdf.vue"
- const pdfUrl = ref('');
- const httpUrl = ref('');
- const ssRef = ref(null)
- const banben1 =ref('');
- const nianji1 =ref('');
- function updatePdfUrl({banben,nianji}) {
- httpApi.getPDFUrl({
- banben,
- nianji,
- }).then(res => {
- httpUrl.value = res.data;
- pdfUrl.value = '/static/pdf/web/viewer.html?file=' + encodeURIComponent(res.data);
- })
- }
-
- function getPostMessage() {
- // console.log('执行下载操作')
- ssRef.value.toDownload({
- type:2,
- src: httpUrl.value
- })
- }
- onBackPress((d) => {
- console.log('地址:',`/pages/my/sxtkPage?banben=${banben1.value}&nianji=${nianji1.value}`)
- uni.redirectTo({
- url: `/pages/my/sxtkPage?banben=${banben1.value}&nianji=${nianji1.value}`
- })
- return true
- })
-
- onLoad(({banben, nianji}) => {
- nianji1.value = nianji;
- banben1.value = banben;
- updatePdfUrl({banben, nianji});
- })
-
- </script>
- <style>
- </style>
|