$('.sp1 a').attr('href', 'javascript:;') $('.sp2 a').attr('href', 'javascript:;') var Initials = '' //字母 var jobTitle = '' //职称 var team = '' //团队 getList() // 点击 "职称"、"字母"、"团队" $('.sp2').on('click', 'a', function () { $(this).parent('.sp2').prev('.sp1').children('a').removeClass('on') $(this).siblings('a').removeClass('on') $(this).addClass('on') if ($(this).parents('li').index() == 0) { Initials = $(this).children('i').text().toUpperCase() } else if ($(this).parents('li').index() == 1) { jobTitle = $(this).text() } else if ($(this).parents('li').index() == 2) { team = $(this).text() } curPage = 1 getList() }) // 点击 "全部" $('.sp1 a').click(function () { $(this).parent('.sp1').next('.sp2').find('a').removeClass('on') $(this).addClass('on') if ($(this).parents('li').index() == 0) { Initials = '' } else if ($(this).parents('li').index() == 1) { jobTitle = '' } else if ($(this).parents('li').index() == 2) { team = '' } curPage = 1 getList() }) function getList() { $.ajax({ // url: '北京科技大学能环学院_files/nhxyszdw.json', url: '/common/nhxyszdw.json', success: function (data) { var list = data.data; var newArr = [] var InitialsArr = [] jobTitleArr = [] teamArr = [] list.map(function (item, index, arr) { if (item.contentProperty['姓氏检索'].toUpperCase().slice(0, 1) == Initials) { InitialsArr.push(item) } }) list.map(function (item, index, arr) { if (item.contentProperty['职称'].trim() == jobTitle) { jobTitleArr.push(item) } }) list.map(function (item, index, arr) { if (item.contentProperty['系所'].trim() == team) { teamArr.push(item) } }) debugger; let arr2 = [] if (Initials != '') { if (jobTitle != '') { if (team != '') { arr2 = [InitialsArr, jobTitleArr, teamArr] newArr = qjj(arr2) } else { arr2 = [InitialsArr, jobTitleArr] newArr = qjj(arr2) } } else { if (team != '') { arr2 = [InitialsArr, teamArr] newArr = qjj(arr2) } else { arr2 = [InitialsArr] newArr = qjj(arr2) } } } else { if (jobTitle != '') { if (team != '') { arr2 = [jobTitleArr, teamArr] newArr = qjj(arr2) } else { arr2 = [jobTitleArr] newArr = qjj(arr2) } } else { if (team != '') { arr2 = [teamArr] newArr = qjj(arr2) } else { newArr = list } } } // 按姓名排序 let newArr2 = newArr.sort((a, b) => a.title.localeCompare(b.title, 'zh')); var html = '' $.each(newArr2, function (i, item) { html += '
' + item.contentProperty['职称完整名'].trim() + '
' + '' + '