dynamic-detail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <script setup lang='ts'>
  2. import { DynamicApi } from '@/api/api/dynamic';
  3. import { showToast } from 'vant';
  4. import { baseIMGUrl } from '@/api/request.ts'
  5. // import { DynamicApi } from "@/api/api/dynamic/index";
  6. // import { showToast } from "vant";
  7. // const router = useRouter()
  8. const route = useRoute()
  9. export type dynamicDetailType = {
  10. createTime: string,
  11. creatorId: number,
  12. creatorName: string,
  13. description: string,
  14. dirCode: string,
  15. fileIds: string,
  16. files: any,
  17. id: number,
  18. name: string,
  19. publishDate: string,
  20. rtf: string,
  21. thumb: string,
  22. type: string,
  23. updateTime: string
  24. }
  25. const dynamicDetail = ref({} as dynamicDetailType)
  26. const videos = ref([] as any)
  27. const getDetailById = async () => {
  28. // 获取活动详情
  29. const res: any = await DynamicApi.getDetailById(Number(route.params.id))
  30. if (res.code == 0) {
  31. dynamicDetail.value = res.data
  32. videos.value = res.data.files.filter((item: any) => {
  33. return item.filePath.includes('.mp4')
  34. })
  35. } else {
  36. showToast(res.msg)
  37. }
  38. }
  39. const formatrtf = computed(() => {
  40. return dynamicDetail.value.rtf.replace(
  41. /<img /g,
  42. '<img style="width: 100%;" '
  43. ).replace(
  44. /<p\b[^>]*>/g,
  45. '<p style="width: 100%; word-wrap: break-word;">'
  46. );
  47. })
  48. onBeforeMount(async () => {
  49. getDetailById()
  50. })
  51. </script>
  52. <template>
  53. <div class='detail-box'>
  54. <img class="themb-box" :src="baseIMGUrl + dynamicDetail.thumb" alt="">
  55. <div class="content-box">
  56. <div class="title-box">{{ dynamicDetail.name }}</div>
  57. <div class="time-box">发布时间:{{ dynamicDetail.publishDate }}</div>
  58. <div class="abstract-box">{{ dynamicDetail.description }}</div>
  59. <div class="mainbody-box" v-html="formatrtf"></div>
  60. <div class="video-box">
  61. <video :src="baseIMGUrl + item.filePath" controls v-for="(item, index) in videos" :key="index"></video>
  62. </div>
  63. </div>
  64. <!-- <img class="back-icon" @click="() => { router.back() }" src="@/assets/images/back.png" alt=""> -->
  65. </div>
  66. </template>
  67. <style lang='less' scoped>
  68. .detail-box {
  69. width: 100%;
  70. min-height: 100%;
  71. overflow: auto;
  72. .themb-box {
  73. width: 100%;
  74. height: 30vh;
  75. object-fit: cover;
  76. }
  77. .content-box {
  78. width: 100%;
  79. height: calc(70vh + 25px);
  80. background: #F7F3E8;
  81. border-radius: 20px 20px 0 0;
  82. margin-top: -30px;
  83. position: relative;
  84. z-index: 2;
  85. padding: 8% 15px 8% 15px 20% 15px;
  86. box-sizing: border-box;
  87. overflow: auto;
  88. .title-box {
  89. font-size: 1.4em;
  90. font-weight: bold;
  91. line-height: 1.5em;
  92. color: #333333;
  93. margin-bottom: 10px;
  94. padding: 0 10px;
  95. font-family: 'SourceHanSansCN-Medium';
  96. margin-bottom: 5px;
  97. }
  98. .time-box {
  99. color: #9D4F0B;
  100. font-size: 0.9em;
  101. margin-bottom: 15px;
  102. padding: 0 10px;
  103. font-family: 'SourceHanSansCN-Regular';
  104. }
  105. .abstract-box {
  106. color: #88866F;
  107. font-size: 1em;
  108. margin-bottom: 10px;
  109. padding: 0 10px;
  110. font-family: 'SourceHanSansCN-Medium';
  111. overflow-wrap: break-word;
  112. }
  113. .mainbody-box {
  114. width: 100%;
  115. // white-space: pre;
  116. margin-bottom: 10px;
  117. padding: 0 10px;
  118. }
  119. .video-box {
  120. width: 100%;
  121. video {
  122. width: 100%;
  123. height: 30vh;
  124. margin-bottom: 10px;
  125. }
  126. }
  127. }
  128. // .back-icon {
  129. // width: 40px;
  130. // position: fixed;
  131. // right: 10px;
  132. // bottom: 10vh;
  133. // }
  134. }
  135. </style>