InfoGoodsSwipe.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!-- GoodsSwipe.vue -->
  2. <template>
  3. <view id="goods-swipe" class="div swipe-wrapper ui-common-swiper info-goods-swipe" v-bind:style="'width:'+getBannerStyle.width+'px;height:'+getBannerStyle.height+'px'" v-if="detailInfo">
  4. <view class="div" v-if="detailInfo.goodsvideo_url">
  5. <view class="div m-btn show-btn" @click="goNavigate('/pages/home/goodsdetail/GoodsVideo')"><text class="span iconfont">&#xe6c5;</text>视频</view>
  6. </view>
  7. <!-- 轮播图 -->
  8. <swiper
  9. :autoplay="false"
  10. class="ui-common-swiper goods-image"
  11. :prevent="false"
  12. :stop-propagation="true"
  13. :indicator-dots="detailInfo.photos && detailInfo.photos.length>1"
  14. @change="handleChange"
  15. >
  16. <swiper-item
  17. v-for="(item, index) in detailInfo.photos"
  18. v-bind:key="index"
  19. v-if="detailInfo.photos && detailInfo.photos.length > 0"
  20. >
  21. <image mode="aspectFit" class="img" v-bind:src="item" v-on:click="setPopupVisible(index)" />
  22. </swiper-item>
  23. </swiper>
  24. </view>
  25. </template>
  26. <script>
  27. import PreviewPicture from './PreviewPicture'
  28. import { mapState, mapMutations } from 'vuex'
  29. export default {
  30. data () {
  31. return {
  32. popupVisible: false,
  33. index: 0
  34. }
  35. },
  36. components: {
  37. 'v-picture': PreviewPicture
  38. },
  39. created () {
  40. uni.$on('hide-priview-picture', value => {
  41. this.popupVisible = value
  42. this.setisPreviewPicture(value)
  43. })
  44. },
  45. computed: {
  46. ...mapState({
  47. detailInfo: state => state.goodsdetail.detailInfo
  48. }),
  49. getBannerStyle: function () {
  50. const res = uni.getSystemInfoSync()
  51. var width = res.windowWidth
  52. var height = res.windowHeight
  53. let itemWidth = width
  54. let itemHeight = width
  55. return {
  56. width: itemWidth,
  57. height: itemHeight
  58. }
  59. },
  60. },
  61. beforeDestroy: function () {
  62. uni.$off('hide-priview-picture')
  63. },
  64. methods: {
  65. ...mapMutations({
  66. setisPreviewPicture: 'setisPreviewPicture',
  67. setSwiperId: 'setSwiperId'
  68. }),
  69. goNavigate(path){
  70. uni.navigateTo({url:path})
  71. },
  72. setPopupVisible () {
  73. this.popupVisible = true
  74. this.setisPreviewPicture(true)
  75. },
  76. handleChange (index) {
  77. this.index = index
  78. this.setSwiperId(index)
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .info-goods-swipe {
  85. .mint-swipe-items-wrap {
  86. .mint-swipe-item {
  87. text-align: center;
  88. overflow: hidden;
  89. .img {
  90. height: 100%;
  91. width: auto;
  92. }
  93. }
  94. }
  95. .mint-swipe-indicators {
  96. .div.mint-swipe-indicator {
  97. background: #efeff4;
  98. opacity: 1;
  99. &.is-active {
  100. background: $primaryColor;
  101. }
  102. }
  103. }
  104. }
  105. </style>
  106. <style scoped lang="scss">
  107. .ui-common-swiper{width: 100%;height: 100%;}
  108. .swipe-wrapper{position: relative}
  109. .goods-image{position: absolute;z-index: 10;top:0;left:0}
  110. .goods-video{position: absolute;z-index: 20;top:0;left:0;background: #000}
  111. .m-btn{position: absolute;font-size:$h1;}
  112. .close-btn{top:.5rem;right:.5rem;z-index: 30}
  113. .show-btn{bottom:.5rem;left:.5rem;z-index: 15;height: 1.5rem;line-height: 1.5rem;border-radius: 1.5rem;background: $primaryColor;color: #fff;font-size:$subFontSize;padding:0 .5rem;}
  114. </style>