var vm = new Vue({ el:"#school-list", data:{ loading:false, uniOrCollege:'university', localProvinceRange:['山东省', '浙江省', '广东省', '海南省', '辽宁省'], localProvince:'山东省', uniProvince:['北京', '天津', '河北', '山西', '辽宁', '吉林', '黑龙江', '上海', '江苏', '浙江', '安徽', '福建', '江西', '山东', '河南', '湖北', '湖南', '广东', '重庆', '四川', '陕西', '内蒙古','广西','海南','贵州','云南','西藏','甘肃','青海','宁夏','新疆','台湾','香港','澳门'], uniType:['综合','理工','农林','医药','师范','语言','财经','政法','体育','艺术','民族','军事','其他'], uniProperty:['公立','民办','中外合作办学','内地与港澳台地区合作办学'], universityTags: ['C9','985','211','保研资格','研究生院','教育部直属','中央部属','强基计划','世界一流大学建设高校','世界一流学科建设高校'], collegeTags: ['中央部属','高水平学校建设单位(A档)','高水平学校建设单位(B档)','高水平学校建设单位(C档)','高水平专业群建设单位(A档)','高水平专业群建设单位(B档)','高水平专业群建设单位(C档)'], uniTags:[], page:0, enrollBatch:'university', activeProvince:'', searchWords:'', allScores:[], scoreRange: [150, 750], scoreMarks: { 150: '150 分', 250: '250 分', 350: '350 分', 450: '450 分', 550: '550 分', 650: '650 分', }, year:'2023', sortBy: 'id', signature:'', }, methods: { // get signature data getSignature(){ this.signature = this.getCookie('signature') }, switchUniOrCollege(){ this.uniOrCollege = this.uniOrCollege == 'university' ? 'college' : 'university'; if(this.uniOrCollege == 'university'){ this.uniTags = this.universityTags; }else{ this.uniTags = this.collegeTags; } this.initScore(); }, // score change listener scoreChangeListener(e) { //judge click from if((e.target).tagName != "LABEL"){ // console.log('特殊标签',(e.target).tagName) this.page = 0; this.allScores = []; this.getScore() }else{ } }, // init score initScore() { this.page = 0; this.allScores = []; this.getScore() }, getScore(){ // set loading status this.loading = true; // start get score setTimeout(() => { const formDom = document.getElementById('form'); let formData = new FormData(formDom); if(formData.get('uni-province') != null){ this.activeProvince = formData.get('uni-province'); } this.invokeGetScore(formData); },50); }, invokeGetScore(formData){ this.page++; let Ajax = new XMLHttpRequest(); let batch = this.uniOrCollege == 'university' ? 1 : 2; let url = 'https://api.suscoo.com/gaokao/api.Score/'; Ajax.open("POST", url); formData.append('year',this.year); formData.append('localProvince',this.localProvince); formData.append('batch',batch); formData.append('minScore',this.scoreRange[0]); formData.append('maxScore',this.scoreRange[1]); formData.append('search',this.searchWords); formData.append('signature',this.signature); formData.append('page',this.page); Ajax.send(formData); Ajax.onreadystatechange = ()=> { if(Ajax.readyState==4){ // console.log('res', Ajax.responseText) let data = Ajax.responseText; data = atob(data); if(JSON.parse(data).code == '400'){ alert('页面停留太久,请刷新...'); } data = JSON.parse(data).data; this.allScores = this.allScores.concat(data); // get the result,close the loading bar this.loading = false; // edit loading message let num = this.allScores.length; let loadNum = data.length; let loadingText = '点击加载更多...'; if(num == 0 && loadNum == 0){ loadingText = "o(╥﹏╥)o,没找到结果,换个条件吧..."; }else if(num !== 0 && loadNum == 0) { loadingText = "你碰到我的底线了亲..."; }else{ loadingText = loadingText; } document.getElementById("loading").innerHTML = loadingText; //add marks this.addWaterMark(); // add web information for (let index = 0; index < num; index++) { let school = this.allScores[index].uni_name; this.getWebInfo(index, school); } } } }, // get web school information getWebInfo(index, school){ let Ajax = new XMLHttpRequest(); let url = '/index.php?m=api&c=school&a=infoByName'; let postData = 'school=' + school; Ajax.open("POST", url); Ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded"); Ajax.send(postData); Ajax.onreadystatechange = ()=> { if(Ajax.readyState==4){ //console.log(Ajax.responseText); let data = Ajax.responseText; res = JSON.parse(data).data; //set school detail info if(res[0] != undefined && res[0] != "" && vm.allScores[index]){ Vue.set( vm.allScores[index], "webUrl", res[0].url); Vue.set( vm.allScores[index], "views", res[0].views); } } } }, // set cookie setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + "; " + expires + ";path=/"; }, // get cookie getCookie(cname){ var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i { var showText1 = window.location.host + vm.Dateformat(new Date(),"yyyy-MM-dd hh:mm:ss"); watermark.load({ watermark_parent_node: "secret-area", watermark_txt: showText1, watermark_width: 200, watermark_alpha:0.06, }); }, 3000); //每3秒刷新一次 3000的单位是毫秒 }, pressEnter(){ document.addEventListener("keydown", (event)=> { // enter to search if (event.code === 'Enter') { this.initScore(); } }) }, Dateformat(Date, fmt) { var o = { "M+": Date.getMonth() + 1, //月份 "d+": Date.getDate(), //日 "h+": Date.getHours(), //小时 "m+": Date.getMinutes(), //分 "s+": Date.getSeconds(), //秒 "q+": Math.floor((Date.getMonth() + 3) / 3), //季度 "S": Date.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (Date.getFullYear() + "").substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); } } return fmt; }, loadingMore(){ this.getScore(); } }, filters: { // optimize the double first course optimizeDoubleFirst(courseList, courseName){ if(typeof courseList === 'string' && typeof courseName === 'string'){ if(courseList.indexOf(courseName)>= 0){ return '双一流专业' }else{ } if(courseName.indexOf('类')>= 0){ return '大类招生' }else{ } }else{ } return '' }, optimizeNationalCharacteristics(courseList, courseName){ if(typeof courseList === 'string' && typeof courseName === 'string'){ if(courseList.indexOf(courseName)>= 0){ return '国家特色专业' }else{ } }else{ } return '' }, optimizeEvaluate(evaluate, courseName){ if(typeof evaluate === 'string'){ return courseName + '【' + evaluate + '】' }else{ } return '' }, // optimize the score , escape 0 on show optimizeScore(score){ if (score == 0){ return '' }else{ return score } } }, mounted(){ // init get signature this.getSignature(); // init uniTags this.uniTags = this.universityTags; //deal with press enter button this.pressEnter(); //data init this.initScore(); }, });