Aucune description

studentbrowse.js 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. var professorResource = function(odata) {
  38. var $data = odata;
  39. var html = [];
  40. for(var i = 0; i < odata.length; i++) {
  41. var string = '<li class="mui-table-view-cell mui-media" resouseId=' + $data[i].resourceId + '>'
  42. string += '<a class="proinfor"><div class="mui-media-object mui-pull-left ResImgBox ResImgBox2">'
  43. if($data[i].images.length) {
  44. string += '<img class="resImg headRadius" src="' + baseUrl + '/images/resource/' + $data[i].resourceId + '.jpg">'
  45. } else {
  46. string += '<img class="resImg headRadius" src="../images/default-resource.jpg">'
  47. }
  48. string += '</div><div class="mui-media-body">'
  49. string += '<span class="listtit">' + $data[i].resourceName + '</span>'
  50. string += '<p class="listtit2">' + $data[i].supportedServices + '</p>'
  51. string += '<p class="listtit3 resbrief">'
  52. if($data[i].descp) {
  53. string += $data[i].descp;
  54. }
  55. string += '</p></div></a></li>'
  56. html.push(string);
  57. }
  58. document.getElementById("resourceList").innerHTML = html.join('');
  59. }
  60. /*获取个人信息*/
  61. function personalMessage() {
  62. mui.ajax(baseUrl + "/ajax/professor/info/" + proId, {
  63. dataType: 'json', //数据格式类型
  64. type: 'GET', //http请求类型
  65. timeout: 10000, //超时设置
  66. success: function(data) {
  67. plus.nativeUI.closeWaiting();
  68. plus.webview.currentWebview().show("slide-in-right", 150);
  69. var $data = data.data;
  70. personalMaterial[0].innerText = $data.name;
  71. document.getElementById("professorName").innerText=$data.name;
  72. //基本信息
  73. if($data.consultCount){
  74. document.getElementsByClassName("consultCount")[0].innerText = $data.consultCount;
  75. }else{
  76. document.getElementById("accessHistory").style.display="none";
  77. }
  78. var startLeval = parseInt($data.starLevel);
  79. var start = document.getElementsByClassName("start");
  80. for(var i = 0; i < startLeval; i++) {
  81. start[i].classList.add("icon-favorfill");
  82. start[i].classList.remove("icon-favor");
  83. }
  84. if($data.hasHeadImage) {
  85. document.getElementsByClassName("headimg")[0].src = baseUrl + "/images/head/" + $data.id + "_l.jpg";
  86. } else {
  87. document.getElementsByClassName("headimg")[0].src = "../images/default-photo.jpg";
  88. }
  89. if($data.authType) {
  90. nameli.classList.add('icon-vip');
  91. nameli.classList.add('authicon-cu');
  92. } else {
  93. if($data.authStatus){
  94. if($data.authentication==1){
  95. nameli.classList.add('icon-renzheng');
  96. nameli.classList.add('authicon-mana');
  97. //nameli.innerHTML="<span>科研</span>";
  98. }else if($data.authentication==2){
  99. nameli.classList.add('icon-renzheng');
  100. nameli.classList.add('authicon-staff');
  101. //nameli.innerHTML="<span>企业</span>";
  102. }else{
  103. nameli.classList.add('icon-renzheng');
  104. nameli.classList.add('authicon-stu');
  105. //nameli.innerHTML="<span>学生</span>";
  106. }
  107. }
  108. }
  109. if($data.orgName) {
  110. if($data.department) {
  111. personalMaterial[1].innerText = $data.orgName + ",";
  112. } else {
  113. if($data.address) {
  114. personalMaterial[1].innerText = $data.orgName+ " | ";
  115. } else {
  116. personalMaterial[1].innerText = $data.orgName
  117. }
  118. }
  119. }
  120. if($data.department) {
  121. if($data.address) {
  122. personalMaterial[2].innerText = $data.department + " | ";
  123. } else {
  124. personalMaterial[2].innerText = $data.department;
  125. }
  126. }
  127. if($data.address) {
  128. personalMaterial[3].innerText = $data.address;
  129. }
  130. //个人简介
  131. if($data.descp) {
  132. personSummary.innerHTML = $data.descp;
  133. } else {
  134. document.getElementById("professorBreifinfo").style.display = "none";
  135. }
  136. //专家资源
  137. if($data.resources.length) {
  138. professorResource($data.resources);
  139. } else {
  140. document.getElementById("professorresourceList").style.display = "none";
  141. }
  142. //如无详细内容数据,隐藏详细点击的按钮
  143. if(!$data.edus.length && !$data.jobs.length && !$data.projects.length && !$data.papers.length && !$data.patents.length && !$data.honors.length) {
  144. document.getElementById("detailProfessor").style.display = "none";
  145. }
  146. },
  147. error: function() {
  148. plus.nativeUI.toast("服务器链接超时", toastStyle);
  149. return;
  150. }
  151. });
  152. }
  153. //修改详细页面
  154. document.getElementsByClassName("gotonext")[0].addEventListener("tap", function() {
  155. var nwaiting = plus.nativeUI.showWaiting();
  156. var web = plus.webview.create("../html/proinforbrow-more.html", "proinforbrow-more.html", {}, {
  157. pro: proId
  158. }); //后台创建webview并打开show.html
  159. web.addEventListener("loaded", function() {}, false);
  160. });
  161. personalMessage();
  162. /*进入资源详细页面*/
  163. mui("#resourceList").on('tap', 'li', function() {
  164. var resouId = this.getAttribute("resouseId");
  165. plus.nativeUI.showWaiting();
  166. plus.webview.create("../html/resinforbrow.html", 'resinforbrow.html', {}, {
  167. resourceId: resouId
  168. });
  169. });
  170. /*咨询成功,返回专家信息*/
  171. window.addEventListener('backproinfo', function(event) {
  172. var proid = event.detail.proId;
  173. console.log(proid);
  174. /*ozixun.classList.add('displayNone');*/
  175. });
  176. ifCollection();
  177. yesExpert.addEventListener('tap', function() {
  178. var $this = this;
  179. if(userid && userid != null && userid != "null") {
  180. collectionExpert($this);
  181. } else {
  182. plus.nativeUI.toast("请先登录");
  183. }
  184. });
  185. noExpert.addEventListener('tap', function() {
  186. var $this = this;
  187. cancelCollectionExpert($this);
  188. });
  189. /*判断是非收藏专家*/
  190. function ifCollection() {
  191. mui.ajax(baseUrl + '/ajax/watch/hasWatch', {
  192. data: {
  193. "professorId": userid,
  194. "watchObject": proId
  195. },
  196. dataType: 'json', //数据格式类型
  197. type: 'get', //http请求类型
  198. timeout: 10000,
  199. async: false,
  200. success: function(data) {
  201. if(data.success && data.data != null) {
  202. yesExpert.style.display = "none";
  203. noExpert.style.display = "block";
  204. returnId = data.data.watchObject;
  205. } else {
  206. yesExpert.style.display = "block";
  207. noExpert.style.display = "none";
  208. }
  209. },
  210. error: function() {
  211. plus.nativeUI.toast("服务器链接超时", toastStyle);
  212. }
  213. });
  214. }
  215. /*收藏专家*/
  216. function collectionExpert($this) {
  217. mui.ajax(baseUrl + '/ajax/watch', {
  218. data: {
  219. "professorId": userid,
  220. "watchObject": proId,
  221. "watchType": 1
  222. },
  223. dataType: 'json', //数据格式类型
  224. type: 'POST', //http请求类型
  225. timeout: 10000,
  226. async: false,
  227. success: function(data) {
  228. console.log(data.success)
  229. if(data.success) {
  230. $this.style.display = "none";
  231. noExpert.style.display = "block";
  232. returnId = data.data;
  233. //console.log(returnId)
  234. plus.nativeUI.toast("专家关注成功", toastStyle);
  235. }
  236. },
  237. error: function() {
  238. plus.nativeUI.toast("服务器链接超时", toastStyle);
  239. }
  240. });
  241. }
  242. /*取消收藏专家*/
  243. function cancelCollectionExpert($this) {
  244. //console.log(returnId)
  245. // console.log(userid)
  246. mui.ajax({
  247. url: baseUrl + '/ajax/watch/delete',
  248. data: {
  249. professorId: userid,
  250. watchObject: returnId
  251. },
  252. dataType: 'json', //数据格式类型
  253. type: 'post', //http请求类型
  254. timeout: 10000,
  255. async: true,
  256. success: function(data) {
  257. console.log(data.success)
  258. if(data.success) {
  259. $this.style.display = "none";
  260. yesExpert.style.display = "block";
  261. plus.nativeUI.toast("取消关注成功", toastStyle);
  262. }
  263. },
  264. error: function(data) {
  265. plus.nativeUI.toast("服务器链接超时", toastStyle);
  266. }
  267. });
  268. }
  269. /*专家的历史和评价*/
  270. document.getElementById("accessHistory").addEventListener('tap', function() {
  271. mui.openWindow({
  272. url: '../html/coophistory-other.html',
  273. id: 'html/coophistory-other.html',
  274. show: {
  275. autoShow: false,
  276. },
  277. extras: {
  278. professorId: proId
  279. }
  280. });
  281. })
  282. });