1163b9c2 by 任超

style:新闻动态

1 parent 475ef4d5
......@@ -8,23 +8,22 @@ $(function () {
addTabs('#news');
});
//加载新闻列表数据
function LoadNewsData(currentPage=1) {
function LoadNewsData(currentPage = 1) {
$.ajax({
type: "get", //提交方式
url: portal.api_url + "/portal/MhNews/getNewsArticleList",//路径
data:{
"currentPage":currentPage,
"pageSize":5
data: {
"currentPage": currentPage,
"pageSize": 5
},
async: false,
dataType: "json",
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
data.total = result.data.total
data.total = result.data.total;
if (result.code == 200 && result.data != null) {
data.list = result.data.records;
}
}
})
layui.use('laytpl', function () {
laytpl = layui.laytpl;
var getTpl = document.getElementById('demo').innerHTML
......@@ -33,6 +32,8 @@ function LoadNewsData(currentPage=1) {
view.innerHTML = html;
});
});
}
})
}
// 获取新闻动态的推荐数据
function HotArticle() {
......@@ -46,12 +47,11 @@ function HotArticle() {
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
console.log(result.data)
for (var i = 0; i < result.data.length; i++) {
li = '<li class="tj">';
li += '<img src="' + result.data[i].cover + '">';
li += '<span class="tj-title">'+result.data[i].headline+'</span>';
li += '<span class="tj-date">'+result.data[i].deadtime+'</span>';
li += '<span class="tj-title">' + result.data[i].headline + '</span>';
li += '<span class="tj-date">' + result.data[i].deadtime + '</span>';
li += '</li>';
recommend.append(li);
}
......@@ -73,9 +73,9 @@ function PolicyHotArticle() {
if (result.code == 200 && result.data != null) {
for (var i = 0; i < result.data.length; i++) {
li = '<li class="zcfg">'
li += '<div class="zcfg-top">'+result.data[i].headline+'</div>'
li += '<p class="zcfg-body">'+result.data[i].summary+'</p>'
li += '<div class="zcfg-bottom">'+result.data[i].deadtime+'</div>'
li += '<div class="zcfg-top">' + result.data[i].headline + '</div>'
li += '<p class="zcfg-body">' + result.data[i].summary + '</p>'
li += '<div class="zcfg-bottom">' + result.data[i].deadtime + '</div>'
li += '</li>'
regulation.append(li);
}
......@@ -87,7 +87,6 @@ function PolicyHotArticle() {
layui.use('laypage', function () {
let laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
, count: data.total //数据总数,从服务端得到
......@@ -95,8 +94,8 @@ layui.use('laypage', function () {
, prev: '<'
, next: '>'
, theme: '#0091FF'
, jump: function(obj, first){
if(!first){
, jump: function (obj, first) {
if (!first) {
LoadNewsData(obj.curr);
}
}
......