$(function () {
var enterprisedynamic = '/nx/article/enterprisedynamic';//企业宣传
var industrynews = '/nx/article/industrynews'; //行业动态
var policies = '/nx/article/policies'; //政策法规
var url = enterprisedynamic;
var getNews = function (url, p) {
p = p || 1;
$.ajax({
url: getServerHttp('cp') + url,
type: 'post',
cache: false,
dataType: 'json',
data: {
p: p
},
success: function (data) {
var data = ajaxDataParames(data);
var dom = '';
for (var i = 0; i < data.rows.length; i++) {
var _href = './component/news.html?kid=' + data.rows[i].kid;
dom += '
' + data.rows[i].title + '' + data.rows[i].date + ''
}
$('.lists ul').html(dom);
layui.laypage.render({
elem: 'paging',
count: data.number,
limit: 20,
first: '首页',
last: '尾页',
curr: data.p,
groups: 5,
jump: function (obj, first) {
if (!first) {
console.log('第' + obj.curr + '页')
getNews(url, obj.curr)
}
}
});
}
})
}
$('.option').on('click', function (e) {
if (e.target.name === 'enterprisedynamic') {
url = enterprisedynamic;
} else if (e.target.name === 'industrynews') {
url = industrynews;
} else if (e.target.name === 'policies') {
url = policies;
}
getNews(url);
});
getNews(url);
});