Sin Descripción

proinforupdate.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. mui.ready(function() {
  2. mui.plusReady(function() {
  3. var userid = plus.storage.getItem('userid');
  4. var oImg=document.getElementsByTagName("img")[0];
  5. var personalMaterial=document.getElementsByClassName('personalMaterial');
  6. var personSummary=document.getElementsByClassName("breifinfo")[0];
  7. var fl;
  8. window.addEventListener("newId",function(event){
  9. fl=event.detail.rd;
  10. personalMaterial[1].parentNode.style.display = "block";
  11. personalMaterial[2].parentNode.style.display = "block";
  12. personalMaterial[3].parentNode.style.display = "block";
  13. personalMaterial[4].parentNode.style.display = "block";
  14. personalMaterial[5].parentNode.style.display = "block";
  15. personalMaterial[6].parentNode.style.display = "block";
  16. personalMaterial[7].parentNode.style.display = "block";
  17. personalMessage();
  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 industryShow = 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("infoapply")[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><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><div class='likenum'>";
  89. }
  90. if($photos.length > 0) {
  91. for(var j = 0; j < $photos.length; ++j) {
  92. if($photos[j].hasHeadImage) {
  93. showDiv += "<span class='likepeople headRadius'><img class='like-h' src='../images/head/" + $photos[j] + "_s.jpg'></span>";
  94. } else {
  95. showDiv += "<span class='likepeople headRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
  96. }
  97. }
  98. }
  99. if($photos.length >= 3) {
  100. showDiv += "<span class='mui-icon iconfont icon-more likepeople likemore headRadius'></span>";
  101. }
  102. showDiv += "</div></div></div>";
  103. html.push(showDiv);
  104. }
  105. document.getElementsByClassName("reserachMess")[0].innerHTML = html.join('')
  106. }
  107. }
  108. //获取个人的信息
  109. function personalMessage() {
  110. mui.ajax(baseUrl + "/ajax/professor/info/" + userid, {
  111. dataType: 'json', //数据格式类型
  112. type: 'GET', //http请求类型
  113. timeout: 10000, //超时设置
  114. success: function(data) {
  115. if(!fl){
  116. plus.nativeUI.closeWaiting();
  117. plus.webview.currentWebview().show("slide-in-right", 150);
  118. }
  119. var $data = data.data;
  120. personalMaterial[0].innerText = $data.name;
  121. //头像
  122. if($data.hasHeadImage) {
  123. oImg.src = baseUrl + "/images/head/" + $data.id + "_l.jpg";
  124. }
  125. //基本信息
  126. // if(!$data.authType) {
  127. // document.getElementsByClassName('authword')[0].innerText = "未认证";
  128. // document.getElementsByClassName('authword')[0].style.backgroundColor = "#cccccc";
  129. // }
  130. if($data.office) {
  131. personalMaterial[1].innerText = $data.office;
  132. } else {
  133. personalMaterial[1].parentNode.style.display = "none";
  134. }
  135. if($data.title) {
  136. personalMaterial[2].innerText = $data.title;
  137. } else {
  138. personalMaterial[2].parentNode.style.display = "none";
  139. }
  140. if($data.orgName) {
  141. personalMaterial[3].innerText = $data.orgName;
  142. } else {
  143. personalMaterial[3].parentNode.style.display = "none";
  144. }
  145. if($data.department) {
  146. personalMaterial[4].innerText = $data.department;
  147. } else {
  148. personalMaterial[4].parentNode.style.display = "none";
  149. }
  150. if($data.address) {
  151. personalMaterial[5].innerText =$data.province+" "+$data.address;
  152. } else {
  153. personalMaterial[5].parentNode.style.display = "none";
  154. }
  155. if($data.phone) {
  156. personalMaterial[6].innerText = $data.phone;
  157. } else {
  158. personalMaterial[6].parentNode.style.display = "none";
  159. }
  160. if($data.email) {
  161. personalMaterial[7].innerText = $data.email;
  162. } else {
  163. personalMaterial[7].parentNode.style.display = "none";
  164. }
  165. //个人简介
  166. if($data.descp) {
  167. personSummary.innerHTML = $data.descp;
  168. }
  169. //学术领域
  170. if($data.subject) {
  171. subjectShow($data.subject);
  172. }
  173. //研究方向
  174. if($data.researchAreas.length) {
  175. researchAreaShow($data.researchAreas, $data.editResearchAreaLogs);
  176. }
  177. //应用行业
  178. if($data.industry) {
  179. industryShow($data.industry);
  180. }
  181. //我的资源
  182. if($data.resources.length) {
  183. resource($data.resources, $data.resources.length);
  184. }
  185. },
  186. error: function() {
  187. plus.nativeUI.toast("服务器链接超时", toastStyle);
  188. return;
  189. }
  190. });
  191. }
  192. //我的所有资源、
  193. function resource(oDa, n) {
  194. var $data = oDa;
  195. var html = [];
  196. for(var i = 0; i < n; i++) {
  197. var string = '<li class="mui-table-view-cell mui-media listitem" resouId=' + $data[i].resourceId + '>'
  198. string += '<a class="proinfor" href="resinforupdate.html"><div class="mui-media-object mui-pull-left ResImgBox">'
  199. if($data[i].images.length) {
  200. string += '<img class="resImg headRadius" src="'+baseUrl+'/images/resource/' + $data[i].resourceId + '.jpg">'
  201. } else {
  202. string += '<img class="resImg headRadius" src="../images/default-resource.jpg">'
  203. }
  204. string += '</div><div class="mui-media-body">'
  205. string += '<span class="listtit">' + $data[i].resourceName + '<div class="updatebox updatebox2" style="top:24px;"><em class="mui-icon mui-icon-compose updatebtn"></em></div></span>'
  206. string += '<p class="listtit2">' + $data[i].supportedServices + '</p>'
  207. string += '<p class="listtit3 resbrief">'
  208. if($data[i].descp) {
  209. string += $data[i].descp;
  210. }
  211. string += '</p></div></a></li>'
  212. html.push(string);
  213. }
  214. document.getElementById("resourceList").innerHTML = html.join('');
  215. }
  216. //个人信息修改
  217. document.getElementsByClassName("updatebox")[0].addEventListener("tap", function() {
  218. var nwaiting = plus.nativeUI.showWaiting(); //显示原生等待框
  219. var arr = {
  220. name: personalMaterial[0].innerText,
  221. office: personalMaterial[1].innerText,
  222. title: personalMaterial[2].innerText,
  223. orgName: personalMaterial[3].innerText,
  224. department: personalMaterial[4].innerText,
  225. address: personalMaterial[5].innerText
  226. }
  227. webviewShow = plus.webview.create("../html/updateinfo1.html", "../html/updateinfo1.html", {}, arr); //后台创建webview并打开show.html
  228. webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件
  229. // nwaiting.close(); //新webview的载入完毕后关闭等待框
  230. // webviewShow.show("slide-in-right", 150); //把新webview窗体显示出来,显示动画效果为速度150毫秒的右侧移入动画
  231. }, false);
  232. });
  233. document.getElementsByClassName("updatebox")[1].addEventListener("tap", function() {
  234. var nwaiting = plus.nativeUI.showWaiting(); //显示原生等待框
  235. var arr = {
  236. descp: personSummary.innerText,
  237. flag:2
  238. }
  239. webviewShow = plus.webview.create("../html/updateinfo2.html", "updateinfo2.html", {}, arr); //后台创建webview并打开show.html
  240. webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件
  241. nwaiting.close(); //新webview的载入完毕后关闭等待框
  242. webviewShow.show("slide-in-right", 150); //把新webview窗体显示出来,显示动画效果为速度150毫秒的右侧移入动画
  243. }, false);
  244. });
  245. var page = mui.preload({
  246. url: "../html/updateinfo3.html",
  247. id: "updateinfo3.html"
  248. })
  249. document.getElementsByClassName("updatebox")[2].addEventListener("tap", function() {
  250. page.show("slide-in-right", 150);
  251. });
  252. var page1 = mui.preload({
  253. url: "../html/updateinfo4.html",
  254. id: "updateinfo4.html"
  255. })
  256. document.getElementsByClassName("updatebox")[3].addEventListener("tap", function() {
  257. page1.show("slide-in-right", 150);
  258. });
  259. var page2 = mui.preload({
  260. url: "../html/updateinfo5.html",
  261. id: "updateinfo5.html"
  262. })
  263. document.getElementsByClassName("updatebox")[4].addEventListener("tap", function() {
  264. page2.show("slide-in-right", 150);
  265. });
  266. //添加我的资源
  267. document.getElementsByClassName("addinfobox")[0].addEventListener("tap", function() {
  268. var nwaiting = plus.nativeUI.showWaiting();
  269. var web = plus.webview.create("../html/updateinfo-res01.html", "updateinfo-res01.html",{},{reFlag:0}); //后台创建webview并打开show.html
  270. web.addEventListener("loaded", function() {
  271. plus.nativeUI.closeWaiting();
  272. web.show("slide-in-right", 150);
  273. }, false);
  274. });
  275. //修改我的资源
  276. mui("#resourceList").on("tap", "li", function() {
  277. var resouId = this.getAttribute("resouId");
  278. var nwaiting = plus.nativeUI.showWaiting();
  279. var web = plus.webview.create("../html/resinforupdate.html", "resinforupdate.html", {}, {
  280. resourceId: resouId,
  281. reFlag:0
  282. }); //后台创建webview并打开show.html
  283. web.addEventListener("loaded", function() {
  284. }, false);
  285. })
  286. //修改详细页面
  287. document.getElementsByClassName("gotonext2")[0].addEventListener("tap", function() {
  288. var nwaiting = plus.nativeUI.showWaiting();
  289. var web = plus.webview.create("../html/proinforupdate-more.html", "proinforupdate-more.html"); //后台创建webview并打开show.html
  290. web.addEventListener("loaded", function() {}, false);
  291. });
  292. personalMessage();
  293. });
  294. });