Hot.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <div class="Hot" :class="{ active: show }" @click.stop="">
  3. <div class="close" @click="$emit('hotClose')">
  4. <img src="../assets/img/hotClose.png" alt="" />
  5. </div>
  6. <!-- 查看图片 -->
  7. <viewer class="viewerCla" ref="viewer" :images="lookPics">
  8. <img :src="lookPics[0]" alt="" />
  9. </viewer>
  10. <!-- 轮播图 -->
  11. <div class="swBox">
  12. <div class="swiper-container" ref="mySwiper" :key="type">
  13. <div class="swiper-wrapper">
  14. <div class="swiper-slide" v-for="(item, index) in data" :key="index">
  15. <div
  16. class="infoTxt"
  17. :class="{ videoAc: type === 'video' }"
  18. v-if="item.title"
  19. >
  20. <h3>{{ item.title.split("&")[0] }}</h3>
  21. <div v-html="item.content" v-show="type !== 'video'"></div>
  22. </div>
  23. <!-- 图片 -->
  24. <template v-if="type === 'image'">
  25. <img
  26. @click="
  27. lookImg(
  28. `https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.image[0].src}`
  29. )
  30. "
  31. v-if="item.media && item.media.image[0]"
  32. v-lazy="
  33. `https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.image[0].src}`
  34. "
  35. alt=""
  36. />
  37. <img
  38. src="../assets/img/IMGerror.png"
  39. style="pointer-events: none"
  40. alt=""
  41. v-else
  42. />
  43. </template>
  44. <!-- 视频 -->
  45. <template v-else-if="type === 'video'">
  46. <div class="videoBox">
  47. <div>
  48. <video
  49. v-if="item.media && item.media.video[0]"
  50. controls
  51. :src="`https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.video[0].src}`"
  52. ></video>
  53. </div>
  54. </div>
  55. </template>
  56. <!-- 模型 -->
  57. <template v-else-if="type === 'link'">
  58. <div class="ifrBox">
  59. <iframe
  60. v-if="item.media && item.media.link[0]"
  61. :src="`${item.media.link[0].src}`"
  62. frameborder="0"
  63. ></iframe>
  64. </div>
  65. </template>
  66. <!-- 音乐 -->
  67. <template v-else>
  68. <Audio
  69. :Aid="item.media.audio[0].src"
  70. v-if="item.media && item.media.audio[0]&&audioIndex===index"
  71. :audioSrc="`https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.audio[0].src}`"
  72. />
  73. </template>
  74. </div>
  75. </div>
  76. <div class="swiper-pagination" v-show="data.length > 1"></div>
  77. <div
  78. class="swiper-button-prev swiper-button-white"
  79. v-show="data.length > 1"
  80. :class="{ noneAc: true }"
  81. ></div>
  82. <div
  83. class="swiper-button-next swiper-button-white"
  84. v-show="data.length > 1"
  85. :class="{ noneAc: true }"
  86. ></div>
  87. </div>
  88. </div>
  89. <!-- 右下角的按钮 -->
  90. <div class="mainrr">
  91. <div
  92. class="row"
  93. v-show="item.show"
  94. v-for="item in rightList"
  95. :key="item.id"
  96. @click="type = item.type"
  97. :class="{ active: item.type === type }"
  98. >
  99. <img
  100. :src="
  101. require(`@/assets/img/Hot/inco${item.id}${
  102. item.type === type ? 'Ac' : ''
  103. }.png`)
  104. "
  105. alt=""
  106. />
  107. <p>{{ item.name }}{{ info[item.type] && info[item.type].length }}</p>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. <script>
  113. import Audio from "./Audio.vue";
  114. import Swiper from "./swiper.js";
  115. export default {
  116. props: {
  117. info: {
  118. type: Object,
  119. default: () => {},
  120. },
  121. },
  122. name: "Hot",
  123. components: { Audio },
  124. data() {
  125. //这里存放数据
  126. return {
  127. lookPics: [],
  128. show: false,
  129. data: [],
  130. type: "",
  131. rightList: [
  132. { name: "视频", id: 1, show: false, type: "video" },
  133. { name: "模型", id: 2, show: false, type: "link" },
  134. { name: "音乐", id: 3, show: false, type: "audio" },
  135. { name: "图片", id: 4, show: false, type: "image" },
  136. ],
  137. Swiper: null,
  138. KKNum: window.KKNum,
  139. audioIndex:0
  140. };
  141. },
  142. //监听属性 类似于data概念
  143. computed: {},
  144. //监控data中的数据变化
  145. watch: {
  146. type(val) {
  147. if (val === "video") {
  148. this.$nextTick(() => {
  149. setTimeout(() => {
  150. let videoDoms = document.querySelectorAll(".Hot video");
  151. videoDoms[0].play();
  152. }, 200);
  153. });
  154. }
  155. // else if (val === "audio") {
  156. // this.$nextTick(() => {
  157. // setTimeout(() => {
  158. // let audioDoms = document.querySelectorAll(".Hot audio");
  159. // audioDoms[0].play();
  160. // }, 200);
  161. // });
  162. // }
  163. this.Swiper = null;
  164. this.data = this.info[val];
  165. this.$nextTick(() => {
  166. setTimeout(() => {
  167. this.Swiper = new Swiper(".Hot .swiper-container", {
  168. slidesPerView: 1,
  169. // 如果需要前进后退按钮
  170. navigation: {
  171. nextEl: ".swiper-button-next",
  172. prevEl: ".swiper-button-prev",
  173. },
  174. pagination: {
  175. el: ".swiper-pagination",
  176. },
  177. on: {
  178. slideChange: () => {
  179. if (val === "video") {
  180. let dom = document.querySelectorAll(
  181. ".Hot .swiper-pagination-bullet"
  182. );
  183. let index;
  184. dom.forEach((v, i) => {
  185. if (v.className.includes("swiper-pagination-bullet-active"))
  186. index = i;
  187. });
  188. this.$nextTick(() => {
  189. setTimeout(() => {
  190. let videoDoms = document.querySelectorAll(".Hot video");
  191. videoDoms.forEach((v, i) => {
  192. if (i === index) v.play();
  193. else v.pause();
  194. });
  195. }, 200);
  196. });
  197. }
  198. if (val === "audio") {
  199. let dom = document.querySelectorAll(
  200. ".Hot .swiper-pagination-bullet"
  201. );
  202. dom.forEach((v, i) => {
  203. if (v.className.includes("swiper-pagination-bullet-active"))
  204. this.audioIndex = i;
  205. });
  206. // this.$nextTick(() => {
  207. // setTimeout(() => {
  208. // let audioDoms = document.querySelectorAll(".Hot audio");
  209. // audioDoms.forEach((v, i) => {
  210. // if (i === this.audioIndex) v.play();
  211. // else v.pause();
  212. // });
  213. // }, 200);
  214. // });
  215. }
  216. },
  217. },
  218. });
  219. }, 100);
  220. });
  221. },
  222. info: {
  223. handler(val) {
  224. this.info = val;
  225. let obj = {
  226. video: 0,
  227. link: 1,
  228. audio: 2,
  229. image: 3,
  230. };
  231. for (const k in val) {
  232. if (val[k].length) this.rightList[obj[k]].show = true;
  233. }
  234. if (val["image"] && val["image"].length) this.type = "image";
  235. else if (val["video"] && val["video"].length) this.type = "video";
  236. else if (val["link"] && val["link"].length) this.type = "link";
  237. else if (val["audio"] && val["audio"].length) this.type = "audio";
  238. },
  239. immediate: true,
  240. },
  241. },
  242. //方法集合
  243. methods: {
  244. // 点击查看大图
  245. lookImg(url) {
  246. let dom = this.$refs.viewer.$viewer;
  247. this.lookPics = [url];
  248. dom.show();
  249. },
  250. },
  251. //生命周期 - 创建完成(可以访问当前this实例)
  252. created() {},
  253. //生命周期 - 挂载完成(可以访问DOM元素)
  254. mounted() {
  255. setTimeout(() => {
  256. this.show = true;
  257. }, 300);
  258. },
  259. beforeCreate() {}, //生命周期 - 创建之前
  260. beforeMount() {}, //生命周期 - 挂载之前
  261. beforeUpdate() {}, //生命周期 - 更新之前
  262. updated() {}, //生命周期 - 更新之后
  263. beforeDestroy() {}, //生命周期 - 销毁之前
  264. destroyed() {}, //生命周期 - 销毁完成
  265. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  266. };
  267. </script>
  268. <style lang='less' scoped>
  269. @import "./swiper.css";
  270. .viewerCla img {
  271. display: none;
  272. }
  273. .Hot {
  274. opacity: 0.3;
  275. pointer-events: none;
  276. transition: opacity 0.3s;
  277. position: absolute;
  278. top: 0;
  279. left: 0;
  280. z-index: 99;
  281. width: 100%;
  282. height: 100%;
  283. background-color: rgba(255, 251, 245, 0.9);
  284. backdrop-filter: blur(4px);
  285. .close {
  286. cursor: pointer;
  287. width: 60px;
  288. position: absolute;
  289. z-index: 10;
  290. top: 45px;
  291. right: 45px;
  292. img {
  293. width: 60px;
  294. }
  295. }
  296. .mainrr {
  297. display: flex;
  298. position: absolute;
  299. bottom: 15px;
  300. right: 20px;
  301. z-index: 10;
  302. .row {
  303. position: relative;
  304. cursor: pointer;
  305. width: 50px;
  306. text-align: center;
  307. margin-left: 15px;
  308. color: #666666;
  309. & > img {
  310. width: 50px;
  311. }
  312. p {
  313. font-size: 12px;
  314. }
  315. .likeMove {
  316. color: #930909;
  317. position: absolute;
  318. top: 10px;
  319. width: 100%;
  320. text-align: center;
  321. }
  322. }
  323. .active {
  324. color: #930909;
  325. font-weight: 700;
  326. p {
  327. font-size: 12px;
  328. }
  329. }
  330. }
  331. .swBox {
  332. position: absolute;
  333. top: 0;
  334. left: 0;
  335. width: 100%;
  336. height: 100%;
  337. .swiper-container {
  338. cursor: grab;
  339. height: 100%;
  340. .swiper-slide {
  341. position: relative;
  342. .infoTxt {
  343. z-index: 10;
  344. position: absolute;
  345. top: 40px;
  346. left: 40px;
  347. width: 310px;
  348. & > h3 {
  349. font-size: 20px;
  350. color: #930909;
  351. font-weight: 700;
  352. line-height: 28px;
  353. margin-bottom: 15px;
  354. }
  355. & > div {
  356. color: #666666;
  357. font-size: 16px;
  358. }
  359. }
  360. .videoAc {
  361. pointer-events: none;
  362. width: 1200px;
  363. height: 680px;
  364. position: absolute;
  365. top: 50%;
  366. left: 50%;
  367. transform: translate(-50%, -50%);
  368. padding: 74px 0 0 140px;
  369. z-index: 30;
  370. h3 {
  371. color: #ffffff;
  372. }
  373. }
  374. .videoBox {
  375. width: 1200px;
  376. height: 680px;
  377. position: absolute;
  378. top: 50%;
  379. left: 50%;
  380. transform: translate(-50%, -50%);
  381. background-image: url("../assets/img/Hot/videoBac.png");
  382. background-size: 100% 100%;
  383. padding: 135px 90px 0 140px;
  384. & > div {
  385. width: 100%;
  386. height: 100%;
  387. overflow: hidden;
  388. video {
  389. height: 100%;
  390. }
  391. }
  392. }
  393. .ifrBox {
  394. position: absolute;
  395. top: 0;
  396. left: 0;
  397. width: 100%;
  398. height: 100%;
  399. overflow: hidden;
  400. iframe {
  401. width: 100%;
  402. height: 100%;
  403. }
  404. }
  405. img {
  406. cursor: pointer;
  407. position: absolute;
  408. top: 50%;
  409. left: 50%;
  410. transform: translate(-50%, -50%);
  411. max-width: 900px;
  412. max-height: 700px;
  413. object-fit: cover;
  414. }
  415. }
  416. .swiper-pagination {
  417. bottom: 50px;
  418. }
  419. .swiper-button-next {
  420. // opacity: 1;
  421. // pointer-events: auto;
  422. width: 40px;
  423. height: 60px;
  424. right: 60px;
  425. background-image: url("../assets/img/Hot/right.png");
  426. background-size: 100% 100%;
  427. color: transparent;
  428. }
  429. .swiper-button-prev {
  430. // opacity: 1;
  431. // pointer-events: auto;
  432. width: 40px;
  433. height: 60px;
  434. left: 60px;
  435. background-image: url("../assets/img/Hot/left.png");
  436. background-size: 100% 100%;
  437. color: transparent;
  438. }
  439. /deep/.swiper-pagination-bullet {
  440. width: 70px;
  441. height: 4px;
  442. border-radius: 1px;
  443. opacity: 1;
  444. background-color: #999999;
  445. }
  446. /deep/.swiper-pagination-bullet-active {
  447. background-color: #930909;
  448. }
  449. }
  450. }
  451. }
  452. .active {
  453. opacity: 1;
  454. pointer-events: auto;
  455. }
  456. </style>