123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- var ozixun = document.getElementById("zixun");
- var yesExpert = document.getElementById("yesExpert");
- var noExpert = document.getElementById("noExpert");
- var personalMaterial = document.getElementsByClassName('personalMaterial');
- var personSummary = document.getElementsByClassName("breifinfo")[0];
- mui.plusReady(function() {
- var userid = plus.storage.getItem('userid');
- var self = plus.webview.currentWebview();
- var proId = self.proid;
- console.log(userid);
-
- if(userid) {
- ozixun.addEventListener('tap', function() {
- var flag = 'professor';
- var nwaiting = plus.nativeUI.showWaiting();
- webviewShow = plus.webview.create("../html/consultapply.html", 'consultapply.html', {}, {
- 'proId': proId,
- 'flag': flag
- });
- webviewShow.addEventListener("loaded", function() {
- }, false);
- });
- } else if(userid == '' || userid == undefined) {
- ozixun.addEventListener('tap', function() {
-
- mui.openWindow({
- url: '../html/login.html',
- id: 'html/login.html',
- show: {
- aniShow: "slide-in-left"
- }
- });
- });*/
- plus.nativeUI.toast("请先登录");
- });
- }
-
- var subjectShow = function(data) {
- if(data != undefined && data.length != 0) {
- var subs = new Array();
- if(data.indexOf(',')) {
- subs = data.split(',');
- } else {
- subs[0] = data;
- }
- if(subs.length > 0) {
- var html = [];
- for(var i = 0; i < subs.length; i++) {
- html.push("<li>" + subs[i] + "</li>");
- };
- document.getElementsByClassName("infosubject")[0].innerHTML = html.join('');
- }
- }
- }
-
- var getRecords = function($researchAreaLogs, caption) {
- var ret = [];
- var t = 0;
- for(var i = 0; i < $researchAreaLogs.length; i++) {
- if(caption == $researchAreaLogs[i].caption) {
- ret[t] = {
- id: $researchAreaLogs[i].opreteProfessorId,
- img: $researchAreaLogs[i].hasHeadImage
- }
- t++;
- }
- }
- return ret;
- }
- var researchAreaShow = function($datas, $datarecords) {
- if($datas != undefined && $datas.length != 0) {
- var html = [];
- for(var i = 0; i < $datas.length; ++i) {
- var $data = $datas[i];
- var $photos = [];
-
- if($datarecords.length > 0) {
- $photos = getRecords($datarecords, $data.caption);
- }
- var isAgree = -1;
- for(var j = 0; j < $photos.length; j++) {
- if(userid == $photos[j].id)
- isAgree++;
- }
- if(isAgree) {
- var showDiv = "<div class='listbox'><div class='listbrowse mui-ellipsis'><span class='like'>" + $data.count + "</span>" + $data.caption + "</div><span class=' mui-icon iconfont plusbtn icon-appreciate' data-pid='" + $data.professorId + "' data-caption='" + $data.caption + "' data-isagree='" + isAgree + "' ></span><div class='likenum'>";
- } else {
- var showDiv = "<div class='listbox'><div class='listbrowse mui-ellipsis'><span class='like'>" + $data.count + "</span>" + $data.caption + "</div><span class=' mui-icon iconfont plusbtn icon-appreciatefill' data-pid='" + $data.professorId + "' data-caption='" + $data.caption + "' data-isagree='" + isAgree + "' ></span><div class='likenum'>";
- }
- if($photos.length < 4) {
- for(var j = 0; j < $photos.length; ++j) {
- if($photos[j].img) {
- showDiv += "<span class='likepeople headRadius'><img class='like-h' src='" + baseUrl + "/images/head/" + $photos[j].id + "_s.jpg'></span>";
- } else {
- showDiv += "<span class='likepeople headRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
- }
- }
- } else {
- for(var j = $photos.length - 2; j < $photos.length; ++j) {
- if($photos[j].img) {
- showDiv += "<span class='likepeople headRadius'><img class='like-h' src='" + baseUrl + "/images/head/" + $photos[j].id + "_s.jpg'></span>";
- } else {
- showDiv += "<span class='likepeople headRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
- }
- }
- showDiv += "<span class='mui-icon iconfont icon-more likepeople likemore headRadius'></span>";
- }
- showDiv += "</div></div></div>";
- html.push(showDiv);
- }
- document.getElementsByClassName("reserachMess")[0].innerHTML = html.join('')
- }
- }
-
- var industryShow = function(data) {
- if(data != undefined && data.length != 0) {
- var subs = new Array();
- if(data.indexOf(',')) {
- subs = data.split(',');
- } else {
- subs[0] = data;
- }
- if(subs.length > 0) {
- var html = [];
- for(var i = 0; i < subs.length; i++) {
- html.push("<li>" + subs[i] + "</li>");
- };
- document.getElementsByClassName("infoapply")[0].innerHTML = html.join('');
- }
- }
- }
- var professorResource = function(odata) {
- var $data = odata;
- var html = [];
- for(var i = 0; i < odata.length; i++) {
- var string = '<li class="mui-table-view-cell mui-media" resouseId=' + $data[i].resourceId + '>'
- string += '<a class="proinfor">'
- if($data[i].images.length) {
- string += '<img class="mui-media-object mui-pull-left resimg" src="' + baseUrl + '/images/resource/' + $data[i].resourceId + '.jpg">'
- } else {
- string += '<img class="mui-media-object mui-pull-left resimg" src="../images/default-resource.jpg">'
- }
- string += '<div class="mui-media-body">'
- string += '<span class="listtit">' + $data[i].resourceName + '</span>'
- string += '<p class="listtit2">' + $data[i].supportedServices + '</p>'
- string += '<p class="listtit3 resbrief">'
- if($data[i].descp) {
- string += $data[i].descp;
- }
- string += '</p></div></a></li>'
- html.push(string);
- }
- document.getElementById("resourceList").innerHTML = html.join('');
- }
-
- function personalMessage() {
- mui.ajax(baseUrl + "/ajax/professor/info/" + proId, {
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- plus.nativeUI.closeWaiting();
- plus.webview.currentWebview().show("slide-in-right", 150);
- var $data = data.data;
- personalMaterial[0].innerText = $data.name;
-
- document.getElementsByClassName("consultCount")[0].innerText = $data.consultCount;
- var startLeval = parseInt($data.starLevel);
- var start = document.getElementsByClassName("start");
- for(var i = 0; i < startLeval; i++) {
- start[i].classList.add("icon-favorfill");
- start[i].classList.remove("icon-favor");
- }
- if($data.hasHeadImage) {
- document.getElementsByClassName("headimg")[0].src = baseUrl + "/images/head/" + $data.id + "_l.jpg";
- } else {
- document.getElementsByClassName("headimg")[0].src = "../images/default-photo.jpg";
- }
- if(!$data.authentication) {
- document.getElementsByClassName('icon-vip')[0].classList.remove("authicon");
- document.getElementsByClassName('icon-vip')[0].classList.add("unauthicon");
- }
- if($data.office) {
- if($data.title) {
- personalMaterial[1].innerText = $data.office + ",";
- } else {
- personalMaterial[1].innerText = $data.office;
- }
- }
- if($data.title) {
- personalMaterial[2].innerText = $data.title;
- }
- if($data.orgName) {
- if($data.department) {
- personalMaterial[3].innerText = $data.orgName + " , ";
- } else {
- personalMaterial[3].innerText = $data.orgName;
- }
- }
- if($data.department) {
- if($data.address) {
- personalMaterial[4].innerText = $data.department + " | ";
- } else {
- personalMaterial[4].innerText = $data.department;
- }
- }
- if($data.address) {
- personalMaterial[5].innerText = $data.address;
- }
-
- if($data.descp) {
- personSummary.innerHTML = $data.descp;
- } else {
- document.getElementById("professorBreifinfo").style.display = "none";
- }
-
- if($data.subject) {
- subjectShow($data.subject);
- } else {
- document.getElementById("professorInfosubject").style.display = "none";
- }
-
- if($data.researchAreas.length) {
- researchAreaShow($data.researchAreas, $data.editResearchAreaLogs);
- } else {
- document.getElementById("professorReserachMess").style.display = "none";
- }
-
- if($data.industry) {
- industryShow($data.industry);
- } else {
- document.getElementById("professorinfoapply").style.display = "none";
- }
-
- if($data.resources.length) {
- professorResource($data.resources);
- } else {
- document.getElementById("professorresourceList").style.display = "none";
- }
-
- if(!$data.edus.length && !$data.jobs.length && !$data.projects.length && !$data.papers.length && !$data.patents.length && !$data.honors.length) {
- document.getElementById("detailProfessor").style.display = "none";
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- });
- }
-
- document.getElementsByClassName("gotonext")[0].addEventListener("tap", function() {
- var nwaiting = plus.nativeUI.showWaiting();
- var web = plus.webview.create("../html/proinforbrow-more.html", "proinforbrow-more.html", {}, {
- pro: proId
- });
- web.addEventListener("loaded", function() {}, false);
- });
-
- var clFlag = 1;
- mui(".reserachMess").on("click", ".plusbtn", function() {
- if(userid && userid != null && userid != "null") {
- if(clFlag) {
- clFlag = 0;
- } else {
- return;
- }
- if(this.getAttribute("data-isagree") > -1) {
- this.classList.remove("icon-appreciatefill");
- this.classList.add("icon-appreciate");
- } else {
- this.classList.add("icon-appreciatefill");
-
- }
- mui.ajax(this.getAttribute("data-isagree") > -1 ? baseUrl + "/ajax/researchArea/unAgree" : baseUrl + "/ajax/researchArea/agree", {
- "type": "POST",
- "data": {
- "targetId": this.getAttribute("data-pid"),
- "targetCaption": this.getAttribute("data-caption"),
- "opId": userid
- },
- "contentType": "application/x-www-form-urlencoded",
- "success": function($data) {
- if($data.success) {
- mui.ajax(baseUrl + "/ajax/professor/info/" + proId, {
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- clFlag = 1;
- var $data = data.data;
-
- document.getElementsByClassName("reserachMess")[0].innerHTML = "";
- if($data.researchAreas.length) {
- researchAreaShow($data.researchAreas, $data.editResearchAreaLogs);
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- });
- }
- }
- })
- } else {
- plus.nativeUI.toast("请先登录");
- }
- })
- personalMessage();
-
- mui("#resourceList").on('tap', 'li', function() {
- var resouId = this.getAttribute("resouseId");
- plus.nativeUI.showWaiting();
- plus.webview.create("../html/resinforbrow.html", 'resinforbrow.html', {}, {
- resourceId: resouId
- });
- });
-
- window.addEventListener('backproinfo', function(event) {
- var proid = event.detail.proId;
- console.log(proid);
-
- });
- ifCollection();
- yesExpert.addEventListener('tap', function() {
- var $this = this;
- if(userid && userid != null && userid != "null") {
- collectionExpert($this);
- } else {
- plus.nativeUI.toast("请先登录");
- }
- });
- noExpert.addEventListener('tap', function() {
- var $this = this;
- cancelCollectionExpert($this);
- });
-
- function ifCollection() {
- mui.ajax(baseUrl + '/ajax/watch/hasWatch', {
- data: {
- "professorId": userid,
- "watchObject": proId
- },
- dataType: 'json',
- type: 'get',
- timeout: 10000,
- async: false,
- success: function(data) {
- if(data.success && data.data != null) {
- yesExpert.style.display = "none";
- noExpert.style.display = "block";
- returnId = data.data.watchObject;
- } else {
- yesExpert.style.display = "block";
- noExpert.style.display = "none";
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- }
-
- function collectionExpert($this) {
- mui.ajax(baseUrl + '/ajax/watch', {
- data: {
- "professorId": userid,
- "watchObject": proId,
- "watchType": 1
- },
- dataType: 'json',
- type: 'POST',
- timeout: 10000,
- async: false,
- success: function(data) {
- console.log(data.success)
- if(data.success) {
- $this.style.display = "none";
- noExpert.style.display = "block";
- returnId = data.data;
-
- plus.nativeUI.toast("专家关注成功", toastStyle);
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- }
-
- function cancelCollectionExpert($this) {
-
-
- mui.ajax({
- url: baseUrl + '/ajax/watch/delete',
- data: {
- professorId: userid,
- watchObject: returnId
- },
- dataType: 'json',
- type: 'post',
- timeout: 10000,
- async: true,
- success: function(data) {
- console.log(data.success)
- if(data.success) {
- $this.style.display = "none";
- yesExpert.style.display = "block";
- plus.nativeUI.toast("取消关注成功", toastStyle);
- }
- },
- error: function(data) {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- }
- });
- }
-
- document.getElementById("accessHistory").addEventListener('tap', function() {
- mui.openWindow({
- url: '../html/coophistory-other.html',
- id: 'html/coophistory-other.html',
- show: {
- autoShow: false,
- },
- extras: {
- professorId: proId
- }
- });
- })
- });
|