137 lines
5.9 KiB
JavaScript
137 lines
5.9 KiB
JavaScript
function initReadid() {
|
||
// Top read点进去的文章列表
|
||
var read_ID = getQueryString('read_id'); //Top read
|
||
|
||
if (read_ID != null) {
|
||
var urlList = {
|
||
list: 'api/Main/getThireTopArticles'
|
||
}
|
||
|
||
commonInit()
|
||
var read_tcp = {};
|
||
read_tcp.pageIndex = 1;
|
||
read_tcp.pageSize = 10;
|
||
read_tcp.type = 'read';
|
||
var totalPage;//总页码
|
||
var totalRecords;//总数据条数
|
||
var pageNo = read_tcp.pageIndex;//当前页码
|
||
$.ajax({
|
||
type: 'post', url: apiUrl + urlList.list,
|
||
data: read_tcp,
|
||
success: function (result) {
|
||
if (result.code == 0) {
|
||
totalPage = result.data.count % read_tcp.pageSize == 0 ? (result.data.count / read_tcp.pageSize) : (Math.ceil(result.data.count / read_tcp.pageSize));
|
||
totalRecords = result.data.count;
|
||
$('.wenz_list .tioashu').html(result.data.count);
|
||
|
||
$('.wenz_list>h4').html('Top read');
|
||
|
||
|
||
initArticle(result.data.articles)
|
||
//生成分页
|
||
//有些参数是可选的,比如lang,若不传有默认值
|
||
kkpager.generPageHtml({
|
||
pno: pageNo,
|
||
//总页码
|
||
total: totalPage,
|
||
//总数据条数
|
||
totalRecords: totalRecords,
|
||
mode: 'click',//默认值是link,可选link或者click
|
||
click: function (n) {
|
||
this.selectPage(n);
|
||
//除了第一页写逻辑跳转
|
||
read_tcp.pageIndex = n;
|
||
$.ajax({
|
||
type: 'post', url: apiUrl + urlList.list,
|
||
data: read_tcp,
|
||
success: function (result) {
|
||
if (result.code == 0) {
|
||
$('.goup-container').click();
|
||
totalRecords = result.data.count;
|
||
$('.wenz_list .tioashu').html(result.data.count);
|
||
|
||
$('.wenz_list>h4').html('Top read');
|
||
initArticle(result.data.articles)
|
||
|
||
} else {
|
||
ShowDanger("请求失败!");
|
||
}
|
||
},
|
||
error: function () {
|
||
ShowDanger("error!");
|
||
}
|
||
})
|
||
return false;
|
||
}, lang: {
|
||
firstPageText: 'First page',
|
||
firstPageTipText: 'First page',
|
||
lastPageText: 'Last page',
|
||
lastPageTipText: 'Last page',
|
||
prePageText: 'Previous page',
|
||
prePageTipText: 'Previous page',
|
||
nextPageText: 'Next page',
|
||
nextPageTipText: 'Next page',
|
||
totalPageBeforeText: '',
|
||
totalPageAfterText: '',
|
||
currPageBeforeText: 'on page ',
|
||
currPageAfterText: '',
|
||
totalInfoSplitStr: ' of ',
|
||
totalRecordsBeforeText: '',
|
||
totalRecordsAfterText: '',
|
||
gopageBeforeText: ' Go to page',
|
||
gopageButtonOkText: 'Go',
|
||
gopageAfterText: 'page',
|
||
buttonTipBeforeText: '第',
|
||
buttonTipAfterText: '页'
|
||
}
|
||
});
|
||
|
||
|
||
} else {
|
||
ShowDanger("请求失败!");
|
||
}
|
||
},
|
||
error: function () {
|
||
ShowDanger("error!");
|
||
}
|
||
})
|
||
|
||
|
||
function initArticle(arr) {
|
||
var str = "";
|
||
for (var i = 0; i < arr.length; i++) {
|
||
if (arr[i].icon == '') {
|
||
continue
|
||
}
|
||
if (arr[i].icon == '') {
|
||
var img_i = 'img/baiss.png'
|
||
} else {
|
||
var img_i = imgarticleUrl + arr[i].icon
|
||
}
|
||
var baseInfo = commonGetItemHtml({ data: arr[i], i: i, img_i: img_i, c_t_a: '' })
|
||
str += `
|
||
|
||
<li>
|
||
<div class="dbt_header">${arr[i].type}${baseInfo.pub_date}</div><a id="${arr[i].article_id}" target="_blank"
|
||
href="article.html?J_num=${arr[i].journal_id}&a_id=${arr[i].article_id}"
|
||
class="txt_biaoti">${baseInfo.otStat}${arr[i].title}</a>
|
||
<div class="authorList">${arr[i].authortitle}<br>
|
||
|
||
${arr[i].journal_title}. ${arr[i].stage_year}, ${arr[i].stage_vol}${baseInfo.stage_}${baseInfo.npp_}<a
|
||
target="_blank" href="https://doi.org/${arr[i].doi}">${baseInfo.doi_}</a>
|
||
</div>
|
||
<div class="links_">${baseInfo.link_}</div>
|
||
<div class="apwrap"><a onclick="imgbig(this)" class="imgdiv">${baseInfo.person_img}</a>${baseInfo.trad_tion}<br
|
||
clear="both"></div>
|
||
</li>
|
||
|
||
`
|
||
}
|
||
$('.wenz_list>ul').html(str);
|
||
$('.links_ .txt_copy').css('background', localStorage.Journals_color);
|
||
commonHandleClickHtml()
|
||
}
|
||
}
|
||
}
|
||
|