Home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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" v-if="flooTab.length > 1">
  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: url("../assets/images/pc/hot_bg.png") no-repeat center center;
  240. background-color: rgba(transparent, 0.8);
  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: 30px 20px 20px 20px;
  282. display: flex;
  283. align-items: center;
  284. flex-direction: column;
  285. gap: 20px;
  286. justify-content: center;
  287. .myTitle {
  288. font-size: 22px;
  289. font-weight: 700;
  290. margin-bottom: 20px;
  291. padding: 0 30px;
  292. letter-spacing: 4px;
  293. color: #fff;
  294. }
  295. .fixedTx {
  296. font-size: 14px;
  297. width: 250px;
  298. height: 30px;
  299. margin-bottom: 20px;
  300. padding: 0 30px;
  301. letter-spacing: 4px;
  302. color: #535353;
  303. }
  304. .logo {
  305. margin-bottom: 20px;
  306. padding: 0 30px;
  307. & > img {
  308. width: 45px;
  309. object-fit: contain;
  310. }
  311. }
  312. .mainCon {
  313. position: relative;
  314. border-radius: 6px;
  315. overflow: hidden;
  316. width: 700px;
  317. height: calc(100% - 240px);
  318. margin-top: 40px;
  319. .oneTabNum {
  320. z-index: 10;
  321. position: absolute;
  322. bottom: 0;
  323. left: 50%;
  324. transform: translateX(-50%);
  325. font-size: 14px;
  326. }
  327. .contenBoxMain {
  328. position: relative;
  329. width: 100%;
  330. height: 100%;
  331. }
  332. .contenBox {
  333. .modelBox,
  334. .videoBox,
  335. .imgBox {
  336. width: 100%;
  337. height: 100%;
  338. }
  339. .modelBox {
  340. iframe {
  341. width: 100%;
  342. height: 100%;
  343. }
  344. }
  345. .videoBox {
  346. padding: 0px 50px;
  347. video {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. }
  352. .imgBox {
  353. padding: 0px 140px;
  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: 40px;
  373. height: 60px;
  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. height: 0;
  393. flex: 1;
  394. width: 100%;
  395. .flooTxt {
  396. margin: 0 auto;
  397. margin-top: 10px;
  398. width: 100%;
  399. height: 100%;
  400. max-height: 170px;
  401. .flooTxtBox {
  402. width: 100%;
  403. height: 100%;
  404. padding: 0 30px;
  405. overflow-y: auto;
  406. .myTxt {
  407. font-size: 16px;
  408. color: #f9f9f1;
  409. letter-spacing: 3px;
  410. line-height: 32px;
  411. }
  412. &::-webkit-scrollbar {
  413. /*滚动条整体样式*/
  414. width: 3px;
  415. /*高宽分别对应横竖滚动条的尺寸*/
  416. height: 1px;
  417. }
  418. &::-webkit-scrollbar-thumb {
  419. /*滚动条里面小方块*/
  420. border-radius: 10px;
  421. -webkit-box-shadow: inset 0 0 5px transparent;
  422. background: rgb(192, 166, 126);
  423. }
  424. &::-webkit-scrollbar-track {
  425. /*滚动条里面轨道*/
  426. -webkit-box-shadow: inset 0 0 5px transparent;
  427. border-radius: 10px;
  428. background: transparent;
  429. }
  430. }
  431. }
  432. }
  433. .flooTxtOne {
  434. height: 600px;
  435. }
  436. }
  437. // 底部
  438. .flooTabBox {
  439. z-index: 10;
  440. position: absolute;
  441. bottom: 20px;
  442. right: 20px;
  443. display: flex;
  444. .tabRow {
  445. width: 60px;
  446. cursor: pointer;
  447. display: flex;
  448. flex-direction: column;
  449. align-items: center;
  450. font-size: 12px;
  451. // background-color: #dedede;
  452. color: black;
  453. border-radius: 18px;
  454. & > img {
  455. width: 40px;
  456. display: inline-block;
  457. margin-bottom: 3px;
  458. }
  459. & > div {
  460. min-width: 40px;
  461. text-align: center;
  462. }
  463. }
  464. .tabRowAc {
  465. // background-color: #c8aa7d;
  466. pointer-events: none;
  467. // color: #c7aa7c;
  468. }
  469. }
  470. }
  471. // 移动端
  472. @media screen and (max-width: 1000px) {
  473. .home {
  474. background: url("../assets/images/pc/hot_bg_M.png") no-repeat center center;
  475. background-size: 100% 100% !important;
  476. .swiper-pagination {
  477. margin: 10px 0 0;
  478. gap: 4px;
  479. :deep(.swiper-pagination-bullet) {
  480. width: 15px;
  481. height: 3px;
  482. }
  483. }
  484. #myAudio {
  485. width: 90vw;
  486. max-width: 500px;
  487. }
  488. .main {
  489. width: 100%;
  490. height: 100%;
  491. padding: 0;
  492. position: absolute;
  493. .myTitle {
  494. font-size: 16px;
  495. margin: 8px 0;
  496. }
  497. .mainCon {
  498. border-radius: 0;
  499. height: calc(100% - 300px);
  500. width: 100%;
  501. .contenBox {
  502. .videoBox {
  503. padding: 0 30px;
  504. position: relative;
  505. video {
  506. width: calc(100% - 60px);
  507. max-height: 100%;
  508. height: auto;
  509. position: absolute;
  510. top: 50%;
  511. left: 50%;
  512. transform: translate(-50%, -50%);
  513. }
  514. }
  515. .imgBox {
  516. // padding: 60px 50px 80px;
  517. padding: 0 15px;
  518. .smImgBox {
  519. cursor: default;
  520. }
  521. }
  522. }
  523. .awccJJ {
  524. left: 0;
  525. width: 28px;
  526. height: 57px;
  527. cursor: default;
  528. background-image: url("../assets/images/pc/icon-left.png");
  529. }
  530. .rightJJ {
  531. left: auto;
  532. right: 0;
  533. background-image: url("../assets/images/pc/icon-right.png");
  534. }
  535. }
  536. .txtBox {
  537. .flooTxt {
  538. margin-top: -5px;
  539. width: 100%;
  540. padding: 10px 15px 0px 15px;
  541. max-height: 200px;
  542. .flooTxtBox {
  543. padding: 0;
  544. .myTxt {
  545. font-size: 14px;
  546. line-height: 22px;
  547. }
  548. }
  549. }
  550. }
  551. .flooTxtOne {
  552. height: 100%;
  553. }
  554. }
  555. .flooTabBox {
  556. width: 100%;
  557. bottom: 220px;
  558. right: 0;
  559. justify-content: center;
  560. .tabRow {
  561. cursor: default;
  562. // margin: 0 6px;
  563. // padding: 0 10px;
  564. height: 32px;
  565. & > img {
  566. width: 30px;
  567. }
  568. }
  569. }
  570. }
  571. }
  572. </style>