portal html css js resource

resourceShow.js 16KB

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