HomeMobile.vue 9.2 KB

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