portal html css js resource

resourceInfo.js 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. $(document).ready(function() {
  2. loginStatus();//判断个人是否登录
  3. /*获取资源ID*/
  4. var resourceId = GetQueryString("resourceId");
  5. var professorId;
  6. var userid = $.cookie("userid");
  7. //填充学术领域
  8. var subjectShow = function(data) {
  9. if(data != undefined && data.length != 0) {
  10. var subs = new Array();
  11. if(data.indexOf(',')) {
  12. subs = data.split(',');
  13. } else {
  14. subs[0] = data;
  15. }
  16. if(subs.length > 0) {
  17. for(var i = 0; i < subs.length; i++) {
  18. $("#subjectList").append("<li>" + subs[i] + "</li>")
  19. };
  20. }
  21. }
  22. }
  23. //填充应用行业
  24. var industryShow = function(data) {
  25. if(data != undefined && data.length != 0) {
  26. var subs = new Array();
  27. if(data.indexOf(',')) {
  28. subs = data.split(',');
  29. } else {
  30. subs[0] = data;
  31. }
  32. if(subs.length > 0) {
  33. for(var i = 0; i < subs.length; i++) {
  34. $("#industryList").append("<li>" + subs[i] + "</li>")
  35. };
  36. }
  37. }
  38. }
  39. /*获取资源的数据的函数*/
  40. var resourceData = function() {
  41. $.ajax({
  42. "url": "/ajax/resource/resourceInfo",
  43. data: {
  44. 'resourceId': resourceId
  45. },
  46. "type": "get",
  47. "async": true,
  48. "success": function(info) {
  49. if(info.success) {
  50. //console.log(info)
  51. var $info = info.data;
  52. if($info.editProfessor.authType) {
  53. $("#authFlag").addClass("authicon authicon-cu");
  54. } else {
  55. if($info.editProfessor.authStatus==3) {
  56. if($info.editProfessor.authentication == 1) {
  57. $("#authFlag").addClass("authicon2 authicon-mana");
  58. } else if($info.editProfessor.authentication == 2) {
  59. $("#authFlag").addClass("authicon2 authicon-staff");
  60. } else {
  61. $("#authFlag").addClass("authicon2 authicon-stu");
  62. }
  63. }
  64. }
  65. $(".h2Font").text($info.resourceName);
  66. $("#application").text($info.supportedServices);
  67. professorId = $info.professorId;
  68. if(userid==professorId){
  69. $("#consultin,.attentBtn").hide()
  70. }
  71. if($info.subject) {
  72. subjectShow($info.subject)
  73. } else {
  74. $("span:contains('学术领域')").hide();
  75. }
  76. if($info.industry) {
  77. industryShow($info.industry)
  78. } else {
  79. $("span:contains('应用行业')").hide();
  80. }
  81. if($info.cooperationNotes) {
  82. $("#cooperationNote").text($info.cooperationNotes);
  83. } else {
  84. $("span:contains('合作备注')").hide();
  85. }
  86. if(!$info.subject && !$info.industry && !$info.cooperationNotes) {
  87. $(".resAbout").hide();
  88. }
  89. if($info.images.length) {
  90. $("#resouImg").attr("src", "/images/resource/" + $info.resourceId + ".jpg")
  91. }
  92. if($info.descp) {
  93. $(".resMore").html($info.descp);
  94. var pWidth = $(".resMore").find("p").width();
  95. var leng = $(".resMore").find("img").length;
  96. for(var i = 0; i < leng; i++) {
  97. (function(i) {
  98. $(".resMore").find("img").eq(i).load(function() {
  99. var imgWidth = $(".resMore").find("img").eq(i).width();
  100. if(imgWidth > pWidth) {
  101. $(".resMore").find("img").eq(i).css({
  102. "width": "100%"
  103. })
  104. }
  105. })
  106. })(i)
  107. }
  108. } else {
  109. $(".resBottom").hide();
  110. }
  111. $("#nameS").text($info.editProfessor.name);
  112. if($info.editProfessor.title) {
  113. if($info.editProfessor.office) {
  114. $("#title").text($info.editProfessor.title + ",");
  115. } else {
  116. $("#title").text($info.editProfessor.title);
  117. }
  118. }
  119. if($info.editProfessor.office) {
  120. $("#office").text($info.editProfessor.office);
  121. }
  122. if($info.editProfessor.department) {
  123. $("#department").text($info.editProfessor.department);
  124. }
  125. if($info.editProfessor.orgName) {
  126. $("#orgName").text($info.editProfessor.orgName);
  127. }
  128. if($info.editProfessor.address) {
  129. $("#address").text($info.editProfessor.address);
  130. }
  131. if($info.editProfessor.hasHeadImage) {
  132. $("#headImg").attr("src", "/images/head/" + $info.professorId + "_l.jpg")
  133. }
  134. var resourcetitle = $info.resourceName + "-科袖网";
  135. window.setInterval(function() {
  136. document.title = resourcetitle;
  137. }, 500);
  138. //专家相关资源
  139. relevantResource($info.professorId, $info.resourceId)
  140. } else {
  141. $.MsgBox.Alert('消息提醒', info.msg);
  142. }
  143. },
  144. "error": function() {
  145. $.MsgBox.Alert('message', 'failed')
  146. }
  147. });
  148. }
  149. /*资源信息*/
  150. resourceData();
  151. /*点击专家头像进入专家页面*/
  152. $("#headImg").on("click", function() {
  153. location.href = "information-brow.html?professorId=" + professorId;
  154. });
  155. /*点击咨询*/
  156. $("#consultin").on("click", function() {
  157. clickResouceConsultHandler();
  158. });
  159. /*咨询函数*/
  160. function clickResouceConsultHandler() {
  161. if(userid && userid != "null" && userid != null) {
  162. ConsultApply();
  163. concultProInfo(professorId); //专家信息common.js中
  164. //默认选中资源咨询和标题
  165. for(var i = 0; i < $("ul.menucon").children().length; i++) {
  166. $("ul.menucon").children().eq(i).removeClass("clicknow");
  167. $("ul.menucon").children().eq(1).addClass("clicknow");
  168. }
  169. var consultTitleVal = $(".h2Font").text();
  170. $("#consultTitle").val("关于" + consultTitleVal + "的咨询");
  171. //点击的发送
  172. $("#sendConsultBtn").click(function() {
  173. sendConsultHandler(professorId); //common.js中
  174. });
  175. } else {
  176. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  177. $("#mb_btn_ok").val("去登录");
  178. var aele = document.createElement('a');
  179. $("#mb_btnbox").append(aele);
  180. $("#mb_btnbox a").css({
  181. 'display': "block",
  182. 'width': '100%',
  183. 'height': '40px',
  184. 'position': 'absolute',
  185. 'bottom': '-6px',
  186. 'left': '0'
  187. });
  188. aele.setAttribute('href', '../login.html');
  189. }
  190. };
  191. /*专家相关资源*/
  192. var relevantResource = function(id, reid) {
  193. $.ajax({
  194. "url": "/ajax/resource/qapro",
  195. "type": "get",
  196. "data": {
  197. "professorId": id
  198. },
  199. "async": true,
  200. "success": function(data) {
  201. if(data.success) {
  202. var $info = data.data;
  203. var reId = reid;
  204. var j = 0;
  205. for(var i = 0; i < $info.length; i++) {
  206. if($info[i].resourceId != reId) {
  207. var string = ""
  208. string += '<li>'
  209. string += '<a class="resoumag" href="resourceInfo.html?resourceId=' + $info[i].resourceId + '">'
  210. string += '<div class="ResImgBox resourceImgBox">'
  211. if($info[i].images.length) {
  212. string += '<img class="resImg headRadius resourceImg" src="/images/resource/' + $info[i].resourceId + '.jpg" />'
  213. } else {
  214. string += '<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />'
  215. }
  216. string += '</div>'
  217. string += '<h2>' + $info[i].resourceName + '</h2>'
  218. string += '</a>'
  219. string += '</li>'
  220. j++;
  221. if(j == 4) {
  222. return;
  223. }
  224. $(".otherRes").append(string);
  225. }
  226. if($info.length == 1) {
  227. $("#relaResou").hide()
  228. }
  229. }
  230. } else {
  231. $.MsgBox.Alert("消息", data.msg);
  232. }
  233. },
  234. "error": function() {
  235. $.MsgBox.Alert('message', 'fail')
  236. }
  237. });
  238. }
  239. })