app-goods-banner.vue 7.7 KB

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