1
0

app-goods-banner.vue 7.0 KB

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