richDemo.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view >
  3. <view class="pdf-container">
  4. <web-view
  5. v-if="pdfUrl"
  6. :src="pdfUrl"
  7. class="web-view"
  8. ></web-view>
  9. </view>
  10. <view>
  11. <mp-html :content="content" />
  12. </view>
  13. </view>
  14. </template>
  15. <script setup>
  16. import {
  17. toast
  18. } from "@/utils/common";
  19. import {
  20. onLoad
  21. } from "@dcloudio/uni-app";
  22. import {
  23. zhaoshengZhaopinInfo
  24. } from '@/api/login.js'
  25. import cacheManager from '@/utils/cacheManager.js'
  26. import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html'
  27. import {
  28. ref
  29. } from 'vue';
  30. const content = ref('')
  31. const pdfUrl = ref('')
  32. onLoad(() => {
  33. getZhaopinInfo()
  34. })
  35. function getZhaopinInfo() {
  36. zhaoshengZhaopinInfo({}).then(res => {
  37. console.log('res', res);
  38. content.value = res.data.content
  39. pdfUrl.value = `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`
  40. // pdfUrl.value = res.data.pdfUrl
  41. })
  42. }
  43. </script>
  44. <style lang="scss">
  45. .lli-demo-page {
  46. display: flex;
  47. flex-direction: column;
  48. height: 100vh;
  49. padding-bottom: 60rpx;
  50. box-sizing: border-box;
  51. .demo-scroll-view {
  52. overflow-y: auto;
  53. flex: 1;
  54. }
  55. .content-view {
  56. padding: 24px;
  57. box-sizing: border-box;
  58. }
  59. .demo-title {
  60. margin: 24px 0 10px;
  61. }
  62. }
  63. .pdf-container {
  64. width: 100%;
  65. height: 500px; // 固定高度
  66. position: relative;
  67. overflow: hidden;
  68. border: 1px solid #eee;
  69. margin-top: 20px;
  70. .web-view {
  71. width: 100%;
  72. height: 100%;
  73. display: block;
  74. }
  75. }
  76. </style>