showCollection.vue 9.0 KB

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