superSearch.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. var pageSize = 50;
  2. var nbflag = false;//是否显示的是最新招标数据
  3. var currentPage = 1;//当前页
  4. var submitflag = true;
  5. var tabularflag = "Y";
  6. $(function() {
  7. priceTime();
  8. $(".Price-content").find("span:first-child").click(function(){
  9. $(this).addClass("active");
  10. $(".pricefat").removeClass("active");
  11. beforeSubmit();
  12. })
  13. $(".timer").find("ul li:first-child").click(function(){
  14. timeshow = false;
  15. $("#starttime").css({"border-color":""});
  16. $("#endtime").css({"border-color":""});
  17. $("#timebut").hide();
  18. $(".timerInput").removeClass("customtime-active");
  19. $(this).addClass("active");
  20. $(".timerInput").removeClass("active");
  21. })
  22. //
  23. $(".pricebut").click(function(){
  24. priceCss();
  25. beforeSubmit();
  26. })
  27. //
  28. $("#timebut").click(function(){
  29. timeshow=false;
  30. $(this).hide();
  31. $(".timerInput").removeClass("customtime-active");
  32. if($("#starttime").val()==""&&$("#endtime").val()==""){
  33. $("#starttime").css({"border-color":""});
  34. $("#endtime").css({"border-color":""});
  35. $("#timebut").hide();
  36. $(".timerInput").removeClass("customtime-active");
  37. $("#timerAll").addClass("active");
  38. $(".timerInput").removeClass("active");
  39. }else{
  40. $(".timerInput").addClass("active");
  41. $(".timer").find("ul li:first-child").removeClass("active");
  42. $(".release-time .timer li").removeClass("active");
  43. }
  44. beforeSubmit()
  45. })
  46. //
  47. $(".nbprev").click(function(){
  48. $(window).scrollTop(0);
  49. $('.custom-checkbox.check-all').prop('checked', false)
  50. prev();
  51. })
  52. $(".nbnext").click(function(){
  53. $(window).scrollTop(0);
  54. $('.custom-checkbox.check-all').prop('checked', false)
  55. next();
  56. })
  57. //筛选关闭和打开
  58. //根据cookie值设置筛选是否显示
  59. var rsw = localStorage.getItem("hideorshow");
  60. if(rsw!=null){
  61. if(rsw=="D"){
  62. $("#screenBtn").addClass("down");
  63. $(".searchTender").show();
  64. $('#fold').show()
  65. }else{
  66. $("#screenBtn").removeClass("down");
  67. $(".searchTender").hide();
  68. $('#fold').hide()
  69. }
  70. }
  71. //记录用户刷选按钮状态
  72. $("#screenBtn").click(function(){
  73. if($(this).attr("class").indexOf("down")>0){
  74. localStorage.setItem("hideorshow", "D");
  75. $('#fold').show()
  76. }else{
  77. localStorage.setItem("hideorshow", "U");
  78. $('#fold').hide()
  79. }
  80. })
  81. //
  82. var iuod = localStorage.getItem("industryuod");
  83. if(iuod!=null){
  84. if(iuod=="U"){
  85. $(".stop").click();
  86. }
  87. }
  88. //
  89. $(".stop").click(function(){
  90. if($(this).attr("class").indexOf("up")>0){
  91. localStorage.setItem("industryuod", "U");
  92. }else{
  93. localStorage.setItem("industryuod", "D");
  94. }
  95. })
  96. //全文检索和标题检索切换
  97. $("#newsclass li:nth-child(2)").click(function(){
  98. // searchInnerVue.listState.total = totalPage
  99. // 重置全选按钮
  100. $('.custom-checkbox.check-all').prop('checked', false)
  101. $(".tabContainer-2 .lucene ul").html("");
  102. $("#zbSeatchT [name='selectType']").val("all");
  103. $("#right-list").addClass("active").siblings().removeClass("active");
  104. $("#allnews .lucene").show().siblings().hide();
  105. $(".tabContainer-2").hide();
  106. currentPage=1;
  107. if(submitflag){
  108. $(".hasNoData").hide();
  109. $(".working").show();
  110. // 隐藏页码
  111. searchInnerVue.showPage = false
  112. $(".tabContainer").css("min-height","600px");
  113. selectType = "all";
  114. searchOnsubmit();
  115. submitflag=false;
  116. }
  117. })
  118. $("#newsclass li:nth-child(1)").click(function(){
  119. // 重置全选按钮
  120. $('.custom-checkbox.check-all').prop('checked', false)
  121. $("#allnews .lucene ul").html("");
  122. $("#zbSeatchT [name='selectType']").val("title");
  123. $("#right-list").addClass("active").siblings().removeClass("active");
  124. $(".tabContainer-2 .lucene").show().siblings().hide();
  125. $("#allnews").hide();
  126. currentPage=1;
  127. if(submitflag){
  128. $(".hasNoData").hide();
  129. $(".working").show();
  130. // 隐藏页码
  131. searchInnerVue.showPage = false
  132. $(".tabContainer").css("min-height","600px");
  133. selectType = "title";
  134. searchOnsubmit();
  135. submitflag=false;
  136. }
  137. })
  138. $('#entsearch, #pursearch, #gysearch').on('click', function () {
  139. location.href= $(this).attr('datahref')
  140. })
  141. })
  142. //
  143. function next(){
  144. if($(".nbnext").hasClass("disabled")){
  145. return false;
  146. }
  147. $(".hasNoData").hide();
  148. $(".working").show();
  149. $(".tabContainer").hide();
  150. $("#allnews").hide();
  151. $(".pagination").hide();
  152. currentPage = parseInt($(".pagination-inner").find("span").text())+parseInt(1)
  153. if(currentPage==10){
  154. $(".nbnext").addClass("disabled");
  155. }else if(currentPage==2){
  156. $(".nbprev").removeClass("disabled");
  157. }
  158. if($("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='industry']").val()==""){
  159. getNewBids(currentPage);
  160. }else{
  161. if(!$("#right-table").hasClass("active")){
  162. if(secondFlag=="T"){
  163. $(".tabContainer").show();
  164. $(".hasNoData").hide();
  165. $(".nbnext").addClass("disabled");
  166. appendDatas(secondList,true,false);
  167. }else if(!nbflag&&currentPage<11){
  168. getNewBiddings();
  169. }else{
  170. searchOnsubmit(true);
  171. }
  172. }else{
  173. //表格点击下一页
  174. // if(secondFlag=="T"){
  175. // $(".tabContainer").show();
  176. // $(".hasNoData").hide();
  177. // $(".nbnext").addClass("disabled");
  178. // appendDatas(secondList,true,false);
  179. // }else{
  180. // getVIPData(true);
  181. // }
  182. }
  183. }
  184. }
  185. function prev(){
  186. if($(".nbprev").hasClass("disabled")){
  187. return false;
  188. }
  189. $(".hasNoData").hide();
  190. $(".working").show();
  191. $(".tabContainer").hide();
  192. $("#allnews").hide();
  193. $(".pagination").hide();
  194. currentPage = parseInt($(".pagination-inner").find("span").text())-parseInt(1)
  195. if(currentPage==1){
  196. $(".nbprev").addClass("disabled");
  197. }else if(currentPage<10){
  198. $(".nbnext").removeClass("disabled");
  199. }
  200. if($("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='industry']").val()==""){
  201. getNewBids(currentPage);
  202. }else{
  203. if(!$("#right-table").hasClass("active")){
  204. if(secondFlag=="T"){
  205. $(".tabContainer").show();
  206. $(".hasNoData").hide();
  207. //$(".nbnext").addClass("disabled");
  208. appendDatas(list,true,false);
  209. }else if(!nbflag&&currentPage>0){
  210. getNewBiddings();
  211. }else{
  212. searchOnsubmit(true);
  213. }
  214. }else{
  215. //表格点击上一页
  216. // getVIPData(true);
  217. }
  218. }
  219. }
  220. //取redis里的数据
  221. function getNewBids(pnum){
  222. $.post("/jylab/supsearch/getNewBids",{pageNumber:pnum,pageType:""},function(r){
  223. if(r&&r.list!=null&&r.list.length>0){
  224. $(".tabContainer").show();
  225. //$(".pagination").show();
  226. $(".hasNoData").hide();
  227. //$(".pagination-inner").find("span").text(currentPage);
  228. if(r.list.length<pageSize||currentPage==10){
  229. $(".nbnext").addClass("disabled");
  230. }else{
  231. $(".nbnext").removeClass("disabled");
  232. }
  233. searchInnerVue.listState.total = Math.ceil(r.count/50)
  234. searchInnerVue.checkPageNumAdd1()
  235. appendDatas(r.list,false,true);
  236. }else{
  237. submitflag=true;
  238. $(".tabContainer").hide();
  239. $(".pagination").hide();
  240. $(".working").hide();
  241. $(".hasNoData").show();
  242. // 隐藏页码
  243. searchInnerVue.showPage = false
  244. }
  245. // getBidIsColl()
  246. })
  247. }
  248. ////最新招标信息
  249. function getNewBiddings(){
  250. // $("#newsclass").hide();
  251. // $("#newsnow").show();
  252. if(currentPage==1){
  253. $(".nbprev").addClass("disabled");
  254. }
  255. var param = {
  256. pageNumber: currentPage,
  257. reqType: "lastNews",
  258. searchvalue: $("#zbSeatchT [name='keywords']").val(),
  259. area: $("#zbSeatchT [name='area']").val(),
  260. subtype: $("#zbSeatchT [name='subtype']").val(),
  261. publishtime: $("#zbSeatchT [name='publishtime']").val(),
  262. selectType : $("#zbSeatchT [name='selectType']").val() || 'title',
  263. minprice : $("#zbSeatchT [name='minprice']").val(),
  264. maxprice : $("#zbSeatchT [name='maxprice']").val(),
  265. industry : $("#zbSeatchT [name='industry']").val(),
  266. buyerclass: $("#zbSeatchT [name='buyerclass']").val(),
  267. buyertel: $("#zbSeatchT [name='buyertel']").val(),
  268. winnertel: $("#zbSeatchT [name='winnertel']").val(),
  269. notkey: $(".not-key-input-group input").val().slice(0, 10)
  270. };
  271. $.post("/front/pcAjaxReq",param,function(r){
  272. if(r&&r.list!=null&&r.list.length>0){
  273. // 计算总页码
  274. if (currentPage == 1) {
  275. searchInnerVue.listState.total = Math.ceil(r.count/50)
  276. searchInnerVue.checkPageNumAdd1()
  277. }
  278. $(".tabContainer").show();
  279. //$(".pagination").show();
  280. $(".hasNoData").hide();
  281. //$(".pagination-inner").find("span").text(currentPage);
  282. if(r.list.length<pageSize||currentPage==10){
  283. $(".nbnext").addClass("disabled");
  284. }else{
  285. $(".nbnext").removeClass("disabled");
  286. }
  287. appendDatas(r.list,false,true);
  288. }else{
  289. if(currentPage>1){
  290. $(".nbnext").addClass("disabled");
  291. if(currentPage==2){
  292. $(".nbprev").addClass("disabled");
  293. }
  294. currentPage = currentPage-1;
  295. return false
  296. }
  297. submitflag=true;
  298. $(".tabContainer").hide();
  299. $(".pagination").hide();
  300. $(".working").hide();
  301. $(".hasNoData").show();
  302. // 隐藏页码
  303. searchInnerVue.showPage = false
  304. }
  305. })
  306. }
  307. //
  308. function appendDatas(datas,flag,isNew,onlyUpdateTable){
  309. // flag // 是否有输入
  310. // console.log('selectType: ' + selectType,',flag: ',flag)
  311. var listHtml = '';
  312. var tableHtml = '';
  313. $(".working").hide();
  314. $(".pagination").show();
  315. // 显示页码
  316. searchInnerVue.showPage = true
  317. var searchvalueArray = searchvalue.split("+");
  318. $(".pagination-inner").find("span").text(currentPage);
  319. if(datas.length<pageSize){
  320. $(".nbnext").addClass("disabled");
  321. }
  322. if(!isNew && typeof(totalPage) != "undefined"){
  323. if(currentPage == totalPage){
  324. $(".nbnext").addClass("disabled");
  325. }else{
  326. $(".nbnext").removeClass("disabled");
  327. }
  328. }
  329. //(数据够20条显示查看更多遮罩层)
  330. if (currentPage==1){//第一页得时候需要判断 是否显示遮罩层
  331. if(datas.length>=20){
  332. $(".shade_table").css("display","");
  333. }else{
  334. $(".shade_table").css("display","none");
  335. }
  336. }
  337. for(var i=0;i<datas.length;i++){
  338. var index = (currentPage - 1) * pageSize + i + 1;
  339. var title = datas[i].title;
  340. var detail = datas[i].detail;
  341. if(detail){
  342. detail = detail.replace(/[^\{\u4e00-\u9fa5]{1,90}{[^\}\u4e00-\u9fa5]+?}/g,"")
  343. if(detail.length>200){
  344. detail = detail.substring(0,200)+"..."
  345. }
  346. }
  347. if(flag){
  348. title = keyWordHighlight(title,searchvalueArray,"<font class='com-highlight'>$1</font>");
  349. title=title.replace(/\<br>/g,"")
  350. detail = keyWordHighlight(detail,searchvalueArray,"<font class='com-highlight'>$1</font>");
  351. }
  352. if(title.length<40){
  353. title=title+"<span style='color:#fff;display:none;'>"+Math.random().toString(36).substring(2)+"<span>";
  354. }
  355. var type = datas[i].subtype;
  356. if(typeof(type) == "undefined" || type == null || type == ""){
  357. type = datas[i].toptype;
  358. }
  359. if(typeof(type) == "undefined" || type == null || type == ""){
  360. type = datas[i].type;
  361. if(type == "bid"){
  362. type = "中标";
  363. datas[i].stypeadd="ZHB"
  364. }else if(type == "tender"){
  365. datas[i].stypeadd="ZB"
  366. type = "招标";
  367. }else{
  368. type = "";
  369. }
  370. }
  371. if (!onlyUpdateTable){ //是否仅更新table
  372. listHtml += '<li>'
  373. //if(datas.length==(i+1)){
  374. // listHtml +='<div class="liLuceneList">'
  375. //}else{
  376. listHtml +='<div class="liLuceneList" style="border-bottom: 1px solid #EBEBEB;">'
  377. //}
  378. // 标题搜索 选择框
  379. if (selectType.indexOf('content') == -1 || !flag) {
  380. listHtml += '<input class="custom-checkbox title-text-checkbox" name="bid-list" type="checkbox" dataid="'+datas[i]._id+'" />'
  381. listHtml +='<div class="luce-left"><em class="visited-hd">'+index+'.</em>'
  382. +'<div class="left-title" style="width:700px;">'
  383. +'<a class="visited-hd" onclick="noIn(this)" dataid="'+datas[i]._id+'" dataindustry="'+datas[i].industry+'" target="_blank"> '+title+'</a>'
  384. +'</div>'
  385. }
  386. // 全文搜索
  387. if(flag && selectType.indexOf('content') > -1){
  388. listHtml +='<div class="luce-left"><em class="visited-hd" style="padding-left:30px;">'+index+'.</em>'
  389. +'<div class="left-title" style="width:1080px;">'
  390. +'<a class="visited-hd" onclick="noIn(this)" dataid="'+datas[i]._id+'" dataindustry="'+datas[i].industry+'" target="_blank"> '+title+'</a>'
  391. +'</div>'
  392. // 全文搜索选择框
  393. listHtml += '<div class="left-content" style="width:100%;padding:0;">'
  394. + '<input class="custom-checkbox all-text-checkbox" name="bid-list" type="checkbox" dataid="'+datas[i]._id+'" />'
  395. +'<a style="float:left;width:calc(100% - 32px)" href="javascript:volid(0);">'+detail+'...</a>'
  396. +'</div>'
  397. }
  398. listHtml += '</div><div class="luce-right">'
  399. if($.trim(datas[i].area) != "" && datas[i].area != "A"){
  400. listHtml += '<a href="/list/area/'+datas[i].areaadd+'.html">'+datas[i].area+'</a>';
  401. }else{
  402. listHtml += '<a href="#" style="display:none;"></a>';
  403. }
  404. if(typeof(type) != "undefined" && type != null && type != ""){
  405. listHtml += '<a href="/list/stype/'+datas[i].stypeadd+'.html">'+type+'</a>';
  406. }else{
  407. listHtml += '<a href="#" style="display:none;"></a>';
  408. }
  409. //
  410. if(typeof(datas[i].industry) != "undefined" && datas[i].industry != null && datas[i].industry != ""){
  411. listHtml += '<a href="/list/industry/'+datas[i].indadd+'.html">'+datas[i].industry+'</a>';
  412. }else{
  413. listHtml += '<a href="javascript:volid(0);" style="display:none;"></a>';
  414. }
  415. // vipState付费用户显示采购单位类型 免费用户不显示
  416. // if(typeof(datas[i].buyerclass) != "undefined" && datas[i].buyerclass != null && datas[i].buyerclass != "" && vipState){
  417. // listHtml += '<a href="javascript:;">'+datas[i].buyerclass+'</a>';
  418. // }else{
  419. // listHtml += '<a href="javascript:volid(0);" style="display:none;"></a>';
  420. // }
  421. var amount= getacount(datas[i].bidamount,datas[i].budget)
  422. if(amount!=""){
  423. listHtml += '<a>'+conversionMoeny(amount)+'</a>';
  424. }else{
  425. listHtml += '<a href="javascript:volid(0);" style="display:none;"></a>';
  426. }
  427. //
  428. if(typeof(datas[i].publishtime) != "undefined" && datas[i].publishtime != null && datas[i].publishtime != ""){
  429. var diff = utils.dateFromNow(Number(datas[i].publishtime+"000"));
  430. if(diff != null){
  431. listHtml += '<span class="com-time">'+diff+'</span>';
  432. }
  433. }
  434. // 是否收藏
  435. listHtml += '<i class="icon-collect" dataid="'+datas[i]._id+'"></i>'
  436. listHtml += '</div></li>';
  437. if(i == 5) {
  438. listHtml += '<div class="_t3di2018y5"></div>'
  439. }
  440. if(i == 26) {
  441. listHtml += '<div class="_6omliqck79a"></div>'
  442. }
  443. }
  444. //表格仅显示前20条信息
  445. if (i >= 20||currentPage!=1){
  446. continue
  447. }
  448. tableHtml +='<tr onclick="noIn(this)" dataid="'+datas[i]._id+'" dataindustry="'+datas[i].industry+'" target="_blank">'
  449. +'<td width="48"><div>'+index+'</div></td>'
  450. if(typeof(datas[i].projectname) != "undefined" && datas[i].projectname != null && datas[i].projectname != ""){
  451. datas[i].projectname = keyWordHighlight(datas[i].projectname,searchvalueArray,"<font class='com-highlight'>$1</font>");
  452. tableHtml += '<td class="tt-l" width="315"><div>'+datas[i].projectname+'</div></td>';
  453. }else{
  454. let title=datas[i].title.replace(/\<br>/g,"")
  455. tableHtml += '<td class="tt-l" width="315"><div>'+title+'</div></td>';
  456. }
  457. if(typeof(type) != "undefined" && type != null && type != ""){
  458. tableHtml += '<td width="84"><div>'+type+'公告</div></td>';
  459. }else{
  460. tableHtml += '<td width="84"><div></div></td>';
  461. }
  462. if(typeof(datas[i].budget) != "undefined" && datas[i].budget != null && datas[i].budget != ""){
  463. var budget =parseInt(datas[i].budget)/10000
  464. if(budget.toString().length>6){
  465. if(budget.toString().indexOf(".")==5){
  466. budget=budget.toString().substr(0,7)
  467. }else{
  468. budget=budget.toString().substr(0,6)
  469. }
  470. }
  471. tableHtml += '<td class="tt-r" width="73"><div>'+budget+'</div></td>';
  472. }else{
  473. tableHtml += '<td class="tt-r" width="73"><div></div></td>';
  474. }
  475. if(typeof(datas[i].buyer) != "undefined" && datas[i].buyer != null && datas[i].buyer != ""){
  476. tableHtml += '<td class="tt-l" width="181"><div>'+datas[i].buyer+'</div></td>';
  477. }else{
  478. tableHtml += '<td class="tt-l" width="181"><div></div></td>';
  479. }
  480. if(typeof(datas[i].bidopentime) != "undefined" && datas[i].bidopentime != null && datas[i].bidopentime != ""){
  481. var diff = formatDate(Number(datas[i].bidopentime),"l");
  482. tableHtml += '<td width="103"><div>'+diff+'</div></td>';
  483. }else{
  484. tableHtml += '<td width="103"><div></div></td>';
  485. }
  486. if(typeof(datas[i].winner) != "undefined" && datas[i].winner != null && datas[i].winner != ""){
  487. tableHtml += '<td class="tt-l" width="174"><div>'+datas[i].winner+'</div></td>';
  488. }else{
  489. tableHtml += '<td class="tt-l" width="174"><div></div></td>';
  490. }
  491. if(typeof(datas[i].bidamount) != "undefined" && datas[i].bidamount != null && datas[i].bidamount != ""){
  492. var bidamount = parseInt(datas[i].bidamount)/10000;
  493. if(bidamount.toString().length>6){
  494. if(bidamount.toString().indexOf(".")==5){
  495. bidamount=bidamount.toString().substr(0,7);
  496. }else{
  497. bidamount=bidamount.toString().substr(0,6);
  498. }
  499. }
  500. tableHtml += '<td class="tt-r" width="76"><div>'+bidamount+'</div></td>';
  501. }else{
  502. tableHtml += '<td class="tt-r" width="76"><div></div></td>';
  503. }
  504. if(typeof(datas[i].publishtime) != "undefined" && datas[i].publishtime != null && datas[i].publishtime != ""){
  505. var diff = formatDate(Number(datas[i].publishtime),"s");
  506. if(diff != null){
  507. tableHtml += '<td width="103"><div>'+diff+'</div></td>';
  508. }
  509. }else{
  510. tableHtml += '<td width="103"><div></div></td>';
  511. }
  512. tableHtml+='</tr>'
  513. }
  514. // 搜索框有输入词
  515. if(flag){
  516. if(selectType.indexOf('content') > -1) {
  517. $("#allnews").show();
  518. $(".tabContainer-2").hide();
  519. } else {
  520. $("#allnews").hide();
  521. $(".tabContainer-2").show();
  522. }
  523. }else{
  524. $("#allnews").hide();
  525. $(".tabContainer-2").show();
  526. }
  527. if (currentPage!=1){
  528. tableHtml = sessionStorage.getItem("table_first_context")
  529. }else{
  530. sessionStorage.setItem("table_first_context",tableHtml)
  531. }
  532. // 没有关键词或者没有选中正文
  533. if(!flag||selectType.indexOf('content') == -1){
  534. if (!onlyUpdateTable){
  535. $(".tabContainer-2 .lucene ul").html(listHtml);
  536. }
  537. $(".tabContainer-2 .lucene-table table tbody").html(tableHtml);
  538. }else{
  539. if(selectType.indexOf('content') > -1){
  540. if (!onlyUpdateTable){
  541. $("#allnews .lucene ul").html(listHtml);
  542. }
  543. $("#allnews .lucene-table table tbody").html(tableHtml);
  544. }
  545. }
  546. $(".tabContainer").css("min-height","");
  547. submitflag=true;
  548. // backTopAdjust();
  549. // 生成dom之后再查标讯有无收藏
  550. getBidIsColl()
  551. checkVisited()
  552. // 生成dom之后再查询是否勾选
  553. getCheckList()
  554. }
  555. function getacount(bidamount,budget){
  556. if(typeof(bidamount) != "undefined" && bidamount != null && bidamount != ""){
  557. return bidamount
  558. }
  559. if(typeof(budget) != "undefined" && budget != null && budget != ""){
  560. return budget
  561. }
  562. return ""
  563. }
  564. //金额转化 金额:0-万元以下单位为元 ,万元以上至亿元以下单位为万元 ,亿元以上单位为亿元。保留 小数点后 2 位,不进行四舍五入。
  565. function conversionMoeny(money){
  566. var m = ""+money;
  567. var m_arr = m.split(".")
  568. var m_1 = m_arr[0]
  569. var len_m1 = m_1.length;
  570. if (len_m1 >= 9 ){
  571. m = m_1.substring(0,len_m1-8) + "." + m_1.substring(len_m1-8,len_m1-6) + "亿元"
  572. } else if (len_m1 >= 5) {
  573. m =m_1.substring(0,len_m1-4) + "." + m_1.substring(len_m1-4,len_m1-2) + "万元"
  574. } else {
  575. if(m_arr.length == 1) {
  576. return m + ".00元"
  577. }
  578. var m_2 = m_arr[1]
  579. if (m_2.length > 1) {
  580. m_2 = m_2.substring(0,2)
  581. } else {
  582. m_2 = m_2.substring(0,1) + "0"
  583. }
  584. m = m_1 + "." + m_2 + "元"
  585. }
  586. return m
  587. }
  588. //关闭遮罩层
  589. function layerClose(){
  590. $("#myModal").modal("hide");
  591. }
  592. //
  593. function formatDate(date,sl) {
  594. var myDate = new Date(date*1000);
  595. var year=myDate.getFullYear();
  596. var month=myDate.getMonth()+1;
  597. var date=myDate.getDate();
  598. var hour = myDate.getHours()
  599. var min = myDate.getMinutes()
  600. if(sl=="l"){
  601. if(hour<10){
  602. hour="0"+hour
  603. }
  604. if(min<10){
  605. min="0"+min
  606. }
  607. return year+"-"+month+"-"+date+"<br>"+hour+":"+min;
  608. }else{
  609. return year+"-"+month+"-"+date;
  610. }
  611. }
  612. //
  613. function onpicking(dp,obj){
  614. var time = new Date(dp.cal.newdate.y,dp.cal.newdate.M-1,dp.cal.newdate.d).getTime()+"";
  615. time = time.substring(0,time.length - 3);
  616. $(obj).attr("data-value",time);
  617. }
  618. //
  619. function onclearing(obj){
  620. $(obj).attr("data-value","");
  621. //localStorage.removeItem($(obj).attr("id"))
  622. if($(".customtime").hasClass("active") && getInputTime().join("") == ""){
  623. $(".customtime").removeClass("active");
  624. $("#publishtime #alltime").addClass("active");
  625. }
  626. }
  627. //
  628. function picked(dp,obj){
  629. //localStorage.setItem($(obj).attr("id"),$(obj).val()+"_"+$(obj).attr("data-value"))
  630. }
  631. //
  632. function getInputTime(){
  633. var starttime = $("#starttime").attr("data-value");
  634. if(starttime){
  635. starttime = $.trim(starttime);
  636. }else{
  637. starttime = "";
  638. }
  639. var endtime = $("#endtime").attr("data-value");
  640. if(endtime){
  641. endtime = $.trim(endtime);
  642. }else{
  643. endtime = "";
  644. }
  645. return [starttime,endtime]
  646. }
  647. //---取VIP数据---
  648. function getVIPData(clickpaging){
  649. var this_selectType = $("#zbSeatchT [name='selectType']").val();
  650. if(this_selectType != "all"){
  651. LimitClass.limitFlag = false;
  652. LimitClass.result = null;
  653. LimitClass.list = null;
  654. }else{
  655. if(LimitClass.limitFlag){
  656. if(clickpaging){
  657. LimitClass.paging(currentPage);
  658. }else{
  659. $(".tabContainer .lucene").hide();
  660. $(".tabContainer .lucene-table").show();
  661. }
  662. return true;
  663. }
  664. }
  665. var tlflag = false;
  666. $(".tabContainer-2 .lucene").hide();
  667. $("#allnews").hide();
  668. $(".pagination").hide();
  669. $(".working").show();
  670. // 隐藏页码
  671. searchInnerVue.showPage = false
  672. if($("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='industry']").val()==""){
  673. $(".working").hide();
  674. $(".pagination").show();
  675. // 显示页码
  676. searchInnerVue.showPage = true
  677. return true;
  678. }
  679. var tabflag = false;
  680. if($("#zbSeatchT [name='keywords']").val()!=""){
  681. // $("#newsclass").show();
  682. // $("#newsnow").hide();
  683. tlflag = true;
  684. }else{
  685. // $("#newsclass").hide();
  686. // $("#newsnow").show();
  687. tlflag = false;
  688. }
  689. if(currentPage==1){
  690. $(".nbprev").addClass("disabled");
  691. }
  692. var reqType="bidSearch";
  693. if($("#zbSeatchT [name='keywords']").val()==""){
  694. reqType="lastNews";
  695. }
  696. var param = {
  697. pageNumber: 1,
  698. reqType: reqType,
  699. searchvalue: $("#zbSeatchT [name='keywords']").val(),
  700. area: $("#zbSeatchT [name='area']").val(),
  701. subtype: $("#zbSeatchT [name='subtype']").val(),
  702. publishtime: $("#zbSeatchT [name='publishtime']").val(),
  703. selectType : this_selectType || 'title',
  704. minprice : $("#zbSeatchT [name='minprice']").val(),
  705. maxprice : $("#zbSeatchT [name='maxprice']").val(),
  706. industry : $("#zbSeatchT [name='industry']").val(),
  707. tabularflag : tabularflag,
  708. buyerclass: $("#zbSeatchT [name='buyerclass']").val(),
  709. buyertel: $("#zbSeatchT [name='buyertel']").val(),
  710. winnertel: $("#zbSeatchT [name='winnertel']").val(),
  711. notkey: $(".not-key-input-group input").val().slice(0, 10)
  712. };
  713. $.ajax({
  714. type:'post',
  715. url:'/front/pcAjaxReq',
  716. async:false,
  717. data:param,
  718. dataType:'json',
  719. success:function(r){
  720. afterAjaxReq(r);
  721. if(r&&r.list!=null&&r.list.length>0){
  722. $(".hasNoData").hide();
  723. if(r.list.length<pageSize||currentPage==10){
  724. $(".nbnext").addClass("disabled");
  725. }else{
  726. $(".nbnext").removeClass("disabled");
  727. }
  728. appendDatas(r.list,tlflag,true,true);
  729. }else{
  730. $(".working").hide();
  731. $(".hasNoData").show();
  732. // 隐藏页码
  733. searchInnerVue.showPage = false
  734. }
  735. tabflag = true;
  736. }
  737. })
  738. return tabflag
  739. }
  740. ///
  741. function beforeSubmit(n){
  742. // n有值即执行的是点击搜索按钮或回车搜索事件
  743. // n有值且关键词不为空时 存sessionStorage值
  744. if ($("#zbSeatchT [name='keywords']").val() !=="") {
  745. sessionStorage.setItem('is-click-search', 1)
  746. } else {
  747. sessionStorage.removeItem('is-click-search')
  748. }
  749. // 重置全选按钮
  750. $('.custom-checkbox.check-all').prop('checked', false)
  751. $(".hasNoData").hide();
  752. $(".working").show();
  753. // 隐藏页码
  754. searchInnerVue.showPage = false
  755. //$(".tabContainer-2 .lucene ul").html("");
  756. //$(".tabContainer-2 .lucene-table table tbody").html("");
  757. $(".tabContainer .lucene ul").html("");
  758. //$(".tabContainer .lucene-table table tbody").html("");
  759. $(".tabContainer").css("min-height","600px");
  760. $("#right-list").addClass("active").siblings().removeClass("active");
  761. $(".tabContainer-2 .lucene").show().siblings().hide();
  762. $("#right-list").addClass("active").siblings().removeClass("active");
  763. $("#allnews .lucene").show().siblings().hide();
  764. $(".tabContainer-2").hide();
  765. $("#allnews").hide();
  766. $(".pagination").hide();
  767. setTimeout(function(){
  768. currentPage=1;
  769. // 重置element ui页码为1
  770. searchInnerVue.listState.num = 1
  771. //时间
  772. if(currentPage==1){
  773. $(".nbprev").addClass("disabled");
  774. }
  775. var publishtime = null;
  776. var timeslot = getInputTime().join("_");
  777. if($(".timerInput").hasClass("active")){
  778. if(timeslot != "_"){
  779. $("#zbSeatchT [name='publishtime']").val(timeslot);
  780. }else{
  781. $("#zbSeatchT [name='publishtime']").val("");
  782. }
  783. }else{
  784. publishtime = $(".timer .active").attr("data-value");
  785. if(typeof(publishtime) != "undefined"){
  786. $("#zbSeatchT [name='publishtime']").val(publishtime);
  787. }else{
  788. $("#zbSeatchT [name='publishtime']").val("");
  789. }
  790. }
  791. if(timeslot != "_"){
  792. $("#zbSeatchT [name='timeslot']").val(timeslot);
  793. }else{
  794. $("#zbSeatchT [name='timeslot']").val("");
  795. }
  796. //地区
  797. var selectAreas = "";
  798. $(".region-content .active:not(.parent-node)").each(function(){
  799. var thisText = $(this).text();
  800. if(thisText != "全国"){
  801. if(selectAreas != ""){
  802. selectAreas += ",";
  803. }
  804. selectAreas += thisText;
  805. }
  806. });
  807. $("#zbSeatchT [name='area']").val(selectAreas);
  808. //类型
  809. var selectSubTypes = "";
  810. $(".info-content .active:not(.parent-node)").each(function(){
  811. if($(this).attr("id") == "whole"||$(this).attr("id") == "infoBtn"){
  812. return true;
  813. }
  814. var thisText = $(this).attr("data-value");
  815. if (thisText!=undefined){
  816. if(selectSubTypes != ""){
  817. selectSubTypes += ",";
  818. }
  819. selectSubTypes += thisText;
  820. }
  821. });
  822. $("#zbSeatchT [name='subtype']").val(selectSubTypes);
  823. //行业
  824. var selectIndustrys = "";
  825. var thisText = "";
  826. $(".industry-content .active").each(function(){
  827. if($(this).attr("id") == "induAll"){
  828. return true;
  829. }else if($(this).hasClass("active")&&$(this).hasClass("parent-node")){
  830. $(this).nextUntil(".diver").each(function(){
  831. thisText = $(this).attr("data-value");
  832. if(selectIndustrys != ""){
  833. selectIndustrys += ",";
  834. }
  835. selectIndustrys += thisText;
  836. });
  837. }else{
  838. thisText = $(this).attr("data-value");
  839. if(selectIndustrys != ""){
  840. selectIndustrys += ",";
  841. }
  842. selectIndustrys += thisText;
  843. }
  844. });
  845. $("#zbSeatchT [name='industry']").val(selectIndustrys);
  846. //价格
  847. if(!$("#priceAll").hasClass("active")){
  848. var selectMinPrices = $(".PriceInput [name='minprice']").val();
  849. var selectMaxPrices = $(".PriceInput [name='maxprice']").val();
  850. $("#zbSeatchT [name='minprice']").val(selectMinPrices);
  851. $("#zbSeatchT [name='maxprice']").val(selectMaxPrices);
  852. }else{
  853. $("#zbSeatchT [name='minprice']").val("");
  854. $("#zbSeatchT [name='maxprice']").val("");
  855. }
  856. //搜索关键词
  857. var searchname = $("#zbSeatchT input[name='keywords']").val();
  858. //$("#zbSeatchT input[name='searchvalue']").val($.trim(searchname));
  859. // 采购单位类型
  860. var buyerTypeArr = ""
  861. var buyerText = ""
  862. $(".buyclass .active").each(function(){
  863. if ($(this).hasClass('buyclass-all')) {
  864. return true
  865. } else if ($(this).hasClass('buy-list')) {
  866. if ($(this).attr("data-value")) {
  867. buyerText = $(this).attr("data-value");
  868. if(buyerTypeArr != ""){
  869. buyerTypeArr += ",";
  870. }
  871. buyerTypeArr += buyerText;
  872. }
  873. }
  874. })
  875. //采购单位类型
  876. $("#zbSeatchT [name='buyerclass']").val(buyerTypeArr)
  877. // $("#buyerInput").val(buyerTypeArr);
  878. //采购单位联系方式有无
  879. $("#zbSeatchT [name='buyertel']").val($(".custom-input[name='buyertel']").attr('data-value'));
  880. //中标单位联系方式有无
  881. $("#zbSeatchT [name='winnertel']").val($(".custom-input[name='winnertel']").attr('data-value'));
  882. //排除词
  883. $("#zbSeatchT [name='notkey']").val($(".not-key-input-group input").val().slice(0, 10));
  884. if($("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='industry']").val()==""){
  885. getNewBids(currentPage);
  886. }else{
  887. if(n!="F"){
  888. if(submitflag){
  889. if($.trim(searchname)==""){
  890. getNewBiddings();
  891. nbflag = false;
  892. }else{
  893. searchvalue = $.trim(searchname);
  894. searchOnsubmit();
  895. nbflag = true;
  896. }
  897. submitflag=false;
  898. }
  899. setTimeout(function(){
  900. submitflag=true
  901. },200);
  902. }else{
  903. if($.trim(searchname)!=""){
  904. nbflag = true;
  905. }
  906. }
  907. }
  908. return true
  909. },200)
  910. }
  911. var LimitClass = {
  912. prevNoLimitFlag: false,
  913. limitFlag: false,
  914. list: null,
  915. result: null,
  916. paging: function(cp){
  917. if(LimitClass.list != null){
  918. var start = (cp-1)*pageSize;
  919. var end = start+pageSize;
  920. if(end > LimitClass.list.length){
  921. end = LimitClass.list.length;
  922. }
  923. LimitClass.result.list = LimitClass.list.slice(start,end);
  924. }
  925. pcAjaxReqCallBack(LimitClass.result);
  926. }
  927. };
  928. //搜索关键词信息
  929. function searchOnsubmit(clickpaging){
  930. var this_selectType = $("#zbSeatchT [name='selectType']").val();
  931. if(this_selectType != "all"){
  932. LimitClass.limitFlag = false;
  933. LimitClass.result = null;
  934. LimitClass.list = null;
  935. }else{
  936. if(clickpaging&&LimitClass.limitFlag){
  937. LimitClass.paging(currentPage);
  938. return;
  939. }
  940. }
  941. // $("#newsclass").show();
  942. // $("#newsnow").hide();
  943. if(currentPage==1){
  944. $(".nbprev").addClass("disabled");
  945. }
  946. var param = {
  947. pageNumber: currentPage,
  948. reqType: "bidSearch",
  949. searchvalue: $("#zbSeatchT [name='keywords']").val(),
  950. area: $("#zbSeatchT [name='area']").val(),
  951. subtype: $("#zbSeatchT [name='subtype']").val(),
  952. publishtime: $("#zbSeatchT [name='publishtime']").val(),
  953. selectType : this_selectType || 'title',
  954. minprice : $("#zbSeatchT [name='minprice']").val(),
  955. maxprice : $("#zbSeatchT [name='maxprice']").val(),
  956. industry : $("#zbSeatchT [name='industry']").val(),
  957. tabularflag: "Y",
  958. buyerclass: $("#zbSeatchT [name='buyerclass']").val(),
  959. buyertel: $("#zbSeatchT [name='buyertel']").val(),
  960. winnertel: $("#zbSeatchT [name='winnertel']").val(),
  961. notkey: $(".not-key-input-group input").val().slice(0, 10)
  962. };
  963. $.post("/front/pcAjaxReq",param,function(r){
  964. if(r.limitFlag){
  965. LimitClass.limitFlag = true;
  966. LimitClass.result = r;
  967. LimitClass.list = r.list;
  968. LimitClass.paging(currentPage);
  969. LimitClass.prevNoLimitFlag = false;
  970. // 重新分页
  971. searchInnerVue.listState.total = r.totalPage
  972. searchInnerVue.checkPageNumAdd1()
  973. }else{
  974. LimitClass.prevNoLimitFlag = true;
  975. LimitClass.limitFlag = false;
  976. pcAjaxReqCallBack(r);
  977. }
  978. // getBidIsColl()
  979. });
  980. }
  981. function showSearchTipForTimeRange (type) {
  982. var tempDom = $("#hasNoData_tiptext>font:eq(0)")
  983. var tipMap = {
  984. 'fiveyear': '近5年',
  985. 'threeyear': '近3年',
  986. 'thisyear': '近1年',
  987. 'lately-7': '近7天',
  988. 'lately-30': '近30天'
  989. }
  990. var tempStr = ''
  991. var defaultRange = $("#zbSeatchT [name='publishtime']").val() || selectPublishtime
  992. if (tipMap[defaultRange]) {
  993. tempStr = tipMap[defaultRange]
  994. } else {
  995. var tempTimeList = defaultRange.split('_')
  996. if (tempTimeList[0]) {
  997. tempStr = new Date(tempTimeList[0] * 1000).pattern('yyyy/MM/dd')
  998. }
  999. if (tempTimeList[1]) {
  1000. if (tempStr.length) {
  1001. tempStr += '-'
  1002. }
  1003. tempStr += new Date(tempTimeList[1] * 1000).pattern('yyyy/MM/dd')
  1004. }
  1005. }
  1006. tempDom.find('span').text(tempStr)
  1007. if (type !== false) {
  1008. tempDom.show();
  1009. }
  1010. }
  1011. $(function () {
  1012. setTimeout(function(){
  1013. showSearchTipForTimeRange(false);
  1014. },500)
  1015. })
  1016. function pcAjaxReqCallBack(r){
  1017. afterAjaxReq(r);
  1018. var isAllSearch = $("#zbSeatchT [name='selectType']").val()=="all";
  1019. if(r.list == null || r.list.length == 0){
  1020. $("#hasNoData_tiptext>font").hide();
  1021. if(r.status==-1){
  1022. $("#hasNoData_tiptext>font:eq(1)").show();
  1023. }else if (r.status==-2){
  1024. $("#hasNoData_tiptext>font:eq(2)").show();
  1025. }else{
  1026. showSearchTipForTimeRange()
  1027. }
  1028. if(isAllSearch){
  1029. $("#allSearchModel").hide();
  1030. }else{
  1031. // $("#allSearchModel").show();
  1032. }
  1033. //分页过程中,突然切换控制状态
  1034. if(r.limitFlag && LimitClass.prevNoLimitFlag){
  1035. $("#hasNoData_tiptext>font").hide();
  1036. $("#hasNoData_tiptext>font:eq(1)").show();
  1037. }else{
  1038. if(currentPage>1){
  1039. $(".nbnext").addClass("disabled");
  1040. if(currentPage==2){
  1041. $(".nbprev").addClass("disabled");
  1042. }
  1043. currentPage = currentPage-1;
  1044. return false
  1045. }
  1046. }
  1047. $(".tabContainer").hide();
  1048. $(".pagination").hide();
  1049. $(".working").hide();
  1050. $(".hasNoData").show();
  1051. // 隐藏页码
  1052. searchInnerVue.showPage = false
  1053. submitflag=true;
  1054. }else{
  1055. //$(".tabContainer").show();
  1056. $(".hasNoData").hide();
  1057. appendDatas(r.list,true,false)
  1058. }
  1059. }
  1060. function afterAjaxReq(r){
  1061. secondFlag=r.secondFlag;
  1062. if(r.interceptWord != ""){
  1063. $("#intercept>span").text(r.interceptWord);
  1064. $("#intercept").removeClass("hidden");
  1065. }else{
  1066. $("#intercept").addClass("hidden");
  1067. }
  1068. if(r.keywords != null && typeof(r.keywords) != "undefined"){
  1069. $(".searchname").val(r.keywords);
  1070. }
  1071. $(".side-bar-bottom-font").text("“"+$.trim($(".searchname").val()).replace(/\s+/," ")+"”");
  1072. if(secondFlag==""&&typeof(r.searchvalue) != "undefined"){
  1073. searchvalue = r.searchvalue;
  1074. }
  1075. if(r.pcAjaxFlag=="T"){
  1076. searchvalue = r.searchvalue;
  1077. totalPage = r.totalPage;
  1078. list= r.list;
  1079. secondList= r.secondList;
  1080. // vue 重置总页数
  1081. searchInnerVue.listState.total = totalPage
  1082. searchInnerVue.checkPageNumAdd1()
  1083. }
  1084. if(secondFlag==""&&typeof(totalPage) != "undefined" && currentPage == 1){
  1085. if (r.totalPage==1){
  1086. totalPage = parseInt(r.count/pageSize)+1;
  1087. if(totalPage>10){
  1088. totalPage=10;
  1089. }
  1090. // vue 重置总页数
  1091. searchInnerVue.listState.total = totalPage
  1092. searchInnerVue.checkPageNumAdd1()
  1093. }else{
  1094. totalPage = r.totalPage;
  1095. searchInnerVue.listState.total = totalPage
  1096. searchInnerVue.checkPageNumAdd1()
  1097. }
  1098. }
  1099. }
  1100. function getCheckList() {
  1101. var getSelectNum = 0 // 获取这一页有多少个选中
  1102. var $dom = $('.custom-checkbox:not(.check-all)[name="bid-list"]')
  1103. $dom.each(function() {
  1104. if(selectDataIds.length == 0) return
  1105. selectDataIds.forEach(function(item,index) {
  1106. let dataid = $(this).attr('dataid')
  1107. if (item == dataid) {
  1108. getSelectNum++
  1109. $(this).attr('checked', true)
  1110. }
  1111. })
  1112. })
  1113. if(getSelectNum>=50) {
  1114. $('.custom-checkbox').prop("checked",true)
  1115. } else {
  1116. $('.custom-checkbox').prop("checked",false)
  1117. $dom.each(function() {
  1118. if(selectDataIds.length == 0) return
  1119. selectDataIds.forEach(function(item,index) {
  1120. let dataid = $(this).attr('dataid')
  1121. if (item == dataid) {
  1122. getSelectNum++
  1123. $(this).prop('checked', true)
  1124. }
  1125. })
  1126. })
  1127. }
  1128. }
  1129. /*
  1130. 招标信息是否被收藏接口ajax
  1131. bids: String, // 招标信息id(多个用,号拼接) 必填
  1132. */
  1133. function getBidIsColl () {
  1134. collectClick()
  1135. var bids = ""
  1136. var dataId = ""
  1137. // 区分标题搜索和全文搜索收藏
  1138. var allSearch = selectType.indexOf('content') > -1 && $("#zbSeatchT [name='keywords']").val() !==""
  1139. // console.log('当前是否显示的是全文',allSearch)
  1140. var $dom = allSearch ? $('.all-text-checkbox[name="bid-list"]') : $('.title-text-checkbox[name="bid-list"]')
  1141. $dom.each(function() {
  1142. if ($(this).attr('dataid')) {
  1143. dataId = $(this).attr("dataid");
  1144. if(bids != ""){
  1145. bids += ",";
  1146. }
  1147. bids += dataId;
  1148. }
  1149. })
  1150. $.ajax({
  1151. type:'post',
  1152. url:'/publicapply/bidcoll/isColl?t=' + Date.now(),
  1153. data: {
  1154. bids: bids
  1155. },
  1156. dataType:'json',
  1157. success: function(r){
  1158. if (r.data) {
  1159. var data = r.data
  1160. $('.icon-collect').removeClass('checked')
  1161. data.forEach(function(item,index){
  1162. if (selectType == 'title') {
  1163. $('.icon-collect[dataid="' + item + '"]').addClass('checked')
  1164. } else {
  1165. $('.icon-collect[dataid="' + item + '"]').addClass('checked')
  1166. }
  1167. })
  1168. }
  1169. }
  1170. })
  1171. }
  1172. // 收藏点击事件
  1173. function collectClick() {
  1174. // console.log(vipState, '是否是超级订阅用户')
  1175. // 单个收藏点击事件
  1176. $('.icon-collect').unbind('click').on('click',function(e) {
  1177. // 登录判断
  1178. if (!loginflag) {
  1179. openLoginDig()
  1180. return
  1181. }
  1182. baiduEvent('列表页标讯收藏-星标') // 百度统计代码
  1183. e.stopPropagation()
  1184. var $that = $(this)
  1185. var checked = $(this).hasClass('checked')
  1186. var checkedId = $(this).attr('dataid')
  1187. var binfo = [{
  1188. bid: checkedId
  1189. }]
  1190. if (checked) {
  1191. // 单个取消收藏行为
  1192. collBidAction('R', binfo, function(res) {
  1193. if (res.data) {
  1194. if (selectType == 'title') {
  1195. // 标题搜索下相关样式
  1196. // $that.removeClass('checked').parents().siblings('input[type="checkbox"]').prop("checked",false).removeAttr('disabled')
  1197. $that.removeClass('checked')
  1198. } else {
  1199. // 全文搜索下相关样式
  1200. // $that.removeClass('checked').parents('.luce-right').siblings().find('input[type="checkbox"]').prop("checked",false).removeAttr('disabled')
  1201. $that.removeClass('checked')
  1202. }
  1203. toastFn('已取消收藏', 800)
  1204. } else {
  1205. toastFn(res.error_msg, 1000)
  1206. }
  1207. })
  1208. } else {
  1209. // 单个收藏行为
  1210. vm.dialogTitle = '重要项目一键创建标签收藏!请完善个人信息,为您匹配精准服务'
  1211. // 查询是否需要用户留资料 不需要 则执行下一步回调(收藏标讯行为)
  1212. vm.isNeedSubmit('article_collection',function() {
  1213. sessionStorage.setItem('$save-tags-binfo', JSON.stringify(binfo)) // 将本次收藏的标讯id缓存起来 用于绑定标签时使用
  1214. collBidAction('C', binfo, function(res) {
  1215. if (res.data) {
  1216. toastFn('收藏成功', 1500)
  1217. if (selectType == 'title') {
  1218. $that.addClass('checked')
  1219. } else {
  1220. $that.addClass('checked')
  1221. }
  1222. var top = (parseInt($that.position().top) + 50 ) + 'px';
  1223. $('.tags-box').show(function(){
  1224. activeTags = []
  1225. $('.tag-labels').empty()
  1226. $('.clear-input').val('')
  1227. $('.tags-list').find('.tags-item').removeClass('tags-active')
  1228. $('.tag-placeholder').show()
  1229. }).css('top', top)
  1230. getUserTags()
  1231. } else {
  1232. // 是超级订阅用户或者其他付费用户
  1233. if (vipState || res.error_msg.indexOf('付费') > -1) {
  1234. toastFn('您的标讯收藏上限为5000条,请联系客服人员。', 1500)
  1235. } else {
  1236. updateVipDialog('标讯收藏满100条-去升级')
  1237. }
  1238. }
  1239. })
  1240. }, $(this))
  1241. }
  1242. })
  1243. // 批量收藏
  1244. $('#bid-collect').off('click').bind('click',function(e){
  1245. // 登录判断
  1246. if (!loginflag) {
  1247. openLoginDig()
  1248. return
  1249. }
  1250. baiduEvent('列表页标讯收藏-星标') // 百度统计代码
  1251. e.stopPropagation()
  1252. var top = (parseInt($(this).position().top) + 60 ) + 'px';
  1253. var len = $('.custom-checkbox:not(".check-all"):checked').length;
  1254. var checkedId = [] // 提交后端需要的标讯id数组
  1255. var leftArr = [] // checkbox选中的数据
  1256. var rightArr = [] // 当前已收藏过的数据
  1257. var notSameArr = [] // 选中的数据 与 收藏过的数据相比不同的数组
  1258. $('.custom-checkbox:not(".check-all"):checked').each(function(){
  1259. if ($(this).attr('dataid')) {
  1260. checkedId.push({
  1261. bid: $(this).attr('dataid')
  1262. })
  1263. leftArr.push($(this).attr('dataid'))
  1264. }
  1265. })
  1266. $('.icon-collect.checked').each(function() {
  1267. if ($(this).attr('dataid')) {
  1268. rightArr.push($(this).attr('dataid'))
  1269. }
  1270. })
  1271. var $that = $(this)
  1272. // 判断有无选中的标讯信息
  1273. if (len > 0 || selectDataIds.length > 0) {
  1274. selectDataIds.forEach(function(v) {
  1275. checkedId.push({
  1276. bid: v
  1277. })
  1278. })
  1279. checkedId = arrUnique(checkedId)
  1280. if(leftArr.length <= rightArr.length) {
  1281. for (key in leftArr) {
  1282. var stra = leftArr[key];
  1283. var count = 0;
  1284. for (var j = 0; j < rightArr.length; j++) {
  1285. var strb = rightArr[j];
  1286. if (stra == strb) {
  1287. count++;
  1288. }
  1289. }
  1290. if (count === 0) { //表示数组1的这个值没有重复的,放到notSameArr列表中
  1291. notSameArr.push(stra);
  1292. }
  1293. }
  1294. // 如果没有不同的值 即为选中的标讯都已收藏过 有不同的值即为有未收藏的标讯
  1295. // console.log(notSameArr, 'notSameArr')
  1296. if(notSameArr.length == 0) {
  1297. toastFn('已收藏', 800)
  1298. return
  1299. }
  1300. }
  1301. vm.dialogTitle = '重要项目一键创建标签收藏!请完善个人信息,为您匹配精准服务'
  1302. // 查询是否需要用户留资料 不需要 则执行下一步回调(批量收藏标讯行为)
  1303. vm.isNeedSubmit('article_collection', function() {
  1304. sessionStorage.setItem('$save-tags-binfo', JSON.stringify(checkedId)) // 将本次收藏的标讯id缓存起来 用于绑定标签时使用
  1305. collBidAction('C', checkedId, function(res) {
  1306. if (res.data) {
  1307. toastFn('收藏成功', 1500)
  1308. if (selectType == 'title') {
  1309. $('.custom-checkbox:not(".check-all"):checked').siblings().children('.icon-collect').addClass('checked')
  1310. } else {
  1311. $('.custom-checkbox:not(".check-all"):checked').parents('.liLuceneList').find('.icon-collect').addClass('checked')
  1312. }
  1313. // 收藏成功后再查一次收藏状态,为了区分达到收藏上限点时部分收藏成功,部分收藏失败
  1314. getBidIsColl()
  1315. // 弹出标签弹框时 清除上次选择的标签
  1316. $('.tags-box').show().css('top', top)
  1317. getUserTags()
  1318. } else {
  1319. // 是超级订阅用户或者其他付费用户
  1320. if (vipState || res.error_msg.indexOf('付费') > -1) {
  1321. toastFn('您的标讯收藏上限为5000条,请联系客服人员。', 1500)
  1322. } else {
  1323. updateVipDialog('标讯收藏满100条-去升级')
  1324. }
  1325. }
  1326. })
  1327. })
  1328. } else {
  1329. toastFn('尚未选择标讯,请选择', 1000)
  1330. }
  1331. })
  1332. }
  1333. function arrUnique(arr){
  1334. let ojb = {};
  1335. arr = arr.reduce(function(prevArr, currentItem) {
  1336. //利用对象的键名无法重复的特点,mch_id是唯一区别的属性值
  1337. ojb[currentItem.bid] ? '' : ojb[currentItem.bid] = true && prevArr.push(currentItem);
  1338. return prevArr
  1339. }, [])
  1340. return arr;
  1341. }
  1342. function openBigMemberDialog (str, content) {
  1343. $('.auth-dialog').show()
  1344. $('.auth-dialog .dialog-title').text('您暂无使用权限')
  1345. $('.auth-dialog .dialog-content').html(content || '开通大会员,查看更多招标项目,畅享商机不受限!')
  1346. $('.auth-dialog .default-btn').click(function () {
  1347. $('.auth-dialog').hide(300)
  1348. })
  1349. $('.auth-dialog .confirm-btn').text('免费体验')
  1350. $('.auth-dialog .confirm-btn').off('click').bind('click',function () {
  1351. var advName = '招标搜索' + str + '-去开通'
  1352. baiduEvent(advName) // 点击去开通事件 百度统计
  1353. $('.auth-dialog').hide(300)
  1354. vm.dialogTitle = '免费用户查看超过500条招标搜索结果'
  1355. vm.isNeedSubmit('jylab_see500_plus', function () {
  1356. vm.showSuccess = true
  1357. })
  1358. })
  1359. }
  1360. // 开通提醒弹框
  1361. function openVipDialog(str, content) {
  1362. $('.auth-dialog').show()
  1363. $('.auth-dialog .dialog-title').text('开通超级订阅')
  1364. $('.auth-dialog .dialog-content').html(content || '立享更多搜索权限,寻找商机更精准')
  1365. $('.auth-dialog .default-btn').click(function () {
  1366. $('.auth-dialog').hide(300)
  1367. })
  1368. $('.auth-dialog .confirm-btn').text('去开通')
  1369. $('.auth-dialog .confirm-btn').off('click').bind('click',function () {
  1370. var advName = '招标搜索' + str + '-去开通'
  1371. baiduEvent(advName) // 点击去开通事件 百度统计
  1372. window.open('/swordfish/page_big_pc/free/svip/buy')
  1373. })
  1374. }
  1375. // 升级提醒弹框
  1376. function updateVipDialog(str) {
  1377. $('.update-dialog').show()
  1378. $('.update-dialog .default-btn').click(function () {
  1379. $('.update-dialog').hide(300)
  1380. })
  1381. $('.update-dialog .confirm-btn').off('click').bind('click',function () {
  1382. baiduEvent(str) // 点击去升级事件 百度统计
  1383. window.open('/front/subscribe.html')
  1384. })
  1385. }
  1386. // 列表页收藏点击事件 百度统计
  1387. function baiduEvent(name) {
  1388. // console.log(name, 'name')
  1389. try {
  1390. _hmt.push(['_trackEvent', '超级订阅-pc', 'click', name]);
  1391. } catch (e) {
  1392. console.log('未初始化百度统计')
  1393. }
  1394. }
  1395. // toast上限提示
  1396. function toastFn (text, duration) {
  1397. if (duration) {
  1398. duration = 1000
  1399. }
  1400. var _html = ""
  1401. _html+='<div class="custom-toast"><div class="mask" style="background-color: transparent;"></div><div class="toast-container">'
  1402. _html+='<span>' + text + '</span></div></div>'
  1403. $('body').append(_html)
  1404. setTimeout(function(){
  1405. $(".custom-toast").fadeOut().remove();
  1406. },duration)
  1407. }
  1408. // 是否有权限
  1409. // isPower()
  1410. function isPower () {
  1411. $.ajax({
  1412. type:'post',
  1413. url:'/publicapply/bidcoll/power?t=' + Date.now(),
  1414. success: function(r){
  1415. if (r.data) {
  1416. var entniche = r.data.entniche
  1417. var member = r.data.member
  1418. var vip = r.data.vip
  1419. if (entniche || member || vip > 0) {
  1420. return 'true'
  1421. } else {
  1422. return 'false'
  1423. }
  1424. } else {
  1425. return 'false'
  1426. }
  1427. }
  1428. })
  1429. }