No Description

proinfobrow.js 11KB

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