Nenhuma Descrição

proinfobrow.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. var ozixun = document.getElementById("zixun");
  2. var yesExpert = document.getElementById("yesExpert");
  3. var noExpert = document.getElementById("noExpert");
  4. var personalMaterial = document.getElementsByClassName('personalMaterial');
  5. var personSummary = document.getElementsByClassName("breifinfo")[0];
  6. mui.plusReady(function() {
  7. var userid = plus.storage.getItem('userid');
  8. var self = plus.webview.currentWebview();
  9. var proId = self.proid;
  10. console.log(userid);
  11. /*点击咨询*/
  12. if(userid) {
  13. ozixun.addEventListener('tap', function() {
  14. var flag = 'professor';
  15. var nwaiting = plus.nativeUI.showWaiting(); //显示原生等待框
  16. webviewShow = plus.webview.create("../html/consultapply.html", 'consultapply.html', {}, {
  17. 'proId': proId,
  18. 'flag': flag
  19. });
  20. webviewShow.addEventListener("loaded", function() {
  21. }, false);
  22. });
  23. } else if(userid == '' || userid == undefined) {
  24. ozixun.addEventListener('tap', function() {
  25. /*mui.alert('请登录', '' ,function(){
  26. mui.openWindow({
  27. url: '../html/login.html',
  28. id: 'html/login.html',
  29. show: {
  30. aniShow: "slide-in-left"
  31. }
  32. });
  33. });*/
  34. plus.nativeUI.toast("请先登录");
  35. });
  36. }
  37. //查询学术领域
  38. var subjectShow = function(data) {
  39. if(data != undefined && data.length != 0) {
  40. var subs = new Array();
  41. if(data.indexOf(',')) {
  42. subs = data.split(',');
  43. } else {
  44. subs[0] = data;
  45. }
  46. if(subs.length > 0) {
  47. var html = [];
  48. for(var i = 0; i < subs.length; i++) {
  49. html.push("<li>" + subs[i] + "</li>");
  50. };
  51. document.getElementsByClassName("infosubject")[0].innerHTML = html.join('');
  52. }
  53. }
  54. }
  55. //查询研究方向
  56. var getRecords = function($researchAreaLogs, caption) {
  57. var ret = [];
  58. var t = 0;
  59. for(var i = 0; i < $researchAreaLogs.length; i++) {
  60. if(caption == $researchAreaLogs[i].caption) {
  61. ret[t] = {
  62. id: $researchAreaLogs[i].opreteProfessorId,
  63. img: $researchAreaLogs[i].hasHeadImage
  64. }
  65. t++;
  66. }
  67. }
  68. return ret;
  69. }
  70. var researchAreaShow = function($datas, $datarecords) {
  71. if($datas != undefined && $datas.length != 0) {
  72. var html = [];
  73. for(var i = 0; i < $datas.length; ++i) {
  74. var $data = $datas[i];
  75. var $photos = [];
  76. //获取头像
  77. if($datarecords.length > 0) {
  78. $photos = getRecords($datarecords, $data.caption);
  79. }
  80. var isAgree = -1;
  81. for(var j = 0; j < $photos.length; j++) {
  82. if(userid == $photos[j].id)
  83. isAgree++;
  84. }
  85. if(isAgree) {
  86. 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'>";
  87. } else {
  88. 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'>";
  89. }
  90. if($photos.length < 4) {
  91. for(var j = 0; j < $photos.length; ++j) {
  92. if($photos[j].img) {
  93. showDiv += "<span class='likepeople headRadius'><img class='like-h' src='" + baseUrl + "/images/head/" + $photos[j].id + "_s.jpg'></span>";
  94. } else {
  95. showDiv += "<span class='likepeople headRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
  96. }
  97. }
  98. } else {
  99. for(var j = $photos.length - 2; j < $photos.length; ++j) {
  100. if($photos[j].img) {
  101. showDiv += "<span class='likepeople headRadius'><img class='like-h' src='" + baseUrl + "/images/head/" + $photos[j].id + "_s.jpg'></span>";
  102. } else {
  103. showDiv += "<span class='likepeople headRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
  104. }
  105. }
  106. showDiv += "<span class='mui-icon iconfont icon-more likepeople likemore headRadius'></span>";
  107. }
  108. showDiv += "</div></div></div>";
  109. html.push(showDiv);
  110. }
  111. document.getElementsByClassName("reserachMess")[0].innerHTML = html.join('')
  112. }
  113. }
  114. //查询应用行业
  115. var industryShow = function(data) {
  116. if(data != undefined && data.length != 0) {
  117. var subs = new Array();
  118. if(data.indexOf(',')) {
  119. subs = data.split(',');
  120. } else {
  121. subs[0] = data;
  122. }
  123. if(subs.length > 0) {
  124. var html = [];
  125. for(var i = 0; i < subs.length; i++) {
  126. html.push("<li>" + subs[i] + "</li>");
  127. };
  128. document.getElementsByClassName("infoapply")[0].innerHTML = html.join('');
  129. }
  130. }
  131. }
  132. var professorResource = function(odata) {
  133. var $data = odata;
  134. var html = [];
  135. for(var i = 0; i < odata.length; i++) {
  136. var string = '<li class="mui-table-view-cell mui-media" resouseId=' + $data[i].resourceId + '>'
  137. string += '<a class="proinfor">'
  138. if($data[i].images.length) {
  139. string += '<img class="mui-media-object mui-pull-left resimg" src="' + baseUrl + '/images/resource/' + $data[i].resourceId + '.jpg">'
  140. } else {
  141. string += '<img class="mui-media-object mui-pull-left resimg" src="../images/default-resource.jpg">'
  142. }
  143. string += '<div class="mui-media-body">'
  144. string += '<span class="listtit">' + $data[i].resourceName + '</span>'
  145. string += '<p class="listtit2">' + $data[i].supportedServices + '</p>'
  146. string += '<p class="listtit3 resbrief">'
  147. if($data[i].descp) {
  148. string += $data[i].descp;
  149. }
  150. string += '</p></div></a></li>'
  151. html.push(string);
  152. }
  153. document.getElementById("resourceList").innerHTML = html.join('');
  154. }
  155. /*获取个人信息*/
  156. function personalMessage() {
  157. mui.ajax(baseUrl + "/ajax/professor/info/" + proId, {
  158. dataType: 'json', //数据格式类型
  159. type: 'GET', //http请求类型
  160. timeout: 10000, //超时设置
  161. success: function(data) {
  162. plus.nativeUI.closeWaiting();
  163. plus.webview.currentWebview().show("slide-in-right", 150);
  164. var $data = data.data;
  165. personalMaterial[0].innerText = $data.name;
  166. //基本信息
  167. document.getElementsByClassName("consultCount")[0].innerText = $data.consultCount;
  168. var startLeval = parseInt($data.starLevel);
  169. var start = document.getElementsByClassName("start");
  170. for(var i = 0; i < startLeval; i++) {
  171. start[i].classList.add("icon-favorfill");
  172. start[i].classList.remove("icon-favor");
  173. }
  174. if($data.hasHeadImage) {
  175. document.getElementsByClassName("headimg")[0].src = baseUrl + "/images/head/" + $data.id + "_l.jpg";
  176. } else {
  177. document.getElementsByClassName("headimg")[0].src = "../images/default-photo.jpg";
  178. }
  179. if(!$data.authentication) {
  180. document.getElementsByClassName('icon-vip')[0].classList.remove("authicon");
  181. document.getElementsByClassName('icon-vip')[0].classList.add("unauthicon");
  182. }
  183. if($data.office) {
  184. if($data.title) {
  185. personalMaterial[1].innerText = $data.office + ",";
  186. } else {
  187. personalMaterial[1].innerText = $data.office;
  188. }
  189. }
  190. if($data.title) {
  191. personalMaterial[2].innerText = $data.title;
  192. }
  193. if($data.orgName) {
  194. if($data.department) {
  195. personalMaterial[3].innerText = $data.orgName + " , ";
  196. } else {
  197. personalMaterial[3].innerText = $data.orgName;
  198. }
  199. }
  200. if($data.department) {
  201. if($data.address) {
  202. personalMaterial[4].innerText = $data.department + " | ";
  203. } else {
  204. personalMaterial[4].innerText = $data.department;
  205. }
  206. }
  207. if($data.address) {
  208. personalMaterial[5].innerText = $data.address;
  209. }
  210. //个人简介
  211. if($data.descp) {
  212. personSummary.innerHTML = $data.descp;
  213. } else {
  214. document.getElementById("professorBreifinfo").style.display = "none";
  215. }
  216. //学术领域
  217. if($data.subject) {
  218. subjectShow($data.subject);
  219. } else {
  220. document.getElementById("professorInfosubject").style.display = "none";
  221. }
  222. //研究方向
  223. if($data.researchAreas.length) {
  224. researchAreaShow($data.researchAreas, $data.editResearchAreaLogs);
  225. } else {
  226. document.getElementById("professorReserachMess").style.display = "none";
  227. }
  228. //应用行业
  229. if($data.industry) {
  230. industryShow($data.industry);
  231. } else {
  232. document.getElementById("professorinfoapply").style.display = "none";
  233. }
  234. //专家资源
  235. if($data.resources.length) {
  236. professorResource($data.resources);
  237. } else {
  238. document.getElementById("professorresourceList").style.display = "none";
  239. }
  240. //如无详细内容数据,隐藏详细点击的按钮
  241. if(!$data.edus.length && !$data.jobs.length && !$data.projects.length && !$data.papers.length && !$data.patents.length && !$data.honors.length) {
  242. document.getElementById("detailProfessor").style.display = "none";
  243. }
  244. },
  245. error: function() {
  246. plus.nativeUI.toast("服务器链接超时", toastStyle);
  247. return;
  248. }
  249. });
  250. }
  251. //修改详细页面
  252. document.getElementsByClassName("gotonext")[0].addEventListener("tap", function() {
  253. var nwaiting = plus.nativeUI.showWaiting();
  254. var web = plus.webview.create("../html/proinforbrow-more.html", "proinforbrow-more.html", {}, {
  255. pro: proId
  256. }); //后台创建webview并打开show.html
  257. web.addEventListener("loaded", function() {}, false);
  258. });
  259. //点赞
  260. var clFlag = 1;
  261. mui(".reserachMess").on("click", ".plusbtn", function() {
  262. if(userid && userid != null && userid != "null") {
  263. if(clFlag) {
  264. clFlag = 0;
  265. } else {
  266. return;
  267. }
  268. if(this.getAttribute("data-isagree") > -1) {
  269. this.classList.remove("icon-appreciatefill");
  270. this.classList.add("icon-appreciate");
  271. } else {
  272. this.classList.add("icon-appreciatefill");
  273. //this.classlist.remove("plusbtn");
  274. }
  275. mui.ajax(this.getAttribute("data-isagree") > -1 ? baseUrl + "/ajax/researchArea/unAgree" : baseUrl + "/ajax/researchArea/agree", {
  276. "type": "POST",
  277. "data": {
  278. "targetId": this.getAttribute("data-pid"),
  279. "targetCaption": this.getAttribute("data-caption"),
  280. "opId": userid
  281. },
  282. "contentType": "application/x-www-form-urlencoded",
  283. "success": function($data) {
  284. if($data.success) {
  285. mui.ajax(baseUrl + "/ajax/professor/info/" + proId, {
  286. dataType: 'json', //数据格式类型
  287. type: 'GET', //http请求类型
  288. timeout: 10000, //超时设置
  289. success: function(data) {
  290. clFlag = 1;
  291. var $data = data.data;
  292. //研究方向
  293. document.getElementsByClassName("reserachMess")[0].innerHTML = "";
  294. if($data.researchAreas.length) {
  295. researchAreaShow($data.researchAreas, $data.editResearchAreaLogs);
  296. }
  297. },
  298. error: function() {
  299. plus.nativeUI.toast("服务器链接超时", toastStyle);
  300. return;
  301. }
  302. });
  303. }
  304. }
  305. })
  306. } else {
  307. plus.nativeUI.toast("请先登录");
  308. }
  309. })
  310. personalMessage();
  311. /*进入资源详细页面*/
  312. mui("#resourceList").on('tap', 'li', function() {
  313. var resouId = this.getAttribute("resouseId");
  314. plus.nativeUI.showWaiting();
  315. plus.webview.create("../html/resinforbrow.html", 'resinforbrow.html', {}, {
  316. resourceId: resouId
  317. });
  318. });
  319. /*咨询成功,返回专家信息*/
  320. window.addEventListener('backproinfo', function(event) {
  321. var proid = event.detail.proId;
  322. console.log(proid);
  323. /*ozixun.classList.add('displayNone');*/
  324. });
  325. ifCollection();
  326. yesExpert.addEventListener('tap', function() {
  327. var $this = this;
  328. if(userid && userid != null && userid != "null") {
  329. collectionExpert($this);
  330. } else {
  331. plus.nativeUI.toast("请先登录");
  332. }
  333. });
  334. noExpert.addEventListener('tap', function() {
  335. var $this = this;
  336. cancelCollectionExpert($this);
  337. });
  338. /*判断是非收藏专家*/
  339. function ifCollection() {
  340. mui.ajax(baseUrl + '/ajax/watch/hasWatch', {
  341. data: {
  342. "professorId": userid,
  343. "watchObject": proId
  344. },
  345. dataType: 'json', //数据格式类型
  346. type: 'get', //http请求类型
  347. timeout: 10000,
  348. async: false,
  349. success: function(data) {
  350. if(data.success && data.data != null) {
  351. yesExpert.style.display = "none";
  352. noExpert.style.display = "block";
  353. returnId = data.data.watchObject;
  354. } else {
  355. yesExpert.style.display = "block";
  356. noExpert.style.display = "none";
  357. }
  358. },
  359. error: function() {
  360. plus.nativeUI.toast("服务器链接超时", toastStyle);
  361. }
  362. });
  363. }
  364. /*收藏专家*/
  365. function collectionExpert($this) {
  366. mui.ajax(baseUrl + '/ajax/watch', {
  367. data: {
  368. "professorId": userid,
  369. "watchObject": proId,
  370. "watchType": 1
  371. },
  372. dataType: 'json', //数据格式类型
  373. type: 'POST', //http请求类型
  374. timeout: 10000,
  375. async: false,
  376. success: function(data) {
  377. console.log(data.success)
  378. if(data.success) {
  379. $this.style.display = "none";
  380. noExpert.style.display = "block";
  381. returnId = data.data;
  382. //console.log(returnId)
  383. plus.nativeUI.toast("专家关注成功", toastStyle);
  384. }
  385. },
  386. error: function() {
  387. plus.nativeUI.toast("服务器链接超时", toastStyle);
  388. }
  389. });
  390. }
  391. /*取消收藏专家*/
  392. function cancelCollectionExpert($this) {
  393. //console.log(returnId)
  394. // console.log(userid)
  395. mui.ajax({
  396. url: baseUrl + '/ajax/watch/delete',
  397. data: {
  398. professorId: userid,
  399. watchObject: returnId
  400. },
  401. dataType: 'json', //数据格式类型
  402. type: 'post', //http请求类型
  403. timeout: 10000,
  404. async: true,
  405. success: function(data) {
  406. console.log(data.success)
  407. if(data.success) {
  408. $this.style.display = "none";
  409. yesExpert.style.display = "block";
  410. plus.nativeUI.toast("取消关注成功", toastStyle);
  411. }
  412. },
  413. error: function(data) {
  414. plus.nativeUI.toast("服务器链接超时", toastStyle);
  415. }
  416. });
  417. }
  418. /*专家的历史和评价*/
  419. document.getElementById("accessHistory").addEventListener('tap', function() {
  420. mui.openWindow({
  421. url: '../html/coophistory-other.html',
  422. id: 'html/coophistory-other.html',
  423. show: {
  424. autoShow: false,
  425. },
  426. extras: {
  427. professorId: proId
  428. }
  429. });
  430. })
  431. });