portal html css js resource

resourceShow.js 19KB

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