123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <div id="kangri" class="kangri">
- <div class="kangricon">
- <span @click="(active -= 1), autoplay()" :class="{ noshow: active <= 0 }"
- >上一张</span
- >
- <video
- ref="video"
- autoplay
- loop
- x5-video-player-type="h5"
- x5-video-player-fullscreen="true"
- webkit-playsinline=""
- playsinline=""
- x5-playsinline=""
- crossorigin="anonymous"
- :key="active"
- >
- <source
- :src="require(`@/assets/videos/kangri/${videocon[active].video}`)"
- type="video/mp4"
- />
- </video>
- <span
- @click="(active += 1), autoplay()"
- :class="{ noshow: active >= videocon.length - 1 }"
- >下一张</span
- >
- </div>
- </div>
- </template>
- <script>
- let videocon = [
- {
- id: "1",
- video: "1.mp4",
- },
- {
- id: "2",
- video: "2.mp4",
- },
- {
- id: "3",
- video: "3.mp4",
- },
- {
- id: "4",
- video: "4.mp4",
- },
- {
- id: "5",
- video: "5.mp4",
- },
- ];
- export default {
- data() {
- return {
- videocon,
- active: 0,
- };
- },
- methods: {
- changeVideo(item) {
- this.active = item.id;
- },
- autoplay() {
- this.$nextTick(() => {
- this.$refs.video.play();
- });
- },
- },
- mounted() {
- document.addEventListener(
- "WeixinJSBridgeReady",
- () => {
- this.autoplay();
- },
- false
- );
- window.player.on("autoplay", () => {
- this.autoplay();
- });
- },
- };
- </script>
- <style lang="less" scoped>
- .noshow {
- opacity: 0 !important;
- pointer-events: none !important;
- }
- .kangri {
- width: 100%;
- height: 100%;
- text-align: center;
- position: relative;
- pointer-events: none !important;
- .kangricon {
- height: 100%;
- width: 100%;
- color: #fff;
- display: flex;
- justify-content: center;
- pointer-events: none !important;
- align-items: center;
- > video {
- width: 50%;
- background-color: #000;
- height: 100%;
- pointer-events: auto;
- object-fit: fill;
- }
- > span {
- pointer-events: auto;
- display: inline-block;
- padding: 20px 60px;
- box-sizing: content-box;
- font-size: 40px;
- height: 50px;
- line-height: 50px;
- background: rgba(188, 21, 21, 0.9);
- border: 2px solid #dba761;
- border-radius: 77px;
- cursor: pointer;
- margin: 0 100px;
- &:hover,
- &.active {
- color: #dba761;
- }
- }
- }
- }
- </style>
|