var search_tit,search_page=0 var data1 function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } if(getQueryVariable('keywords')){//第一次打开页面判断keywords是否有值 search_click(0,getQueryVariable('keywords')) } var yema=true,fanye=false $('.f_button').on('click',function(){//搜索按钮触发 var inpCont = $('input[name=input_ss]').val(); //inpCont=encodeURI(inpCont) if (inpCont.replace(/(^\s*)|(\s*$)/g, "") != "") { search_click(search_page,inpCont) $('.invalid-feedback').hide() }else{ $('.invalid-feedback').show() } yema=true,fanye=false console.log('搜索按钮触发') }) function search_click(search_page,search_tit){ console.log(search_page+','+search_tit) var data1 = { "from": search_page*10, "size": 10, "sort":{ "DETAIL_ES.es_date_prePublishTime":"desc" }, "query": { "function_score": { "min_score": 0.000001, "query": { "bool": { "should": [ { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20677" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_zshtc": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.tsaob": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20679" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_zshtc": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.tsaob": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20681" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_zshtc": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.tsaob": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20689" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_rudao": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.zdlcm": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20690" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_uzjhi": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.zdlcm": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20692" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_uzjhi": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.zdlcm": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135174" } }, { "term": { "TID": "20693" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_rudao": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.zdlcm": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135491" } }, { "term": { "TID": "20859" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_uzjhi": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.tsaob": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135491" } }, { "term": { "TID": "20860" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_uzjhi": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.tsaob": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135491" } }, { "term": { "TID": "22475" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "135491" } }, { "term": { "TID": "23648" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "DETAIL_ES.es_symbol_tsaob": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.yjpqi": search_tit } } ] } }, { "bool": { "filter": [ { "term": { "_index": "cms_site_low_code" } }, { "term": { "TENANT_ID": 282178 } }, { "term": { "appId": "141309" } }, { "term": { "TID": "23075" } } ], "should": [ { "match_phrase": { "DETAIL_ES.es_symbol_entityTitle": search_tit } }, { "match_phrase": { "TEXT_DETAIL_ES.es_text_des": search_tit } }, { "match_phrase": { "CONTENT.zdlcm": search_tit } } ] } } ] } } } } } $.ajax({ url: "/nportal/fwebapi/cms/lowcode/totalStationSearch", type: "POST", data: JSON.stringify(data1), cache: false, dataType: "json", contentType: "application/json;charset=utf8", success: function (data) { var TotalData=data.data.result.list console.log(data.data.result) var DataHtml='' $('.s_length .p_resNum').html(data.data.result.page.totalCount) $('.s_length').show() if(yema){ yema=false function getOptionsFromForm(){ var opt = { callback: pageselectCallback, items_per_page:1,//每页显示的个数 num_display_entries:3,//...前面显示出来的页数 num_edge_entries:1, //最后留的页数 prev_text:'<', next_text:'>', link_to:'javascript:;', load_first_page : true }; return opt; } var num_entries = Math.ceil(data.data.result.page.totalCount / 10); optInit = getOptionsFromForm(); $(".pagination_box").pagination(num_entries, optInit) function pageselectCallback(page_index, jq) { if(fanye){ search_click(page_index,search_tit) } fanye=true } } for(var i=0;i' }else if(TotalData[i].TID=='20689'||TotalData[i].TID=='20690'||TotalData[i].TID=='20692'||TotalData[i].TID=='20693'){ if(TotalData[i].batjp) img = '
' }else if(TotalData[i].TID=='23648'){ if(TotalData[i].zdlcm) img = '
' }else if(TotalData[i].TID=='23075'){ if(TotalData[i].tsaob) img = '
' } var source='' switch (TotalData[i].TID) { case '20677': source='发布荟' break; case '20679': source='学习荟' break; case '20681': source='风采荟' break; case '20689': source='公告栏' break; case '20690': source='时政要闻' break; case '20692': source='党务百科' break; case '20693': source='党建工作动态' break; case '20859': source='公司动态' break; case '20860': source='媒体报道' break; case '23648': source='Ftimes-列表' break; case '23075': source='专项报告' break; } var time=TotalData[i].prePublishTime time=time.substring(time.lastIndexOf("\-")+3, 0) DataHtml += '
' + img+''+time+'来源:'+source+'
' } //console.log(DataHtml) $('.search_result').html(DataHtml) $(".search_result .tit,.search_result .des").each(function () { var $key = $('input[name=input_ss]').val() var oP = $(this).text(); oP = oP.replace(new RegExp($key, "isg"), "" + $key + ""); // oP = oP.split($key).join("" + $key + ""); // 两者选其一都行。逻辑:先匹配之后再进行整体输出 $(this).html(oP); }); DataHtml='' }, error: function (err) {} }) }