123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- $(function () {
-
- $.ajax({
- type: 'GET',
- url: '/js/index/aj.json',
- async:false,
- dataType: 'json',
- success: function(data){
- var html='';
- if(data.code == 200){
- $.each(data.data,function(k,v){
- var index = v.grade;
- html += '<li>';
- html += '<div class="div_left">';
- html += '<a href="javascript:viod(0);">';
- html += '<img src="'+rank(index)+'" title="紧急"></a>';
- html += '</div>';
- html += '<div class="div_right">';
- html += '<a href="#" >'+v.name+'</a>:'+v.title+'';
- html += '<div class="twit_item_time">'+v.time+'</div>';
- html += '</div>';
- html += '<div class="layui_btn"><button class="layui-btn layui-btn-xs">查看详情</button></div>';
- html += '</li>';
- })
- $('.con ul').append(html);
- }
- },
- error: function(xhr, type){
- console.log('数据请求失败!')
- }
- });
-
- function rank(v){
- var url="";
- switch(v){
- case "1":
- return url ="/js/index/roll/urgent.png";
- break;
- case "2":
- return url ="/js/index/roll/important.png";
- break;
- case "3":
- return url ="/js/index/roll/temporary.png";
- break;
- case "4":
- return url ="/js/index/roll/inform.png";
- break;
- }
- }
-
- var _length = $('.con ul li').length;
- if(_length > 4){
- $('.con').attr('id','con');
- }
-
- layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
- var laypage = layui.laypage
- ,layer = layui.layer
- ,table = layui.table
- ,element = layui.element
- ,form = layui.form;
-
- $('.layui_btn').on('click',function(){
- layer.open({
- type: 2,
- title: '通知详情页',
- area: ['600px', '500px'],
- content:'/index/show',
- end:function(){
- }
- });
- })
- })
-
- var scrtime;
- var $ul = $("#con ul");
- var liFirstHeight = $ul.find("li:first").height();
- $ul.css({ top: "-" + liFirstHeight - 20 + "px" });
- $("#con").hover(function () {
- $ul.pause();
- clearInterval(scrtime);
- }, function () {
- $ul.resume();
- scrtime = setInterval(function scrolllist() {
-
- $ul.animate({ top: 0 + "px" }, 1500, function () {
-
- $ul.find("li:last").prependTo($ul);
- liFirstHeight = $ul.find("li:first").height();
- $ul.css({ top: "-" + liFirstHeight - 20 + "px" });
- });
- }, 3300);
- }).trigger("mouseleave");
- });
|