Home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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 controls :src="item.url" v-if="index === myInd"></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"></div>
  56. </div>
  57. </div>
  58. <!-- 下面的文字介绍 -->
  59. <div class="flooTxt" :class="{ flooTxtOne: oneTxt }">
  60. <div class="flooTxtBox">
  61. <div class="myTitle">{{ myTitle }}</div>
  62. <!-- 视频的介绍 -->
  63. <div class="myTxt" v-if="myType === 'video' && videoTxt[myInd]">
  64. {{ videoTxt[myInd] }}
  65. </div>
  66. <div class="myTxt" v-if="myType === 'img' && imgTxt[myInd]">
  67. {{ imgTxt[myInd] }}
  68. </div>
  69. <div class="myTxt" v-html="myTxt"></div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- 查看图片 -->
  74. <viewer class="viewerCla" ref="viewer" :images="lookPics">
  75. <img :src="lookPics[0]" alt="" />
  76. </viewer>
  77. </div>
  78. </template>
  79. <script>
  80. export default {
  81. name: "Home",
  82. data() {
  83. return {
  84. m: this.$route.query.m,
  85. id: this.$route.query.id,
  86. // 音频地址
  87. audio: "",
  88. // 如果只有单独的音频
  89. isOneAduio: false,
  90. // 音频状态
  91. audioSta: false,
  92. data: {
  93. // 模型数组
  94. model: [],
  95. // 视频数组
  96. video: [],
  97. // 图片数组
  98. img: [],
  99. },
  100. // 当前 type
  101. myType: "",
  102. // 底部的tab
  103. flooTab: [],
  104. // 当前索引
  105. myInd: 0,
  106. // 查看图片
  107. lookPics: [],
  108. // 标题
  109. myTitle: "",
  110. // 内容
  111. myTxt: "",
  112. // 视频内容
  113. videoTxt: [],
  114. imgTxt: [],
  115. // 只有标题和文字(没有视频,没有模型,没有图片)
  116. oneTxt: false,
  117. };
  118. },
  119. watch: {
  120. myType() {
  121. this.myInd = 0;
  122. },
  123. // 音频的开启和关闭
  124. audioSta(val) {
  125. const dom = document.querySelector("#myAudio");
  126. if (val) {
  127. dom.play();
  128. dom.onended = () => {
  129. // console.log("----音频播放完毕");
  130. this.audioSta = false;
  131. };
  132. } else dom.pause();
  133. },
  134. },
  135. computed: {},
  136. components: {},
  137. methods: {
  138. // 点击左右箭头
  139. cutMyInd(num, flag) {
  140. if (flag) return;
  141. this.myInd += num;
  142. },
  143. // 点击查看大图
  144. lookImg(url) {
  145. let dom = this.$refs.viewer.$viewer;
  146. this.lookPics = [url];
  147. dom.show();
  148. },
  149. async getData() {
  150. // https://www.4dmodel.com/
  151. let url = `https://super.4dage.com/data/${this.id
  152. }/hot/js/data.js?time=${Math.random()}`;
  153. let result = (await this.$http.get(url)).data;
  154. const resData = result[this.m];
  155. console.log("----", resData);
  156. if (resData) {
  157. this.audio = resData.backgroundMusic;
  158. // 只有单独的音频上传
  159. if (
  160. resData.backgroundMusic &&
  161. !resData.model &&
  162. !resData.video &&
  163. !resData.images
  164. ) {
  165. this.isOneAduio = true;
  166. }
  167. // 底部的tab
  168. const arr = [];
  169. const obj = {};
  170. if (resData.model) {
  171. obj.model = resData.model;
  172. arr.push({ id: 1, type: "model", name: "模型" });
  173. }
  174. if (resData.video) {
  175. obj.video = resData.video;
  176. arr.push({ id: 2, type: "video", name: "视频" });
  177. }
  178. if (resData.images) {
  179. obj.img = resData.images;
  180. arr.push({ id: 3, type: "img", name: "图片" });
  181. }
  182. this.flooTab = arr;
  183. this.data = obj;
  184. // 当前type的值 应该为
  185. if (resData.model) this.myType = "model";
  186. else if (resData.video) this.myType = "video";
  187. else if (resData.images) this.myType = "img";
  188. this.myTitle = resData.title || "";
  189. this.myTxt = resData.content || "";
  190. this.videoTxt = resData.videosDesc || [];
  191. this.imgTxt = resData.imagesDesc || [];
  192. // 只有 标题和 文字介绍(没有视频,没有模型,没有图片)
  193. if (!obj.model && !obj.video && !obj.img && !resData.backgroundMusic) {
  194. this.oneTxt = true;
  195. }
  196. }
  197. },
  198. },
  199. mounted() {
  200. this.getData();
  201. },
  202. };
  203. </script>
  204. <style lang="less" scoped>
  205. .home {
  206. .viewerCla img {
  207. display: none;
  208. }
  209. width: 100%;
  210. height: 100%;
  211. background-color: rgba(0, 0, 0, 0.79);
  212. // backdrop-filter: blur(10px);
  213. position: relative;
  214. #myAudio {
  215. z-index: 11;
  216. position: absolute;
  217. top: 50%;
  218. left: 50%;
  219. transform: translate(-50%, -50%);
  220. width: 500px;
  221. height: 60px;
  222. }
  223. .main {
  224. width: 1200px;
  225. margin: 0 auto;
  226. height: 100%;
  227. padding-top: 40px;
  228. .mainCon {
  229. position: relative;
  230. border-radius: 6px;
  231. overflow: hidden;
  232. width: 100%;
  233. height: calc(100% - 200px);
  234. // background: linear-gradient(#929292, #c5c5c5);
  235. .audioIcon {
  236. z-index: 10;
  237. cursor: pointer;
  238. position: absolute;
  239. right: 20px;
  240. bottom: 30px;
  241. }
  242. .oneTabNum {
  243. z-index: 10;
  244. position: absolute;
  245. bottom: 30px;
  246. left: 50%;
  247. transform: translateX(-50%);
  248. font-size: 14px;
  249. }
  250. .flooTabBox {
  251. z-index: 10;
  252. position: absolute;
  253. bottom: 30px;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. display: flex;
  257. .tabRow {
  258. cursor: pointer;
  259. display: flex;
  260. align-items: center;
  261. margin: 0 12px;
  262. font-size: 12px;
  263. background-color: #489182;
  264. color: #FCE9AC;
  265. padding: 0px 14px;
  266. height: 36px;
  267. border-radius: 18px;
  268. &>img {
  269. margin-right: 6px;
  270. }
  271. }
  272. .tabRowAc {
  273. background-color: #EAD5A3;
  274. pointer-events: none;
  275. color: #489182;
  276. }
  277. }
  278. .contenBoxMain {
  279. position: relative;
  280. width: 100%;
  281. height: 100%;
  282. }
  283. .contenBox {
  284. width: 100%;
  285. height: 100%;
  286. position: absolute;
  287. top: 0;
  288. left: 0;
  289. opacity: 0;
  290. pointer-events: none;
  291. transition: all 0.5s;
  292. .modelBox,
  293. .videoBox,
  294. .imgBox {
  295. width: 100%;
  296. height: 100%;
  297. }
  298. .modelBox {
  299. iframe {
  300. width: 100%;
  301. height: 100%;
  302. }
  303. }
  304. .videoBox {
  305. padding: 100px 100px 120px;
  306. video {
  307. width: 100%;
  308. height: 100%;
  309. }
  310. }
  311. .imgBox {
  312. // padding: 100px 100px 120px;
  313. .smImgBox {
  314. width: 100%;
  315. height: 100%;
  316. cursor: zoom-in;
  317. &>img {
  318. pointer-events: none;
  319. width: 100%;
  320. height: 100%;
  321. object-fit: contain;
  322. }
  323. }
  324. }
  325. }
  326. .contenBoxAc {
  327. opacity: 1;
  328. pointer-events: auto;
  329. }
  330. .awccJJ {
  331. cursor: pointer;
  332. position: absolute;
  333. top: 50%;
  334. transform: translateY(-50%);
  335. left: 10px;
  336. width: 37px;
  337. height: 37px;
  338. background-image: url("../assets/images/pc/left.png");
  339. background-size: 100% 100%;
  340. &:focus {
  341. outline: none;
  342. }
  343. }
  344. .rightJJ {
  345. left: auto;
  346. right: 10px;
  347. background-image: url("../assets/images/pc/right.png");
  348. }
  349. .noClick {
  350. cursor: default;
  351. opacity: 0.4;
  352. }
  353. }
  354. .flooTxt {
  355. margin-top: 20px;
  356. width: 100%;
  357. height: 160px;
  358. .flooTxtBox {
  359. width: 100%;
  360. height: 100%;
  361. overflow-y: auto;
  362. .myTitle {
  363. color: #fff;
  364. font-size: 22px;
  365. font-weight: 700;
  366. margin-bottom: 10px;
  367. text-align: center;
  368. }
  369. .myTxt {
  370. font-size: 16px;
  371. color: #ffffff;
  372. line-height: 24px;
  373. }
  374. &::-webkit-scrollbar {
  375. /*滚动条整体样式*/
  376. width: 3px;
  377. /*高宽分别对应横竖滚动条的尺寸*/
  378. height: 1px;
  379. }
  380. &::-webkit-scrollbar-thumb {
  381. /*滚动条里面小方块*/
  382. border-radius: 10px;
  383. -webkit-box-shadow: inset 0 0 5px transparent;
  384. background: #EAD5A3;
  385. }
  386. &::-webkit-scrollbar-track {
  387. /*滚动条里面轨道*/
  388. -webkit-box-shadow: inset 0 0 5px transparent;
  389. border-radius: 10px;
  390. background: transparent;
  391. }
  392. }
  393. }
  394. .flooTxtOne {
  395. height: 600px;
  396. }
  397. }
  398. }
  399. // 移动端
  400. @media screen and (max-width: 1000px) {
  401. .home {
  402. #myAudio {
  403. width: 90vw;
  404. max-width: 500px;
  405. }
  406. .main {
  407. width: 90%;
  408. height: 94%;
  409. padding: 0;
  410. position: absolute;
  411. top: 50%;
  412. left: 50%;
  413. transform: translate(-50%, -50%);
  414. .mainCon {
  415. border-radius: 8px 8px 0 0;
  416. .audioIcon {
  417. cursor: default;
  418. right: auto;
  419. bottom: auto;
  420. top: 6px;
  421. left: 6px;
  422. &>img {
  423. width: 30px;
  424. }
  425. }
  426. .flooTabBox {
  427. width: 100%;
  428. bottom: 20px;
  429. justify-content: center;
  430. .tabRow {
  431. cursor: default;
  432. margin: 0 6px;
  433. padding: 0 10px;
  434. height: 32px;
  435. &>img {
  436. width: 16px;
  437. }
  438. }
  439. }
  440. .contenBox {
  441. .videoBox {
  442. padding: 0px 0;
  443. position: relative;
  444. video {
  445. width: 96%;
  446. max-height: 100%;
  447. height: auto;
  448. position: absolute;
  449. top: 50%;
  450. left: 2%;
  451. transform: translateY(-50%);
  452. }
  453. }
  454. .imgBox {
  455. // padding: 60px 50px 80px;
  456. .smImgBox {
  457. cursor: default;
  458. }
  459. }
  460. }
  461. .awccJJ {
  462. left: 0;
  463. width: 28px;
  464. height: 57px;
  465. cursor: default;
  466. background-image: url("../assets/images/pc/icon-left.png");
  467. }
  468. .rightJJ {
  469. left: auto;
  470. right: 0;
  471. background-image: url("../assets/images/pc/icon-right.png");
  472. }
  473. }
  474. .flooTxt {
  475. margin-top: 0;
  476. padding: 20px 15px 15px;
  477. height: 200px;
  478. // background-color: #fff;
  479. border-radius: 0 0 8px 8px;
  480. .flooTxtBox {
  481. .myTitle {
  482. font-size: 18px;
  483. }
  484. .myTxt {
  485. font-size: 14px;
  486. line-height: 22px;
  487. }
  488. }
  489. }
  490. .flooTxtOne {
  491. height: 100%;
  492. }
  493. }
  494. }
  495. }</style>