dqgzDangjiangongzuoInfo.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view v-if="data.info">
  3. <!-- 详情页面 -->
  4. <view>校园动态</view>
  5. <!-- 导航 -->
  6. <view>首页>校园动态>学院新闻</view>
  7. <!-- 标题 -->
  8. <view>{{data.info.title}}</view>
  9. <!-- 时间 -->
  10. <view>{{formatDate.join('-') }}</view>
  11. <!-- 富文本 -->
  12. <!-- <mp-html @fullscreenchange="handleFullscreen" :content="data.info.content" />-->
  13. <MtaMpHtml :content="data.info.content" ></MtaMpHtml>
  14. <view @click="handleDownFile">文件下载</view>
  15. <!-- PDF -->
  16. <!-- <web-view
  17. v-if="pdfUrl"
  18. :src="pdfUrl"
  19. class="web-view"
  20. ></web-view> -->
  21. </view>
  22. </template>
  23. <script setup>
  24. import {
  25. ref,
  26. reactive,
  27. computed,
  28. onMounted,
  29. onUnmounted
  30. } from "vue";
  31. import {
  32. onLoad
  33. } from "@dcloudio/uni-app"
  34. import * as httpApi from "@/api/common.js"
  35. import {formatDateToYearMonthDay } from "@/utils/common.js"
  36. import MtaMpHtml from "@/components/MTAMpHtml/MtaMpHtml.vue"
  37. const data = reactive({
  38. info: null,
  39. id: null
  40. })
  41. const isFullscreen = ref(false)
  42. const formatDate = computed(() => {
  43. if (data.info && data.info.createTime) {
  44. return formatDateToYearMonthDay(data.info.createTime)
  45. }
  46. return []
  47. })
  48. const pdfUrl = "https://kf3.mtavip.com/api/upload/resource/uploadFile60eebb8881e94278bc46bedba12aece6.pdf"
  49. onLoad(({
  50. id
  51. }) => {
  52. data.id = id;
  53. pageInit();
  54. })
  55. onMounted(() => {
  56. // 监听全屏变化
  57. document.addEventListener('fullscreenchange', handleFullscreenChange)
  58. document.addEventListener('webkitfullscreenchange', handleFullscreenChange)
  59. })
  60. onUnmounted(() => {
  61. document.removeEventListener('fullscreenchange', handleFullscreenChange)
  62. document.removeEventListener('webkitfullscreenchange', handleFullscreenChange)
  63. })
  64. function handleFullscreen(e) {
  65. // 处理全屏事件
  66. isFullscreen.value = e.detail.fullscreen
  67. }
  68. function handleFullscreenChange() {
  69. // 检查当前是否处于全屏状态
  70. const fullscreenElement = document.fullscreenElement ||
  71. document.webkitFullscreenElement
  72. if (!fullscreenElement) {
  73. // 如果退出全屏
  74. isFullscreen.value = false
  75. }
  76. }
  77. function handleDownFile() {
  78. window.location.href = pdfUrl;
  79. }
  80. function pageInit() {
  81. httpApi.getDangjianGongzuoInfo({
  82. id: data.id
  83. }).then(res => {
  84. data.info = res.data;
  85. console.log('dddd', data.info)
  86. })
  87. }
  88. </script>
  89. <style lang="scss">
  90. .web-view {
  91. height: 200px;
  92. margin-top: 20px
  93. }
  94. </style>