HomeMobile.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <div class="hotspot-home">
  3. <audio
  4. ref="bg-audio"
  5. class="bg-audio"
  6. :src="bgAudioUrl"
  7. loop
  8. autoplay
  9. />
  10. <button
  11. class="close"
  12. @click="onClickClose"
  13. >
  14. <img
  15. src="@/assets/images/close.png"
  16. alt="关闭"
  17. draggable="false"
  18. >
  19. </button>
  20. <h1
  21. :title="hotspotData.title"
  22. v-html="hotspotData.title"
  23. />
  24. <!-- <button class="download">
  25. <img
  26. class=""
  27. src="@/assets/images/download.png"
  28. alt=""
  29. draggable="false"
  30. >
  31. <span>
  32. Download brochure
  33. </span>
  34. </button> -->
  35. <div class="content-wrapper">
  36. <div
  37. class="desc"
  38. v-html="descForShow"
  39. />
  40. <div
  41. class="swiper-wrapper-mine image-wrapper"
  42. >
  43. <div
  44. class="swiper-root"
  45. >
  46. <div
  47. v-viewer="{
  48. button: true,
  49. navbar: false,
  50. title: false,
  51. toolbar: false,
  52. tooltip: false,
  53. movable: true,
  54. zoomable: true,
  55. rotatable: true,
  56. scalable: true,
  57. transition: false,
  58. fullscreen: false,
  59. keyboard: true,
  60. loop: false,
  61. }"
  62. class="swiper-wrapper img-list-wrapper"
  63. >
  64. <img
  65. v-for="(item, index) in hotspotData.images"
  66. :key="index"
  67. v-lazy="item"
  68. class="swiper-slide"
  69. :class="{
  70. single: hotspotData.images.length === 1
  71. }"
  72. alt=""
  73. draggable="false"
  74. >
  75. </div>
  76. <!-- <div class="swiper-pagination" />
  77. <div class="swiper-button-prev" />
  78. <div class="swiper-button-next" /> -->
  79. </div>
  80. </div>
  81. <div
  82. class="swiper-wrapper-mine video-wrapper"
  83. >
  84. <div
  85. class="swiper-root"
  86. >
  87. <div
  88. class="swiper-wrapper video-list-wrapper"
  89. >
  90. <div
  91. v-for="(item, index) in hotspotData.video"
  92. :key="index"
  93. class="swiper-slide"
  94. :class="{
  95. single: hotspotData.images.length === 1
  96. }"
  97. @click="viewVideo(item)"
  98. >
  99. <video
  100. ref="video"
  101. :src="item.url"
  102. />
  103. <img
  104. class="icon"
  105. src="@/assets/images/play.png"
  106. alt=""
  107. draggable="false"
  108. >
  109. </div>
  110. </div>
  111. <!-- <div class="swiper-pagination" />
  112. <div class="swiper-button-prev" />
  113. <div class="swiper-button-next" /> -->
  114. </div>
  115. </div>
  116. </div>
  117. <!-- <menu>
  118. <button
  119. v-if="bgAudioUrl"
  120. @click="isBgAudioMuted = !isBgAudioMuted"
  121. >
  122. <img
  123. v-show="isBgAudioMuted"
  124. class="bg-audio-control"
  125. src="@/assets/images/bg-audio-mobile.png"
  126. alt=""
  127. draggable="false"
  128. >
  129. <img
  130. v-show="!isBgAudioMuted"
  131. class="bg-audio-control"
  132. src="@/assets/images/bg-audio-mobile-muted.png"
  133. alt=""
  134. draggable="false"
  135. >
  136. </button>
  137. </menu> -->
  138. <div
  139. v-if="isShowVideoForPlay"
  140. class="video-for-play-wrapper"
  141. >
  142. <button
  143. class="close"
  144. @click="isShowVideoForPlay = false"
  145. >
  146. <img
  147. src="@/assets/images/close.png"
  148. alt="关闭"
  149. draggable="false"
  150. >
  151. </button>
  152. <video
  153. ref="video-for-play"
  154. :src="videoSrcForPlay"
  155. controls
  156. controlslist="nodownload"
  157. disablePictureInPicture
  158. />
  159. </div>
  160. </div>
  161. </template>
  162. <script>
  163. import Swiper from 'swiper/swiper-bundle.esm.js'
  164. import 'swiper/swiper-bundle.css'
  165. import { deepProcess } from "@/utils/other.js"
  166. export default {
  167. data() {
  168. return {
  169. hotspotData: {}, // 热点数据
  170. isShowVideoForPlay: false,
  171. videoSrcForPlay: '',
  172. bgAudioUrl: "", //背景音频url
  173. isBgAudioMuted: false,
  174. }
  175. },
  176. computed: {
  177. descForShow() {
  178. return this.hotspotData.content
  179. },
  180. },
  181. watch: {
  182. isBgAudioMuted: {
  183. handler(vNew) {
  184. if (vNew) {
  185. this.$refs['bg-audio'].pause() // or toggle静音?
  186. } else {
  187. this.$refs['bg-audio'].play() // or toggle静音?
  188. }
  189. }
  190. }
  191. },
  192. async mounted() {
  193. await this.getData()
  194. this.$nextTick(() => {
  195. const that = this
  196. new Swiper('.swiper-wrapper-mine .swiper-root', {
  197. slidesPerView: 'auto',
  198. // pagination: {
  199. // el: '.swiper-pagination',
  200. // },
  201. // navigation: {
  202. // nextEl: '.swiper-button-next',
  203. // prevEl: '.swiper-button-prev',
  204. // },
  205. // on: {
  206. // // 自动播放
  207. // afterInit: function (e) {
  208. // if (that.isShowVideos) {
  209. // that.$nextTick(() => {
  210. // that.$refs.video[0].play()
  211. // })
  212. // }
  213. // if (that.isShowAudios) {
  214. // that.$nextTick(() => {
  215. // that.$refs.audio[0].play()
  216. // })
  217. // }
  218. // },
  219. // slideChange: function(e) {
  220. // that.currentSlideIdx = e.activeIndex
  221. // // 自动播放
  222. // if (that.isShowVideos) {
  223. // for (let index = 0; index < that.$refs.video.length; index++) {
  224. // if (index !== that.currentSlideIdx) {
  225. // that.$refs.video[index].pause()
  226. // } else {
  227. // that.$refs.video[index].play()
  228. // }
  229. // }
  230. // }
  231. // if (that.isShowAudios) {
  232. // for (let index = 0; index < that.$refs.audio.length; index++) {
  233. // if (index !== that.currentSlideIdx) {
  234. // that.$refs.audio[index].pause()
  235. // } else {
  236. // that.$refs.audio[index].play()
  237. // }
  238. // }
  239. // }
  240. // }
  241. // }
  242. })
  243. })
  244. },
  245. methods: {
  246. // changeSubStr(str) {
  247. // return str.replace('https://super.4dage.com/', process.env.VUE_APP_G_PREFIX)
  248. // },
  249. async getData() {
  250. let url = `${process.env.VUE_APP_G_PREFIX}/data/${this.$route.query.id}/hot/js/data.js?time=${Math.random()}`
  251. let result = (await this.$http.get(url)).data
  252. // deepProcess(result, this.changeSubStr) // 本地化部署时的处理
  253. this.hotspotData = result[this.$route.query.m]
  254. if (!this.hotspotData) {
  255. return alert("热点解析错误")
  256. }
  257. console.log('热点数据:', this.hotspotData)
  258. this.bgAudioUrl = this.hotspotData.backgroundMusic
  259. if (this.hotspotData.backgroundMusic) {
  260. this.isShowAudios = true
  261. this.hotspotData.audio = [{ url: this.hotspotData.backgroundMusic }]
  262. }
  263. },
  264. viewVideo(videoItem) {
  265. this.videoSrcForPlay = videoItem.url
  266. this.isShowVideoForPlay = true
  267. this.$nextTick(() => {
  268. this.$refs['video-for-play'].play()
  269. })
  270. },
  271. onClickClose() {
  272. window.parent.document.getElementById('closepop').click()
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="less" scoped>
  278. .hotspot-home {
  279. position: absolute;
  280. left: 50%;
  281. top: 50%;
  282. transform: translate(-50%, -50%);
  283. z-index: 0;
  284. border-top: 2.1vw solid #00A0E6;
  285. width: 81.5vw;
  286. height: 80vh;
  287. background: #fff;
  288. display: flex;
  289. flex-direction: column;
  290. align-items: flex-start;
  291. padding: 9vw 1vw 4vw 4vw;
  292. > .bg-audio {
  293. display: none;
  294. }
  295. > button.close {
  296. position: absolute;
  297. top: 4.8vw;
  298. right: 2.8vw;
  299. width: 6.2vw;
  300. height: 6.2vw;
  301. z-index: 1;
  302. > img {
  303. width: 100%;
  304. height: 100%;
  305. }
  306. }
  307. > h1 {
  308. font-size: 5vw;
  309. font-weight: bold;
  310. color: #1F3E7C;
  311. line-height: 1.5em;
  312. flex: 0 0 auto;
  313. }
  314. > button.download {
  315. margin-top: 3vw;
  316. height: 5.4vw;
  317. border: 1px solid #00A0E6;
  318. border-radius: 2.7vw;
  319. padding-left: 2.5vw;
  320. padding-right: 2.5vw;
  321. font-size: 2.8vw;
  322. color: #00A0E6;
  323. > img {
  324. vertical-align: middle;
  325. width: 2.9vw;
  326. height: 3.2vw;
  327. margin-right: 1vw;
  328. }
  329. > span {
  330. vertical-align: middle;
  331. }
  332. }
  333. > .content-wrapper {
  334. flex: 1 0 1px;
  335. overflow: auto;
  336. margin-top: 6.2vw;
  337. padding-right: 3vw;
  338. width: 100%;
  339. > .desc {
  340. font-family: Adobe Heiti Std;
  341. font-size: 3.6vw;
  342. color: #666666;
  343. line-height: 5.3vw;
  344. }
  345. .swiper-wrapper-mine {
  346. margin-top: 5vw;
  347. .swiper-root {
  348. overflow: hidden;
  349. height: 100%;
  350. width: 100%;
  351. .swiper-wrapper.img-list-wrapper {
  352. > .swiper-slide {
  353. object-fit: contain;
  354. border-radius: 4px;
  355. margin-right: 1.8vw;
  356. width: 30.2vw;
  357. height: 19.6vw;
  358. position: relative;
  359. }
  360. > .swiper-slide.single {
  361. width: 100%;
  362. height: initial;
  363. margin-right: initial;
  364. }
  365. }
  366. .swiper-wrapper.video-list-wrapper {
  367. > .swiper-slide {
  368. margin-right: 1.8vw;
  369. width: 30.2vw;
  370. height: 19.6vw;
  371. position: relative;
  372. > video {
  373. object-fit: contain;
  374. border-radius: 4px;
  375. width: 100%;
  376. height: 100%;
  377. }
  378. > img.icon {
  379. position: absolute;
  380. left: 50%;
  381. top: 50%;
  382. transform: translate(-50%, -50%);
  383. width: 6.2vw;
  384. height: 6.2vw;
  385. }
  386. }
  387. > .swiper-slide.single {
  388. width: 100%;
  389. height: initial;
  390. margin-right: initial;
  391. }
  392. }
  393. .swiper-pagination {
  394. }
  395. .swiper-button-prev {
  396. }
  397. .swiper-button-next {
  398. }
  399. }
  400. }
  401. }
  402. > .video-for-play-wrapper {
  403. position: absolute;
  404. left: 0;
  405. top: 0;
  406. width: 100%;
  407. height: 100%;
  408. background: rgba(0, 0, 0, 0.95);
  409. z-index: 2;
  410. > button.close {
  411. position: absolute;
  412. top: 4.8vw;
  413. right: 2.8vw;
  414. width: 6.2vw;
  415. height: 6.2vw;
  416. z-index: 1;
  417. > img {
  418. width: 100%;
  419. height: 100%;
  420. }
  421. }
  422. > video {
  423. position: absolute;
  424. left: 50%;
  425. top: 50%;
  426. transform: translate(-50%, -50%);
  427. width: 100%;
  428. }
  429. }
  430. }
  431. /deep/.swiper-pagination-bullet-active {
  432. background: #a10e0c;
  433. }
  434. </style>