HomeNew.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div class="hotspot-home">
  3. <h1
  4. :title="hotspotData.title"
  5. v-html="hotspotData.title"
  6. />
  7. <button
  8. class="close"
  9. @click="onClickClose"
  10. >
  11. <img
  12. src="@/assets/images/close.png"
  13. alt="关闭"
  14. draggable="false"
  15. >
  16. </button>
  17. <div
  18. v-if="isShowVideos"
  19. class="swiper-wrapper-mine video-wrap"
  20. >
  21. <div
  22. class="swiper-root swiper-root"
  23. >
  24. <div
  25. class="swiper-wrapper"
  26. >
  27. <div
  28. v-for="(item, index) in hotspotData.video"
  29. :key="index"
  30. class="swiper-slide"
  31. >
  32. <video
  33. ref="video"
  34. :src="item.url"
  35. controls
  36. controlslist="nodownload"
  37. disablePictureInPicture
  38. />
  39. </div>
  40. </div>
  41. <div class="swiper-pagination">
  42. <!-- <span class="cur">{{ currentSlideIdx + 1 }}</span> / <span>{{ typesForShow[currentTabIdx].list.length }}</span> -->
  43. </div>
  44. <div class="swiper-button-prev" />
  45. <div class="swiper-button-next" />
  46. </div>
  47. </div>
  48. <div
  49. v-show="isShowImages"
  50. class="swiper-wrapper-mine image-wrap"
  51. >
  52. <div
  53. class="swiper-root"
  54. >
  55. <div
  56. v-viewer="{
  57. button: true,
  58. navbar: false,
  59. title: false,
  60. toolbar: false,
  61. tooltip: false,
  62. movable: true,
  63. zoomable: true,
  64. rotatable: true,
  65. scalable: true,
  66. transition: false,
  67. fullscreen: false,
  68. keyboard: true,
  69. loop: false,
  70. }"
  71. class="swiper-wrapper"
  72. >
  73. <img
  74. v-for="(item, index) in hotspotData.images"
  75. :key="index"
  76. v-lazy="item"
  77. class="swiper-slide"
  78. alt=""
  79. draggable="false"
  80. >
  81. </div>
  82. <div class="swiper-pagination">
  83. <!-- <span
  84. class="cur"
  85. >
  86. {{ currentSlideIdx + 1 }}
  87. </span>
  88. /
  89. <span>
  90. {{ hotspotData.Images ? hotspotData.images.length : '' }}
  91. </span> -->
  92. </div>
  93. <div class="swiper-button-prev" />
  94. <div class="swiper-button-next" />
  95. </div>
  96. </div>
  97. <p
  98. class="desc"
  99. v-html="descForShow"
  100. />
  101. </div>
  102. </template>
  103. <script>
  104. import Swiper from 'swiper/swiper-bundle.esm.js'
  105. import 'swiper/swiper-bundle.css'
  106. // import browser from "@/utils/browser";
  107. export default {
  108. data() {
  109. return {
  110. hotspotData: {}, // 热点数据
  111. audioUrl: "", //背景音频url
  112. isShowImages: false,
  113. isShowVideos: false,
  114. currentSlideIdx: 0,
  115. }
  116. },
  117. computed: {
  118. descForShow() {
  119. if (this.isShowImages) {
  120. return this.hotspotData.imagesDesc[this.currentSlideIdx] || this.hotspotData.content
  121. } else if (this.isShowVideos) {
  122. return this.hotspotData.videosDesc[this.currentSlideIdx] || this.hotspotData.content
  123. } else {
  124. return ''
  125. }
  126. },
  127. },
  128. async mounted() {
  129. await this.getData()
  130. this.$nextTick(() => {
  131. const that = this
  132. new Swiper('.swiper-root', {
  133. pagination: {
  134. el: '.swiper-pagination',
  135. },
  136. navigation: {
  137. nextEl: '.swiper-button-next',
  138. prevEl: '.swiper-button-prev',
  139. },
  140. on: {
  141. // 自动播放
  142. afterInit: function (e) {
  143. if (that.isShowVideos) {
  144. that.$nextTick(() => {
  145. that.$refs.video[0].play()
  146. })
  147. }
  148. // if (that.typesForShow[vNew].key === 'audio') {
  149. // that.$nextTick(() => {
  150. // that.$refs['audio-comp'][0].play()
  151. // })
  152. // }
  153. },
  154. slideChange: function(e) {
  155. that.currentSlideIdx = e.activeIndex
  156. // 自动播放
  157. if (that.isShowVideos) {
  158. for (let index = 0; index < that.$refs.video.length; index++) {
  159. if (index !== that.currentSlideIdx) {
  160. that.$refs.video[index].pause()
  161. } else {
  162. that.$refs.video[index].play()
  163. }
  164. }
  165. }
  166. // if (that.typesForShow[vNew].key === 'audio') {
  167. // for (let index = 0; index < that.$refs['audio-comp'].length; index++) {
  168. // if (index !== that.currentSlideIdx) {
  169. // that.$refs['audio-comp'][index].pause()
  170. // } else {
  171. // that.$refs['audio-comp'][index].play()
  172. // }
  173. // }
  174. // }
  175. }
  176. }
  177. })
  178. })
  179. },
  180. methods: {
  181. async getData() {
  182. let url = `https://super.4dage.com/data/${this.$route.query.id}/hot/js/data.js?time=${Math.random()}`
  183. let result = (await this.$http.get(url)).data
  184. this.hotspotData = result[this.$route.query.m]
  185. if (!this.hotspotData) {
  186. return alert("热点解析错误")
  187. }
  188. console.log('热点数据:', this.hotspotData)
  189. this.audioUrl = this.hotspotData["backgroundMusic"]
  190. if (this.hotspotData.images && this.hotspotData.images.length) {
  191. this.isShowImages = true
  192. } else if (this.hotspotData.video && this.hotspotData.video.length) {
  193. this.isShowVideos = true
  194. }
  195. },
  196. onClickClose() {
  197. window.parent.document.getElementById('closepop').click()
  198. },
  199. }
  200. }
  201. </script>
  202. <style lang="less" scoped>
  203. .hotspot-home {
  204. position: absolute;
  205. left: 50%;
  206. top: 50%;
  207. transform: translate(-50%, -50%);
  208. width: 100%;
  209. height: 100%;
  210. max-width: 1329px;
  211. max-height: 848px;
  212. background: #E5DFCD;
  213. border-top: solid 8px #A10E0C;
  214. border-bottom: solid 8px #A10E0C;
  215. padding: 28px 100px;
  216. > button.close {
  217. position: absolute;
  218. top: 29px;
  219. right: 37px;
  220. width: 28px;
  221. height: 28px;
  222. > img {
  223. width: 100%;
  224. height: 100%;
  225. }
  226. }
  227. > h1 {
  228. text-align: center;
  229. font-size: 32px;
  230. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  231. font-weight: 400;
  232. color: #A10E0C;
  233. overflow: hidden;
  234. white-space: pre;
  235. text-overflow: ellipsis;
  236. margin-bottom: 28px;
  237. }
  238. .swiper-wrapper-mine {
  239. height: calc(100% - 32px - 28px - 22px - 72px);
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. position: relative;
  244. margin-bottom: 22px;
  245. .swiper-root {
  246. overflow: hidden;
  247. height: 100%;
  248. width: 100%;
  249. .swiper-wrapper {
  250. }
  251. .swiper-pagination {
  252. position: absolute;
  253. top: 100%;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. font-size: 1.33rem;
  257. font-family: Inter-Regular, Inter;
  258. color: #666;
  259. .cur {
  260. color: #930909;
  261. }
  262. }
  263. .swiper-button-prev {
  264. left: calc(-1.67rem - 1.83rem);
  265. width: 1.83rem;
  266. height: 3.58rem;
  267. background-image: url(../assets/images/arrow-left.png);
  268. background-size: contain;
  269. &::after {
  270. content: '';
  271. }
  272. }
  273. .swiper-button-next {
  274. right: calc(-1.67rem - 1.83rem);
  275. width: 1.83rem;
  276. height: 3.58rem;
  277. background-image: url(../assets/images/arrow-right.png);
  278. background-size: contain;
  279. &::after {
  280. content: '';
  281. }
  282. }
  283. }
  284. }
  285. .swiper-wrapper-mine.video-wrap {
  286. .swiper-root {
  287. .swiper-wrapper {
  288. .swiper-slide {
  289. > video {
  290. width: 100%;
  291. height: 100%;
  292. background: #000;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. // .swiper-wrapper-mine.model-wrap {
  299. // .swiper-root {
  300. // .swiper-wrapper {
  301. // }
  302. // }
  303. // }
  304. // .swiper-wrapper-mine.audio-wrap {
  305. // width: calc(100% - 1.67rem * 2 - 1.83rem * 2 - 1.67rem * 2);
  306. // height: 30rem;
  307. // position: absolute;
  308. // left: 50%;
  309. // top: 50%;
  310. // transform: translate(-50%, -70%);
  311. // .swiper-root {
  312. // width: 100%;
  313. // .swiper-wrapper {
  314. // }
  315. // }
  316. // }
  317. .swiper-wrapper-mine.image-wrap {
  318. .swiper-root {
  319. .swiper-wrapper {
  320. > img {
  321. width: 100%;
  322. height: 100%;
  323. object-fit: contain;
  324. }
  325. }
  326. }
  327. }
  328. > p.desc {
  329. font-size: 16px;
  330. color: #494140;
  331. line-height: 19px;
  332. height: 72px;
  333. overflow: auto;
  334. padding-right: 6px;
  335. }
  336. }
  337. /deep/.swiper-pagination-bullet-active {
  338. background: #a10e0c;
  339. }
  340. </style>