| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <div class="slider-banner product-bg">
- <swiper
- class="swiper-wrapper"
- :options="ProductConSwiper"
- v-if="imgUrls.length > 0"
- ref="mySwiper"
- >
- <swiperSlide
- class="swiper-slide"
- v-for="(item, index) in imgUrls"
- :key="index"
- ref="goodSwiper"
- >
- <div
- class="slide-image"
- :style="{
- background: 'url(' + item + ') no-repeat center center',
- 'background-size': '100% 100%'
- }"
- >
- <img
- src="../assets/images/videos.png"
- class="video_play"
- v-if="videolines && index === 0"
- />
- </div>
- </swiperSlide>
- </swiper>
- <div class="videoBox" v-show="isOnPlay">
- <video
- ref="videoIds"
- :poster="imgUrls[0]"
- class="video-source"
- loop=""
- controls
- style="width:100%;object-fit:fill"
- preload="auto"
- x-webkit-airplay="true"
- x5-video-player-fullscreen="true"
- x5-video-orientation="portraint"
- x5-video-player-type=""
- :src="videolines"
- @pause="endVideo"
- >
- 您的浏览器可能不支持视频播放
- </video>
- </div>
- <div class="pages">{{ currents || 1 }}/{{ imgUrls.length || 1 }}</div>
- </div>
- </template>
- <script>
- import { swiper, swiperSlide } from "vue-awesome-swiper";
- import "@assets/css/swiper.min.css";
- let vm = null;
- export default {
- name: "ProductConSwiper",
- components: {
- swiper,
- swiperSlide
- },
- props: {
- imgUrls: {
- type: Array,
- default: () => []
- },
- videoline: {
- type: String,
- default: () => ""
- }
- },
- watch: {
- videoline: {
- handler(newName) {
- this.videolines = newName;
- },
- deep: true
- }
- },
- data: function() {
- let that = this;
- return {
- videolines: this.videoline,
- mobile: "",
- isOnPlay: false,
- currents: 1,
- ProductConSwiper: {
- // autoplay: {
- // disableOnInteraction: false,
- // delay: 2000
- // },
- loop: true,
- speed: 1000,
- observer: true,
- observeParents: true,
- on: {
- slideChangeTransitionStart: function() {
- that.currents = this.realIndex + 1;
- if (that.mobile === "iPhone") {
- const oDiv = that.$refs.videoIds;
- oDiv.pause();
- }
- },
- tap: function() {
- const realIndex = this.realIndex;
- if (realIndex === 0) {
- vm.videoPlay();
- }
- }
- }
- }
- };
- },
- mounted: function() {},
- created() {
- vm = this;
- if (navigator.platform.indexOf("Win") !== -1) this.mobile = "iPhone";
- },
- methods: {
- endVideo() {
- this.isOnPlay = false;
- const oDiv = this.$refs.videoIds;
- oDiv.pause();
- },
- videoPlay() {
- if (this.videolines) {
- this.isOnPlay = true;
- const oDiv = this.$refs.videoIds;
- oDiv.play();
- }
- }
- }
- };
- </script>
- <style scoped>
- .videoBox {
- position: fixed;
- z-index: 999;
- top: 0;
- width: 100%;
- height: 100%;
- }
- .videoBox video {
- width: 100%;
- height: 100%;
- }
- .video-source {
- width: 100%;
- height: 100%;
- }
- .video_play {
- position: absolute;
- width: 1rem;
- height: 1rem;
- left: 45%;
- top: 45%;
- z-index: 11;
- }
- </style>
|