index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <!-- 属性规格放大图轮播 -->
  3. <view class="previewImg" v-if="showBox" @touchmove.stop.prevent>
  4. <view class="mask" @click="close">
  5. <swiper @change="changeSwiper" class="mask-swiper" :current="currentIndex" :circular="circular" :duration="duration">
  6. <swiper-item v-for="(src, i) in list" :key="i" class="flex flex-column justify-center align-center">
  7. <image class="mask-swiper-img" :src="src.image" mode="widthFix" />
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <view class="pagebox" v-if="list.length>0">{{ Number(currentIndex) + 1 }} / {{ list.length }}</view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'cus-previewImg',
  17. props: {
  18. list: {
  19. type: Array,
  20. required: true,
  21. default: () => {
  22. return [];
  23. }
  24. },
  25. circular: {
  26. type: Boolean,
  27. default: true
  28. },
  29. duration: {
  30. type: Number,
  31. default: 500
  32. }
  33. },
  34. data() {
  35. return {
  36. currentIndex: 0,
  37. showBox: false
  38. };
  39. },
  40. watch: {
  41. list(val) {
  42. // console.log('图片预览', val)
  43. }
  44. },
  45. methods: {
  46. // 左右切换
  47. changeSwiper(e) {
  48. this.currentIndex = e.target.current;
  49. this.$emit('changeSwitch',e.target.current)
  50. },
  51. open(current) {
  52. if (!current || !this.list.length) return;
  53. this.currentIndex = this.list.map((item)=>item.suk).indexOf(current);
  54. this.showBox = true;
  55. },
  56. close() {
  57. this.showBox = false;
  58. }
  59. // shareFriend(){
  60. // this.$emit('shareFriend')
  61. // }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. @mixin full {
  67. width: 100%;
  68. height: 100%;
  69. }
  70. .previewImg {
  71. position: fixed;
  72. top: 0;
  73. left: 0;
  74. z-index: 3000;
  75. @include full;
  76. .mask {
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. background-color: #000;
  81. opacity: 1;
  82. z-index: 8;
  83. @include full;
  84. &-swiper {
  85. @include full;
  86. &-img {
  87. width: 100%;
  88. }
  89. }
  90. }
  91. .pagebox{
  92. position: absolute;
  93. width: 100%;
  94. top: 164rpx;
  95. z-index: 300;
  96. color: #fff;
  97. text-align: center;
  98. }
  99. }
  100. .mask_sku{
  101. color: #fff;
  102. max-width: 80%;
  103. z-index: 300;
  104. text-align: center;
  105. display: flex;
  106. flex-direction: column;
  107. align-items: center;
  108. margin-top: 30rpx;
  109. .sku_name{
  110. font-size: 12px;
  111. border: 1px solid #fff;
  112. padding: 10rpx 30rpx 10rpx;
  113. border-radius: 40px;
  114. box-sizing: border-box;
  115. }
  116. .sku_price{
  117. padding-top: 10px;
  118. }
  119. }
  120. .font12{
  121. font-size: 24rpx;
  122. }
  123. .share_btn{
  124. position: absolute;
  125. top:70rpx;
  126. right:50rpx;
  127. font-size: 40rpx;
  128. color:#fff;
  129. z-index: 300;
  130. }
  131. .flex-column{flex-direction: column;}
  132. .justify-center {justify-content: center;}
  133. .align-center {align-items: center;}
  134. </style>