123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- var allPages = 1,
- pageSize = 0,
- pageNo = 1;
- checkedindex = 0
- var table = document.body.querySelector('.list');
- var table1 = document.body.querySelector('.list2');
- mui.init({
- pullRefresh: {
- container: '#pullrefresh',
- up: {
- contentrefresh: '正在加载...',
- callback: pullupRefresh,
-
- }
- }
- });
- function pullupRefresh() {
- pageNo = ++pageNo;
- console.log(pageNo)
- setTimeout(function() {
- expert2(pageNo, 10)
- }, 1000);
- }
- if(mui.os.plus) {
- mui.plusReady(function() {
- setTimeout(function() {
- mui('#pullrefresh').pullRefresh().pulldownLoading();
- }, 500);
- });
- } else {
- mui.ready(function() {
- mui('#pullrefresh').pullRefresh().pulldownLoading();
- });
- }
- mui("#fixbtn").on("tap", "li", function() {
- window.scrollTo(0, 0);
- checkedindex = this.getAttribute("index");
- var checkedcontent_arr = document.getElementsByClassName("childlist");
- var libtn_arr = document.getElementById("fixbtn").getElementsByTagName("li");
- if(checkedindex == 0) {
- libtn_arr[0].classList.add("liactive");
- libtn_arr[1].classList.remove("liactive");
- checkedcontent_arr[1].style.display = 'none';
- checkedcontent_arr[0].style.display = 'block';
- mui('#pullrefresh').pullRefresh().refresh(true);
- } else {
- libtn_arr[1].classList.add("liactive");
- libtn_arr[0].classList.remove("liactive");
- checkedcontent_arr[0].style.display = 'none';
- checkedcontent_arr[1].style.display = 'block';
- mui('#pullrefresh').pullRefresh().refresh(true);
- }
- })
- getOneExpert(1, 10);
- getOneResources(1, 10);
- mui.plusReady(function(){
- mui('.list').on('tap','a',function(){
- var id=this.getAttribute("data-id");
- plus.nativeUI.showWaiting();
- plus.webview.create("../html/proinforbrow.html",'proinforbrow.html',{},{proid:id});
- console.log(id)
- })
- mui('.list2').on('tap','a',function(){
- var id=this.getAttribute("data-id");
- plus.nativeUI.showWaiting();
- plus.webview.create("../html/resinforbrow.html",'resinforbrow.html',{},{resourceId:id});
- })
- })
- function getOneExpert(pageNo, pageSize) {
- mui.plusReady(function() {
- var userId = plus.storage.getItem('userid');
- mui.ajax(baseUrl + '/ajax/watch/qaPro', {
- data: {
- "professorId": userId,
- "watchType": 1,
- "pageNo": pageNo,
- "pageSize": pageSize
- },
- dataType: 'json',
- type: 'GET',
-
-
- success: function(data) {
- console.log("1");
- if(data.success && data.data.data != "") {
- var datalist = data.data.data;
- datalistEach(datalist);
- }
- mui('#pullrefresh').pullRefresh().refresh(true);
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- });
- }
- function getOneResources(pageNo, pageSize) {
- mui.plusReady(function() {
- var userId = plus.storage.getItem('userid');
- mui.ajax(baseUrl + '/ajax/watch/qaPro', {
- data: {
- "professorId": userId,
- "watchType": 2,
- "pageNo": pageNo,
- "pageSize": pageSize
- },
- dataType: 'json',
- type: 'GET',
-
-
- success: function(data) {
- console.log("2");
- plus.nativeUI.closeWaiting();
- plus.webview.currentWebview().show("slide-in-right", 150);
- if(data.success && data.data.data != "") {
- var datalistd = data.data.data;
- resourcesEach2(datalistd);
- }
- mui('#pullrefresh').pullRefresh().refresh(true);
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- });
- }
- function expert2(pageNo, pageSize) {
- if(checkedindex == 0) {
- mui.plusReady(function() {
- var userId = plus.storage.getItem('userid');
- mui.ajax(baseUrl + '/ajax/watch/qaPro', {
- data: {
- "professorId": userId,
- "watchType": 1,
- "pageNo": pageNo,
- "pageSize": pageSize
- },
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
-
- success: function(data) {
- console.log(data.success)
- if(data.success && data.data.data != "") {
- plus.nativeUI.closeWaiting();
- mui('#pullrefresh').pullRefresh().enablePullupToRefresh();
- var dice1 = data.data.total;
- var dice2 = data.data.pageSize;
- allPages = Math.ceil(dice1 / dice2);
- if(allPages == 1) {
- table.innerHTML = '';
- }
- var datalist = data.data.data;
- datalistEach(datalist);
- mui('#pullrefresh').pullRefresh().refresh(true);
- if(pageNo < allPages) {
- mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
- } else {
- mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
- }
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- });
- } else {
- mui.plusReady(function() {
- var userId = plus.storage.getItem('userid');
- mui.ajax(baseUrl + '/ajax/watch/qaPro', {
- data: {
- "professorId": userId,
- "watchType": 2,
- "pageNo": pageNo,
- "pageSize": pageSize
- },
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
-
- success: function(data) {
- console.log(data.success)
- if(data.success && data.data.data != "") {
- plus.nativeUI.closeWaiting();
- mui('#pullrefresh').pullRefresh().enablePullupToRefresh();
- var dice1 = data.data.total;
- var dice2 = data.data.pageSize;
- allPages = Math.ceil(dice1 / dice2);
- if(allPages == 1) {
- table.innerHTML = '';
- }
- var datalist = data.data.data;
- resourcesEach2(datalist);
- mui('#pullrefresh').pullRefresh().refresh(true);
- if(pageNo < allPages) {
- mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
- } else {
- mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
- }
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- });
- }
- }
- function datalistEach(datalist) {
- mui.each(datalist, function(index, item) {
-
- console.log(JSON.stringify(item));
- if(item.professor.hasHeadImage == 1) {
- var img = baseUrl + "/images/head/" + item.professor.id + "_m.jpg";
- } else {
- var img = "../images/default-photo.jpg";
- }
-
- var researchAreas = item.professor.researchAreas;
-
- var rlist = '';
- for(var n = 0; n < researchAreas.length; n++) {
-
- rlist = '<span>' + researchAreas[n].caption + '</span>';
- }
-
- var icon = '';
- console.log(item.professor.authType)
- if(item.professor.authType) {
- icon = '<em class="mui-icon iconfont icon-vip authicon-cu"></em>';
-
- } else {
- if(item.professor.authStatus){
- if(item.professor.authentication==1){
- icon = '<em class="mui-icon iconfont icon-renzheng authicon-mana"><span>科研</span></em>';
- }else if(item.professor.authentication==2){
- icon = '<em class="mui-icon iconfont icon-renzheng authicon-staff"><span>企业</span></em>';
- }else{
- icon = '<em class="mui-icon iconfont icon-renzheng authicon-stu"><span>学生</span></em>';
- }
- }
- }
-
- var resources = item.professor.resources;
- var zlist = '';
- for(var m = 0; m < resources.length; m++) {
-
- zlist = '<span>' + resources[m].resourceName + '</span>';
- }
- 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 = '<a class="proinfor" data-id="' + item.professor.id + '"' +
- '<p><img class="mui-media-object mui-pull-left headimg headRadius" src="' + img + '"></p>' +
- '<div class="mui-media-body">' +
- '<span class="listtit">' + item.professor.name + icon + '</span>' +
- '<p class="listtit2"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
- '<p class="mui-ellipsis listtit3">' + rlist + '</p>' +
- '<p class="mui-ellipsis listtit3">' + zlist + '</p>' +
- '</div></a></li>';
- table.appendChild(li, table.firstChild);
-
- });
- }
- function resourcesEach2(datalistd) {
- mui.each(datalistd, function(index, item) {
-
- if(item.resource.images.length) {
- var img = baseUrl + "/images/resource/" + item.resource.resourceId + ".jpg";
- } else {
- var img = "../images/default-resource.jpg";
- }
-
- var icont = '';
- if(item.resource.professor.authentication == 1) {
- icont = '<em class="mui-icon iconfont icon-vip authicon"></em>';
- } else {
- icont = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
- }
- var title = item.resource.professor.title || "";
- var office = item.resource.professor.office || "";
- var orgName = item.resource.professor.orgName || "";
- var address = item.resource.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 = '<a class="proinfor" data-id="' + item.resource.resourceId + '"' +
- '<p><img class="mui-media-object mui-pull-left resimg" src="' + img + '" ></p>' +
- '<div class="mui-media-body">' +
- '<span class="listtit">' + item.resource.resourceName + '</span>' +
- '<p class="mui-ellipsis listtit2">' + item.resource.supportedServices + '</p>' +
- '<span class="listtit">' + item.resource.professor.name + icont + '</span>' +
- '<p class="listtit3"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
- '</div></a></li>';
- table1.appendChild(li, table1.firstChild);
-
- });
- }
|