app-goods-banner.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="app-goods-banner">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <view class='account-box' v-if='mallConfig.mall.setting.is_official_account == 1'>
  5. <official-account></official-account>
  6. </view>
  7. <!-- #endif -->
  8. <swiper class="swiper"
  9. :autoplay="autoplay"
  10. :indicator-dots="picList.length>1"
  11. circular @change='bannerChange'
  12. indicator-color="rgba(255,255,255,.3)"
  13. indicator-active-color="#30353c"
  14. >
  15. <!-- #ifndef MP-BAIDU -->
  16. <swiper-item v-if="videoUrl && getVideo == 1 && sign !== 'lottery' && sign !== 'bargain'">
  17. <view class="swiper-img" @click="routeJumpT" :style="{backgroundImage: 'url(' + picList[0].pic_url + ')'}">
  18. <image class="video-play" src="/static/image/video-play.png"></image>
  19. </view>
  20. </swiper-item>
  21. <!-- #endif-->
  22. <swiper-item v-for="(item, index) in picList" :key="index">
  23. <view class="swiper-img" :style="{backgroundImage: 'url(' + item.pic_url + ')'}"
  24. @click="clickImage(index)">
  25. <!-- #ifndef MP-BAIDU -->
  26. <app-video
  27. :pic-url="item.pic_url"
  28. height="750rpx"
  29. @video-start="videoStart"
  30. @tap.native.stop="preventD"
  31. :url="videoUrl"
  32. v-if="index === 0 && videoUrl && getVideo == 0"
  33. ></app-video>
  34. <app-video
  35. :pic-url="item.pic_url"
  36. height="750rpx"
  37. @video-start="videoStart"
  38. @tap.native.stop="preventD"
  39. :url="videoUrl"
  40. v-if="index === 0 && videoUrl && getVideo == 1 && (sign === 'lottery' || sign === 'bargain')"
  41. ></app-video>
  42. <!-- #endif -->
  43. <!-- #ifdef MP-BAIDU-->
  44. <app-video
  45. :pic-url="item.pic_url"
  46. height="750rpx"
  47. @video-start="videoStart"
  48. @tap.native.stop="preventD"
  49. :url="videoUrl"
  50. v-if="index === 0 && videoUrl"
  51. ></app-video>
  52. <!-- #endif -->
  53. </view>
  54. </swiper-item>
  55. </swiper>
  56. <!-- <view>
  57. <app-jump-button url="/pages/cart/cart" v-if="isCart">
  58. <view class="cart" :style="{'top': isScanQrCode ? '250rpx' : '60rpx'}">
  59. <image load-lazy src="../../../static/image/icon/nav-icon-cart.png"></image>
  60. </view>
  61. </app-jump-button>
  62. </view> -->
  63. <view class="share-commission dir-left-nowrap cross-center" v-if="share > 0">
  64. <image load-lazy src="../../../static/image/icon/share/share_commission.png"></image>
  65. <view class="text">
  66. <view>分销最高可赚</view>
  67. <view>¥{{share}}</view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import appGoodsVideo from './index.vue';
  74. import appVideo from "../../page-component/app-video/app-video.vue";
  75. import { mapState, mapGetters } from 'vuex';
  76. export default {
  77. components: {
  78. 'app-video': appVideo,
  79. appGoodsVideo
  80. },
  81. props: {
  82. picList: Array,
  83. share: Number,
  84. isCart: {
  85. type: Boolean,
  86. default() {
  87. return true;
  88. }
  89. },
  90. videoUrl: String,
  91. goods_id: Number,
  92. sign: String,
  93. },
  94. data() {
  95. return {
  96. autoplay: true
  97. };
  98. },
  99. methods: {
  100. bannerChange() {
  101. this.$event.trigger(this.$const.EVENT_VIDEO_END);
  102. },
  103. videoStart(videoStatus) {
  104. videoStatus ? this.autoplay = false : this.autoplay = true;
  105. },
  106. preventD() {
  107. console.log('--遮罩层防止冒泡事件--')
  108. },
  109. clickImage(index) {
  110. let urls = [];
  111. this.picList.forEach(item => {
  112. urls.push(item.pic_url);
  113. });
  114. uni.previewImage({
  115. current: index,
  116. urls: urls
  117. });
  118. },
  119. routeJumpT() {
  120. uni.navigateTo({
  121. url: `/pages/goods/video?goods_id=${this.goods_id}&sign=${this.sign}`
  122. })
  123. }
  124. },
  125. computed: {
  126. ...mapState({
  127. mallConfig: state => state.mallConfig,
  128. isScanQrCode: state => state.page.isScanQrCode
  129. }),
  130. // #ifndef MP-BAIDU
  131. ...mapGetters('mallConfig',{
  132. getVideo: 'getVideo'
  133. }),
  134. // #endif
  135. },
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .app-goods-banner {
  140. position: relative;
  141. }
  142. .cart {
  143. position: fixed;
  144. right: #{24rpx};
  145. top: #{60rpx};
  146. background: rgba(255, 255, 255, 0.5);
  147. font-size: 0;
  148. padding: #{20rpx};
  149. border-radius: #{999rpx};
  150. box-shadow: 0 #{1rpx} #{3rpx} rgba(0, 0, 0, 0.2);
  151. z-index: 100;
  152. image {
  153. width: #{42rpx};
  154. height: #{42rpx};
  155. }
  156. }
  157. .share-commission {
  158. height: #{80rpx};
  159. width: #{220rpx};
  160. position: absolute;
  161. right: 0;
  162. bottom: #{80rpx};
  163. border-top-left-radius: #{40rpx};
  164. border-bottom-left-radius: #{40rpx};
  165. background-color: rgba(0, 0, 0, 0.4);
  166. z-index: 100;
  167. image {
  168. width: #{44rpx};
  169. height: #{44rpx};
  170. margin-right: #{14rpx};
  171. margin-left: #{20rpx};
  172. }
  173. .text {
  174. color: #ffffff;
  175. font-size: $uni-font-size-weak-two;
  176. }
  177. }
  178. .swiper {
  179. height: #{750rpx};
  180. .swiper-img {
  181. width: 100%;
  182. height: #{750rpx};
  183. background-size: cover;
  184. background-repeat: no-repeat;
  185. background-position: center;
  186. position: relative;
  187. }
  188. }
  189. .video-play {
  190. width: #{128upx};
  191. height: #{128upx};
  192. position: absolute;
  193. top: 50%;
  194. left: 50%;
  195. transform: translate(-50%, -50%);
  196. }
  197. </style>