superSearch.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. var pageSize = 50;
  2. var nbflag = false;//是否显示的是最新招标数据
  3. var currentPage = 1;
  4. var submitflag = true;
  5. var searchvalue = "";
  6. var searchvalueArray = searchvalue.split("+");
  7. $(function() {
  8. $("#minprice").click(function(){
  9. $(".pricebut").show();
  10. $(".pricefat").addClass("customtime-active");
  11. })
  12. $("#maxprice").click(function(){
  13. $(".pricebut").show();
  14. $(".pricefat").addClass("customtime-active");
  15. })
  16. $("#starttime").click(function(){
  17. $("#timebut").show();
  18. $(".timerInput").addClass("customtime-active");
  19. })
  20. $("#endtime").click(function(){
  21. $("#timebut").show();
  22. $(".timerInput").addClass("customtime-active");
  23. })
  24. $(".Price-content").find("span:first-child").click(function(){
  25. $(this).addClass("active");
  26. $(".pricefat").removeClass("active");
  27. beforeSubmit();
  28. })
  29. $(".timer").find("ul li:first-child").click(function(){
  30. $(this).addClass("active");
  31. $(".timerInput").removeClass("active");
  32. })
  33. //
  34. $(".pricebut").click(function(){
  35. var minp = $("#minprice").val();
  36. var maxp = $("#maxprice").val();
  37. if (minp==""||maxp==""){
  38. return false;
  39. }
  40. if (minp>maxp){
  41. $("#minprice").val(maxp);
  42. $("#maxprice").val(minp);
  43. }
  44. $(this).hide();
  45. $(".pricefat").addClass("active");
  46. $(".Price-content").find("span:first-child").removeClass("active");
  47. $(".pricefat").removeClass("customtime-active");
  48. beforeSubmit()
  49. })
  50. //
  51. $("#timebut").click(function(){
  52. $(this).hide();
  53. $(".timerInput").addClass("active");
  54. $(".timerInput").removeClass("customtime-active");
  55. $(".timer").find("ul li:first-child").removeClass("active");
  56. $(".release-time .timer li").removeClass("active");
  57. beforeSubmit()
  58. })
  59. //
  60. $(".nbprev").click(function(){
  61. $(window).scrollTop(0);
  62. prev();
  63. })
  64. $(".nbnext").click(function(){
  65. $(window).scrollTop(0);
  66. next();
  67. })
  68. //筛选关闭和打开
  69. //根据cookie值设置筛选是否显示
  70. var rsw = localStorage.getItem("hideorshow");
  71. if(rsw==null){
  72. setTimeout(function(){
  73. $(".searchTender").stop(false,true).slideDown(1000);
  74. localStorage.setItem("hideorshow", "D");
  75. },500);
  76. }else{
  77. if(rsw=="U"){
  78. $("#screenBtn").addClass("down");
  79. $(".searchTender").hide();
  80. }else{
  81. $("#screenBtn").removeClass("down");
  82. $(".searchTender").show();
  83. }
  84. }
  85. //记录用户刷选按钮状态
  86. $("#screenBtn").click(function(){
  87. if($(this).attr("class").indexOf("down")>0){
  88. localStorage.setItem("hideorshow", "U");
  89. }else{
  90. localStorage.setItem("hideorshow", "D");
  91. }
  92. })
  93. //
  94. $("#zbSeatchT input[type='button']").click(function(){
  95. beforeSubmit()
  96. })
  97. })
  98. //
  99. function next(){
  100. if($(".nbnext").hasClass("disabled")){
  101. return false;
  102. }
  103. var page = parseInt($(".pagination-inner").find("span").text())+parseInt(1)
  104. if(!nbflag&&page<11){
  105. if(page==10){
  106. $(".nbnext").addClass("disabled");
  107. }else if(page==2){
  108. $(".nbprev").removeClass("disabled");
  109. }
  110. getNewBiddings(page)
  111. }
  112. }
  113. function prev(){
  114. if($(".nbprev").hasClass("disabled")){
  115. return false;
  116. }
  117. var page = parseInt($(".pagination-inner").find("span").text())-parseInt(1)
  118. if(!nbflag&&page>0){
  119. if(page==1){
  120. $(".nbprev").addClass("disabled");
  121. }else if(page==9){
  122. $(".nbnext").removeClass("disabled");
  123. }
  124. getNewBiddings(page)
  125. }
  126. }
  127. ////最新招标信息
  128. function getNewBiddings(page){
  129. currentPage = page
  130. if(page==1){
  131. $(".nbprev").addClass("disabled");
  132. }
  133. var param = {
  134. pageNumber: currentPage,
  135. reqType: "lastNews",
  136. searchvalue: $("#zbSeatchT [name='searchvalue']").val(),
  137. area: $("#zbSeatchT [name='area']").val(),
  138. subtype: $("#zbSeatchT [name='subtype']").val(),
  139. publishtime: $("#zbSeatchT [name='publishtime']").val(),
  140. selectType : $("#zbSeatchT [name='selectType']").val(),
  141. minprice : $("#zbSeatchT [name='minprice']").val(),
  142. maxprice : $("#zbSeatchT [name='maxprice']").val(),
  143. industry : $("#zbSeatchT [name='industry']").val(),
  144. };
  145. $.post("/front/pcAjaxReq",param,function(r){
  146. if(r&&r.list!=null&&r.list.length>0){
  147. $(".tabContainer").show();
  148. $(".pagination").show();
  149. $(".hasNoData").hide();
  150. $(".pagination-inner").find("span").text(page);
  151. if(r.list.length<pageSize||page==10){
  152. $(".nbnext").addClass("disabled");
  153. }else{
  154. $(".nbnext").removeClass("disabled");
  155. }
  156. appendDatas(r.list,false);
  157. }else{
  158. $(".tabContainer").hide();
  159. $(".pagination").hide();
  160. $(".hasNoData").show();
  161. }
  162. })
  163. }
  164. //
  165. function appendDatas(datas,flag){
  166. var listHtml = '';
  167. var tableHtml = '';
  168. var searchvalue = '';
  169. for(var i=0;i<datas.length;i++){
  170. var index = (currentPage - 1) * pageSize + i + 1;
  171. var title = datas[i].title;
  172. var detail = datas[i].detail;
  173. if(flag){
  174. title = keyWordHighlight(title,searchvalueArray.join("|"),"<font class='com-highlight'>$1</font>");
  175. detail = keyWordHighlight(detail,searchvalueArray.join("|"),"<font class='com-highlight'>$1</font>");
  176. }
  177. var href = datas[i].href.replace(/\n/g,"");
  178. var aHref = '/article/content/'+datas[i]._id;
  179. if(searchvalue != ""){
  180. aHref += '.html?kds='+searchvalue;
  181. }else{
  182. aHref += '.html';
  183. }
  184. var type = datas[i].subtype;
  185. if(typeof(type) == "undefined" || type == null || type == ""){
  186. type = datas[i].toptype;
  187. }
  188. if(typeof(type) == "undefined" || type == null || type == ""){
  189. type = datas[i].type;
  190. if(type == "bid"){
  191. type = "中标";
  192. datas[i].stypeadd="ZHB"
  193. }else if(type == "tender"){
  194. datas[i].stypeadd="ZB"
  195. type = "招标";
  196. }else{
  197. type = "";
  198. }
  199. }
  200. if(!flag){
  201. $("#allnews").hide();
  202. $(".tabContainer-2").show();
  203. }else{
  204. $("#allnews").show();
  205. $(".tabContainer-2").hide();
  206. }
  207. listHtml += '<li>'
  208. +'<div class="liLuceneList">'
  209. +'<div class="luce-left"><em>'+index+'.</em>'
  210. +'<div class="left-title">'
  211. +'<a href="'+aHref+'"> '+title+'</a>'
  212. +'</div>'
  213. if(flag){
  214. listHtml += '<div class="left-content">'
  215. +'<a href="'+aHref+'">'+detail+'...</a>'
  216. +'</div>'
  217. }
  218. listHtml += '</div><div class="luce-right">'
  219. if($.trim(datas[i].area) != "" && datas[i].area != "A"){
  220. listHtml += '<a href="/list/area/'+datas[i].areaadd+'.html">'+datas[i].area+'</a>';
  221. }else{
  222. listHtml += '<a href="#" style="display:none;"></a>';
  223. }
  224. if(typeof(type) != "undefined" && type != null && type != ""){
  225. listHtml += '<a href="/list/stype/'+datas[i].stypeadd+'.html">'+type+'</a>';
  226. }else{
  227. listHtml += '<a href="#" style="display:none;"></a>';
  228. }
  229. //
  230. if(typeof(datas[i].industry) != "undefined" && datas[i].industry != null && datas[i].industry != ""){
  231. listHtml += '<a href="#">'+datas[i].industry+'</a>';
  232. }else{
  233. listHtml += '<a href="#" style="display:none;"></a>';
  234. }
  235. //
  236. if(typeof(datas[i].publishtime) != "undefined" && datas[i].publishtime != null && datas[i].publishtime != ""){
  237. var diff = timeDiff(new Date(Number(datas[i].publishtime+"000")));
  238. if(diff != null){
  239. listHtml += '<span class="com-time">'+diff+'</span>';
  240. }
  241. }
  242. listHtml += '</div></li>';
  243. tableHtml +='<tr>'
  244. +'<td><div>'+index+'</div></td>'
  245. if(typeof(datas[i].publishtime) != "undefined" && datas[i].publishtime != null && datas[i].publishtime != ""){
  246. var diff = formatDate(Number(datas[i].publishtime),"s");
  247. if(diff != null){
  248. tableHtml += '<td><div>'+diff+'</div></td>';
  249. }
  250. }else{
  251. tableHtml += '<td><div></div></td>';
  252. }
  253. if(typeof(type) != "undefined" && type != null && type != ""){
  254. tableHtml += '<td><div>'+type+'公告</div></td>';
  255. }else{
  256. tableHtml += '<td><div></div></td>';
  257. }
  258. if(typeof(datas[i].agency) != "undefined" && datas[i].agency != null && datas[i].agency != ""){
  259. tableHtml += '<td class="tt-l"><div>'+datas[i].agency+'</div></td>';
  260. }else{
  261. tableHtml += '<td class="tt-l"><div></div></td>';
  262. }
  263. if(typeof(datas[i].projectname) != "undefined" && datas[i].projectname != null && datas[i].projectname != ""){
  264. tableHtml += '<td class="tt-l"><div>'+datas[i].projectname+'</div></td>';
  265. }else{
  266. tableHtml += '<td class="tt-l"><div></div></td>';
  267. }
  268. if(typeof(datas[i].budget) != "undefined" && datas[i].budget != null && datas[i].budget != ""){
  269. var budget =parseInt(datas[i].budget)/10000
  270. if(budget.toString().length>6){
  271. if(budget.toString().indexOf(".")==5){
  272. budget=budget.toString().substr(0,7)
  273. }else{
  274. budget=budget.toString().substr(0,6)
  275. }
  276. }
  277. tableHtml += '<td class="tt-r"><div>'+budget+'</div></td>';
  278. }else{
  279. tableHtml += '<td class="tt-r"><div></div></td>';
  280. }
  281. if(typeof(datas[i].bidopentime) != "undefined" && datas[i].bidopentime != null && datas[i].bidopentime != ""){
  282. var diff = formatDate(Number(datas[i].publishtime),"l");
  283. tableHtml += '<td><div>'+diff+'</div></td>';
  284. }else{
  285. tableHtml += '<td><div></div></td>';
  286. }
  287. if(typeof(datas[i].winner) != "undefined" && datas[i].winner != null && datas[i].winner != ""){
  288. tableHtml += '<td class="tt-l"><div>'+datas[i].winner+'</div></td>';
  289. }else{
  290. tableHtml += '<td class="tt-l"><div></div></td>';
  291. }
  292. if(typeof(datas[i].bidamount) != "undefined" && datas[i].bidamount != null && datas[i].bidamount != ""){
  293. var bidamount = parseInt(datas[i].bidamount)/10000
  294. if(bidamount.toString().length>6){
  295. if(bidamount.toString().indexOf(".")==5){
  296. bidamount=bidamount.toString().substr(0,7)
  297. }else{
  298. bidamount=bidamount.toString().substr(0,6)
  299. }
  300. }
  301. tableHtml += '<td class="tt-r"><div>'+bidamount+'</div></td>';
  302. }else{
  303. tableHtml += '<td class="tt-r"><div></div></td>';
  304. }
  305. tableHtml+='</tr>'
  306. }
  307. $(".tabContainer-2 .lucene ul").html(listHtml);
  308. $(".tabContainer-2 .lucene-table table tbody").html(tableHtml);
  309. backTopAdjust();
  310. }
  311. //
  312. //
  313. function formatDate(date,sl) {
  314. var myDate = new Date(date*1000);
  315. var year=myDate.getFullYear();
  316. var month=myDate.getMonth()+1;
  317. // if(month<10){
  318. // month="0"+month
  319. // }
  320. var date=myDate.getDate();
  321. // if(date<10){
  322. // date="0"+date
  323. // }
  324. var hour = myDate.getHours()
  325. var min = myDate.getMinutes()
  326. if(sl=="l"){
  327. if(hour<10){
  328. hour="0"+hour
  329. }
  330. if(min<10){
  331. min="0"+min
  332. }
  333. return year+"-"+month+"-"+date+"<br>"+hour+":"+min;
  334. }else{
  335. return year+"-"+month+"-"+date;
  336. }
  337. }
  338. //
  339. function onpicking(dp,obj){
  340. var time = new Date(dp.cal.newdate.y,dp.cal.newdate.M-1,dp.cal.newdate.d).getTime()+"";
  341. time = time.substring(0,time.length - 3);
  342. $(obj).attr("data-value",time);
  343. }
  344. //
  345. function onclearing(obj){
  346. $(obj).attr("data-value","");
  347. //localStorage.removeItem($(obj).attr("id"))
  348. if($(".customtime").hasClass("active") && getInputTime().join("") == ""){
  349. $(".customtime").removeClass("active");
  350. $("#publishtime #alltime").addClass("active");
  351. }
  352. }
  353. //
  354. function picked(dp,obj){
  355. //localStorage.setItem($(obj).attr("id"),$(obj).val()+"_"+$(obj).attr("data-value"))
  356. }
  357. //
  358. function getInputTime(){
  359. var starttime = $("#starttime").attr("data-value");
  360. if(starttime){
  361. starttime = $.trim(starttime);
  362. }else{
  363. starttime = "";
  364. }
  365. var endtime = $("#endtime").attr("data-value");
  366. if(endtime){
  367. endtime = $.trim(endtime);
  368. }else{
  369. endtime = "";
  370. }
  371. return [starttime,endtime]
  372. }
  373. ///
  374. function beforeSubmit(){
  375. setTimeout(function(){
  376. //时间
  377. var publishtime = null;
  378. var timeslot = getInputTime().join("_");
  379. if($(".timerInput").hasClass("active")){
  380. if(timeslot != "_"){
  381. $("#zbSeatchT [name='publishtime']").val(timeslot);
  382. }else{
  383. $("#zbSeatchT [name='publishtime']").val("");
  384. }
  385. }else{
  386. publishtime = $(".timer .active").attr("data-value");
  387. if(typeof(publishtime) != "undefined"){
  388. $("#zbSeatchT [name='publishtime']").val(publishtime);
  389. }else{
  390. $("#zbSeatchT [name='publishtime']").val("");
  391. }
  392. }
  393. if(timeslot != "_"){
  394. $("#zbSeatchT [name='timeslot']").val(timeslot);
  395. }else{
  396. $("#zbSeatchT [name='timeslot']").val("");
  397. }
  398. //地区
  399. var selectAreas = "";
  400. $(".region-content .active:not(.parent-node)").each(function(){
  401. var thisText = $(this).text();
  402. if(thisText != "全国"){
  403. if(selectAreas != ""){
  404. selectAreas += ",";
  405. }
  406. selectAreas += thisText;
  407. }
  408. });
  409. $("#zbSeatchT [name='area']").val(selectAreas);
  410. //类型
  411. var selectSubTypes = "";
  412. $(".info-content .active:not(.parent-node)").each(function(){
  413. if($(this).attr("id") == "whole"||$(this).attr("id") == "infoBtn"){
  414. return true;
  415. }
  416. var thisText = $(this).attr("data-value");
  417. if(selectSubTypes != ""){
  418. selectSubTypes += ",";
  419. }
  420. selectSubTypes += thisText;
  421. });
  422. $("#zbSeatchT [name='subtype']").val(selectSubTypes);
  423. //行业
  424. var selectIndustrys = "";
  425. $(".industry-content .active:not(.parent-node)").each(function(){
  426. if($(this).attr("id") == "induAll"){
  427. return true;
  428. }
  429. var thisText = $(this).attr("data-value");
  430. if(selectIndustrys != ""){
  431. selectIndustrys += ",";
  432. }
  433. selectIndustrys += thisText;
  434. });
  435. $("#zbSeatchT [name='industry']").val(selectIndustrys);
  436. //价格
  437. var selectMinPrices = $(".PriceInput [name='minprice']").val();
  438. var selectMaxPrices = $(".PriceInput [name='maxprice']").val();
  439. $("#zbSeatchT [name='minprice']").val(selectMinPrices);
  440. $("#zbSeatchT [name='maxprice']").val(selectMaxPrices);
  441. //搜索关键词
  442. var searchname = $("#zbSeatchT input[name='keywords']").val();
  443. $("#zbSeatchT input[name='searchvalue']").val($.trim(searchname))
  444. if(submitflag){
  445. if($.trim(searchname)==""){
  446. getNewBiddings(1)
  447. nbflag = false;
  448. console.log(nbflag+"-----")
  449. }else{
  450. searchOnsubmit();
  451. nbflag = true;
  452. console.log("2222")
  453. }
  454. submitflag=false;
  455. }
  456. setTimeout(function(){
  457. submitflag=true
  458. },200);
  459. return true
  460. },200)
  461. }
  462. //
  463. function searchOnsubmit(){
  464. var param = {
  465. pageNumber: currentPage,
  466. reqType: "bidSearch",
  467. searchvalue: $("#zbSeatchT [name='searchvalue']").val(),
  468. area: $("#zbSeatchT [name='area']").val(),
  469. subtype: $("#zbSeatchT [name='subtype']").val(),
  470. publishtime: $("#zbSeatchT [name='publishtime']").val(),
  471. selectType : $("#zbSeatchT [name='selectType']").val(),
  472. minprice : $("#zbSeatchT [name='minprice']").val(),
  473. maxprice : $("#zbSeatchT [name='maxprice']").val(),
  474. industry : $("#zbSeatchT [name='industry']").val(),
  475. };
  476. $.post("/front/pcAjaxReq",param,function(r){
  477. if(r.list == null || r.list.length == 0){
  478. }else{
  479. appendDatas(r.list,true)
  480. }
  481. });
  482. }