portal html css js resource

resourceShow.js 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. $(document).ready(function() {
  2. $(".jqzoom").imagezoom();
  3. $("#thumblist").on("click", "li a", function() {
  4. $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
  5. $(".jqzoom").attr('src', $(this).find("img").attr("src"));
  6. $(".jqzoom").attr('rel', $(this).find("img").attr("src"));
  7. });
  8. $('.shareWeixin').hover(function() {
  9. $('.shareCode').stop(true, false).fadeToggle();
  10. });
  11. var resourceId = GetQueryString("resourceId");
  12. var professorId = "";
  13. getRecourceMe();
  14. /*获取资源信息*/
  15. function getRecourceMe() {
  16. $.ajax({
  17. "url": "/ajax/resource/queryOne",
  18. "type": "GET",
  19. "success": function(data) {
  20. console.log(data);
  21. if(data.success) {
  22. resourceHtml(data.data);
  23. }
  24. },
  25. "data": {
  26. "resourceId": resourceId
  27. },
  28. dataType: "json",
  29. 'error': function() {
  30. $.MsgBox.Alert('提示', '服务器连接超时!');
  31. }
  32. });
  33. }
  34. /*合作备注及性能参数存储换行格式*/
  35. function outHTML(selecter) {
  36. var getValue = selecter;
  37. var aa = "";
  38. if(getValue) {
  39. var endValue = ((getValue.replace(/<(.+?)>/gi, "&lt;$1&gt;")).replace(/ /gi, "&nbsp;")).replace(/\n/gi, "|");
  40. var cc = endValue.split("|");
  41. for(var i = 0; i < cc.length; i++) {
  42. aa += cc[i] + '<br/>'
  43. }
  44. }
  45. return aa;
  46. }
  47. /*处理资源html代码*/
  48. function resourceHtml($da) {
  49. $("#resourceName").text($da.resourceName); //名字
  50. $("#application").text($da.supportedServices); //应用用途
  51. if($da.orgName) { //所属机构
  52. $("#organizationName").text($da.orgName).parents("li").show();
  53. }
  54. $("#nameS").text($da.editProfessor.name);
  55. if($da.editProfessor.title) {
  56. $("#titleOffice").text($da.editProfessor.title);
  57. } else {
  58. if($da.editProfessor.office) {
  59. $("#titleOffice").text($da.editProfessor.office);
  60. }
  61. }
  62. if($da.editProfessor.orgName) {
  63. $("#orgType").text($da.editProfessor.orgName);
  64. }
  65. professorId = $da.editProfessor.id;
  66. var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus);
  67. $("#authFlag").addClass(professorFlag.sty).attr("title", professorFlag.title);
  68. if($da.editProfessor.hasHeadImage == 1) {
  69. $("#headImg").css("background-image", 'url(/images/head/' + $da.editProfessor.id + '_l.jpg)');
  70. }
  71. if($da.spec) { //厂商型号
  72. $("#modelNumber").text($da.spec).parents("li").show();
  73. }
  74. if($da.parameter) { //性能参数
  75. $("#performancePa").html(outHTML($da.parameter)).parents("li").show();
  76. }
  77. if($da.cooperationNotes) { //合作备注
  78. $("#remarkContent").html(outHTML($da.cooperationNotes)).parents("li").show();
  79. }
  80. if($da.subject) {
  81. var oSub = $da.subject.split(",");
  82. interestingResources(oSub);
  83. var oSt = "";
  84. for(var i = 0; i < oSub.length; i++) {
  85. oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
  86. }
  87. $(".tagList").html(oSt);
  88. }
  89. if($da.descp) { //编辑器
  90. $("#descp").html($da.descp).parents("li").show();
  91. }
  92. //return;
  93. if($da.images.length) {
  94. $("#firstFigure").attr({
  95. "src": "/data/resource/" + $da.images[0].imageSrc,
  96. "rel": "/data/resource/" + $da.images[0].imageSrc
  97. }).parent().attr("href", "/data/resource/" + $da.images[0].imageSrc);
  98. var arr = "";
  99. for(var i = 0; i < $da.images.length; i++) {
  100. if($da.images[i] == $da.images[0]) {
  101. var oString = '<li class="tb-selected">' +
  102. '<div class="tb-pic tb-s66">' +
  103. '<a href="javascript:void(0);">' +
  104. '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
  105. '</a>' +
  106. '</div>' +
  107. '</li>'
  108. } else {
  109. var oString = '<li >' +
  110. '<div class="tb-pic tb-s66">' +
  111. '<a href="javascript:void(0);">' +
  112. '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
  113. '</a>' +
  114. '</div>' +
  115. '</li>'
  116. }
  117. arr += oString;
  118. }
  119. $("#thumblist").html(arr);
  120. }
  121. }
  122. /*点击名字及头像跳转个人浏览页面*/
  123. $("#nameS,#headImg").click(function() {
  124. location.href = "information-brow.html?professorId=" + professorId;
  125. })
  126. /*资源里面相关文章*/
  127. function relatedArticles() {
  128. $.ajax({
  129. "url": "/ajax/resource/articles",
  130. "type": "GET",
  131. "success": function(data) {
  132. console.log(data);
  133. if(data.success) {
  134. relatedArticlesHtml(data.data);
  135. }
  136. },
  137. "data": {
  138. "resourceId": resourceId,
  139. "rows": 5
  140. },
  141. dataType: "json",
  142. 'error': function() {
  143. $.MsgBox.Alert('提示', '服务器连接超时!');
  144. }
  145. });
  146. }
  147. relatedArticles();
  148. /*资源相关文章html*/
  149. function relatedArticlesHtml($html) {
  150. for(var i = 0; i < $html.length; i++) {
  151. (function(n) {
  152. $.ajax({
  153. "url": "/ajax/professor/baseInfo/" + $html[i].article.professorId,
  154. "type": "GET",
  155. "success": function(data) {
  156. if(data.success) {
  157. var stl = autho(data.data.authType, data.data.orgAuth, data.data.authStatus);
  158. var str = ""
  159. str += '<li>'
  160. if($html[n].article.articleImg) {
  161. str += '<div class="madiaHead artHead" style="background-image: url(/data/article/' + $html[n].article.articleImg + ')"></div>'
  162. } else {
  163. str += '<div class="madiaHead artHead"></div>'
  164. }
  165. str += '<div class="madiaInfo">'
  166. str += '<p class="h1Font ellipsisSty-2">' + $html[n].article.articleTitle + '</p>'
  167. str += '<p><span class="h1Font">' + data.data.name + '</span><em class="authiconNew ' + stl.sty + '" title="' + stl.title + '"></em></p>'
  168. str += '</div></li>'
  169. $("#oArticle").append(str);
  170. }
  171. },
  172. 'dataType': "json",
  173. 'error': function() {
  174. $.MsgBox.Alert('提示', '服务器连接超时!');
  175. }
  176. });
  177. })(i);
  178. }
  179. }
  180. /*感兴趣的资源*/
  181. function interestingResources(arry) {
  182. $.ajax({
  183. "url": "/ajax/resource/ralateRes",
  184. "type": "GET",
  185. "success": function(data) {
  186. console.log(data);
  187. if(data.success) {
  188. interestingResourcesHtml(data.data);
  189. }
  190. },
  191. "data": {
  192. "keys": arry
  193. },
  194. "traditional":true,
  195. dataType: "json",
  196. 'error': function() {
  197. $.MsgBox.Alert('提示', '服务器连接超时!');
  198. }
  199. });
  200. }
  201. /*感兴趣资源的html*/
  202. function interestingResourcesHtml($respond) {
  203. for(var i=0;i<$respond.length;i++) {
  204. var oStr='';
  205. if($respond[i].images.length) {
  206. oStr+='<li><div class="madiaHead resouseHead"style="background-image: url(/data/resource/'+$respond[i].images[0].imageSrc+')"></div>'
  207. }else {
  208. oStr+='<li><div class="madiaHead resouseHead"></div>'
  209. }
  210. oStr+='<div class="madiaInfo">'
  211. oStr+='<p class="h1Font">'+$respond[i].resourceName+'</p>'
  212. oStr+='<p class="h2Font ellipsisSty">用途:<span>'+$respond[i].supportedServices+'</span></p>'
  213. //oStr += '<p><span class="h1Font">' + data.data.name + '</span><em class="authiconNew ' + stl.sty + '" title="' + stl.title + '"></em></p>'
  214. oStr+='</div></li>'
  215. $("#resourceList").append(oStr);
  216. }
  217. }
  218. })