//搜索首页
var ifdiv = false;
var bigClass = 1,
allPages = 1; // 总页数;
var key = "",
subject = "",
industry = "",
province = "",
address = "",
authentication = "",
pageSize = 0,
pageNo = 1;
var showblock = document.getElementById("li_show");
var selectblock = document.getElementById("div_select");
var searchVal = document.getElementById("searchval");
var table = document.body.querySelector('.list');
var yyhy = document.getElementById("yyhy");
var xsly = document.getElementById("xsly");
var provinceVal = document.getElementById("provinceval");
var addressVal = document.getElementById("addressval");
var subjectid = document.getElementById("subjectid");
var industryid = document.getElementById("industryid");
var nodatabox = document.getElementById("nodatabox");
mui.init({
pullRefresh: {
container: '#pullrefresh3',
up: {
contentrefresh: '正在加载...',
callback: pullupRefresh,
auto:true
}
}
});
function pullupRefresh() {
pageNo = ++pageNo;
console.log(pageNo)
key = searchVal.value;
setTimeout(function() {
expert2(key, subject, industry, province, address, authentication, 10, pageNo)
}, 1000);
mui('#pullrefresh3').pullRefresh().refresh(true);
}
if(mui.os.plus) {
mui.plusReady(function() {
setTimeout(function() {
mui('#pullrefresh3').pullRefresh().pulldownLoading();
}, 500);
});
} else {
mui.ready(function() {
mui('#pullrefresh3').pullRefresh().pulldownLoading();
});
}
mui.plusReady(function(){
/*点击专家和资源列表*/
mui('.list').on('tap','a',function(){
var id=this.getAttribute("data-id");
//console.log(id);
plus.nativeUI.showWaiting();//显示原生等待框
if(bigClass==1){
plus.webview.create("../html/proinforbrow.html",'proinforbrow.html',{},{proid:id});
}else{
plus.webview.create("../html/resinforbrow.html",'resinforbrow.html',{},{resourceId:id});
}
})
var self = plus.webview.currentWebview();
if(self.key==undefined){
self.key="";
}else{
key=self.key;
searchVal.value=key;
}
if(self.subject==undefined){
self.subject="学术领域";
}else{
subject=self.subject;
subjectid.innerText = self.subject;
}
bigClass=self.bigClass;
if(bigClass==1){
selectblock.innerText='专家';
}else{
selectblock.innerText='资源';
}
expert(key, subject, industry, province, address, authentication, 10, 1);
})
/*搜专家搜资源的下拉选择框*/
selectblock.addEventListener('tap', function() {
showblock.style.display = 'block';
});
mui("#li_show").on('tap', 'li', function() {
pageNo = 1
bigClass = this.getAttribute("data-num");
if(bigClass==1){
searchVal.setAttribute("placeholder","输入专家姓名、研究方向等关键字");
}else{
searchVal.setAttribute("placeholder","输入资源名称、应用用途等关键字");
}
selectblock.innerHTML = this.innerHTML;
showblock.style.display = 'none';
plus.nativeUI.showWaiting();
expert(key, subject, industry, province, address, authentication, 10, 1);
});
/*按键字搜索*/
searchval.addEventListener("keyup", function() {
var e = event || window.event || arguments.caller.arguments[0];
if(e.keyCode == 13) {
pageNo = 1
key = searchVal.value;
/* console.log(key);
console.log(subject);
console.log(industry);
console.log(address);
console.log(province);
console.log(authentication);*/
plus.nativeUI.showWaiting();
expert(key, subject, industry, province, address, authentication, 10, 1);
}
})
/*省会*/
mui(".provinceval").on('tap', 'a', function() {
key = searchVal.value;
province = this.innerText;
document.querySelector('#provinceval li a.active').classList.remove('active');
this.classList.add("active");
if(province == "全国") {
province = "";
address = "";
document.getElementById("addressid").innerText = "全国";
addressVal.innerHTML = "";
plus.nativeUI.showWaiting();
mui('.mui-popover').popover('hide');
expert(key, subject, industry, province, address, authentication, 10, 1);
} else {
mui.ajax(baseUrl + '/ajax/dataDict/qaCity', {
data: {
"dictCode": "ADDRESS",
province: province
},
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
timeout: 10000,
success: function(data) {
if(province == "北京市" || province == "上海市" || province == "天津市" || province == "重庆市" ){
var finallist = '';
}else{
var finallist = '
全省';
}
console.log(data.success)
console.log(JSON.stringify(data.data))
if(data.success && data.data != "") {
mui.each(data.data, function(i, n) {
finallist += '' + n.caption + '';
});
addressVal.innerHTML = finallist;
addressVal.firstChild.childNodes.item(0).classList.add('active');
}
},
error: function() {
plus.nativeUI.toast("服务器链接超时", toastStyle);
}
});
}
});
/*市检索*/
mui("#addressval").on('tap', 'a', function() {
key = searchVal.value;
address = this.innerText;
document.getElementById("addressid").innerText = address;
document.querySelector('#addressval li a.active').classList.remove('active');
this.classList.add("active");
if(address == "全省") {
address = "";
document.getElementById("addressid").innerText = province;
}
//console.log(province);
//console.log(address);
plus.nativeUI.showWaiting();
mui('.mui-popover').popover('hide');
expert(key, subject, industry, province, address, authentication, 10, 1);
})
/*应用行业*/
mui(".yyhy").on('tap', 'a', function() {
pageNo = 1
key = searchVal.value;
industry = this.innerText;
industryid.innerText = industry;
document.querySelector('#yyhy li a.active').classList.remove('active');
this.classList.add("active");
if(industry == "不限") {
industry = "";
industryid.innerText ="应用行业";
}
plus.nativeUI.showWaiting();
mui('.mui-popover').popover('hide');
/*console.log(key);
console.log(subject);
console.log(industry);
console.log(address);
console.log(province);
console.log(authentication);*/
expert(key, subject, industry, province, address, authentication, 10, 1);
});
/*学术领域*/
mui(".xsly").on('tap', 'a', function() {
pageNo = 1
key = searchVal.value;
subject = this.innerText;
subjectid.innerText = subject;
document.querySelector('#xsly li a.active').classList.remove('active');
this.classList.add("active");
if(subject == "不限") {
subject = "";
subjectid.innerText="学术领域";
}
/* console.log(key);
console.log(subject);
console.log(industry);
console.log(address);
console.log(province);
console.log(authentication);*/
plus.nativeUI.showWaiting();
mui('.mui-popover').popover('hide');
expert(key, subject, industry, province, address, authentication, 10, 1);
});
/*初始化数据*/
function expert(key, subject, industry, province, address, authentication, pageSize, pageNo) {
//console.log(bigClass)
if(bigClass == 1) {
mui.ajax(baseUrl + '/ajax/professor/pqAPP', {
data: {
"key": key,
"subject": subject,
"industry": industry,
"province": province,
"address": address,
"authentication": authentication,
"pageSize": pageSize,
"pageNo": pageNo,
},
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
timeout: 10000,
success: function(data) {
table.innerHTML = '';
plus.webview.currentWebview().show("slide-in-right",150);
plus.nativeUI.closeWaiting();
var perrid = plus.webview.getWebviewById('../html/search-home.html');
if(perrid){
setTimeout(function() {
perrid.close();
}, 1000);
}
if(data.success && data.data.data != '') {
nodatabox.style.display = 'none';
var datalist = data.data.data;
console.log(data.data.total)
datalistEach(datalist);
mui('#pullrefresh3').pullRefresh().refresh(true);
mui('#pullrefresh3').pullRefresh().scrollTo(0,0);
if(data.data.total';
}
/*获取资源信息*/
var resources = item.resources;
var zlist = ''
for(var m = 0; m < resources.length; m++) {
zlist = '' + resources[m].resourceName + '';
}
//var title;
//(item.title != '') ? title = item.title + " , " : title = '';
var title = item.title || "";
var office = item.office || "";
var orgName = item.orgName || "";
var address = item.address || "";
if(title != "") {
title = title + " , ";
}
if(office != "") {
office = office + " , ";
}
if(orgName != "") {
orgName = orgName;
}
if(address != "") {
address = " | " + address;
}
var li = document.createElement('li');
li.className = 'mui-table-view-cell mui-media';
li.innerHTML = '' +
'' +
'
' + item.name + icon + '' +
'
' + title + '' + office + '' + orgName + '' + address + '
' +
'
' + rlist + '
' +
'
' + zlist + '
' +
'
';
table.appendChild(li, table.firstChild);
});
}
/*资源数据遍历*/
function resourcesEach(datalist) {
mui.each(datalist, function(index, item) {
/*获取头像*/
if(item.images.length) {
var img = baseUrl + "/images/resource/" + item.resourceId + ".jpg";
} else {
var img = "../images/default-resource.jpg";
}
/*判断用户是否认证*/
var icon = '';
if(item.authType) {
icon=' ';
} else {
if(item.authStatus) {
if(item.authentication == 1) {
icon='科研';
} else if(item.authentication == 2) {
icon='企业';
} else {
icon='学生';
}
}
}
var title = item.professor.title || "";
var office = item.professor.office || "";
var orgName = item.professor.orgName || "";
var address = item.professor.address || "";
if(title != "") {
title = title + " , ";
}
if(office != "") {
office = office + " , ";
}
if(orgName != "") {
orgName = orgName;
}
if(address != "") {
address = " | " + address;
}
var li = document.createElement('li');
li.className = 'mui-table-view-cell mui-media';
li.innerHTML = '' +
'' +
'
' + item.resourceName + '' +
'
' + item.supportedServices + '
' +
'
' + item.professor.name + icon + '' +
'
' + title + '' + office + '' + orgName + '' + address + '
' +
'
';
table.appendChild(li, table.firstChild);
});
}
mui.plusReady(function(){
//省
mui.ajax(baseUrl + '/ajax/dataDict/qaCity', {
data: {
"dictCode": "PROVINCE"
},
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
timeout: 10000,
success: function(data) {
var finallist = '全国';
console.log(data.success)
console.log(JSON.stringify(data.data))
if(data.success && data.data != "") {
mui.each(data.data, function(i, n) {
finallist += '' + n.caption + '';
});
provinceVal.innerHTML = finallist;
}
},
error: function() {
plus.nativeUI.toast("服务器链接超时", toastStyle);
}
});
//应用行业
mui.ajax(baseUrl + '/ajax/dataDict/qaDictCode', {
data: {
"dictCode": "INDUSTRY"
},
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
timeout: 10000,
success: function(data) {
var finallist = '不限';
console.log(data.success)
console.log(JSON.stringify(data.data))
if(data.success && data.data != "") {
mui.each(data.data, function(i, n) {
finallist += '' + n.caption + '';
});
yyhy.innerHTML = finallist;
}
},
error: function() {
plus.nativeUI.toast("服务器链接超时", toastStyle);
}
});
//学术领域
mui.ajax(baseUrl + '/ajax/dataDict/qaDictCode', {
data: {
"dictCode": "SUBJECT"
},
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
timeout: 10000,
success: function(data) {
var finallist = '不限';
//console.log(data.success)
//console.log(JSON.stringify(data.data))
if(data.success && data.data != "") {
mui.each(data.data, function(i, n) {
finallist += '' + n.caption + '';
});
xsly.innerHTML = finallist;
}
mui("#xsly li a").each(function () {
if(this.innerText==subject){
document.querySelector('#xsly li a.active').classList.remove('active');
this.classList.add("active");
}
});
},
error: function() {
plus.nativeUI.toast("服务器链接超时", toastStyle);
}
});
})