index.vue 3.0 KB

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