Home.vue 16 KB

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