cus-previewImg.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="previewImg" v-if="showBox" @touchmove.stop.prevent>
  3. <view class="mask" @click="close">
  4. <swiper @change="changeSwiper" class="mask-swiper" :current="currentIndex" :circular="circular"
  5. :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 mb-34">{{src.sku}}</text>
  10. <PointsPrice v-if="src.type === ProductTypeEnum.Integral" :pointsPrice="src"
  11. :pointsGoodsStyle="hotPointsStyle"></PointsPrice>
  12. <view v-else>
  13. <text class="sku_price">¥{{!type?src.price:src.groupPrice}}</text>
  14. </view>
  15. </view>
  16. </swiper-item>
  17. </swiper>
  18. </view>
  19. <view class="pagebox" v-if="list.length>0">{{ Number(currentIndex) + 1 }} / {{ list.length }}</view>
  20. <!-- #ifndef MP -->
  21. <text class="iconfont icon-fenxiang share_btn" @click="shareFriend()"></text>
  22. <!-- #endif -->
  23. </view>
  24. </template>
  25. <script>
  26. // +----------------------------------------------------------------------
  27. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  28. // +----------------------------------------------------------------------
  29. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  30. // +----------------------------------------------------------------------
  31. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  32. // +----------------------------------------------------------------------
  33. // | Author: CRMEB Team <admin@crmeb.com>
  34. // +----------------------------------------------------------------------
  35. import PointsPrice from '@/components/PointsPrice.vue';
  36. import {
  37. ProductTypeEnum
  38. } from "@/enums/productEnums";
  39. export default {
  40. name: 'cus-previewImg',
  41. components: {
  42. PointsPrice
  43. },
  44. props: {
  45. list: {
  46. type: Array,
  47. required: true,
  48. default: () => {
  49. return [];
  50. }
  51. },
  52. circular: {
  53. type: Boolean,
  54. default: true
  55. },
  56. duration: {
  57. type: Number,
  58. default: 500
  59. }
  60. },
  61. data() {
  62. return {
  63. ProductTypeEnum: ProductTypeEnum,
  64. hotPointsStyle: {
  65. iconStyle: {
  66. width: '32rpx',
  67. height: '32rpx'
  68. },
  69. priceStyle: {
  70. fontSize: '32rpx',
  71. },
  72. unitStyle: {
  73. fontSize: '28rpx',
  74. },
  75. priceColor: {
  76. color: '#fff'
  77. }
  78. },
  79. currentIndex: 0,
  80. showBox: false,
  81. type: 0,
  82. };
  83. },
  84. methods: {
  85. // 左右切换
  86. changeSwiper(e) {
  87. this.currentIndex = e.target.current;
  88. this.$emit('changeSwitch', e.target.current)
  89. },
  90. open(current, type) {
  91. if (type) {
  92. this.type = type
  93. }
  94. if (!current || !this.list.length) return;
  95. this.currentIndex = this.list.map((item) => item.sku).indexOf(current);
  96. this.showBox = true;
  97. },
  98. close() {
  99. this.showBox = false;
  100. },
  101. shareFriend() {
  102. this.$emit('shareFriend')
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. /deep/.price-box{
  109. color: #fff !important;
  110. }
  111. @mixin full {
  112. width: 100%;
  113. height: 100%;
  114. }
  115. .previewImg {
  116. position: fixed;
  117. top: 0;
  118. left: 0;
  119. z-index: 300;
  120. @include full;
  121. .mask {
  122. display: flex;
  123. justify-content: center;
  124. align-items: center;
  125. background-color: #000;
  126. opacity: 1;
  127. z-index: 8;
  128. @include full;
  129. &-swiper {
  130. @include full;
  131. &-img {
  132. width: 100%;
  133. }
  134. }
  135. }
  136. .pagebox {
  137. position: absolute;
  138. width: 100%;
  139. bottom: 20rpx;
  140. z-index: 300;
  141. color: #fff;
  142. text-align: center;
  143. }
  144. }
  145. .mask_sku {
  146. color: #fff;
  147. max-width: 80%;
  148. z-index: 300;
  149. text-align: center;
  150. display: flex;
  151. flex-direction: column;
  152. align-items: center;
  153. margin-top: 90rpx;
  154. .sku_name {
  155. font-size: 12px;
  156. border: 1px solid #fff;
  157. padding: 10rpx 30rpx 10rpx;
  158. border-radius: 40px;
  159. box-sizing: border-box;
  160. }
  161. .sku_price {
  162. padding-top: 10px;
  163. }
  164. }
  165. .font12 {
  166. font-size: 24rpx;
  167. }
  168. .share_btn {
  169. position: absolute;
  170. top: 70rpx;
  171. right: 50rpx;
  172. font-size: 40rpx;
  173. color: #fff;
  174. z-index: 300;
  175. }
  176. .flex-column {
  177. flex-direction: column;
  178. }
  179. .justify-center {
  180. justify-content: center;
  181. }
  182. .align-center {
  183. align-items: center;
  184. }
  185. </style>