index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="product-bg"
  3. :class="productType === ProductTypeEnum.Integral || isGroup=== ProductMarketingTypeEnum.Groupbuying ?'new-redeemIntegral':'new-users'">
  4. <swiper :indicator-dots="indicatorDots" :indicator-active-color="indicatorBg" :autoplay="autoplay"
  5. :circular="circular" :interval="interval" :duration="duration" @change="change" v-if="isPlay">
  6. <!-- #ifndef APP-PLUS -->
  7. <swiper-item v-if="videoline">
  8. <view class="item">
  9. <view v-show="!controls" style="width: 100%; height: 100%">
  10. <video id="myVideo" :src="videoline" objectFit="cover" controls
  11. style="width: 100%; height: 100%" show-center-play-btn show-mute-btn="true"
  12. auto-pause-if-navigate :custom-cache="false" :enable-progress-gesture="false"
  13. :poster="imgUrls[0]" @pause="videoPause"></video>
  14. </view>
  15. <view class="poster" v-show="controls">
  16. <image class="image" :src="imgUrls[0]"></image>
  17. </view>
  18. <view class="stop" v-show="controls" @tap="bindPause">
  19. <image class="image" src="../../static/images/stop.png"></image>
  20. </view>
  21. </view>
  22. </swiper-item>
  23. <!-- #endif -->
  24. <!-- #ifdef APP-PLUS -->
  25. <swiper-item v-if="videoline">
  26. <view class="item">
  27. <view class="poster" v-show="controls">
  28. <image class="image" :src="imgUrls[0]"></image>
  29. </view>
  30. <view class="stop" v-show="controls" @tap="bindPause">
  31. <image class="image" src="../../static/images/stop.png"></image>
  32. </view>
  33. </view>
  34. </swiper-item>
  35. <!-- #endif -->
  36. <block v-for="(item, index) in imgUrls" :key="index">
  37. <swiper-item v-if="videoline ? index >= 1 : index >= 0">
  38. <image :src="item" class="slide-image" />
  39. </swiper-item>
  40. </block>
  41. </swiper>
  42. <!-- #ifdef APP-PLUS -->
  43. <view v-if="!isPlay" style="width: 100%; height: 750rpx">
  44. <video id="myVideo" :src="videoline" objectFit="cover" controls style="width: 100%; height: 100%"
  45. show-center-play-btn show-mute-btn="true" autoplay="true" auto-pause-if-navigate :custom-cache="false"
  46. :enable-progress-gesture="false" :poster="imgUrls[0]" @pause="videoPause"></video>
  47. </view>
  48. <!-- #endif -->
  49. </view>
  50. </template>
  51. <script>
  52. // +----------------------------------------------------------------------
  53. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  54. // +----------------------------------------------------------------------
  55. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  56. // +----------------------------------------------------------------------
  57. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  58. // +----------------------------------------------------------------------
  59. // | Author: CRMEB Team <admin@crmeb.com>
  60. // +----------------------------------------------------------------------
  61. import {
  62. setThemeColor
  63. } from "@/utils/setTheme.js";
  64. import {
  65. ProductTypeEnum,
  66. ProductMarketingTypeEnum
  67. } from "@/enums/productEnums";
  68. export default {
  69. props: {
  70. imgUrls: {
  71. type: Array,
  72. default: function() {
  73. return [];
  74. },
  75. },
  76. videoline: {
  77. type: String,
  78. value: "",
  79. },
  80. isGroup: {
  81. type: Number,
  82. value: 0,
  83. },
  84. //商品类型
  85. productType: {
  86. type: Number,
  87. value: 0,
  88. }
  89. },
  90. data() {
  91. return {
  92. ProductMarketingTypeEnum: ProductMarketingTypeEnum,
  93. ProductTypeEnum: ProductTypeEnum,
  94. indicatorDots: true,
  95. circular: true,
  96. autoplay: true,
  97. interval: 3000,
  98. duration: 500,
  99. currents: "1",
  100. controls: true,
  101. isPlay: true,
  102. videoContext: "",
  103. };
  104. },
  105. computed: {
  106. indicatorBg() {
  107. if (this.isGroup != 2) {
  108. return setThemeColor()
  109. }
  110. return '#e93323'
  111. }
  112. },
  113. mounted() {
  114. if (this.videoline) {
  115. this.imgUrls.shift();
  116. }
  117. // #ifndef APP-PLUS
  118. this.videoContext = uni.createVideoContext("myVideo", this);
  119. // #endif
  120. },
  121. methods: {
  122. videoPause(e) {
  123. // #ifdef APP-PLUS
  124. this.isPlay = true;
  125. this.autoplay = true;
  126. // #endif
  127. },
  128. bindPause: function() {
  129. // #ifndef APP-PLUS
  130. this.videoContext.play();
  131. this.$set(this, "controls", false);
  132. this.autoplay = false;
  133. // #endif
  134. // #ifdef APP-PLUS
  135. this.isPlay = false;
  136. this.videoContext = uni.createVideoContext("myVideo", this);
  137. this.videoContext.play();
  138. // #endif
  139. },
  140. change: function(e) {
  141. this.$set(this, "currents", e.detail.current + 1);
  142. },
  143. },
  144. };
  145. </script>
  146. <style scoped lang="scss">
  147. .product-bg {
  148. width: 100%;
  149. height: 750rpx !important;
  150. position: relative;
  151. }
  152. .product-bg swiper {
  153. width: 100%;
  154. height: 100%;
  155. position: relative;
  156. }
  157. .product-bg .slide-image {
  158. width: 100%;
  159. height: 100%;
  160. }
  161. .product-bg .pages {
  162. position: absolute;
  163. background-color: #fff;
  164. height: 34rpx;
  165. padding: 0 10rpx;
  166. border-radius: 3rpx;
  167. right: 30rpx;
  168. bottom: 30rpx;
  169. line-height: 34rpx;
  170. font-size: 24rpx;
  171. color: #050505;
  172. }
  173. #myVideo {
  174. width: 100%;
  175. height: 100%;
  176. }
  177. .product-bg .item {
  178. position: relative;
  179. width: 100%;
  180. height: 100%;
  181. }
  182. .product-bg .item .poster {
  183. position: absolute;
  184. top: 0;
  185. left: 0;
  186. height: 750rpx;
  187. width: 100%;
  188. z-index: 9;
  189. }
  190. .product-bg .item .poster .image {
  191. width: 100%;
  192. height: 100%;
  193. }
  194. .product-bg .item .stop {
  195. position: absolute;
  196. top: 50%;
  197. left: 50%;
  198. width: 136rpx;
  199. height: 136rpx;
  200. margin-top: -68rpx;
  201. margin-left: -68rpx;
  202. z-index: 9;
  203. }
  204. .product-bg .item .stop .image {
  205. width: 100%;
  206. height: 100%;
  207. }
  208. </style>