portal html css js resource

resourceInfo.js 7.0KB

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