Home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <template>
  2. <div class="home">
  3. <div class="main">
  4. <div class="mainCon" v-show="!oneTxt">
  5. <!-- 音频播放器 -->
  6. <audio id="myAudio" v-if="audio" v-show="isOneAduio" :src="audio" controls></audio>
  7. <!-- 音频图标 -->
  8. <div class="audioIcon" v-if="audio && !isOneAduio" @click="audioSta = !audioSta"
  9. :title="audioSta ? '关闭音频' : '打开音频'">
  10. <img :src="require(`@/assets/images/pc/audio${audioSta ? 'Ac' : ''}.png`)
  11. " alt="" />
  12. </div>
  13. <!-- 如果只有一个模块 -->
  14. <div class="oneTabNum" v-if="flooTab.length === 1 && data[myType] && data[myType].length">
  15. {{ myInd + 1 }} / {{ data[myType].length }}
  16. </div>
  17. <!-- 底部的tab -->
  18. <div class="flooTabBox" v-if="flooTab.length > 1">
  19. <div @click="myType = item.type" class="tabRow" :class="{ tabRowAc: myType === item.type }"
  20. v-for="item in flooTab" :key="item.id">
  21. <img :src="require(`@/assets/images/pc/icon${item.id}${myType === item.type ? 'Ac' : ''
  22. }.png`)
  23. " alt="" />
  24. <!-- {{ item.name }}
  25. <span v-if="data[item.type] &&
  26. data[item.type].length &&
  27. data[item.type].length > 1
  28. ">{{ item.type === myType ? myInd + 1 + "/" : null
  29. }}{{ data[item.type].length }}</span> -->
  30. </div>
  31. </div>
  32. <!-- 主要内容 -->
  33. <div class="contenBoxMain">
  34. <div class="contenBox" :class="{ contenBoxAc: index === myInd }" v-for="(item, index) in data[myType]"
  35. :key="myType === 'video' ? item.url : item">
  36. <!-- 模型页面 -->
  37. <div class="modelBox" v-if="myType === 'model'">
  38. <iframe :src="item" frameborder="0" v-if="index === myInd"></iframe>
  39. </div>
  40. <!-- 视频页面 -->
  41. <div class="videoBox" v-else-if="myType === 'video'">
  42. <video id="videoID" controls :src="item.url" v-if="index === myInd" autoplay></video>
  43. </div>
  44. <!-- 图片页面 -->
  45. <div class="imgBox" v-else-if="myType === 'img'">
  46. <div class="smImgBox" @click="lookImg(item)">
  47. <img v-lazy="item" alt="" />
  48. </div>
  49. </div>
  50. </div>
  51. <!-- 左右箭头 -->
  52. <div @click="cutMyInd(-1, myInd === 0)" class="leftJJ awccJJ" :class="{ noClick: myInd === 0 }"
  53. v-if="data[myType] && data[myType].length > 1"></div>
  54. <div @click="cutMyInd(1, myInd === data[myType].length - 1)" class="rightJJ awccJJ"
  55. :class="{ noClick: myInd === data[myType].length - 1 }" v-if="data[myType] && data[myType].length > 1">
  56. </div>
  57. </div>
  58. </div>
  59. <!-- 下面的文字介绍 -->
  60. <div class="flooTxt" :class="{ flooTxtOne: oneTxt }">
  61. <div class="flooTxtBox">
  62. <div class="myTitle">{{ myTitle }}</div>
  63. <!-- 视频的介绍 -->
  64. <div class="myTxt" v-if="myType === 'video' && videoTxt[myInd]">
  65. {{ videoTxt[myInd] }}
  66. </div>
  67. <div class="myTxt" v-if="myType === 'img' && imgTxt[myInd]">
  68. {{ imgTxt[myInd] }}
  69. </div>
  70. <div class="myTxt" v-html="myTxt"></div>
  71. </div>
  72. </div>
  73. </div>
  74. <!-- 查看图片 -->
  75. <viewer class="viewerCla" ref="viewer" :images="lookPics">
  76. <img :src="lookPics[0]" alt="" />
  77. </viewer>
  78. </div>
  79. </template>
  80. <script>
  81. export default {
  82. name: "Home",
  83. data() {
  84. return {
  85. m: this.$route.query.m,
  86. id: this.$route.query.id,
  87. // 音频地址
  88. audio: "",
  89. // 如果只有单独的音频
  90. isOneAduio: false,
  91. // 音频状态
  92. audioSta: false,
  93. data: {
  94. // 模型数组
  95. model: [],
  96. // 视频数组
  97. video: [],
  98. // 图片数组
  99. img: [],
  100. },
  101. // 当前 type
  102. myType: "",
  103. // 底部的tab
  104. flooTab: [],
  105. // 当前索引
  106. myInd: 0,
  107. // 查看图片
  108. lookPics: [],
  109. // 标题
  110. myTitle: "",
  111. // 内容
  112. myTxt: "",
  113. // 视频内容
  114. videoTxt: [],
  115. imgTxt: [],
  116. // 只有标题和文字(没有视频,没有模型,没有图片)
  117. oneTxt: false,
  118. // 热点打开时间
  119. time: 0,
  120. };
  121. },
  122. watch: {
  123. myType(val) {
  124. this.myInd = 0;
  125. if (val === 'img') {
  126. // 开始计时
  127. const timer = setInterval(() => {
  128. this.time += 1
  129. console.log('热点打开计时', this.time)
  130. if (this.time === 5) {
  131. console.log('热点打开计时', this.time, '已经到5s了,可以进行积分了')
  132. this.time = 0
  133. // 5s后停止计时器,且调用方法
  134. clearInterval(timer)
  135. // 点开展板,累计积分
  136. if (window.parent && window.parent.window.parent.window && window.parent.window.parent.window.addScoreFu) {
  137. window.parent.window.parent.window.addScoreFu('观看展板')
  138. }
  139. }
  140. }, 1000)
  141. } else if (val === 'video') {
  142. // 开始计时
  143. const timer = setInterval(() => {
  144. this.time += 1
  145. console.log('热点打开计时', this.time)
  146. if (this.time === 10) {
  147. console.log('热点打开计时', this.time, '已经到10s了,可以进行积分了')
  148. this.time = 0
  149. // 5s后停止计时器,且调用方法
  150. clearInterval(timer)
  151. // 点开视频,累计积分
  152. if (window.parent && window.parent.window.parent.window && window.parent.window.parent.window.addScoreFu) {
  153. window.parent.window.parent.window.addScoreFu('观看视频')
  154. }
  155. }
  156. }, 1000)
  157. }
  158. },
  159. // 音频的开启和关闭
  160. audioSta(val) {
  161. const dom = document.querySelector("#myAudio");
  162. if (val) {
  163. dom.play();
  164. dom.onended = () => {
  165. // console.log("----音频播放完毕");
  166. this.audioSta = false;
  167. };
  168. } else dom.pause();
  169. },
  170. },
  171. computed: {},
  172. components: {},
  173. methods: {
  174. // 点击左右箭头
  175. cutMyInd(num, flag) {
  176. if (flag) return;
  177. this.myInd += num;
  178. },
  179. // 点击查看大图
  180. lookImg(url) {
  181. let dom = this.$refs.viewer.$viewer;
  182. this.lookPics = [url];
  183. dom.show();
  184. },
  185. async getData() {
  186. // https://www.4dmodel.com/
  187. let url = `https://super.4dage.com/data/${this.id
  188. }/hot/js/data.js?time=${Math.random()}`;
  189. let result = (await this.$http.get(url)).data;
  190. const resData = result[this.m];
  191. console.log("----", resData);
  192. if (resData) {
  193. this.audio = resData.backgroundMusic;
  194. // 只有单独的音频上传
  195. if (
  196. resData.backgroundMusic &&
  197. !resData.model &&
  198. !resData.video &&
  199. !resData.images
  200. ) {
  201. this.isOneAduio = true;
  202. }
  203. // 底部的tab
  204. const arr = [];
  205. const obj = {};
  206. if (resData.model) {
  207. obj.model = resData.model;
  208. arr.push({ id: 1, type: "model", name: "模型" });
  209. }
  210. if (resData.video) {
  211. obj.video = resData.video;
  212. arr.push({ id: 2, type: "video", name: "视频" });
  213. }
  214. if (resData.images) {
  215. obj.img = resData.images;
  216. arr.push({ id: 3, type: "img", name: "图片" });
  217. }
  218. this.flooTab = arr;
  219. this.data = obj;
  220. // 当前type的值 应该为
  221. if (resData.model) this.myType = "model";
  222. else if (resData.video) this.myType = "video";
  223. else if (resData.images) this.myType = "img";
  224. this.myTitle = resData.title || "";
  225. this.myTxt = resData.content || "";
  226. this.videoTxt = resData.videosDesc || [];
  227. this.imgTxt = resData.imagesDesc || [];
  228. // 只有 标题和 文字介绍(没有视频,没有模型,没有图片)
  229. if (!obj.model && !obj.video && !obj.img && !resData.backgroundMusic) {
  230. this.oneTxt = true;
  231. }
  232. }
  233. },
  234. },
  235. mounted() {
  236. this.getData();
  237. // 监听视频观看完成时,记录积分
  238. // setTimeout(() => {
  239. // const videoIDDom = document.getElementById('videoID')
  240. // videoIDDom.addEventListener('ended', () => {
  241. // if (window.parent && window.parent.window.parent.window && window.parent.window.parent.window.addScoreFu) {
  242. // window.parent.window.parent.window.addScoreFu('观看视频')
  243. // }
  244. // })
  245. // }, 800)
  246. },
  247. };
  248. </script>
  249. <style lang="less" scoped>
  250. .home {
  251. .viewerCla img {
  252. display: none;
  253. }
  254. width: 100%;
  255. height: 100%;
  256. background-color: rgba(0, 0, 0, 0.85);
  257. // backdrop-filter: blur(10px);
  258. position: relative;
  259. #myAudio {
  260. z-index: 11;
  261. position: absolute;
  262. top: 50%;
  263. left: 50%;
  264. transform: translate(-50%, -50%);
  265. width: 500px;
  266. height: 60px;
  267. }
  268. .main {
  269. width: 1200px;
  270. margin: 0 auto;
  271. height: 100%;
  272. padding-top: 40px;
  273. .mainCon {
  274. position: relative;
  275. border-radius: 6px;
  276. overflow: hidden;
  277. width: 100%;
  278. height: calc(100% - 200px);
  279. // background: linear-gradient(#929292, #c5c5c5);
  280. .audioIcon {
  281. z-index: 10;
  282. cursor: pointer;
  283. position: absolute;
  284. right: 20px;
  285. bottom: 30px;
  286. }
  287. .oneTabNum {
  288. z-index: 10;
  289. position: absolute;
  290. bottom: 30px;
  291. left: 50%;
  292. transform: translateX(-50%);
  293. font-size: 14px;
  294. }
  295. .flooTabBox {
  296. z-index: 10;
  297. position: absolute;
  298. bottom: 30px;
  299. left: 50%;
  300. transform: translateX(-50%);
  301. display: flex;
  302. .tabRow {
  303. cursor: pointer;
  304. display: flex;
  305. align-items: center;
  306. margin: 0 8px;
  307. // font-size: 12px;
  308. // background-color: rgb(80, 71, 88);
  309. // color: #FFFFFF;
  310. // padding: 0px 14px;
  311. // height: 36px;
  312. // border-radius: 18px;
  313. &>img {
  314. margin-right: 6px;
  315. }
  316. }
  317. .tabRowAc {
  318. // background-color: #FFFFFF;
  319. pointer-events: none;
  320. // color: rgb(41, 52, 108);
  321. }
  322. }
  323. .contenBoxMain {
  324. position: relative;
  325. width: 100%;
  326. height: 100%;
  327. }
  328. .contenBox {
  329. width: 100%;
  330. height: 100%;
  331. position: absolute;
  332. top: 0;
  333. left: 0;
  334. opacity: 0;
  335. pointer-events: none;
  336. transition: all 0.5s;
  337. .modelBox,
  338. .videoBox,
  339. .imgBox {
  340. width: 100%;
  341. height: 100%;
  342. }
  343. .modelBox {
  344. iframe {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. }
  349. .videoBox {
  350. padding: 100px 100px 120px;
  351. video {
  352. width: 100%;
  353. height: 100%;
  354. }
  355. }
  356. .imgBox {
  357. // padding: 100px 100px 120px;
  358. .smImgBox {
  359. width: 100%;
  360. height: 100%;
  361. cursor: zoom-in;
  362. &>img {
  363. pointer-events: none;
  364. width: 100%;
  365. height: 100%;
  366. object-fit: contain;
  367. }
  368. }
  369. }
  370. }
  371. .contenBoxAc {
  372. opacity: 1;
  373. pointer-events: auto;
  374. }
  375. .awccJJ {
  376. cursor: pointer;
  377. position: absolute;
  378. top: 50%;
  379. transform: translateY(-50%);
  380. left: 10px;
  381. width: 37px;
  382. height: 37px;
  383. background-image: url("../assets/images/pc/left.png");
  384. background-size: 100% 100%;
  385. &:focus {
  386. outline: none;
  387. }
  388. }
  389. .rightJJ {
  390. left: auto;
  391. right: 10px;
  392. background-image: url("../assets/images/pc/right.png");
  393. }
  394. .noClick {
  395. cursor: default;
  396. opacity: 0.4;
  397. }
  398. }
  399. .flooTxt {
  400. margin-top: 20px;
  401. width: 100%;
  402. height: 160px;
  403. .flooTxtBox {
  404. width: 100%;
  405. height: 100%;
  406. overflow-y: auto;
  407. .myTitle {
  408. color: #fff;
  409. font-size: 22px;
  410. font-weight: 700;
  411. margin-bottom: 10px;
  412. text-align: center;
  413. }
  414. .myTxt {
  415. font-size: 16px;
  416. color: #ffffff;
  417. line-height: 24px;
  418. }
  419. &::-webkit-scrollbar {
  420. /*滚动条整体样式*/
  421. width: 3px;
  422. /*高宽分别对应横竖滚动条的尺寸*/
  423. height: 1px;
  424. }
  425. &::-webkit-scrollbar-thumb {
  426. /*滚动条里面小方块*/
  427. border-radius: 10px;
  428. -webkit-box-shadow: inset 0 0 5px transparent;
  429. background: rgb(39, 55, 111);
  430. }
  431. &::-webkit-scrollbar-track {
  432. /*滚动条里面轨道*/
  433. -webkit-box-shadow: inset 0 0 5px transparent;
  434. border-radius: 10px;
  435. background: transparent;
  436. }
  437. }
  438. }
  439. .flooTxtOne {
  440. height: 600px;
  441. }
  442. }
  443. }
  444. @media screen and (max-width: 1200px) and (orientation: landscape) {
  445. .home {
  446. .main {
  447. width: 1000px;
  448. .mainCon{
  449. .contenBox{
  450. .videoBox{
  451. padding: 0px !important;
  452. }
  453. }
  454. }
  455. }
  456. }
  457. }
  458. @media screen and (max-width:1000px) and (orientation: landscape) {
  459. .home {
  460. .main {
  461. .mainCon {
  462. height: calc(100% - 120px);
  463. .flooTabBox {
  464. bottom: 85px !important;
  465. position: fixed;
  466. .tabRow {
  467. img {
  468. width: 30px !important;
  469. }
  470. }
  471. }
  472. }
  473. .flooTxt {
  474. margin-top: 25px !important;
  475. padding: 10px !important;
  476. height: 110px !important;
  477. .flooTxtBox {
  478. .myTitle {
  479. font-size: 16px !important;
  480. margin-bottom: 5px !important;
  481. }
  482. .myTxt {
  483. font-size: 14px !important;
  484. line-height: 20px !important;
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. // 移动端
  492. @media screen and (max-width: 1000px) {
  493. .home {
  494. #myAudio {
  495. width: 90vw;
  496. max-width: 500px;
  497. }
  498. .main {
  499. width: 90%;
  500. height: 94%;
  501. padding: 0;
  502. position: absolute;
  503. top: 50%;
  504. left: 50%;
  505. transform: translate(-50%, -50%);
  506. .mainCon {
  507. border-radius: 8px 8px 0 0;
  508. .audioIcon {
  509. cursor: default;
  510. right: auto;
  511. bottom: auto;
  512. top: 6px;
  513. left: 6px;
  514. &>img {
  515. width: 30px;
  516. }
  517. }
  518. .flooTabBox {
  519. width: 100%;
  520. bottom: 20px;
  521. justify-content: center;
  522. .tabRow {
  523. cursor: default;
  524. margin: 0 6px;
  525. padding: 0 10px;
  526. height: 32px;
  527. &>img {
  528. // width: 16px;
  529. width: 45px;
  530. }
  531. }
  532. }
  533. .contenBox {
  534. .videoBox {
  535. padding: 0px 0;
  536. position: relative;
  537. video {
  538. width: 96%;
  539. max-height: 100%;
  540. height: auto;
  541. position: absolute;
  542. top: 50%;
  543. left: 2%;
  544. transform: translateY(-50%);
  545. }
  546. }
  547. .imgBox {
  548. // padding: 60px 50px 80px;
  549. .smImgBox {
  550. cursor: default;
  551. }
  552. }
  553. }
  554. .awccJJ {
  555. left: 0;
  556. width: 28px;
  557. height: 57px;
  558. cursor: default;
  559. background-image: url("../assets/images/pc/icon-left.png");
  560. }
  561. .rightJJ {
  562. left: auto;
  563. right: 0;
  564. background-image: url("../assets/images/pc/icon-right.png");
  565. }
  566. }
  567. .flooTxt {
  568. margin-top: 0;
  569. padding: 20px 15px 15px;
  570. height: 200px;
  571. // background-color: #fff;
  572. border-radius: 0 0 8px 8px;
  573. .flooTxtBox {
  574. .myTitle {
  575. font-size: 18px;
  576. }
  577. .myTxt {
  578. font-size: 16px;
  579. line-height: 22px;
  580. }
  581. }
  582. }
  583. .flooTxtOne {
  584. height: 100%;
  585. }
  586. }
  587. }
  588. }
  589. </style>