showCollection.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <div v-if="cItem.entity">
  3. <div class="img-body">
  4. <img
  5. class="close"
  6. @click.stop="hideBroadcast"
  7. :src="require(`@/assets/images/icon/close.png`)"
  8. />
  9. <template v-if="cItem.entity.type == 'img'">
  10. <div class="imgTxtInfo">
  11. <h3>{{ cItem.entity.name }}</h3>
  12. <p>{{ cItem.entity.description }}</p>
  13. </div>
  14. <div class="swcon swiper-container" id="imglist">
  15. <ul class="swiper-wrapper">
  16. <li
  17. class="swiper-slide"
  18. v-for="(sub, index) in cItem.file"
  19. :key="index"
  20. >
  21. <div class="sl-item">
  22. <!-- 邵根2023-11-15 -->
  23. <img :src="envUrl+sub.filePath" />
  24. </div>
  25. </li>
  26. </ul>
  27. </div>
  28. <template v-if="cItem.file.length > 1">
  29. <img
  30. :class="{ noneAc: active === 0 }"
  31. class="vpagination left"
  32. :src="require('@/assets/images/icon/left.png')"
  33. @click="slide('slidePrev')"
  34. alt=""
  35. />
  36. <img
  37. v-if="cItem && cItem.file"
  38. :class="{ noneAc: active === cItem.file.length - 1 }"
  39. class="vpagination right"
  40. :src="require('@/assets/images/icon/right.png')"
  41. @click="slide('slideNext')"
  42. alt=""
  43. />
  44. </template>
  45. <ul class="pagna" v-if="cItem.file.length > 1">
  46. <li
  47. v-for="(sub, i) in cItem.file"
  48. :class="{ active: i == active }"
  49. :key="i"
  50. ></li>
  51. </ul>
  52. </template>
  53. <template v-else>
  54. <iframe
  55. v-if="cItem.entity.type == 'model'"
  56. :src="`/model-page/model.html?m=${cItem.entity.filePath}`"
  57. frameborder="0"
  58. ></iframe>
  59. <video
  60. ref="itemvideo"
  61. controlslist="nodownload noplaybackrate"
  62. :disablePictureInPicture="true"
  63. v-else-if="cItem.entity.type == 'video'"
  64. controls
  65. :src="cItem.entity.filePath"
  66. loop
  67. autoplay
  68. ></video>
  69. <vAudio v-else :adata="cItem.entity"></vAudio>
  70. <div
  71. v-if="cItem.entity.type != 'audio'"
  72. class="txtInfo"
  73. :class="{ videoInfo: cItem.entity.type == 'video' }"
  74. >
  75. <h3 class="btmname">
  76. {{ cItem.entity.name }}
  77. </h3>
  78. <div v-if="cItem.entity.type != 'video'">{{cItem.entity.ageName}}&emsp;{{cItem.entity.textureName}}</div>
  79. <p>{{ cItem.entity.description }}</p>
  80. </div>
  81. </template>
  82. </div>
  83. </div>
  84. </template>
  85. <script>
  86. import emitter from "@/mitt/index";
  87. import vAudio from "@/components/Audio";
  88. import {envUrl} from '@/utils/index.js'
  89. export default {
  90. name: "showCollection",
  91. props: ["item", "zhuti"],
  92. data() {
  93. return {
  94. isFull: false,
  95. active: 0,
  96. swInstance: null,
  97. };
  98. },
  99. components: { vAudio },
  100. computed: {
  101. cItem() {
  102. return { ...this.item };
  103. },
  104. },
  105. watch: {
  106. isFull(newVal) {
  107. let tmp = this.cItem.type == "img";
  108. this.$emit("hideSlide", tmp && !newVal);
  109. },
  110. // "swInstance.activeIndex"(val) {
  111. // this.active = val;
  112. // console.log("----------", val);
  113. // },
  114. },
  115. methods: {
  116. slide(type) {
  117. this.swInstance[type]();
  118. },
  119. hideBroadcast() {
  120. emitter.emit("closeCollection");
  121. },
  122. },
  123. mounted() {
  124. let that = this;
  125. this.$nextTick(() => {
  126. let t = setTimeout(() => {
  127. clearTimeout(t);
  128. this.swInstance = new Swiper("#imglist", {
  129. slidesPerView: "auto",
  130. normalizeSlideIndex: false,
  131. on: {
  132. slideChange() {
  133. that.active = this.realIndex;
  134. if (this.realIndex > that.cItem.file.length - 1)
  135. that.active = that.cItem.file.length - 1;
  136. },
  137. },
  138. });
  139. }, 200);
  140. });
  141. },
  142. };
  143. </script>
  144. <style lang="scss" scoped>
  145. .noneAc {
  146. opacity: 0.5;
  147. pointer-events: none;
  148. }
  149. .videoInfo {
  150. top: auto !important;
  151. width: 80% !important;
  152. padding: 0 20px;
  153. position: absolute;
  154. color: #fff;
  155. transform: translateX(-50%);
  156. left: 50% !important;
  157. bottom: 10px;
  158. height: 100px;
  159. display: flex;
  160. justify-content: center;
  161. align-items: center;
  162. h3 {
  163. max-width: 30%;
  164. word-break: break-all;
  165. margin-right: 3%;
  166. }
  167. p {
  168. margin-top: 0 !important;
  169. max-width: 65%;
  170. word-break: break-all;
  171. }
  172. }
  173. .imgTxtInfo {
  174. top: auto !important;
  175. width: 80% !important;
  176. padding: 0 20px;
  177. position: absolute;
  178. color: #fff;
  179. transform: translateX(-50%);
  180. left: 50% !important;
  181. bottom: 40px;
  182. height: 100px;
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. h3 {
  187. max-width: 30%;
  188. word-break: break-all;
  189. margin-right: 3%;
  190. }
  191. p {
  192. margin-top: 0 !important;
  193. max-width: 65%;
  194. word-break: break-all;
  195. }
  196. }
  197. .img-body {
  198. width: 100%;
  199. height: 100%;
  200. position: relative;
  201. color: #fff;
  202. iframe,
  203. audio,
  204. video {
  205. width: 60%;
  206. height: 70%;
  207. transform: translate(-50%, -50%);
  208. top: 50%;
  209. left: 50%;
  210. position: absolute;
  211. }
  212. audio {
  213. width: 50%;
  214. height: 20%;
  215. }
  216. .txtInfo {
  217. position: absolute;
  218. top: 50px;
  219. left: 60px;
  220. width: 240px;
  221. &>div{
  222. margin-top: 15px;
  223. font-size: 16px;
  224. }
  225. .btmname {
  226. word-break: break-all;
  227. font-size: 24px;
  228. }
  229. p {
  230. margin-top: 15px;
  231. word-break: break-all;
  232. font-size: 14px;
  233. }
  234. }
  235. .close {
  236. position: absolute;
  237. right: 40px;
  238. top: 40px;
  239. width: 50px;
  240. height: 50px;
  241. cursor: pointer;
  242. }
  243. .swcon {
  244. position: relative;
  245. width: 60%;
  246. height: 100%;
  247. cursor: grab;
  248. .swiper-wrapper {
  249. padding: 0;
  250. width: 100%;
  251. .swiper-slide {
  252. width: 100%;
  253. transform-style: preserve-3d;
  254. position: relative;
  255. height: 100%;
  256. margin: 0 auto;
  257. transform: translate3d(0, 0, 0);
  258. .sl-item {
  259. width: 100%;
  260. height: 95%;
  261. position: relative;
  262. > img {
  263. width: auto;
  264. max-height: 60%;
  265. max-width: 100%;
  266. position: absolute;
  267. top: 50%;
  268. left: 50%;
  269. transform: translate(-50%, -50%);
  270. object-fit: cover;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. .pagna {
  277. position: absolute;
  278. bottom: 20px;
  279. left: 50%;
  280. transform: translateX(-50%);
  281. text-align: center;
  282. z-index: 999;
  283. > li {
  284. width: 10px;
  285. border-radius: 50%;
  286. height: 10px;
  287. background: rgba(0, 0, 0, 0.3);
  288. display: inline-block;
  289. margin: 0 4px;
  290. &.active {
  291. background: #fff;
  292. }
  293. }
  294. }
  295. .vpagination {
  296. position: absolute;
  297. top: 50%;
  298. transform: translateY(-50%);
  299. cursor: pointer;
  300. width: 50px;
  301. }
  302. $pos: 180px;
  303. .left {
  304. left: $pos;
  305. }
  306. .right {
  307. right: $pos;
  308. }
  309. }
  310. .full {
  311. width: 100%;
  312. height: 100%;
  313. z-index: 99999999;
  314. position: relative;
  315. iframe,
  316. video {
  317. width: 100%;
  318. height: 100%;
  319. }
  320. .conname {
  321. color: #fff;
  322. margin-top: 6px;
  323. position: fixed;
  324. left: 50%;
  325. transform: translateX(-50%);
  326. bottom: 40px;
  327. font-size: 18px;
  328. }
  329. .img {
  330. height: 100%;
  331. position: absolute;
  332. left: 50%;
  333. top: 50%;
  334. transform: translate(-50%, -50%);
  335. }
  336. .full-btn {
  337. width: 30px;
  338. position: absolute;
  339. right: 12px;
  340. bottom: 30px;
  341. cursor: pointer;
  342. }
  343. .full-close {
  344. width: 30px;
  345. position: absolute;
  346. right: 12px;
  347. top: 30px;
  348. cursor: pointer;
  349. }
  350. }
  351. @media screen and (max-width: 1000px) {
  352. .img-body {
  353. width: 100%;
  354. height: 100%;
  355. position: relative;
  356. color: #fff;
  357. iframe,
  358. audio,
  359. video {
  360. width: 100%;
  361. height: 80%;
  362. transform: translate(-50%, -50%);
  363. top: 50%;
  364. left: 50%;
  365. position: absolute;
  366. }
  367. audio {
  368. width: 50%;
  369. height: 20%;
  370. }
  371. .close {
  372. position: absolute;
  373. right: 20px;
  374. top: 20px;
  375. width: 30px;
  376. height: 30px;
  377. cursor: pointer;
  378. z-index: 999999;
  379. }
  380. .swcon {
  381. position: relative;
  382. width: 100%;
  383. height: 100%;
  384. .swiper-wrapper {
  385. padding: 0;
  386. width: 100%;
  387. .swiper-slide {
  388. width: 100%;
  389. transform-style: preserve-3d;
  390. position: relative;
  391. height: 100%;
  392. margin: 0 auto;
  393. transform: translate3d(0, 0, 0);
  394. .sl-item {
  395. width: 100%;
  396. height: 95%;
  397. position: relative;
  398. > img {
  399. width: auto;
  400. max-height: 90vh;
  401. max-width: 100%;
  402. cursor: pointer;
  403. position: absolute;
  404. top: 50%;
  405. left: 50%;
  406. transform: translate(-50%, -50%);
  407. }
  408. > p {
  409. color: #fff;
  410. position: absolute;
  411. bottom: 30px;
  412. transform: translateX(-50%);
  413. left: 50%;
  414. font-size: 24px;
  415. }
  416. }
  417. }
  418. }
  419. }
  420. .pagna {
  421. position: absolute;
  422. bottom: 20px;
  423. left: 50%;
  424. transform: translateX(-50%);
  425. text-align: center;
  426. z-index: 999;
  427. > li {
  428. width: 10px;
  429. border-radius: 50%;
  430. height: 10px;
  431. background: rgba(51, 143, 123, 0.24);
  432. display: inline-block;
  433. margin: 0 4px;
  434. &.active {
  435. background: #338f7b;
  436. }
  437. }
  438. }
  439. .vpagination {
  440. position: absolute;
  441. top: 50%;
  442. transform: translateY(-50%);
  443. cursor: pointer;
  444. width: 50px;
  445. display: none;
  446. }
  447. $pos: 180px;
  448. .left {
  449. left: $pos;
  450. }
  451. .right {
  452. right: $pos;
  453. }
  454. }
  455. .full {
  456. width: 100%;
  457. height: 100%;
  458. z-index: 99999999;
  459. position: relative;
  460. iframe,
  461. video {
  462. width: 100%;
  463. height: 100%;
  464. }
  465. .conname {
  466. color: #fff;
  467. margin-top: 6px;
  468. position: fixed;
  469. left: 50%;
  470. transform: translateX(-50%);
  471. bottom: 40px;
  472. font-size: 18px;
  473. }
  474. .img {
  475. height: 100%;
  476. position: absolute;
  477. left: 50%;
  478. top: 50%;
  479. transform: translate(-50%, -50%);
  480. }
  481. .full-btn {
  482. width: 30px;
  483. position: absolute;
  484. right: 12px;
  485. bottom: 30px;
  486. cursor: pointer;
  487. }
  488. .full-close {
  489. width: 30px;
  490. position: absolute;
  491. right: 12px;
  492. top: 30px;
  493. cursor: pointer;
  494. }
  495. }
  496. }
  497. </style>