app-goods-banner.vue 8.0 KB

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