portal html css js resource

resourceInfo.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. $(".h2Font").text($info.resourceName);
  53. $("#application").text($info.supportedServices);
  54. professorId = $info.professorId;
  55. if(userid==professorId){
  56. $("#consultin,.attentBtn").hide()
  57. }
  58. if($info.subject) {
  59. subjectShow($info.subject)
  60. } else {
  61. $("span:contains('学术领域')").hide();
  62. }
  63. if($info.industry) {
  64. industryShow($info.industry)
  65. } else {
  66. $("span:contains('应用行业')").hide();
  67. }
  68. if($info.cooperationNotes) {
  69. $("#cooperationNote").text($info.cooperationNotes);
  70. } else {
  71. $("span:contains('合作备注')").hide();
  72. }
  73. if(!$info.subject && !$info.industry && !$info.cooperationNotes) {
  74. $(".resAbout").hide();
  75. }
  76. if($info.images.length) {
  77. $("#resouImg").attr("src", "/images/resource/" + $info.resourceId + ".jpg")
  78. }
  79. if($info.descp) {
  80. $(".resMore").html($info.descp);
  81. var pWidth = $(".resMore").find("p").width();
  82. var leng = $(".resMore").find("img").length;
  83. for(var i = 0; i < leng; i++) {
  84. (function(i) {
  85. $(".resMore").find("img").eq(i).load(function() {
  86. var imgWidth = $(".resMore").find("img").eq(i).width();
  87. if(imgWidth > pWidth) {
  88. $(".resMore").find("img").eq(i).css({
  89. "width": "100%"
  90. })
  91. }
  92. })
  93. })(i)
  94. }
  95. } else {
  96. $(".resBottom").hide();
  97. }
  98. $("#nameS").text($info.editProfessor.name);
  99. if($info.editProfessor.title) {
  100. if($info.editProfessor.office) {
  101. $("#title").text($info.editProfessor.title + ",");
  102. } else {
  103. $("#title").text($info.editProfessor.title);
  104. }
  105. }
  106. if($info.editProfessor.office) {
  107. $("#office").text($info.editProfessor.office);
  108. }
  109. if($info.editProfessor.department) {
  110. $("#department").text($info.editProfessor.department);
  111. }
  112. if($info.editProfessor.orgName) {
  113. $("#orgName").text($info.editProfessor.orgName);
  114. }
  115. if($info.editProfessor.address) {
  116. $("#address").text($info.editProfessor.address);
  117. }
  118. if($info.editProfessor.hasHeadImage) {
  119. $("#headImg").attr("src", "/images/head/" + $info.professorId + "_l.jpg")
  120. }
  121. var resourcetitle = $info.resourceName + "-科袖网";
  122. window.setInterval(function() {
  123. document.title = resourcetitle;
  124. }, 500);
  125. //专家相关资源
  126. relevantResource($info.professorId, $info.resourceId)
  127. } else {
  128. $.MsgBox.Alert('消息提醒', info.msg);
  129. }
  130. },
  131. "error": function() {
  132. $.MsgBox.Alert('message', 'failed')
  133. }
  134. });
  135. }
  136. /*资源信息*/
  137. resourceData();
  138. /*点击专家头像进入专家页面*/
  139. $("#headImg").on("click", function() {
  140. location.href = "information-brow.html?professorId=" + professorId;
  141. });
  142. /*点击咨询*/
  143. $("#consultin").on("click", function() {
  144. clickResouceConsultHandler();
  145. });
  146. /*咨询函数*/
  147. function clickResouceConsultHandler() {
  148. if(userid && userid != "null" && userid != null) {
  149. ConsultApply();
  150. concultProInfo(professorId); //专家信息common.js中
  151. //默认选中资源咨询和标题
  152. for(var i = 0; i < $("ul.menucon").children().length; i++) {
  153. $("ul.menucon").children().eq(i).removeClass("clicknow");
  154. $("ul.menucon").children().eq(1).addClass("clicknow");
  155. }
  156. var consultTitleVal = $(".h2Font").text();
  157. $("#consultTitle").val("关于" + consultTitleVal + "的咨询");
  158. //点击的发送
  159. $("#sendConsultBtn").click(function() {
  160. sendConsultHandler(professorId); //common.js中
  161. });
  162. } else {
  163. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  164. $("#mb_btn_ok").val("去登录");
  165. var aele = document.createElement('a');
  166. $("#mb_btnbox").append(aele);
  167. $("#mb_btnbox a").css({
  168. 'display': "block",
  169. 'width': '100%',
  170. 'height': '40px',
  171. 'position': 'absolute',
  172. 'bottom': '-6px',
  173. 'left': '0'
  174. });
  175. aele.setAttribute('href', '../login.html');
  176. }
  177. };
  178. /*专家相关资源*/
  179. var relevantResource = function(id, reid) {
  180. $.ajax({
  181. "url": "/ajax/resource/qapro",
  182. "type": "get",
  183. "data": {
  184. "professorId": id
  185. },
  186. "async": true,
  187. "success": function(data) {
  188. if(data.success) {
  189. var $info = data.data;
  190. var reId = reid;
  191. var j = 0;
  192. for(var i = 0; i < $info.length; i++) {
  193. if($info[i].resourceId != reId) {
  194. var string = ""
  195. string += '<li>'
  196. string += '<a class="resoumag" href="resourceInfo.html?resourceId=' + $info[i].resourceId + '">'
  197. string += '<div class="ResImgBox resourceImgBox">'
  198. if($info[i].images.length) {
  199. string += '<img class="resImg headRadius resourceImg" src="/images/resource/' + $info[i].resourceId + '.jpg" />'
  200. } else {
  201. string += '<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />'
  202. }
  203. string += '</div>'
  204. string += '<h2>' + $info[i].resourceName + '</h2>'
  205. string += '</a>'
  206. string += '</li>'
  207. j++;
  208. if(j == 4) {
  209. return;
  210. }
  211. $(".otherRes").append(string);
  212. }
  213. if($info.length == 1) {
  214. $("#relaResou").hide()
  215. }
  216. }
  217. } else {
  218. $.MsgBox.Alert("消息", data.msg);
  219. }
  220. },
  221. "error": function() {
  222. $.MsgBox.Alert('message', 'fail')
  223. }
  224. });
  225. }
  226. })