新闻接入说明(IU数据源)

  1. 对接接口人提供相对应新闻分类的数据源地址,只需要替换相对应的数据id值就可以(地址如:http://apps.game.qq.com/wmp/v3.1/?p0=1&p1=searchNewsKeywordsList&page=1&pagesize=16&order=sIdxTime&r0=script&r1=NewsObj&type=iKeyword&id=1&openId=&agent=&channel=&area=&&_=
  2. 想要展示哪些分类,找到url上对应id参数的值,展示内容的ID(newslist),比如这样(getNewsData('newslist',10);),idArr数组值,修改css即可实现想要效果
<div class="news-box">
   <ul class="ys-u1" id="ys-u1">
        <li class="on" rel="0">最新资讯</li>
        <li rel="1">综述分析</li>
        <li rel="2">赛事战报</li>
        <li rel="3">战队八卦</li>
    </ul>
    <ul class="newslist" id="newslist"></ul>
</div>

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

function NewsListInit(obj){
    var idArr = ['1','2785','2388','2795'];
    $("#ys-u1 li").click(function(){
        var _index = $(this).attr("rel"); 
        $(this).addClass("on").siblings("li").removeClass("on");
        $("#"+obj).html('');
        getNewsData(obj,idArr[_index]);
    })
}
function getNewsData(obj,id){
    var url = 'http://apps.game.qq.com/wmp/v3.1/?p0=1&p1=searchNewsKeywordsList&page=1&pagesize=16&order=sIdxTime&r0=script&r1=NewsObj&type=iKeyword&id='+ id +'&openId=&agent=&channel=&area=&&_='+new Date().getTime();
    $.getScript(url,function(){
        var newslistPanel = '';
        var data = NewsObj.msg.result;
        for(x in NewsObj.msg.result){
            if(x<9){
                if(x < 1){
                    newslistPanel += '<li class="first"><a href="http://cf.qq.com/cp/a20170113guide/cont.shtml?G_Biz=1&tid='+data[x]['iNewsId']+'" title="" target="_blank">'+ data[x]['sTitle'] +'</a><span class="date">'+data[x]['sIdxTime'].split(' ')[0].slice(5).replace('-','/')+'</span></a></li>';
                }else{
                    newslistPanel += '<li><a href="http://cf.qq.com/cp/a20170113guide/cont.shtml?G_Biz=1&tid='+data[x]['iNewsId']+'" title="" target="_blank">'+ data[x]['sTitle'] +'</a><span class="date">'+data[x]['sIdxTime'].split(' ')[0].slice(5).replace('-','/')+'</span></a></li>';
                }
            }
        }
        $("#"+obj).html(newslistPanel);    
    })
}
getNewsData('newslist',1);
NewsListInit('newslist');

案例地址

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

results matching ""

    No results matching ""

    results matching ""

      No results matching ""