qlg.tsgz.moe/static/app2/js/journalism.js
2019-09-06 23:53:10 +08:00

155 lines
4.7 KiB
JavaScript
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

document.write('<link rel="stylesheet" type="text/css" href="../css/swiper.min.css"/>');
document.write('<script type="text/javascript" src="../js/swiper.min.js"></scr' + 'ipt>');
var num = 1;
var isOver = 1;
var catId = '';
function getMsg(catIdNum, pageNum, pagesizeNum) {
var data_msg = {
catId: catIdNum ? catIdNum : '',
page: pageNum ? pageNum : 1,
pagesize: pagesizeNum ? pagesizeNum : 10
}
if(isOver == 0) {
return;
} else {
isOver = 0;
}
mui.ajax(kxUrl('app/Articles/headLine'), { 
data: data_msg,
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
var data = toJson(data, 1);
if(data.status == 1) {
var html = '';
data = data.data;
if(data.Rows == '') {
if(pageNum == 1) {
$('.con_').html('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
} else if(pageNum > 1) {
$('.con_').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
}
isOver = 0;
return;
}
$.each(data.Rows, function() {
var coverImg = '';
if(data.coverImg) {
coverImg = ectImgUrl(data.coverImg)
} else {
coverImg = '../img/mujiimg.png'
}
html += '<div class="con_block shadown_wai" data-articleId = "' + this.articleId + '" data-><img src="' + coverImg + '" alt="" class="cbimg"/><p class="cbtitle">' + this.articleTitle + '</p><p class="name">' + this.articleKey + ' <img src="../img/icon_eye.png" alt="" />' + this.visitorNum + '</p></div>'
});
if(pageNum == 1) {
$('.con_').html(html);
} else if(pageNum > 1) {
$('.con_').append(html);
}
isOver = 1;
} else {
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(type);      
}  
}); 
}
mui.plusReady(function() {
window.addEventListener('refresh', function(e) {
location.reload();
})
mui.ajax(kxUrl('app/Articles/orange'), { 
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
// var data = toJson(data,1);
if(data.status == 1) {
var html = '<div class="swiper-container" id="timer_swiper"><div class="swiper-wrapper">';
var len = 0;
var data = data.data;
$.each(data, function(num) {
html += '<div class="swiper-slide nav_block" data-catId="' + this.catId + '"><p class="p1">' + this.catName + '</p></div>';
len = num + 1;
})
html += '</div></div>'
$('.nav').html(html);
if(len == 0) {
// mui.back();
} else if(len == 1) {
} else {
$('.t_con').css('display', 'block');
}
if(len > 5) {
len = 4.5
} else {
len = len;
}
var swiper = new Swiper('#timer_swiper', {
slidesPerView: len,
paginationClickable: true,
spaceBetween: 0,
freeMode: true
});
$('.nav_block').eq(0).addClass('on');
catId = $('.nav_block').eq(0).attr('data-catId');
getMsg(catId, 1, 10);
} else {
console.log(data.status);
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
console.log(errorThrown);      
}  
}); 
document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
if(scroll.y == scroll.maxScrollY) {
if(isOver == 1) {
num++;
getMsg(catId, num, 10);
}
}
})
$('.con').on('tap', '.con_block', function() {
var id = $(this).attr('data-articleId');
mui.openWindow({
url: 'journalism_con.html',
id: 'journalism_con.html' + id,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度默认为100%
height: '100%' //新页面高度默认为100%
},
extras: {
data_articleId: id
},
createNew: false, //是否重复创建同样id的webview默认为false:不重复创建,直接显示
show: {},
waiting: {
autoShow: false, //自动显示等待框默认为true
}
})
})
$('.nav').on('tap', '.nav_block', function() {
catId = $(this).attr('data-catId');
isOver = 1;
num = 1;
getMsg(catId, 1, 10);
$(this).addClass('on').siblings().removeClass('on')
})
})