index.vue 5 KB
<template>
    <div>
        <div class="box">
            <div class="first_item"></div>
            <!--商品列表-->
            <div class="item">
                <div @click="link(1)">
                </div>
                <div  @click="link(2)">

                </div>
            </div>
            <!--视频-->
            <div>
                <div class="video_box">
                    <video-player class="video-player vjs-custom-skin" @play="onPlayerPlay($event)"
                                  ref="videoPlayer"
                                  :playsinline="playsinline"
                                  :options="playerOptions"
                                  x5-playsinline
                                  webkit-playsinline>
                    </video-player>
                </div>
            </div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>
            <!--视频-->
            <div>
                <div class="video_box">
                    <video-player class="video-player vjs-custom-skin" @play="onPlayerPlay($event)"
                                  ref="videoPlayer"
                                  :playsinline="playsinline"
                                  :options="playerOptions"
                                  x5-playsinline
                                  webkit-playsinline>
                    </video-player>
                </div>
            </div>
            <div></div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>

            <div></div>

        </div>
    </div>
</template>

<script>
    import { videoPlayer } from 'vue-video-player';
    import 'video.js/dist/video-js.css';
    import '../../../static/css/video.css';
    export default {
        name: 'index',
        data () {
            return {
                playsinline: true,
                playerOptions: {
                    events: [],
                    playbackRates: [0.5, 1.0, 1.5, 2.0], // 播放速度
                    autoplay: false, // 如果true,浏览器准备好时开始回放。
                    controls: true, //  控制条
                    preload: 'auto', // 视频预加载
                    muted: false, //  默认情况下将会消除任何音频。
                    loop: false, // 导致视频一结束就重新开始。
                    language: 'zh-CN',
                    controlBar: {
                        timeDivider: true,
                        durationDisplay: true
                    },
                    aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
                    fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
                    sources: [{
                        type: "video/mp4",
                        src: "http://wjj.ys2.cnliveimg.com/769/shop/video/2019/03/03/5c7bebffe2a35.MP4"
                    }],
                    hls: true, // 启用hls?
                    poster: './static/img/index/video1.png', // 你的封面地址
                    width: document.documentElement.clientWidth || document.body.clientWidth,
                    notSupportedMessage: '此视频暂无法播放,请稍后再试' //  允许覆盖Video.js无法播放媒体源时显示的默认信息。
                }
            }
        },
        components:{
            videoPlayer
        },
        created(){
            document.title = '崇学向上'
        },
        methods: {
            link(index){
                if(index==='1'){
                    window.location.href = "https://wjjshop.cnlive.com/html/mall/1/#/pages/main/detail/detail?id=9520356&uid=10515293"
                }else{
                    window.location.href = "https://wjjshop.cnlive.com/html/mall/1/#/pages/main/detail/detail?id=9520356&uid=10515293"
                }

            },
            /**
             * 视频播放
             * @param {object} $event [播放器对象]
             */
            onPlayerPlay($event) {
                if(this.isiPhone.value && window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.CNDSPlayer) {
                    window.webkit.messageHandlers.CNDSPlayer.postMessage({body: {
                        playUrl:"https://v.youku.com/v_show/id_XNDQyOTAxNjE2MA==.html?s=e438e14b3fa94613a1bb&scm=20140719.manual.15319.show_e438e14b3fa94613a1bb",
//                        playUrl: this.playerOptions.sources[0].src, // 视频URL
                        isLive: 0 // 0录播1直播
                    }});
                }
            },
        }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less" scoped>
    @import "index";
</style>