app-goods-banner.vue 6.1 KB

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