首页>服务中心>常见问题
const ListContent = $(".jobs-wrapper .list-content"); const ListProgress = $(".jobs-wrapper .list-progress"); const lists = [{"id":"5","title":"\u8d56\u8305\u4e0e\u8305\u53f0\u3001\u4e2d\u77f3\u5316\u7684\u5173\u7cfb\uff1f","stitle":"","cover_img":null,"source":"","pubdate":"1532575740","weight":"0","state":"0","author":"","uid":null,"description":"2014\u5e7410\u6708\uff0c\u8d35\u5dde\u8305\u53f0\u9152\u80a1\u4efd\u6709\u9650\u516c\u53f8\u4e0e\u4e2d\u77f3\u5316\u6613\u6377\u9500\u552e\u6709\u9650\u516c\u53f8\u5408\u8d44\u6210\u7acb\u4e86\u8d35\u5dde\u8d56\u8305\u9152\u4e1a\u6709\u9650\u516c\u53f8\u3002\r\n\u8d35\u5dde\u8305\u53f0\u9152\u80a1\u4efd\u6709\u9650\u516c\u53f8\u3001\u4e2d\u77f3\u5316\u6613\u6377\u9500\u552e\u6709\u9650\u516c\u53f8\u4e3a\u8d35\u5dde\u8d56\u8305\u9152\u4e1a\u6709\u9650\u516c\u53f8\u80a1\u4e1c\u3002\r\n\u8d35\u5dde\u8305\u53f0\u9152\u80a1\u4efd\u6709\u9650\u516c\u53f8\u51fa\u54c1\u5168\u7cfb\u5217\u8d56\u8305\u4ea7\u54c1\uff0c\u8d56\u8305\u9152\u4e1a\u6709\u9650\u516c\u53f8\u5728\u5168\u56fd\u8fd0\u8425\u8d56\u8305\u54c1\u724c\u3002","isdel":"0","dateline":"1532850535","cat_id":"11","click":"121","recommend":"1","web_cat_name":"other"}]; const listGroup = [] const total = lists.length; const limit = 10 let index = 1; let key = -1; for(let i = 0; i < total; i++) { if (i % limit === 0) { key++; listGroup.push([]) } listGroup[key].push(lists[i]); } render(); function render() { showGroup(ListContent, listGroup, index - 1); initProgress(ListProgress, listGroup.length + 1, index); toDetail(); }; function showGroup(dom, list, key) { let str = ""; for(let i = 0; i < list[key].length; i++) { let d = new Date(list[key][i].pubdate * 1000).toLocaleDateString().split("/"); // =>'[2020, 02, 20]' for(let k = 1; k < d.length; k++) { d[k] = d[k] > 10 ? d[k] : `0${d[k]}`; } let date = d.join("-"); str += `

Q: ${list[key][i].title}

发布时间: ${date}浏览量: ${list[key][i].click}

`; } ListContent.html(str); }; function initProgress(dom, totalPage, index) { let pageArr = []; let group = 7; let half = Math.floor(group / 2); if (index <= half) { for (let i = 1; i <= group; i++) pageArr.push(i); // [0, 1, 2, 3, 4, 5] } else if (totalPage - index <= half) { for (let i = group - 1; i >= 0; i--) pageArr.push(totalPage - i); // [totalPage-5, totalPage-4, totalPage-3, totalPage-2, totalPage-1, totalPage] } else { for(let i = index - half; i <= index + half; i++) { pageArr.push(i); // [index-2, index-1, index, index+1, index+2] } } let str = ""; for(let i = 0; i <= group - 1; i++) { str += `${pageArr[i]}` } str += ` 共${totalPage}页,跳转到 确定 `; dom.html(str); }; function clickBtn(i) { index = i; render(); }; function clickConfirm(t) { let inputV = +$("#jumpTo").val(); if (0 > inputV || t < inputV) { alert("请填写有效页码!"); return; } index = inputV; render(); } function toDetail() { $('.faq-wrapper .list-content .item').click(function () { var id = $(this).attr("data-id"); window.open(""); }) }