Home.vue 15 KB

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