ProductBanner.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div class="detail-top">
  3. <img src="../assets/png-bg-shangping.png" class="bg-img" alt="" />
  4. <div class="detail-info">
  5. <swiper @swiper="setSwiperRef" class="mySwiper" v-if="banners.length > 0">
  6. <swiper-slide v-for="(item, index) in banners" :key="index">
  7. <!-- <img :src="item" /> -->
  8. <!-- <div class="video-box" v-if="isVideo(item)">
  9. <van-icon color="#fff" size="60" name="play-circle" />
  10. </div> -->
  11. <van-image
  12. @click="preview(index, banners)"
  13. :src="item"
  14. width="calc(100vw - 134px)"
  15. height="calc(100vw - 134px)"
  16. fit="cover"
  17. />
  18. </swiper-slide>
  19. </swiper>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { Swiper, SwiperSlide } from 'swiper/vue'
  25. import 'swiper/swiper.min.css'
  26. import 'swiper/swiper-bundle.min.css'
  27. import { showImagePreview } from 'vant'
  28. import { watch, ref, computed } from 'vue'
  29. import { useWindowSize } from '@vant/use'
  30. export default {
  31. setup() {
  32. const { width, height } = useWindowSize()
  33. let swiperRef = null
  34. const setSwiperRef = swiper => {
  35. swiperRef = swiper
  36. }
  37. watch([width, height], () => {
  38. swiperRef.update(true)
  39. })
  40. return { swiperRef: null, setSwiperRef }
  41. },
  42. props: {
  43. info: {
  44. type: Object,
  45. default: () => {
  46. return {}
  47. }
  48. }
  49. },
  50. components: {
  51. Swiper,
  52. SwiperSlide
  53. },
  54. computed: {
  55. banners() {
  56. return this.info.pic || []
  57. }
  58. },
  59. methods: {
  60. preview(index = 0, list = []) {
  61. // showImagePreview({
  62. // images: [...list],
  63. // closeable: true
  64. // })
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="less" scoped>
  70. @radius: 30px;
  71. .detail-top {
  72. position: relative;
  73. width: 100vw;
  74. // height: 100vw;
  75. .detail-info {
  76. position: absolute;
  77. top: 50%;
  78. left: 50%;
  79. transform: translate(-50%, -50%);
  80. display: flex;
  81. flex-direction: column;
  82. align-items: center;
  83. padding-bottom: 50px;
  84. }
  85. .bg-img {
  86. display: block;
  87. width: 100vw;
  88. }
  89. .mySwiper {
  90. border-radius: @radius;
  91. border: 2px solid var(--ion-text-color);
  92. padding: 5px;
  93. overflow: hidden;
  94. .detail-animate();
  95. width: calc(100vw - 124px);
  96. .swiper-slide {
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. position: relative;
  101. overflow: hidden;
  102. :deep(.van-image) {
  103. border: 2px solid #2f2f2f;
  104. border-radius: @radius;
  105. overflow: hidden;
  106. background-color: transparent;
  107. }
  108. }
  109. }
  110. }
  111. .share-content {
  112. display: flex;
  113. margin-top: 20px;
  114. }
  115. .share-icon {
  116. img {
  117. width: 18px;
  118. height: 18px;
  119. display: inline-block;
  120. vertical-align: middle;
  121. }
  122. span {
  123. font-size: 14px;
  124. color: #949699;
  125. line-height: 24px;
  126. vertical-align: middle;
  127. margin-left: 2px;
  128. }
  129. &.shareLeft {
  130. margin-left: 30px;
  131. }
  132. }
  133. .video-box {
  134. position: absolute;
  135. left: 0;
  136. top: 0;
  137. right: 0;
  138. bottom: 0;
  139. background-color: rgba(var(--ion-text-color-rgb), 0.5);
  140. .f();
  141. justify-content: center;
  142. .van-icon {
  143. color: rgba(0, 0, 0, 0.5) !important;
  144. }
  145. }
  146. .setAvatar {
  147. .f();
  148. img {
  149. width: 18px;
  150. height: 18px;
  151. display: block;
  152. }
  153. span {
  154. font-size: 12px;
  155. color: #949699;
  156. line-height: 24px;
  157. margin-left: 3px;
  158. }
  159. }
  160. @keyframes flipY {
  161. 0% {
  162. transform: perspective(500px) rotateX(0deg) rotateY(15deg);
  163. }
  164. 50% {
  165. transform: perspective(500px) rotateX(0deg) rotateY(-15deg);
  166. }
  167. 100% {
  168. transform: perspective(500px) rotateX(0deg) rotateY(15deg);
  169. }
  170. }
  171. @keyframes flipYLight {
  172. 0% {
  173. left: -100vw;
  174. opacity: 0.3;
  175. width: 25px;
  176. }
  177. 25% {
  178. left: 45vw;
  179. opacity: 0;
  180. width: 45px;
  181. }
  182. 50% {
  183. left: 150vw;
  184. opacity: 0.3;
  185. width: 25px;
  186. }
  187. 75% {
  188. left: 45vw;
  189. opacity: 0;
  190. width: 45px;
  191. }
  192. 100% {
  193. left: -100vw;
  194. opacity: 0.3;
  195. width: 25px;
  196. }
  197. }
  198. .detail-animate() {
  199. animation: flipY 6s ease-in-out infinite;
  200. position: relative;
  201. &::after {
  202. content: '';
  203. background-color: #fff;
  204. position: absolute;
  205. background: #fff;
  206. width: 25px;
  207. height: 100vw;
  208. top: 0;
  209. left: 45px;
  210. opacity: 0;
  211. transform: skewX(-25deg);
  212. z-index: 2;
  213. animation: flipYLight 6s ease-in-out infinite;
  214. }
  215. }
  216. </style>