index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view style="position: absolute;
  3. top: 0;
  4. left: 0;
  5. right: 0;
  6. height: 100%;">
  7. <web-view :src="url"></web-view>
  8. <!-- <iframe width="100%" height="800rpx" :src="url"></iframe> -->
  9. </view>
  10. </template>
  11. <script setup>
  12. import {
  13. onMounted,
  14. computed,
  15. ref
  16. } from 'vue';
  17. import {
  18. onLoad,
  19. } from '@dcloudio/uni-app';
  20. import {
  21. store
  22. } from '../../store';
  23. const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
  24. const url = ref("")
  25. const pdfUrl = ref("")
  26. const webHost = ref(urlList.pdfAppURL)
  27. const fileUrl = ref("")
  28. const pdfjs = ref("/static/hybrid/html/web/viewer.html")
  29. const totalPage = ref(0) //总页码
  30. const currentReadPage = ref(0) //当前页码
  31. onLoad((options) => {
  32. console.log(urlList)
  33. pdfUrl.value = options.param1
  34. fileUrl.value = webHost.value + pdfUrl.value
  35. console.log(webHost.value)
  36. uni.setNavigationBarTitle({
  37. title: ""
  38. });
  39. console.log(fileUrl.value)
  40. init();
  41. });
  42. function init() {
  43. console.log(fileUrl.value)
  44. const encodeFileUrl = encodeURIComponent(fileUrl.value);
  45. console.log(encodeFileUrl, "777")
  46. url.value = pdfjs.value + '?file=' + encodeFileUrl
  47. console.log(11, url.value)
  48. }
  49. </script>
  50. <style>
  51. </style>