portal html css js resource

recommend.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. $(function() {
  2. $(".headnav li").eq(2).addClass("navcurrent");
  3. $("#feedback").hide();
  4. loginStatus();//判断个人是否登录
  5. var userid = $.cookie("userid");
  6. var rows = 20,
  7. pageNo = 1,
  8. dataO = {
  9. patSortNum:"",
  10. patCreateTime:"",
  11. patId:""
  12. },
  13. linkNum=0;//栏目类别导航
  14. var oAjax = function(url, dataS, otype, oFun,beforeFun,completeFun) {
  15. $.ajax({
  16. url:url,
  17. dataType: 'json',
  18. type: otype,
  19. data: dataS,
  20. traditional: true,
  21. beforeSend: beforeFun,
  22. success: function(res) {
  23. if(res.success) {
  24. oFun(res)
  25. }
  26. },
  27. complete:completeFun
  28. });
  29. },
  30. insertNodata = function (targetE,newStr) {
  31. var parent = document.getElementById(targetE).parentNode;
  32. var kong = document.createElement("div");
  33. kong.className = "con-kong";
  34. kong.innerHTML ='<div class="picbox picNull"></div>'+
  35. '<div class="txtbox">暂时没有符合该搜索条件的内容</div>'
  36. if(newStr){
  37. kong.querySelector(".txtbox").innerHTML = newStr;
  38. }
  39. if (parent.firstChild.className == "con-kong") {
  40. return
  41. } else {
  42. parent.insertBefore(kong,parent.firstChild);
  43. }
  44. },
  45. removeNodata = function (targetE) {
  46. var parent = document.getElementById(targetE).parentNode;
  47. if (parent.firstChild.className == "con-kong") {
  48. parent.removeChild(parent.firstChild);
  49. } else {
  50. return
  51. }
  52. },
  53. patentListVal = function(isbind, flag) {
  54. var aimId="table-item-2"
  55. if (flag) {
  56. aimId="table-item-3"
  57. }
  58. oAjax("/ajax/ppatent/index/search",{
  59. "sortNum": dataO.patSortNum,
  60. "createTime":dataO.patCreateTime,
  61. "id": dataO.patId,
  62. "rows": rows
  63. }, "get", function(res){
  64. var $info = res.data;
  65. if($info.length > 0) {
  66. $("#"+aimId).show()
  67. dataO.patSortNum = $info[$info.length - 1].sortNum;
  68. dataO.patCreateTime = $info[$info.length - 1].createTime;
  69. dataO.patId = $info[$info.length - 1].id;
  70. for(var i = 0; i < $info.length; i++) {
  71. var itemlist = '<li class="flexCenter">';
  72. itemlist += '<a target="_blank" href="/' + pageUrl("pt",$info[i]) +'" class="linkhref"><div class="lefthead patenthead"></div>';
  73. itemlist += '<div class="centercon centercon2">';
  74. itemlist += '<p class="h1font ellipsisSty">'+ $info[i].name +'</p>';
  75. itemlist += '<p class="h2font ellipsisSty">发明人:'+ $info[i].authors.substring(0, $info[i].authors.length - 1) +'</p>';
  76. itemlist += '<p class="h2font ellipsisSty">申请人:'+ $info[i].reqPerson +'</p>';
  77. itemlist += '</div></a></li>';
  78. $("#"+aimId).append(itemlist)
  79. }
  80. }
  81. var liLen=document.getElementById(aimId).querySelectorAll("li").length;
  82. removeNodata(aimId);
  83. if($info.length == 0 && liLen == 0 ){
  84. $("#"+aimId).hide()
  85. insertNodata(aimId);
  86. }
  87. if(isbind){
  88. $("#"+aimId).parent().find(".js-load-more").unbind("click").on("click",function(){
  89. if (flag) {
  90. patentListVal(false, true)
  91. } else {
  92. patentListVal(false)
  93. }
  94. })
  95. }
  96. if ($info.length < rows) {
  97. $("#"+aimId).parent().find(".js-load-more").unbind("click");
  98. $("#"+aimId).parent().find(".js-load-more").hide();
  99. }
  100. },function(){
  101. $("#"+aimId).parent().find(".js-load-more").attr("disabled",true);
  102. $("#"+aimId).parent().find(".js-load-more").addClass("active");
  103. },function(){
  104. $("#"+aimId).parent().find(".js-load-more").removeAttr("disabled");
  105. $("#"+aimId).parent().find(".js-load-more").removeClass("active");
  106. })
  107. },
  108. unpatentListVal = function(isbind) {
  109. var aimId="table-item-1"
  110. oAjax("/ajax/resResult/pq",{
  111. "status": ['1'],
  112. "pageSize": rows,
  113. "pageNo": pageNo
  114. }, "get", function(res){
  115. var $info = res.data.data;
  116. if($info.length > 0) {
  117. $("#"+aimId).show()
  118. if(res.data.pageNo !== pageNo){
  119. $("#"+aimId).parent().find(".js-load-more").unbind("click");
  120. $("#"+aimId).parent().find(".js-load-more").hide();
  121. return
  122. }
  123. for(var i = 0; i < $info.length; i++) {
  124. var resIM='<div class="lefthead patenthead"></div>'
  125. if ($info[i].pic) {
  126. var src = '/data/researchResult' + $info[i].pic.split(",")[0]
  127. resIM = '<div class="lefthead patenthead" style="background-image:url('+ src +')"></div>';
  128. }
  129. var itemlist = '<li class="flexCenter">';
  130. itemlist += '<a target="_blank" href="unPatentShow.html?id='+$info[i].id+'" class="linkhref">';
  131. itemlist += resIM
  132. itemlist += '<div class="centercon centercon2">';
  133. itemlist += '<p class="h1font ellipsisSty">'+ $info[i].name +'</p>';
  134. itemlist += '<p class="h2font ellipsisSty displayNone">研究者:<span class="researchers"></span></p>';
  135. if ($info[i].orgId) {
  136. itemlist += '<p class="h2font ellipsisSty">所属机构:<span class="resOrgName"></span></p>';
  137. }
  138. itemlist += '</div></a></li>';
  139. var $itemlist = $(itemlist);
  140. $("#"+aimId).append($itemlist)
  141. queryResearcher($info[i].id, $itemlist)
  142. if ($info[i].orgId) {
  143. queryReseOrgName($info[i].orgId, $itemlist)
  144. }
  145. }
  146. }
  147. var liLen=document.getElementById(aimId).querySelectorAll("li").length;
  148. removeNodata(aimId);
  149. if($info.length == 0 && liLen == 0 ){
  150. $("#"+aimId).hide()
  151. insertNodata(aimId);
  152. }
  153. if(isbind){
  154. $("#"+aimId).parent().find(".js-load-more").unbind("click").on("click",function(){
  155. pageNo++
  156. unpatentListVal(false)
  157. })
  158. }
  159. if ($info.length < rows) {
  160. $("#"+aimId).parent().find(".js-load-more").unbind("click");
  161. $("#"+aimId).parent().find(".js-load-more").hide();
  162. }
  163. },function(){
  164. $("#"+aimId).parent().find(".js-load-more").attr("disabled",true);
  165. $("#"+aimId).parent().find(".js-load-more").addClass("active");
  166. },function(){
  167. $("#"+aimId).parent().find(".js-load-more").removeAttr("disabled");
  168. $("#"+aimId).parent().find(".js-load-more").removeClass("active");
  169. })
  170. },
  171. recommendUnpatent = function(){
  172. var aimId="table-item-0"
  173. oAjax("/ajax/resResult/pq",{
  174. "status": ['1'],
  175. "pageSize": 5,
  176. "pageNo": 1
  177. }, "get", function(res){
  178. var $info = res.data.data;
  179. if($info.length > 0) {
  180. $("#"+aimId).show()
  181. for(var i = 0; i < $info.length; i++) {
  182. var resIM='<div class="lefthead patenthead"></div>'
  183. if ($info[i].pic) {
  184. var src = '/data/researchResult' + $info[i].pic.split(",")[0]
  185. resIM = '<div class="lefthead patenthead" style="background-image:url('+ src +')"></div>';
  186. }
  187. var itemlist = '<li class="flexCenter">';
  188. itemlist += '<a target="_blank" href="unPatentShow.html?id='+$info[i].id+'" class="linkhref">';
  189. itemlist += resIM
  190. itemlist += '<div class="centercon centercon2">';
  191. itemlist += '<p class="h1font ellipsisSty">'+ $info[i].name +'</p>';
  192. itemlist += '<p class="h2font ellipsisSty displayNone">研究者:<span class="researchers"></span></p>';
  193. if ($info[i].orgId) {
  194. itemlist += '<p class="h2font ellipsisSty">所属机构:<span class="resOrgName"></span></p>';
  195. }
  196. itemlist += '</div></a></li>';
  197. var $itemlist = $(itemlist);
  198. $("#"+aimId).append($itemlist)
  199. queryResearcher($info[i].id, $itemlist)
  200. if ($info[i].orgId) {
  201. queryReseOrgName($info[i].orgId, $itemlist)
  202. }
  203. }
  204. }
  205. })
  206. },
  207. hotUnpatentList = function() {
  208. var aimId="hotNews"
  209. oAjax("/ajax/resResult/pq",{
  210. "status": ['1'],
  211. "pageSize": 10,
  212. "pageNo": 1
  213. }, "get", function(res){
  214. var $data = res.data.data;
  215. if($data.length > 0) {
  216. $("#"+aimId).parents(".conItem").removeClass("displayNone");
  217. var oLeng=$data.length<10?$data.length:10;
  218. for(var i=0;i<oLeng;i++) {
  219. var listLi=$('<li class="flexCenter"></li>').appendTo($("#hotNews"));
  220. var str='<a target="_blank" href="unPatentShow.html?id='+$data[i].id+'"><p class="h2Font ellipsisSty-2">'+$data[i].name+'</p></a>'
  221. $(str).appendTo(listLi);
  222. }
  223. }
  224. })
  225. },
  226. navmenu=function(){
  227. $(document).bind("click",function(e){
  228. var target = $(e.target);
  229. if(target.closest(".table-tab-item").length == 0){
  230. $(".table-drop").hide();
  231. $(".rightbtn").find("em").removeClass("unfoldtr").addClass("foldtr");
  232. }
  233. })
  234. $(".table-tab-item").on("mouseenter","li.rightbtn",function(){
  235. $(this).find(".table-drop").show();
  236. $(this).find("em").removeClass("foldtr").addClass("unfoldtr");
  237. }).on("mouseleave","li.rightbtn",function(){
  238. $(this).find("em").removeClass("unfoldtr").addClass("foldtr");
  239. $(this).find(".table-drop").hide();
  240. })
  241. $(".table-drop").on("click","li",function(){
  242. $(".rightbtn").find("span").html($(this).text());
  243. })
  244. $(".table-tab-item").on("click","li",function(){
  245. if($(this).is('.table-tab-slide')){
  246. linkNum = $(this).index(".table-tab-slide");
  247. $(".haveData").find("ul").each(function () {
  248. $(this).html("");
  249. $(this).parent().find(".js-load-more").unbind("click");
  250. $(this).parent().find(".js-load-more").show();
  251. });
  252. $("#table-item-"+linkNum).html("");
  253. dataColNum=$(this).attr('data-col');
  254. $(".table-tab-slide").removeClass("table-tab-slide-active");
  255. $(this).addClass("table-tab-slide-active");
  256. $(".table-drop").fadeOut(1000);
  257. $(".rightbtn").find("em").removeClass("unfoldtr").addClass("foldtr");
  258. $(".table-item-list").eq(linkNum).show().siblings().hide();
  259. if($(".rightbtn").find("li").is(".table-tab-slide-active")){
  260. $(".rightbtn").addClass("table-tab-slide-active");
  261. }else{
  262. $(".rightbtn").removeClass("table-tab-slide-active");
  263. }
  264. dataO = {
  265. patSortNum:"",
  266. patCreateTime:"",
  267. patId:""
  268. }
  269. pageNo=1
  270. if(linkNum==0){
  271. recommendUnpatent()
  272. patentListVal(true, true)
  273. }else if(linkNum == 1){
  274. unpatentListVal(true)
  275. }else if(linkNum == 2){
  276. patentListVal(true)
  277. }
  278. }else{
  279. $(this).find(".table-drop").show();
  280. }
  281. })
  282. },
  283. queryResearcher = function (id, $list) {
  284. if (id) {
  285. oAjax("/ajax/resResult/researcher",{
  286. "id": id
  287. }, 'get', function($data) {
  288. var arr = []
  289. if($data.data.length) {
  290. $list.find('.researchers').parent().removeClass('displayNone')
  291. for (var i = 0; i < $data.data.length;i++) {
  292. arr.push($data.data[i].name)
  293. }
  294. $list.find('.researchers').html(arr.join(','))
  295. }
  296. })
  297. }
  298. },
  299. queryReseOrgName = function (id, $list) {
  300. if (id) {
  301. cacheModel.getCompany(id,function(sc,value){
  302. if(sc){
  303. if(value.forShort){
  304. $list.find(".resOrgName").html(value.forShort)
  305. }else{
  306. $list.find(".resOrgName").html(value.name)
  307. }
  308. }
  309. })
  310. }
  311. },
  312. rightAllCon=function(){
  313. $.ajax({
  314. type:"get",
  315. url:"/ajax/professor/editBaseInfo/"+userid,
  316. success:function(data){
  317. if(data.success){
  318. var dataStr=data.data
  319. var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
  320. var baImg = "../images/default-photo.jpg";
  321. if(dataStr.hasHeadImage == 1) {
  322. baImg = "/images/head/" + dataStr.id + "_l.jpg";
  323. }
  324. var str='<div class="madiaHead useHead" style="background-image:url('+baImg+')"></div>'+
  325. '<div class="h2Font">'+dataStr.name+'<span class="authiconNew ' + userType.sty + '" title="' + userType.title + '"></span></div>'
  326. $(".onlogined .owener-info").html(str)
  327. }
  328. }
  329. });
  330. $.ajax({
  331. url: "/ajax/article/pqProPublish",
  332. dataType: 'json',
  333. type: 'GET',
  334. data: {
  335. "ownerId": userid,
  336. },
  337. success:function(data){
  338. if(data.success){
  339. $("#myPubedArt").html(data.data.total)
  340. }
  341. }
  342. });
  343. $.ajax({//回答数
  344. type:"get",
  345. url:"/ajax/question/answer/count",
  346. data: {
  347. uid: userid
  348. },
  349. async:true,
  350. success:function(data){
  351. if(data.success){
  352. $("#myPubedAnswer").html(data.data)
  353. }
  354. }
  355. });
  356. $.ajax({//总获赞
  357. type:"get",
  358. url:"/ajax/professor/agree/sum",
  359. data: {
  360. id: userid,
  361. },
  362. async:true,
  363. success:function(data){
  364. if(data.success){
  365. $("#agreeMecount").html(data.data)
  366. }
  367. }
  368. });
  369. }
  370. recommendUnpatent()
  371. patentListVal(true, true)
  372. navmenu();
  373. hotUnpatentList();
  374. if(userid && userid != null && userid != "null") {
  375. $(".privateInfo .onlogined").removeClass("displayNone")
  376. $(".privateInfo .unlogined").addClass("displayNone")
  377. rightAllCon()
  378. $(".pubArt").on("click",function(){
  379. window.open('../articalIssue.html')
  380. })
  381. $(".pubQuestion").on("click",function(){
  382. $(".questionCover").fadeIn();
  383. $("body").css("position", "fixed");
  384. })
  385. $(".goarrow").on("click",function(){
  386. window.open('../userInforShow.html?professorId='+ userid +'&iLike=1')
  387. })
  388. $("#workclose").on("click",function(){
  389. $(".questionCover").fadeOut();
  390. $("body").css("position", "");
  391. })
  392. hotKey(".oinput");
  393. //校验关键字
  394. $("#KeyWord").on({
  395. focus: function() {
  396. $("#keyPrompt").text("最多可添加5个关键词,每个关键词15字以内");
  397. },
  398. blur: function() {
  399. $("#keyPrompt").text("");
  400. }
  401. })
  402. $("#keyWordlist").on("click", ".closeThis", function() {
  403. $(this).parent().remove();
  404. var liNum = $("#keyWordlist").find("li").length;
  405. if(liNum < 5) {
  406. $("#keyWordlist").parents(".keyResult").siblings("div.col-w-12").show();
  407. }
  408. })
  409. limitObj("#queTit",50)
  410. $("#queTit").on({
  411. focus: function() {
  412. $(this).parents("li").find(".frmconmsg").text("提问不得少于5个字,不可超过50个字");
  413. },
  414. blur: function() {
  415. $(this).parents("li").find(".frmconmsg").text("");
  416. }
  417. })
  418. limitObj("#queCnt",500)
  419. $("#queCnt").on({
  420. focus: function() {
  421. $(this).parents("li").find(".frmconmsg").text("提问描述不可超过500个字");
  422. },
  423. blur: function() {
  424. $(this).parents("li").find(".frmconmsg").text("");
  425. }
  426. })
  427. var imgStr=[];
  428. var uploader =new WebUploader.create({
  429. auto: true,
  430. fileNumLimit: 3,
  431. swf: '../js/webuploader/Uploader.swf',
  432. server: '../ajax/question/upload',
  433. fileSingleSizeLimit: 2 * 1024 * 1024,
  434. pick: {
  435. id: "#filePicker",
  436. multiple: false
  437. },
  438. accept: {
  439. title: 'Images',
  440. extensions: 'jpg,jpeg,png',
  441. mimeTypes: 'image/jpg,image/jpeg,image/png'
  442. }
  443. });
  444. // 当有文件添加进来的时候
  445. uploader.on('fileQueued', function(file) {
  446. fileId = file.id;
  447. var $len = $("#fileList").find("img").length;
  448. if($len == 0 || $len == 1) {
  449. var oRemove = $("#fileList").find("dd");
  450. oRemove.eq(oRemove.length - 1).remove();
  451. }
  452. var $li = $(
  453. '<dd>' +
  454. '<div class="imgItem" id="' + file.id + '">'+
  455. '<img />' +
  456. '</div>'+
  457. '</dd>'
  458. ),
  459. $btns = $('<div class="file-panel">' +
  460. '<span class="cancel"></span>' +
  461. '</div>').appendTo($li),
  462. $img = $li.find('img');
  463. var $list = $("#fileList");
  464. if($len == 1) {
  465. $list.find("dd").eq(0).after($li)
  466. } else if($len == 2) {
  467. $list.find("dd").eq(1).after($li)
  468. } else {
  469. $list.prepend($li);
  470. }
  471. // 创建缩略图
  472. // 如果为非图片文件,可以不用调用此方法。
  473. // thumbnailWidth x thumbnailHeight 为 100 x 100
  474. uploader.makeThumb(file, function(error, src) {
  475. if(error) {
  476. $img.replaceWith('<span>不能预览</span>');
  477. return;
  478. }
  479. $img.attr('src', src);
  480. }, 1, 1);
  481. });
  482. uploader.onError = function(code) {
  483. if(code=="F_EXCEED_SIZE"){
  484. $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过2M')
  485. }
  486. };
  487. uploader.on('uploadSuccess', function(file, data) {
  488. if(data.success) {
  489. uploader.removeFile(fileId);
  490. //console.log(data)
  491. var orldUrl = imgStr.push(data.data[0].uri);
  492. }else{
  493. $.MsgBox.Alert('提示', '只支持jpeg/jpg/png格式的图片');
  494. }
  495. });
  496. /*删除图片*/
  497. $("#fileList").on("click", ".cancel", function() {
  498. var flag=$(this).attr("flag");
  499. var oNum=$(this).parents("dd").index();
  500. if(flag==1) {
  501. array.splice(oNum,1);
  502. }else{
  503. imgStr.splice(oNum,1);
  504. }
  505. $(this).parent().parent().remove();
  506. var $len = $("#fileList").find("img").length;
  507. if($len != 2) {
  508. $("#fileList").append("<dd></dd>")
  509. }
  510. });
  511. //提问下一步
  512. $("#nextSte").on("click",function(){
  513. if($("#queTit").val().length>50) {
  514. $("#queTit").parents("li").find(".frmconmsg").text("提问不可超过50个字");
  515. $("#queTit").parent().css("border-color","#e03b43");
  516. return;
  517. }
  518. if($("#queTit").val().length<5 || $("#queTit").val().length==0) {
  519. $("#queTit").parents("li").find(".frmconmsg").text("提问不得少于5个字");
  520. $("#queTit").parent().css("border-color","#e03b43");
  521. return;
  522. }
  523. if($("#keyWordlist>li").length==0){
  524. $("#keyPrompt").text("请至少添加1个关键词");
  525. $("#KeyWord").css("border-color","#e03b43");
  526. return;
  527. }
  528. $(".queStep01").addClass("displayNone")
  529. $(".queStep02").removeClass("displayNone")
  530. })
  531. //提问上一步
  532. $("#preSte").on("click",function(){
  533. $(".queStep01").removeClass("displayNone")
  534. $(".queStep02").addClass("displayNone")
  535. })
  536. //提问发布
  537. $("#pubSte").on("click",function(){
  538. var title=$("#queTit").val();
  539. var cnt=$("#queCnt").val();
  540. var subjects = $("#keyWordlist>li");
  541. var subjectAll = "";
  542. if(subjects.length > 0) {
  543. for(var i = 0; i < subjects.length; i++) {
  544. subjectAll += subjects[i].innerText.replace(/删除/, "");
  545. subjectAll += ',';
  546. };
  547. subjectAll = subjectAll.substring(0, subjectAll.length - 1);
  548. }
  549. console.log(cnt+"++++++"+imgStr);
  550. var dataSt={
  551. "title": title,
  552. "cnt": cnt,
  553. "img": imgStr.join(","),
  554. "keys": subjectAll,
  555. "uid": userid
  556. }
  557. $.ajax({
  558. url:'/ajax/question',
  559. data: dataSt,
  560. dataType: 'json',
  561. traditional: true,
  562. type: 'POST',
  563. success: function(data) {
  564. if(data.success) {
  565. console.log(data)
  566. $(".questionCover").fadeOut();
  567. $("body").css("position", "");
  568. $(".queStep").find("textarea").val("")
  569. $("#keyWordlist").html("")
  570. var $len = $("#fileList").find("img").length;
  571. for(var i=0;i<$len;i++) {
  572. $("#fileList").find(".imgItem").parent().remove()
  573. $("#fileList").append("<dd></dd>")
  574. }
  575. $(".queStep").find("input").val("")
  576. $(".queStep01").removeClass("displayNone")
  577. $(".queStep02").addClass("displayNone")
  578. $.MsgBox.Alert("提示","问题发布成功");
  579. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  580. }
  581. }
  582. });
  583. })
  584. }else{
  585. $(".privateInfo .unlogined").removeClass("displayNone")
  586. $(".privateInfo .onlogined").addClass("displayNone")
  587. $(".unlogined").on("click",function(){
  588. quickLog();
  589. operatTab();
  590. closeLog();
  591. })
  592. }
  593. })