111111.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <mp-html @fullscreenchange="handleFullscreen" :content="data.info.content" />
  3. </template>
  4. <script setup>
  5. import {
  6. ref,
  7. reactive,
  8. computed,
  9. onMounted,
  10. onUnmounted
  11. } from "vue";
  12. import {
  13. onLoad
  14. } from "@dcloudio/uni-app"
  15. import * as httpApi from "@/api/common.js"
  16. import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html'
  17. import {formatDateToYearMonthDay } from "@/utils/common.js"
  18. const data = reactive({
  19. info: null,
  20. id: null
  21. })
  22. const isFullscreen = ref(false)
  23. const formatDate = computed(() => {
  24. if (data.info && data.info.createTime) {
  25. return formatDateToYearMonthDay(data.info.createTime)
  26. }
  27. return []
  28. })
  29. const pdfUrl = "https://kf3.mtavip.com/api/upload/resource/uploadFile60eebb8881e94278bc46bedba12aece6.pdf"
  30. onLoad(({
  31. id
  32. }) => {
  33. data.id = id;
  34. pageInit();
  35. })
  36. onMounted(() => {
  37. // 监听全屏变化
  38. document.addEventListener('fullscreenchange', handleFullscreenChange)
  39. document.addEventListener('webkitfullscreenchange', handleFullscreenChange)
  40. })
  41. function handleFullscreen(e) {
  42. // 处理全屏事件
  43. isFullscreen.value = e.detail.fullscreen
  44. }
  45. function handleFullscreenChange() {
  46. // 检查当前是否处于全屏状态
  47. const fullscreenElement = document.fullscreenElement ||
  48. document.webkitFullscreenElement
  49. if (!fullscreenElement) {
  50. // 如果退出全屏
  51. isFullscreen.value = false
  52. }
  53. }
  54. function pageInit() {
  55. httpApi.getDangjianGongzuoInfo({
  56. id: data.id
  57. }).then(res => {
  58. data.info = res.data;
  59. console.log('dddd', data.info)
  60. })
  61. }
  62. onUnmounted(() => {
  63. document.removeEventListener('fullscreenchange', handleFullscreenChange)
  64. document.removeEventListener('webkitfullscreenchange', handleFullscreenChange)
  65. })
  66. </script>
  67. <style lang="scss">
  68. .web-view {
  69. height: 200px;
  70. margin-top: 20px
  71. }
  72. </style>