视频接入说明(AMS数据源)

  1. 对接接口人提供相对应新闻分类的数据源地址,只需要替换相对应的数据url就可以(地址如:http://apps.game.qq.com/wmp/v3.1/?p0=1&p1=searchKeywordsList&page=1&pagesize=30&order=sIdxTime&r0=script&r1=userObj&type=iSubType&id=10&_=
  2. 想要展示哪些分类,找到url上对应id参数的值,展示内容的ID(videoList),比如这样(videoList(10);),修改css即可实现想要效果
<div class="videBox">
    <ul class="videoList" id="videoList"></ul>
</div>

<script src="http://ossweb-img.qq.com/images/cf/script/jquery-1.9.1.min.js"></script>

function reloadPubdate(string) {
            var re = /^(\d{2,4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
            if( re.test(string) ) {
                var t = string.match(re);
                var d = new Date(t[1], t[2]-1, t[3], t[4], t[5], t[6]);
                var c = new Date();
                var s = (c.getTime() - d.getTime())/1000;
                var m = Math.floor(s/60);
                var h = Math.floor(s/3600);
                var d = Math.floor(s/86400);
                var n = Math.floor(s/(86400*30));
                var y = Math.floor(s/(86400*365));
                if(y>0) return y+"年以前"; 
                if(n>0) return n+"个月以前";
                if(d>0) return d+"天以前";
                if(h>0) return h+"小时以前";
                if(m>0) return m+"分钟以前";
            }
            return "刚刚";
    };
    function videoList(id){
        $('#videoList').html('');
        var url = 'http://apps.game.qq.com/wmp/v3.1/?p0=1&p1=searchKeywordsList&page=1&pagesize=30&order=sIdxTime&r0=script&r1=userObj&type=iSubType&id='+ id +'&_='+Date.parse(new Date()); 
        $.getScript(url,function(){
            var videoList = '';
            if(userObj.status < 0){
                $('#videoList').html('没有查询到数据!');
                return;
            }
            for(var i=0;i<10;i++){
                videoList +=     '<li><a class="play" target="_blank" href="http://cf.qq.com/v/detail.shtml?G_Biz=1&tid='+userObj['msg']['result'][i]['iVideoId']+'">';
                videoList +=         '<img src="'+userObj['msg']['result'][i]['sIMG']+'" width="194" height="108">';
                videoList +=         '<p class="v-title">'+decodeURIComponent( userObj['msg']['result'][i]['sTitle'] )+'</p>';
                videoList +=         '</a>';
                videoList +=         '<p class="ys_p"><i class="sp"></i>'+userObj['msg']['result'][i]['iTotalPlay']+'<span>'+reloadPubdate( userObj['msg']['result'][i]['sCreated'] ) +'</span></p>';
                videoList +=     '</li>';

            }
            $('#videoList').html(videoList);
        });    
    } 
    videoList(10);

案例地址

Copyright (c) 2018 Tencent-TGIDEAS. all right reserved,powered by Gitbooktime: 2018-08-21 16:50:42

results matching ""

    No results matching ""

    results matching ""

      No results matching ""