77 lines
2.5 KiB
JavaScript
77 lines
2.5 KiB
JavaScript
var page = 1
|
|
var size = 15
|
|
var totalCount = 1
|
|
var values =1
|
|
|
|
function generPage(total, dom_page_class) {
|
|
totalCount = total % 10 == 0 ? Math.floor(total / 10) : Math.floor(total / 10) + 1
|
|
|
|
|
|
|
|
let domStr = `
|
|
<div class="pb_sys_common pb_sys_normal pb_sys_style1" style="margin-top: 10px; text-align: center; padding-bottom: 15px">
|
|
<span class="p_t">共${total}条</span>
|
|
<span class="p_pages"><span class="p_no" ><a href="javascript:void(0);" onclick="pageChange(1,this)">首页</a></span>
|
|
`
|
|
for (let i = 1; i <= totalCount; i++) {
|
|
|
|
if(values==i){
|
|
domStr += `<span class="p_no_d " ><a href="javascript:void(0)" onclick="pageChange(${i },this)" style="color:white;">` + (i ) + `</a></span>`
|
|
}else{
|
|
domStr += `<span class="p_no " ><a href="javascript:void(0)" onclick="pageChange(${i },this)">` + (i ) + `</a></span>`
|
|
}
|
|
}
|
|
|
|
domStr += ` <span class="p_no"><a href="javascript:void(0);" onclick="pageChange(${totalCount},this)">尾页</a></span></span></div>`;
|
|
console.log('domStr-->',domStr);
|
|
document.querySelector('.' + dom_page_class).innerHTML = domStr
|
|
}
|
|
|
|
function pageChange(currentPage,e) {
|
|
// let jsijg = e.innerText
|
|
page = currentPage
|
|
values = page
|
|
mainListChange(page)
|
|
|
|
console.log(page)
|
|
// 去第一页
|
|
// if(page===1) {
|
|
// console.log('123123123')
|
|
// document.querySelector('.active')?.classList.remove('active')
|
|
// document.querySelector('.first').classList.add('active')
|
|
// }
|
|
// document.querySelector('.current').addEventListener('click',function (e) {
|
|
// if(e.target.tagName ==='DIV') {
|
|
// console.log('点击了按钮')
|
|
// document.querySelector('.active').classList.remove('active')
|
|
// e.target.classList.add('active')
|
|
// }
|
|
// })
|
|
// if(e.className === 'pageEnd') {
|
|
// const pages = document.querySelector('.current').children
|
|
// document.querySelector('.active').classList.remove('active')
|
|
// pages[1].classList.add('active')
|
|
// }
|
|
}
|
|
|
|
function page_go() {
|
|
let content = document.querySelector('#page_input').value
|
|
let reg = /^\d$/
|
|
if(reg.test(content)&&content>0&&content<=totalCount){
|
|
page = content
|
|
values = page
|
|
mainListChange()
|
|
}
|
|
}
|
|
|
|
function prePage() {
|
|
if (page != 1) page = page - 1
|
|
values = page
|
|
mainListChange()
|
|
}
|
|
|
|
function nextPage(count) {
|
|
if (page != count) page = page + 1
|
|
values = page
|
|
mainListChange()
|
|
} |