Brak opisu

proinfobrow.js 12KB

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