portal html css js resource

resourceShow.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. $(document).ready(function() {
  2. loginStatus(); //判断个人是否登录
  3. var userid = $.cookie("userid");
  4. $(".jqzoom").imagezoom();
  5. $("#thumblist").on("click", "li a", function() {
  6. $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
  7. $(".jqzoom").attr('src', $(this).find("img").attr("src"));
  8. $(".jqzoom").attr('rel', $(this).find("img").attr("src"));
  9. });
  10. $('.shareWeixin').hover(function() {
  11. $('.shareCode').stop(true, false).fadeToggle();
  12. });
  13. var resourceId = GetQueryString("resourceId");
  14. ifCollection(resourceId, 2)
  15. var professorId = "";
  16. getRecourceMe();
  17. /*获取资源信息*/
  18. function getRecourceMe() {
  19. $.ajax({
  20. "url": "/ajax/resource/queryOne",
  21. "type": "GET",
  22. "success": function(data) {
  23. console.log(data);
  24. if(data.success) {
  25. resourceHtml(data.data);
  26. var resourceName = data.data.resourceName + "-科袖网";
  27. window.setTimeout(function() {
  28. document.title = resourceName;
  29. }, 500);
  30. }
  31. },
  32. "data": {
  33. "resourceId": resourceId
  34. },
  35. dataType: "json",
  36. 'error': function() {
  37. $.MsgBox.Alert('提示', '服务器连接超时!');
  38. }
  39. });
  40. }
  41. /*合作备注及性能参数存储换行格式*/
  42. function outHTML(selecter) {
  43. var getValue = selecter;
  44. var aa = "";
  45. if(getValue) {
  46. var endValue = ((getValue.replace(/<(.+?)>/gi, "&lt;$1&gt;")).replace(/ /gi, "&nbsp;")).replace(/\n/gi, "|");
  47. var cc = endValue.split("|");
  48. for(var i = 0; i < cc.length; i++) {
  49. aa += cc[i] + '<br/>'
  50. }
  51. }
  52. return aa;
  53. }
  54. /*处理资源html代码*/
  55. function resourceHtml($da) {
  56. $("#resourceName").text($da.resourceName); //名字
  57. $("#application").text($da.supportedServices); //应用用途
  58. if($da.editProfessor) {
  59. $("#person").show();
  60. if($da.orgName) { //所属机构
  61. $("#organizationName").text($da.orgName).parents("li").show();
  62. }
  63. $("#nameS").text($da.editProfessor.name);
  64. if($da.editProfessor.title) {
  65. $("#titleOffice").text($da.editProfessor.title);
  66. } else {
  67. if($da.editProfessor.office) {
  68. $("#titleOffice").text($da.editProfessor.office);
  69. }
  70. }
  71. if($da.editProfessor.orgName) {
  72. $("#orgType").text($da.editProfessor.orgName);
  73. }
  74. professorId = $da.editProfessor.id;
  75. console.log(professorId);
  76. console.log(userid);
  77. if(userid != professorId) {
  78. ifCollection(professorId, 1)
  79. $(".goSpan").show();
  80. }
  81. var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus);
  82. $("#authFlag").addClass(professorFlag.sty).attr("title", professorFlag.title);
  83. if($da.editProfessor.hasHeadImage == 1) {
  84. $("#headImg").css("background-image", 'url(/images/head/' + $da.editProfessor.id + '_l.jpg)');
  85. }
  86. }else{
  87. $("#enterprise,#resPerson").show();
  88. $(".qiyego").attr("href","userInforShow.html?orgId="+$da.organization.id);
  89. if($da.organization.hasOrgLogo) {
  90. $("#Qimg").attr("style", "background-image: url(/images/org/" + $da.organization.id + ".jpg);");
  91. }
  92. if($da.organization.authStatus==3){
  93. $("#QauthFlag").addClass("authicon-com-ok").attr("title", "认证企业");
  94. }
  95. if($da.organization.forShort) {
  96. $("#Qname").text($da.organization.forShort).attr("href","cmpInforShow.html?orgId="+$da.organization.id);
  97. }else{
  98. $("#Qname").text($da.organization.name).attr("href","cmpInforShow.html?orgId="+$da.organization.id);
  99. }
  100. $("#Qindustry").text($da.organization.subject);
  101. $("#QorgType").text(orgTypeShow[$da.organization.orgType])
  102. }
  103. if($da.spec) { //厂商型号
  104. $("#modelNumber").text($da.spec).parents("li").show();
  105. }
  106. if($da.parameter) { //性能参数
  107. $("#performancePa").html(outHTML($da.parameter)).parents("li").show();
  108. }
  109. if($da.cooperationNotes) { //合作备注
  110. $("#remarkContent").html(outHTML($da.cooperationNotes)).parents("li").show();
  111. }
  112. if($da.subject) {
  113. var oSub = $da.subject.split(",");
  114. if($da.resourceType==1) {
  115. interestingResources(oSub,$da.professorId,0);
  116. }else{
  117. interestingResources(oSub,$da.orgId,1);
  118. }
  119. var oSt = "";
  120. for(var i = 0; i < oSub.length; i++) {
  121. oSt += '<li><p class="h2Font">' + oSub[i] + '</p></li>'
  122. }
  123. $(".tagList").html(oSt);
  124. } else {
  125. $(".aboutTit:contains('您可能感兴趣的资源')").parent().hide();
  126. }
  127. if($da.descp) { //编辑器
  128. $("#descp").html($da.descp).parents("li").show();
  129. }
  130. var weibotitle = $da.resourceName;
  131. var weibourl = window.location.href;
  132. //return;
  133. if($da.images.length) {
  134. var weibopic = "http://" + window.location.host + "/data/resource/" + $da.images[0].imageSrc;
  135. $("#firstFigure").attr({
  136. "src": "/data/resource/" + $da.images[0].imageSrc,
  137. "rel": "/data/resource/" + $da.images[0].imageSrc
  138. }).parent().attr("href", "/data/resource/" + $da.images[0].imageSrc);
  139. var arr = "";
  140. for(var i = 0; i < $da.images.length; i++) {
  141. if($da.images[i] == $da.images[0]) {
  142. var oString = '<li class="tb-selected">' +
  143. '<div class="tb-pic tb-s66">' +
  144. '<a href="javascript:void(0);">' +
  145. '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
  146. '</a>' +
  147. '</div>' +
  148. '</li>'
  149. } else {
  150. var oString = '<li >' +
  151. '<div class="tb-pic tb-s66">' +
  152. '<a href="javascript:void(0);">' +
  153. '<img src="/data/resource/' + $da.images[i].imageSrc + '"/>' +
  154. '</a>' +
  155. '</div>' +
  156. '</li>'
  157. }
  158. arr += oString;
  159. }
  160. $("#thumblist").html(arr);
  161. } else {
  162. var weibopic = "http://" + window.location.host + "../images/default-resource.jpg";
  163. $("#firstFigure").attr({
  164. "src": '../images/default-resource.jpg',
  165. "rel": '../images/default-resource.jpg'
  166. });
  167. }
  168. $("#weibo").attr("href","http://service.weibo.com/share/share.php?appkey=3677230589&title="+encodeURIComponent(weibotitle)+"&url="+encodeURIComponent(weibourl)+"&pic="+encodeURIComponent(weibopic)+"&content=utf-8"+"&ralateUid=6242830109&searchPic=false&style=simple");
  169. }
  170. /*点击名字及头像跳转个人浏览页面*/
  171. $("#nameS,#headImg").click(function() {
  172. location.href = "userInforShow.html?professorId=" + professorId;
  173. })
  174. //关键词标签点击进去搜索
  175. $(".tagList").on("click","li",function(){
  176. var tagText = $(this).find("p").text();
  177. location.href = "searchNew.html?searchContent=" + tagText + "&tagflag=2";
  178. })
  179. /*资源里面相关文章*/
  180. function relatedArticles() {
  181. $.ajax({
  182. "url": "/ajax/resource/articles",
  183. "type": "GET",
  184. "success": function(data) {
  185. console.log(data);
  186. if(data.success) {
  187. if(data.data.length == 0) {
  188. $("#oArticle").parent().hide();
  189. $(".aboutTit:contains('相关文章')").hide();
  190. return;
  191. }
  192. relatedArticlesHtml(data.data);
  193. }
  194. },
  195. "data": {
  196. "resourceId": resourceId,
  197. "rows": 5
  198. },
  199. dataType: "json",
  200. 'error': function() {
  201. $.MsgBox.Alert('提示', '服务器连接超时!');
  202. }
  203. });
  204. }
  205. relatedArticles();
  206. /*资源相关文章html*/
  207. function relatedArticlesHtml($html) {
  208. for(var i = 0; i < $html.length; i++) {
  209. (function(n) {
  210. var oURL;
  211. if($html[i].article.articleType==1) {
  212. oURL="/ajax/professor/baseInfo/" + $html[i].article.professorId;
  213. }else{
  214. oURL="/ajax/org/" + $html[i].article.orgId;
  215. }
  216. $.ajax({
  217. "url":oURL,
  218. "type": "GET",
  219. "success": function(data) {
  220. if(data.success) {
  221. if($html[n].article.articleType==1) {
  222. var stl = autho(data.data.authType, data.data.orgAuth, data.data.authStatus);
  223. }else {
  224. var stl={};
  225. stl.sty="";
  226. stl.title="";
  227. if(data.data.authStatus==3) {
  228. stl.sty="authicon-com-ok";
  229. stl.title="认证企业";
  230. }
  231. }
  232. var str = ""
  233. str += '<li data-id="' + $html[n].article.articleId + '">'
  234. if($html[n].article.articleImg) {
  235. str += '<div class="madiaHead artHead" style="background-image: url(/data/article/' + $html[n].article.articleImg + ')"></div>'
  236. } else {
  237. str += '<div class="madiaHead artHead"></div>'
  238. }
  239. str += '<div class="madiaInfo" style="margin-top:18px;padding-bottom:8px">'
  240. str += '<p class="h1Font ellipsisSty">' + $html[n].article.articleTitle + '</p>'
  241. str += '<p><span class="h2Font">' + data.data.name + '</span><em class="authiconNew ' + stl.sty + '" title="' + stl.title + '"></em></p>'
  242. str += '</div></li>'
  243. $("#oArticle").append(str);
  244. }
  245. },
  246. 'dataType': "json",
  247. 'error': function() {
  248. $.MsgBox.Alert('提示', '服务器连接超时!');
  249. }
  250. });
  251. })(i);
  252. }
  253. }
  254. /*文章跳转*/
  255. $("#oArticle").on("click", "li", function() {
  256. location.href = "articalShow.html?articleId=" + $(this).attr("data-id");
  257. })
  258. /*感兴趣的资源*/
  259. function interestingResources(arry,oId,oNu) {
  260. var oUrl;
  261. var $in={};
  262. $in.keys= arry;
  263. $in.resourceId= resourceId;
  264. if(oNu==0) {
  265. $in.professorId= oId;
  266. oUrl="/ajax/resource/ralateRes";
  267. }else {
  268. $in.orgId= oId;
  269. oUrl="/ajax/resource/orgRalateRes";
  270. }
  271. $.ajax({
  272. "url": oUrl,
  273. "type": "GET",
  274. "success": function(data) {
  275. console.log(data);
  276. if(data.success) {
  277. if(data.data.length == 0) {
  278. $(".aboutTit:contains('您可能感兴趣的资源')").parent().hide();
  279. return;
  280. }
  281. interestingResourcesHtml(data.data);
  282. }
  283. },
  284. "data":$in,
  285. "traditional": true,
  286. dataType: "json",
  287. 'error': function() {
  288. $.MsgBox.Alert('提示', '服务器连接超时!');
  289. }
  290. });
  291. }
  292. /*感兴趣资源的html*/
  293. function interestingResourcesHtml($respond) {
  294. for(var i = 0; i < $respond.length; i++) {
  295. if($respond[i].organization) {
  296. var stl={};
  297. stl.sty="";
  298. stl.title="";
  299. if($respond[i].organization.authStatus==3) {
  300. stl.sty="authicon-com-ok";
  301. stl.title="认证企业";
  302. }
  303. var name= $respond[i].organization.name;
  304. }else {
  305. var stl = autho($respond[i].editProfessor.authType, $respond[i].editProfessor.orgAuth, $respond[i].editProfessor.authStatus);
  306. var name= $respond[i].editProfessor.name;
  307. }
  308. var oStr = '';
  309. if($respond[i].images.length) {
  310. oStr += '<li data-id="' + $respond[i].resourceId + '"><div class="madiaHead resouseHead"style="background-image: url(/data/resource/' + $respond[i].images[0].imageSrc + ')"></div>'
  311. } else {
  312. oStr += '<li data-id="' + $respond[i].resourceId + '"><div class="madiaHead resouseHead"></div>'
  313. }
  314. oStr += '<div class="madiaInfo">'
  315. oStr += '<p class="h1Font">' + $respond[i].resourceName + '</p>'
  316. oStr += '<p class="h2Font ellipsisSty">用途:<span>' + $respond[i].supportedServices + '</span></p>'
  317. oStr += '<p><span class="h2Font">' + name + '</span><em class="authiconNew ' + stl.sty + '" title="' + stl.title + '"></em></p>'
  318. oStr += '</div></li>'
  319. $("#resourceList").append(oStr);
  320. }
  321. }
  322. /*点击资源列表*/
  323. $("#resourceList").on("click", "li", function() {
  324. location.href = "resourceShow.html?resourceId=" + $(this).attr("data-id");
  325. })
  326. /*点击咨询*/
  327. $("#consultin").on("click", function() {
  328. clickResouceConsultHandler();
  329. });
  330. $("#expertli").on("click", ".addbtn", function() {
  331. var $this = $(this);
  332. clickResouceConsultHandler($this);
  333. })
  334. /*咨询函数*/
  335. function clickResouceConsultHandler($this) {
  336. if(userid && userid != "null" && userid != null) {
  337. ConsultApply();
  338. if(!professorId) {
  339. concultProInfo($this.attr("data-id")); //专家信息common.js中
  340. } else {
  341. concultProInfo(professorId); //专家信息common.js中
  342. }
  343. //默认选中资源咨询和标题
  344. for(var i = 0; i < $("ul.menucon").children().length; i++) {
  345. $("ul.menucon").children().eq(i).removeClass("clicknow");
  346. $("ul.menucon").children().eq(1).addClass("clicknow");
  347. }
  348. var consultTitleVal = $("#resourceName").text();
  349. $("#consultTitle").val("关于" + consultTitleVal + "的咨询");
  350. //点击的发送
  351. $("#sendConsultBtn").click(function() {
  352. sendConsultHandler(professorId); //common.js中
  353. });
  354. } else {
  355. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  356. $("#mb_btn_ok").val("去登录");
  357. var aele = document.createElement('a');
  358. $("#mb_btnbox").append(aele);
  359. $("#mb_btnbox a").css({
  360. 'display': "block",
  361. 'width': '100%',
  362. 'height': '40px',
  363. 'position': 'absolute',
  364. 'bottom': '-6px',
  365. 'left': '0'
  366. });
  367. aele.setAttribute('href', '../login.html');
  368. }
  369. };
  370. //点击专家关注
  371. $('.attenSpan').click(function() {
  372. if(userid && userid != "null" && userid != null) {
  373. if($(this).is('.attenSpanyes')) {
  374. cancelCollectionExpert(professorId, 1)
  375. } else {
  376. collectionExpert(professorId, 1);
  377. }
  378. } else {
  379. $.MsgBox.Alert('提示', "请先登录再进行关注");
  380. $("#mb_btn_ok").val("去登录");
  381. var aele = document.createElement('a');
  382. $("#mb_btnbox").append(aele);
  383. $("#mb_btnbox a").css({
  384. 'display': "block",
  385. 'width': '100%',
  386. 'height': '40px',
  387. 'position': 'absolute',
  388. 'bottom': '-6px',
  389. 'left': '0'
  390. });
  391. aele.setAttribute('href', '../login.html');
  392. }
  393. })
  394. //点击资源收藏
  395. $('#attention em').click(function() {
  396. if(userid && userid != "null" && userid != null) {
  397. if($(this).is('.icon-collected')) {
  398. cancelCollectionExpert(resourceId, 2)
  399. } else {
  400. collectionExpert(resourceId, 2);
  401. }
  402. } else {
  403. $.MsgBox.Alert('提示', "请先登录再进行收藏");
  404. $("#mb_btn_ok").val("去登录");
  405. var aele = document.createElement('a');
  406. $("#mb_btnbox").append(aele);
  407. $("#mb_btnbox a").css({
  408. 'display': "block",
  409. 'width': '100%',
  410. 'height': '40px',
  411. 'position': 'absolute',
  412. 'bottom': '-6px',
  413. 'left': '0'
  414. });
  415. aele.setAttribute('href', '../login.html');
  416. }
  417. })
  418. /*判断是非关注专家*/
  419. function ifCollection(getid, num) {
  420. var data = {
  421. "professorId": userid,
  422. "watchObject": getid
  423. }
  424. //alert(JSON.stringify(data))
  425. $.ajax({
  426. url: "/ajax/watch/hasWatch",
  427. data: data,
  428. dataType: 'json', //数据格式类型
  429. type: 'get', //http请求类型
  430. timeout: 10000,
  431. async: true,
  432. success: function(data) {
  433. if(num == 1) {
  434. if(data.success && data.data != null) {
  435. $('.attenSpan').addClass("attenSpanyes");
  436. $('.attenSpan').addClass("attenedSpan");
  437. $('.attenSpan').text('已关注');
  438. zjreturnId = data.data.watchObject;
  439. } else {
  440. $('.attenSpan').removeClass("attenSpanyes");
  441. $('.attenSpan').removeClass("attenedSpan");
  442. $('.attenSpan').text('关注');
  443. }
  444. }
  445. if(num == 2) {
  446. if(data.success && data.data != null) {
  447. $('#attention em').addClass("icon-collected").removeClass("icon-collect");
  448. wzreturnId = data.data.watchObject;
  449. } else {
  450. $('#attention em').removeClass("icon-collected").addClass("icon-collect");
  451. }
  452. }
  453. },
  454. error: function() {
  455. $.MsgBox.Alert('提示', "服务器链接超时");
  456. }
  457. });
  458. }
  459. /*关注专家*/
  460. function collectionExpert(watchObject, num) {
  461. if(num == 1) {
  462. var data = {
  463. "professorId": userid,
  464. "watchObject": watchObject,
  465. "watchType": 1
  466. }
  467. } else {
  468. var data = {
  469. "professorId": userid,
  470. "watchObject": watchObject,
  471. "watchType": 2
  472. }
  473. }
  474. $.ajax({
  475. url: "/ajax/watch",
  476. data: data,
  477. dataType: 'json', //数据格式类型
  478. type: 'POST', //http请求类型
  479. timeout: 10000,
  480. async: false,
  481. success: function(data) {
  482. if(num == 1) {
  483. if(data.success) {
  484. $('.attenSpan').addClass("attenSpanyes");
  485. $('.attenSpan').addClass("attenedSpan");
  486. $('.attenSpan').text('已关注');
  487. zjreturnId = data.data.watchObject;
  488. }
  489. }
  490. if(num == 2) {
  491. if(data.success) {
  492. $('#attention em').addClass("icon-collected").removeClass("icon-collect");
  493. wzreturnId = data.data.watchObject;
  494. }
  495. }
  496. },
  497. error: function() {
  498. $.MsgBox.Alert('提示', "服务器链接超时");
  499. }
  500. });
  501. }
  502. /*取消收藏专家*/
  503. function cancelCollectionExpert(watchObject, num) {
  504. $.ajax({
  505. url: "/ajax/watch/delete",
  506. data: {
  507. professorId: userid,
  508. watchObject: watchObject
  509. },
  510. dataType: 'json', //数据格式类型
  511. type: 'post', //http请求类型
  512. timeout: 10000,
  513. async: true,
  514. success: function(data) {
  515. console.log(data.success)
  516. if(num == 1) {
  517. if(data.success) {
  518. $('.attenSpan').removeClass("attenSpanyes");
  519. $('.attenSpan').removeClass("attenedSpan");
  520. $('.attenSpan').text('关注');
  521. }
  522. }
  523. if(num == 2) {
  524. if(data.success) {
  525. $('#attention em').removeClass("icon-collected").addClass("icon-collect");
  526. }
  527. }
  528. },
  529. error: function(data) {
  530. $.MsgBox.Alert('提示', "服务器链接超时");
  531. }
  532. });
  533. }
  534. //资源浏览量
  535. function pageViewsVal() {
  536. $.ajax({
  537. "url": "/ajax/resource/pageViews",
  538. "type": "POST",
  539. "dataType": "json",
  540. "data": {
  541. "resourceId": resourceId
  542. },
  543. "success": function(data) {
  544. console.log(data);
  545. if(data.success) {}
  546. },
  547. "error": function() {
  548. $.MsgBox.Alert('提示', '链接服务器超时')
  549. }
  550. });
  551. }
  552. pageViewsVal();
  553. selUse();
  554. function selUse() {
  555. $.ajax({
  556. url: "/ajax/resource/qaLinkman",
  557. type: "GET",
  558. timeout: 10000,
  559. dataType: "json",
  560. async: true,
  561. data: {
  562. "resourceId": resourceId,
  563. },
  564. success: function(data, textState) {
  565. console.log(data)
  566. if(data.success) {
  567. unauthUser(data.data);
  568. }
  569. },
  570. error: function(XMLHttpRequest, textStats, errorThrown) {
  571. $.MsgBox.Alert('提示', '服务器请求失败')
  572. }
  573. })
  574. }
  575. function unauthUser($res) {
  576. var osting = ""
  577. for(var i = 0; i < $res.length; i++) {
  578. var img;
  579. var styC = "";
  580. var oClass = autho($res[i].professor.authType, $res[i].professor.orgAuth, $res[i].professor.authStatus);
  581. var oTitle = "";
  582. if($res[i].professor.title) {
  583. oTitle = $res[i].professor.title;
  584. } else {
  585. if($res[i].professor.office) {
  586. oTitle = $res[i].professor.office;
  587. }
  588. }
  589. if($res[i].professor.hasHeadImage) {
  590. img = "/images/head/" + $res[i].professor.id + "_l.jpg";
  591. } else {
  592. img = "../images/default-photo.jpg"
  593. }
  594. var oSt = '<li class="flexCenter">'
  595. oSt += '<div class="madiaHead useHead" id="userimg" style="background-image: url(' + img + ');"></div>'
  596. oSt += '<div class = "madiaInfo">'
  597. oSt += '<p class = "ellipsisSty">'
  598. oSt += '<span class = "h1Font" id="name">' + $res[i].professor.name + '</span><em class="authiconNew ' + oClass.sty + '" title="' + oClass.title + '"></em >'
  599. oSt += '</p>'
  600. oSt += '<p class="h2Font ellipsisSty">' + oTitle + '</p>'
  601. oSt += '</div>'
  602. oSt += '<span class="addbtn" data-id="' + $res[i].professor.id + '">咨询</span>'
  603. oSt += '</li>'
  604. osting += oSt;
  605. }
  606. $("#expertli").html(osting);
  607. }
  608. })