var urlPrefix = ''; var lang = 'i18n_zh_CN'; var language = 'chinese'; var owner = ''; var token = ''; var headerOwner = ''; var keyWord = ''; var advance = false; var advanceKeyWord = ''; var orderType = 'date'; var searchScope = '1'; var beginDate = ''; var endDate = Vue.formatDate(new Date(), 'yyyy-MM-dd'); var searchDateName = 'time.any_time'; var searchOperator = 1; var searchDateType = ''; var isExpanded=false; /* var isTouch = 'ontouchstart' in window ? true : false; if (false) { if (window.location.href.indexOf('/resultmobile/') < 0) { window.location.href = window.location.href.replaceAll('/resultpc/', '/resultmobile/'); } } else { if (window.location.href.indexOf('/resultpc/') < 0) { window.location.href = window.location.href.replaceAll('/resultmobile/', '/resultpc/'); } } */ var params; try { params = JSON.parse(new Base64().decode(getUrlParam('query'))); } catch (err) {} if (params && params['lang']) { lang = params['lang']; } if (params && params['language']) { language = params['language']; } if (params && params['keyWord']) { keyWord = params['keyWord']; } if (params && params['advance']) { advance = params['advance']; } if (params && params['advanceKeyWord']) { advanceKeyWord = params['advanceKeyWord']; } if (params && params['owner']) { owner = params['owner']; } if (params && params['token']) { // 如果token里有html标签,则token为游客 if (containsHtmlTags(params['token'])) { token='tourist' } else { token = params['token'] ? params['token'].replace(/\r\n/g, '') : 'tourist'; } } if(params&&!params['token']){ token='tourist' } if (params && params['headerOwner']) { headerOwner = params['headerOwner']; } if (owner && !headerOwner) { headerOwner = owner; } if (params && params['urlPrefix']) { urlPrefix = params['urlPrefix']; } if (params && params['orderType']) { orderType = params['orderType']; } if (params && params['searchScope']) { searchScope = params['searchScope']; } if (params && params['searchDateType']) { searchDateType = params['searchDateType']; } if (params && params['searchOperator']) { searchOperator = params['searchOperator']; } if ('week' == searchDateType) { searchDateName = 'time.past_week'; } if ('month' == searchDateType) { searchDateName = 'time.past_month'; } if ('year' == searchDateType) { searchDateName = 'time.past_year'; } if ('all' == searchDateType) { searchDateName = 'time.past_all'; } if (params && params['endDate']) { endDate = params['endDate']; } if (params && params['beginDate']) { beginDate = params['beginDate']; } if (beginDate) { searchDateName = beginDate + '-' + endDate; } jQuery.support.cors = true; $.ajaxSetup({ beforeSend: function (request, settings) { request.setRequestHeader('Authorization', token); request.setRequestHeader('owner', headerOwner); request.setRequestHeader('appId', 'app-search'); request.setRequestHeader('resolutionRatio', window.screen.width + '*' + window.screen.height); }, complete: function (xhr, status) { if (this.url.indexOf('configTemplate') > -1) { var x = xhr.responseJSON; if (x['code'] == '9999') { alert(result['msg']); } } } }); $(document).ready(function () { var i18n = new VueI18n({ locale: lang, messages: messages }); new Vue({ el: '#searchdiv', i18n: i18n, data: function () { return { dataReady: false, loadOver: false, query: { aliasName: 'article_data,open_data', keyWord: keyWord, lastkeyWord: keyWord, searchKeyWord: false, orderType: orderType, searchType: 'text', searchScope: searchScope, searchOperator: searchOperator, searchDateType: searchDateType, searchDateName: searchDateName, beginDate: beginDate, endDate: endDate, language: language, showId: '', auditing: ['1', '5'], owner: owner, token: token, urlPrefix: urlPrefix, filterTerm: { wbsourceid: ['0', '6'] }, page: { current: 0, size: 10, pageSizes: [2, 5, 10, 20, 50, 100], total: 0, totalPage: 0, indexs: [] }, advance: advance, advanceKeyWord: advanceKeyWord, jumpPageNum: '', lang: lang }, config: { searchLogo: '', searchLogoWidth: '304px', searchLogoHeight: '64px', searchBackground: '#425FEE', searchCopyright: '
Copyright© 2015 All Rights Reserved. 高校网站版权所有 京ICP备15000288 号
', searchLogoClick: window.location.origin, src: '/aop_views/search/modules/resultpc/images/soso/sosologo.png', searchPicture: '', searchPictureRepeat: '', searchTitle: '智能搜索' }, oldKeyWord: '', realKeyWord: '', searchHistory: [], onlymysite: false, showData: [], showHotData: [], topSearchData: [], tableData: [], suggestData: [], indexBoxPages: [], indexAppPages: [], local: i18n.t('local'), messages: messages, fingerId: '', isError: false, isLoading: true, isLoadMore: false, loadMoreDone: false, switch_: true, ajaxError: '', isOpenAdvance: false, isExpanded:false, q1:"", q3:"", q4:"", searchOrderTypeinit: '', searchQeruyTypeinit: '' }; }, mounted: function () { this.generateFingerId(); this.hasFingerId(); this.loadTemplate(); this.getTopSearch(); this.getHistory(); var _this_ = this; window.addEventListener('scroll', function () { if (!_this_.loadMoreDone) { if (document.body.offsetWidth < 800) { if (window.pageYOffset + window.innerHeight + 80 >= document.body.offsetHeight) { if (_this_.switch_ == true) { _this_.switch_ = false; this.setTimeout(function () { _this_.loadMore(); }, 300); } } } } }); }, computed: function () { if (this.query.isError) { } }, watch: { currentPage: { handler: function (newValue, oldValue) {} }, pageSize: { handler: function (newValue, oldValue) {} }, 'query.keyWord': { handler: function (newValue, oldValue) { if (newValue == '') { this.suggestData = []; $('.sosoNew').hide(); return; } var _this = this; for (i in _this.$data.showHotData) { if (_this.$data.showHotData[i]['hotWord'] == newValue) { $('.sosoNew').hide(); return; } } } }, 'query.searchDateType': { handler: function (newValue, oldValue) { if (newValue == 'custom') { $('.zdydate').show(); } else { $('.zdydate').hide(); } } } }, methods: { hasFingerId: function () { var _this = this; if (_this.fingerId == '') { setTimeout(function () { _this.hasFingerId(); }, 200); return; } window.localStorage && window.localStorage.setItem('fingerId', _this.fingerId); }, generateFingerId: function () { var _this = this; (function () { if (window.localStorage && window.localStorage.getItem('fingerId') && window.localStorage.getItem('fingerId') != '') { _this.fingerId = window.localStorage.getItem('fingerId'); return; } if (window.requestIdleCallback) { requestIdleCallback(function () { Fingerprint2.get(function (components) { var values = components.map(function (component) { return component.value; }); _this.fingerId = Fingerprint2.x64hash128(values.join(''), 31); }); }); } else { setTimeout(function () { Fingerprint2.get(function (components) { var values = components.map(function (component) { return component.value; }); _this.fingerId = Fingerprint2.x64hash128(values.join(''), 31); }); }, 500); } })(); }, changeLangEvent: function (key) { this.query.lang = key; this.$i18n.locale = this.query.lang; this.local = messages[key]['local']; }, getConfig: function () { var _this = this; $.ajax({ url: urlPrefix + '/webber/search/search/manage/configTemplate/owner' + '?r=' + Math.random(), data: {}, type: 'get', dataType: 'json', success: function (response) { if (response['code'] == '9999') { alert(response['msg']); return; } if(response.code=="0000"){ var data = response.data; if (data['searchLogo']) { _this.$data.config['searchLogo'] = data['searchLogo']; } if(data['searchOrderType']) { _this.$data.searchOrderTypeinit = data['searchOrderType'] == '1'? 'date': 'score'; _this.$data.query.orderType = data['searchOrderType'] == '1'? 'date': 'score'; } if(data['searchQeruyType']) { _this.$data.searchQeruyTypeinit = data['searchQeruyType'] == '1'? '1': '3'; _this.$data.query.searchScope = data['searchQeruyType'] == '1'? '1': '3'; } if (data['searchLogoWidth']) { _this.$data.config['searchLogoWidth'] = data['searchLogoWidth']; } if (data['searchLogoHeight']) { _this.$data.config['searchLogoHeight'] = data['searchLogoHeight']; } if (data['searchBackground']) { _this.$data.config['searchBackground'] = data['searchBackground']; } if (data['searchCopyright']) { _this.$data.config['searchCopyright'] = data['searchCopyright']; } if (data['searchLogoClick']) { _this.$data.config['searchLogoClick'] = data['searchLogoClick']; } if (data['searchTitle']) { _this.$data.config['searchTitle'] = data['searchTitle']; } if (data['searchPicture']) { _this.$data.config['searchPicture'] = data['searchPicture']; } if (data['searchPictureRepeat']) { _this.$data.config['searchPictureRepeat'] = data['searchPictureRepeat']; } $('title').text(_this.$data.config['searchTitle']); if (data['searchLanguage']) { var arr = [ { lang: 'i18n_zh_CN', language: 'chinese' }, { lang: 'i18n_en_US', language: 'english' }, { lang: 'i18n_ru_RU', language: 'russian' }, { lang: 'i18n_fr_FR', language: 'french' }, { lang: 'i18n_es_ES', language: 'spanish' }, { lang: 'i18n_de_DE', language: 'german' } ]; _this.$data.query['language'] = data['searchLanguage']; } _this.changeBackground(); _this.getShowData(); } }, error: function (e) { _this.isError = true; _this.isLoading = false; } }); }, backTop: function () { window.scrollTo({ top: 0, behavior: 'smooth' }); }, getTopSearch: function () { var _this = this; $.ajax({ url: urlPrefix + '/webber/search/search/manage/statistics/topSearch' + '?r=' + Math.random(), data: {}, type: 'get', dataType: 'json', success: function (response) { if (response.code == 220) { alert(response['msg']); _this.isError = true; _this.isLoading = false; return; } var data = response.data; if (data.topTitles && data.topTitles.length > 0) { _this.$data.topSearchData = data.topTitles; } }, error: function (e) { _this.isError = true; _this.isLoading = false; } }); }, addStyle: function (element, style) { element.appendChild(document.createTextNode(style)); }, changeBackground: function () { var _this = this; var picture = _this.config.searchPicture; if (picture) { var searchPictureRepeat = _this.config.searchPictureRepeat; var pictureurl = urlPrefix + '/filesystem/fileshow/' + picture; if (picture.indexOf('/search') == 0) { pictureurl = urlPrefix + '/search/search/file/fileshow' + picture; } else { pictureurl = urlPrefix + '/filesystem/fileshow/' + picture; } if (searchPictureRepeat) { $('.sosoHead').css({ background: "url('" + pictureurl + "') " + searchPictureRepeat + ' left top ' }); } else { $('.sosoHead').css({ 'background-image': "url('" + pictureurl + "')" }); } } var logo = _this.config.searchLogo; if (!logo) { _this.config.src = '/aop_views/search/modules/resultpc/images/soso/sosologo.png'; } else { if (logo.indexOf('http://') == 0) { _this.config.src = logo; } else if (logo.indexOf('./') == 0) { _this.config.src = logo; } else if (logo.indexOf('/search') == 0) { _this.config.src = urlPrefix + '/search/search/file/fileshow' + logo; } else { _this.config.src = urlPrefix + '/filesystem/fileshow/' + logo + '?r=' + Math.random(); } } _this.$nextTick(function () { objectFitImages(); setTimeout(function () { objectFitImages(); }, 100); }); var background = _this.config.searchBackground; var styleEl = document.createElement('style'); styleEl.type = 'text/css'; _this.addStyle(styleEl, 'A:hover { TEXT-DECORATION:none; color:' + background + ';}'); _this.addStyle(styleEl, '.sosoBox .btn{ float: right; width: 100px; line-height: 50px;cursor: pointer; height: 50px; background:' + background + '; border: none; border-bottom-right-radius: 5px; border-top-right-radius: 5px; font-size: 18px; color: #fff; letter-spacing: 3px;}'); _this.addStyle(styleEl, '.sosoMenu ul li:hover{height: 40px; line-height: 40px;}'); _this.addStyle(styleEl, '.sosoMenu ul li:hover a{ color: ' + background + '; }'); _this.addStyle(styleEl, '.sosoMenu ul li.hover{height: 40px; line-height: 40px; background: ' + background + '; color:#fff;}'); _this.addStyle(styleEl, '.sosoMenu ul li.hover a{ color: #fff; }'); _this.addStyle(styleEl, '.pxMenu ul li:hover{background: ' + background + '; border-radius: 3px;}'); _this.addStyle(styleEl, '.pxMenu ul li.hover{background: ' + background + '; border-radius: 3px;}'); _this.addStyle(styleEl, '.pxTie a:hover{ color: ' + background + ';}'); _this.addStyle(styleEl, '.pxTie a.hover{ color: ' + background + ';}'); _this.addStyle(styleEl, '.pageBox .sel{ background: ' + background + '; color: #fff;border-radius: 3px;}'); _this.addStyle(styleEl, '.pageBox1 .sel{ background: ' + background + '; color: #fff;border-radius: 3px;}'); _this.addStyle(styleEl, '.listBox div b{ padding: 0px 5px; line-height: 22px; height:22px; display: inline-block; background-color:transparent; border: ' + background + ' 1px solid; border-radius: 3px; color: ' + background + '; font-size: 15px; margin-right: 5px;}'); _this.addStyle(styleEl, '.sosoOperator .btn {margin: 36px 20px 30px 0px;width: 100px; line-height:' + ' 50px;cursor: pointer; height: 50px; border: none; border-bottom-right-radius: 5px;' + ' border-top-right-radius: 5px; border-radius: 5px;color: #fff; letter-spacing: 3px; background-color: ' + background + ';}'); _this.addStyle(styleEl, '.searchad_box input[type="button"]{ background: ' + background + ';}'); _this.addStyle(styleEl, '.gjjs .searchResult h1{ border-left: 3px solid ' + background + ';}'); _this.addStyle(styleEl,'.mainRig{ border-color:'+background+'}'); _this.addStyle(styleEl,'.mainRig ul li:hover a{ color:'+background+'}'); if (_this.query.lang == 'i18n_en_US') { _this.addStyle(styleEl, '.searchad_box .level label{margin-right: 16px;}'); _this.addStyle(styleEl, '.searchad_box .level .sec {width: 368px;}'); } document.head.appendChild(styleEl); }, getShowData: function () { var _this = this; $.ajax({ url: urlPrefix + '/webber/search/search/manage/show/list' + '?r=' + Math.random(), data: {}, type: 'get', dataType: 'json', success: function (response) { var data = response.data; if (window.screen.width < 900) { if (data.length > 0) { var _width = data.length * 120 + 'px'; $('.sosoMenu ul').css('width', _width); } else { $('.sosoMenu').css('overflow-x', 'auto'); $('.sosoMenu ul').css('height', '0px'); } } else { } _this.$data.showData = data; if (data.length > 0) { _this.query.showId = data[0]['id']; _this.query.aliasName = data[0]['mappingAlias']; _this.getHotData(); } _this.getData(); }, error: function (e) { _this.isError = true; _this.isLoading = false; } }); }, jumpToPage: function () { var _this = this; var reg = /^[1-9]+[0-9]*$/; if (_this.query.jumpPageNum == '') { alert('请输入跳转的页码'); return; } if (!reg.test(_this.query.jumpPageNum)) { alert('请输入大于0的正整数'); return; } if (_this.query.jumpPageNum > _this.query.page.totalPage) { _this.query.jumpPageNum = _this.query.page.totalPage; } _this.query.page.current = _this.query.jumpPageNum - 1; _this.getData(); }, getHotData: function () { var _this = this; var query = {}; query['showId'] = _this.query.showId; $.ajax({ url: urlPrefix + '/webber/search/search/manage/showHot/list' + '?r=' + Math.random(), data: query, type: 'get', dataType: 'json', success: function (response) { if(response.code == '0000'){ var data = response.data; _this.$data.showHotData = data; }else { _this.ajaxError = response.msg; _this.isError = true; _this.isLoading = false; } }, error: function (e) { _this.isError = true; _this.isLoading = false; } }); }, getData: function (e) { var _this = this; _this.loadOver = true; var query = _this.$data.query; if (_this.query.keyWord == null || _this.query.keyWord == '') { if (_this.query.lastkeyWord == null || _this.query.lastkeyWord == '') { _this.isLoading = false; alert(i18n.t('search.search_alert')); return; } else { _this.$data.query.keyWord = _this.query.lastkeyWord; } } _this.isLoading = true; _this.$forceUpdate(); if (_this.query.advance) { if(_this.q1) { $('#q1').val(_this.q1); } if(_this.q3) { $('#q3').val(_this.q3); } if(_this.q4) { $('#q4').val(_this.q4); } $('.gjjs').show(); $('.gjjs').slideDown(100); var advanceKeyWord = ''; var searchKeyWord = ''; if ($('#q1').val()) { advanceKeyWord = advanceKeyWord + $('#q1').val(); searchKeyWord = searchKeyWord + ' ' + i18n.t('search_advanced.search_contains') + ' ' + $('#q1').val(); } if ($('#q3').val()) { advanceKeyWord = advanceKeyWord + ' AND ' + $('#q3').val(); searchKeyWord = searchKeyWord + ' ' + i18n.t('search_advanced.search_contains') + ' ' + $('#q3').val(); } if ($('#q4').val()) { advanceKeyWord = advanceKeyWord + ' NOT ' + $('#q4').val(); searchKeyWord = searchKeyWord + ' ' + i18n.t('search_advanced.search_not_included') + ' ' + $('#q4').val(); } _this.query.keyWord=searchKeyWord } else { $('.gjjs').hide(); } var data = {}; var data = { jsessionId: _this.fingerId, keyWord: _this.query.keyWord, createDate: _this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'), index: '', indexId: '', url: '', title: '', type: 'clickButton' }; $.ajax({ url: _this.query.urlPrefix + '/webber/search/search/search/clickButton' + '?r=' + Math.random(), data: data, crossDomain: true, type: 'post', dataType: 'json', success: function (response) {}, error: function (e) {} }); var temp = query['keyWord']; if (_this.query.advance) { query['keyWord'] = advanceKeyWord; } if(!query['token']){ query.token="tourist" } // 全英文的情况下走模糊搜索,否则精准检索; if(/^[a-zA-Z]+$/.test(query["keyWord"])) { query.isMatchQuery = true; } else { query.isMatchQuery = false; } $.ajax({ url: urlPrefix + '/webber/search/search/search/queryPage' + '?r=' + Math.random(), data: JSON.stringify(query), crossDomain: true, type: 'post', contentType: 'application/json;charset=utf-8', dataType: 'json', success: function (response) { if (_this.query.advance) { query['keyWord'] = temp; } if (response.code == '0000') { _this.isError = false; _this.isLoading = false; if (e) { var data = response.data.page; if(data.records==null){ _this.$data.tableData=[]; }else{ for (var index = 0; index < data.records.length; index++) { _this.$data.tableData.push(data.records[index]); } } if(_this.$data.tableData.length>0){ $(".sosoRig .sosoBox #keyWord").val(query.keyWord) }else{ $(".sosoRig .sosoBox #keyWord").val("") $("#q1").val(""); $("#q3").val(""); $("#q4").val(""); } if (data.total <= _this.$data.tableData.length) { _this.$data.loadMoreDone = true; } if (data.records == null) { _this.$data.query.page.total = 0; } else { _this.$data.query.page.total = data.total; } $('.sosoNew').hide(); _this.isLoading = false; _this.switch_ = true; _this.dataReady = true; } else { var data = response.data.page; _this.$data.oldKeyWord = response.data.oldKeyWord; _this.$data.realKeyWord = response.data.realKeyWord; if(data.records==null){ _this.$data.tableData=[]; }else{ _this.$data.tableData=data.records; _this.$forceUpdate(); } if(_this.$data.tableData.length>0){ $(".sosoRig .sosoBox #keyWord").val(query.keyWord); if(_this.query.advance) { $("#q1").val(_this.q1); $("#q3").val(_this.q3); $("#q4").val(_this.q4); } }else{ $(".sosoRig .sosoBox #keyWord").val("") $(".sosoRig .sosoBox #queryadvancekeyWord").val("") $("#q1").val(""); $("#q3").val(""); $("#q4").val(""); } if (data.records == null) { _this.$data.query.page.total = 0; } else { _this.$data.query.page.total = data.total; } _this.$data.query.page.current = data.current; _this.$data.query.page.size = data.size; if (response.data.indexPages) { if (response.data.indexPages['box']) { _this.$data.indexBoxPages = response.data.indexPages['box']; } if (response.data.indexPages['app']) { _this.$data.indexAppPages = response.data.indexPages['app']; } } $('.sosoNew').hide(); _this.indexs(); _this.imagesStyle(_this.$data.indexBoxPages); _this.imagesStyle(_this.$data.indexAppPages); _this.addImagesStyle(_this.$data.tableData); $('html,body').animate({ scrollTop: $('#searchDiv') }, 1e3); _this.dataReady = true; } } else { _this.ajaxError = response.msg; _this.isError = true; _this.isLoading = false; } }, error: function (e) { _this.isError = true; _this.isLoading = false; } }); }, indexs: function () { var _this = this; _this.query.page.totalPage = Math.ceil(_this.query.page.total / _this.query.page.size); var left = 1; var right = _this.query.page.totalPage; var ar = []; if (_this.query.page.totalPage >= 10) { if (_this.query.page.current > 5 && _this.query.page.current < _this.query.page.totalPage) { left = _this.query.page.current - 4; if (_this.query.page.current + 5 > _this.query.page.totalPage) { right = _this.query.page.totalPage; } else { right = _this.query.page.current + 5; } } else { if (_this.query.page.current <= 10) { left = 1; right = 10; } else { right = _this.query.page.totalPage; left = _this.query.page.totalPage - 9; } } } while (left <= right) { ar.push(left); left++; } _this.query.page.indexs = ar; }, imagesStyle: function (data) { for (var i = 0; i < data.length; i++) { this.addImagesStyle(data[i]['records']); } }, addImagesStyle: function (data) { if (!data) { return; } for (var i = 0; i < data.length; i++) { if (data[i]['picture']) { for (var j = 0; j < data[i]['picture'].length; j++) { var img = new Image(); if (data[i]['picture'][j]['url']) { img.src = data[i]['picture'][j]['url']; } else if (data[i]['picture'][j]['shortCode']) { img.src = urlPrefix + '/filesystem/fileshow/' + data[i]['picture'][j]['shortCode']; } else { continue; } var _this = this; (function (i, j) { img.onload = function () { _this.judgeImagesPixel(img, data[i]['picture'][j]); }; })(i, j); } } } }, judgeImagesPixel: function (img, imgdata) { var i = img.width - img.height; if (i < -50) { imgdata['style'] = '1'; } else if (i < 50) { imgdata['style'] = '2'; } else { imgdata['style'] = '3'; } }, getSuggestData: function () { var timeID = null; var _this = this; clearTimeout(timeID) timeID = setTimeout(function () { var mlgbkeyWord=$(".inp").val(); var query = { aliasName: _this.query.aliasName, showId: _this.query.showId, keyWord: mlgbkeyWord }; $.ajax({ url: urlPrefix + '/webber/search/search/search/suggest' + '?r=' + Math.random(), data: JSON.stringify(query), type: 'post', contentType: 'application/json;charset=utf-8', dataType: 'json', success: function (response) { if (response.data != null) { var suggests = response.data.suggests; _this.$data.suggestData = suggests; if (suggests == null || suggests.length == 0) { $('.sosoNew').hide(); } else { if(_this.loadOver == false) { $('.sosoNew').show(); } } } }, error: function (e) { _this.isError = true; _this.isLoading = false; } }); }, 1000); }, getHistory: function () { if (window.localStorage) { var storage = window.localStorage; var localHisotry = storage['history'] && JSON.parse(storage['history']); if (localHisotry) { this.searchHistory = localHisotry; } } }, addSearchHistory: function (query) { var _this = this; _this.searchHistory = Array.prototype.reverse.call(_this.searchHistory); var index = _this.searchHistory.indexOf(query['keyWord']); if (index > -1) { _this.searchHistory.splice(index, 1); } _this.searchHistory.push(query['keyWord']); _this.searchHistory = Array.prototype.reverse.call(_this.searchHistory); if (window.localStorage) { var storage = window.localStorage; storage['history'] = JSON.stringify(_this.searchHistory); } else { _this.addCookie('searchHistory', _this.searchHistory); } }, addCookie: function (name, value, expireHours) { var cookieString = name + '=' + escape(value); if (expireHours > 0) { var date = new Date(); date.setTime(date.getTime + expireHours * 3600 * 1e3); cookieString = cookieString + '; expire=' + date.toGMTString(); } document.cookie = cookieString; }, getCookie: function (name) { var strCookie = document.cookie; var arrCookie = strCookie.split('; '); for (var i = 0; i < arrCookie.length; i++) { var arr = arrCookie[i].split('='); if (arr[0] == name) return arr[1]; } return ''; }, changeOrder: function (orderType) { var _this = this; _this.query.orderType = orderType; _this.$data.tableData=[]; _this.loadMoreDone = false; _this.query.page.current = 0; if (window.screen.width <= 900) { _this.isLoadMore = true; _this.getData(_this.isLoadMore); } else { _this.getData(); } }, changeSearchScope: function (searchScope) { var _this = this; _this.query.searchScope = searchScope; _this.$data.tableData=[]; _this.loadMoreDone = false; _this.query.page.current = 0; if (window.screen.width <= 900) { _this.isLoadMore = true; _this.getData(_this.isLoadMore); } else { _this.getData(); } }, minDate: function (time) { if (time <= new Date(this.$data.query.endDate)) { return false; } return true; }, maxDate: function (time) { if (this.$data.query.beginDate != '') { if (time >= new Date(this.$data.query.beginDate) && time <= new Date()) { return false; } } else { if (time < new Date()) { return false; } } return true; }, changeDate: function (dateType) { var _this = this; var beginDate = ''; var endDate = new Date(); if ('week' == dateType) { beginDate = new Date(new Date().setDate(new Date().getDate() - 7)); _this.query.searchDateName = 'time.past_week'; _this.query.beginDate = ''; } if ('month' == dateType) { beginDate = new Date(new Date().setDate(new Date().getMonth() - 1)); _this.query.searchDateName = 'time.past_month'; _this.query.beginDate = ''; } if ('year' == dateType) { beginDate = new Date(new Date().setDate(new Date().getFullYear() - 1)); _this.query.searchDateName = 'time.past_year'; _this.query.beginDate = ''; } if ('all' == dateType) { beginDate = new Date(new Date().setDate(new Date().getFullYear() - 10)); _this.query.searchDateName = 'time.past_all'; _this.query.beginDate = ''; } if ('custom' == dateType) { if (_this.query.beginDate == '') { alert(i18n.t('time.enter_start_time')); return; } beginDate = new Date(_this.query.beginDate); if (_this.query.endDate == '') { alert(i18n.t('time.enter_end_time')); return; } endDate = new Date(_this.query.endDate); _this.query.searchDateName = _this.formatDate(beginDate, 'yyyy-MM-dd') + '-' + _this.formatDate(endDate, 'yyyy-MM-dd'); _this.query.beginDate = _this.formatDate(beginDate, 'yyyy-MM-dd'); } _this.query.endDate = _this.formatDate(endDate, 'yyyy-MM-dd'); _this.query.searchDateType = dateType; _this.query.page.current = 0; $('.timeCon').hide(100); _this.getData(); }, formatDate: function (date, fmt) { if (arguments.length < 2) { fmt = 'yyyy-MM-dd HH:mm:ss'; } var _this = date; var o = { 'M+': _this.getMonth() + 1, 'd+': _this.getDate(), 'h+': _this.getHours() % 12 == 0 ? 12 : _this.getHours() % 12, 'H+': _this.getHours(), 'm+': _this.getMinutes(), 's+': _this.getSeconds(), 'q+': Math.floor((_this.getMonth() + 3) / 3), S: _this.getMilliseconds() }; if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (_this.getFullYear() + '').substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) { fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)); } } return fmt; }, changeShow: function (index, rows) { var row = rows[index]; var _this = this; _this.$data.tableData=[]; _this.loadMoreDone = false; _this.query.showId = row['id']; _this.query.aliasName = row['mappingAlias']; _this.query.page.current = 0; _this.getHotData(); $("#q1").val(_this.q1); $("#q3").val(_this.q3); $("#q4").val(_this.q4); if (window.screen.width <= 900) { _this.isLoadMore = true; _this.getData(_this.isLoadMore); } else { _this.getData(); } }, changeShowHot: function (index, rows) { var row = rows[index]; var _this = this; _this.query.keyWord = row['hotWord']; _this.query.page.current = 0; _this.getData(); }, changeSuggest: function (index, rows) { var row = rows[index]; var _this = this; _this.query.keyWord = row; _this.query.page.current = 0; $('.sosoNew').toggle(100); _this.getData(); }, changeOldKeyWord: function (keyWord) { var _this = this; _this.query.keyWord = keyWord; _this.query.searchKeyWord = true; _this.query.page.current = 0; _this.getData(); }, changeTopSearch: function (title, url) { var _this = this; var data = { jsessionId: _this.fingerId, createDate: this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'), url: url, title: title, type: 'clickTopSearch' }; $.ajax({ url: _this.query.urlPrefix + '/webber/search/search/search/clickUrl' + '?r=' + Math.random(), data: data, crossDomain: true, xhrFields: { withCredentials: true }, type: 'post', dataType: 'json', success: function (response) {}, error: function (e) {} }); if (url) { window.open(url); } }, changeSearchHistory: function (index, rows) { var row = rows[index]; var _this = this; var query = _this.query; query.keyWord = row; query.page.current = 0; var url = window.location.href; if (url.indexOf('?') > -1) { url = url.split('?')[0]; } window.open(url + '?query=' + new Base64().encode(JSON.stringify(query))); }, reload: function () { var _this = this; var query = _this.query; query.page.current = 0; var url = window.location.href; if (url.indexOf('?') > -1) { url = url.split('?')[0]; } window.location.href = url + '?query=' + new Base64().encode(JSON.stringify(query)); }, onSubmit: function (e) { $('.sosoNew').hide(); var _this = this; if (e === true) { _this.query.page.current++; } else { _this.query.page.current = 0; } _this.query.searchKeyWord = false; if (keyWord != _this.query.keyWord) { this.query.searchDateName = 'time.any_time'; this.query.searchDateType = ''; this.query.beginDate = ''; this.query.advance = false; this.query.endDate = this.formatDate(new Date(), 'yyyy-MM-dd'); } this.query.searchOperator = 1; this.getData(this.isLoadMore); }, loadMore: function () { if (window.screen.width <= 900) { this.isLoadMore = true; this.onSubmit(this.isLoadMore); } }, onDownChoose: function (e) { this.loadOver = false; this.getSuggestData(); }, onAdvancedOpen: function (e) { $('#q1').val(''); $('#q3').val(''); $('#q4').val(''); this.q1 = ""; this.q3 = ""; this.q4 = ""; this.isOpenAdvance = !this.isOpenAdvance; if (this.isOpenAdvance) { $('.gjjs').show(); $('.gjjs').slideDown(100); } else { $('.gjjs').slideUp(); $('.gjjs').hide(); } if (this.query.searchDateType == 'custom') { $('.zdydate').show(); } else { $('.zdydate').hide(); } $('.btn_prompt').hide(); }, onAdvancedClose: function () { $('.gjjs').slideUp(); $('.gjjs').hide(); }, onAdvancedSubmit: function () { if ($('#q1').val() != '' || $('#q3').val() != '') { $('.btn_prompt').hide(); } else { $('.btn_prompt').show(); return; } if ('custom' == this.query.searchDateType) { if (this.query.beginDate == '') { alert(i18n.t('time.enter_start_time')); return; } } this.query.advance = true; $(".inp").val(''); $(".sosoRig .sosoBox #keyWord").val(""); this.q1 = $('#q1').val(); this.q3 = $('#q3').val(); this.q4 = $('#q4').val(); this.changeDate(this.query.searchDateType); var advanceKeyWord = ''; var searchKeyWord = ''; if ($('#q1').val()) { advanceKeyWord = advanceKeyWord + $('#q1').val(); searchKeyWord = searchKeyWord + ' ' + i18n.t('search_advanced.search_contains') + ' ' + $('#q1').val(); } if ($('#q3').val()) { advanceKeyWord = advanceKeyWord + ' AND ' + $('#q3').val(); searchKeyWord = searchKeyWord + ' ' + i18n.t('search_advanced.search_contains') + ' ' + $('#q3').val(); } if ($('#q4').val()) { advanceKeyWord = advanceKeyWord + ' NOT ' + $('#q4').val(); searchKeyWord = searchKeyWord + ' ' + i18n.t('search_advanced.search_not_included') + ' ' + $('#q4').val(); } this.query.advance = true; this.query.keyWord = searchKeyWord; this.query.advanceKeyWord = advanceKeyWord; $('.sosoNew').hide(); this.query.page.current = 0; this.query.searchKeyWord = false; this.query.searchOperator = 0; this.getData(); }, onSearchOperator: function () { if(!$('.inp').val()){ alert("请输入查询关键词"); return; } $('#q1').val(""); $('#q3').val(""); $('#q4').val(""); this.q1 = ""; this.q3 = ""; this.q4 = ""; this.isOpenAdvance = false; $('.gjjs').hide(); this.$data.tableData=[]; this.loadMoreDone = false; this.query.searchScope = this.searchQeruyTypeinit || 1; this.query.orderType = this.searchOrderTypeinit || 'date'; this.query.searchDateName = 'time.any_time'; this.query.searchDateType = ''; this.query.beginDate = ''; this.query.advance = false; this.query.endDate = this.formatDate(new Date(), 'yyyy-MM-dd'); this.query.searchOperator = 1; this.query.page.current = 0; this.query.keyWord=$('.inp').val() $('.gjjs').hide(); if (window.screen.width <= 900) { this.isLoadMore = true; this.getData(this.isLoadMore); } else { this.getData(); } }, handleSizeChange: function (val) { var _this = this; this.$data.query.page.size = val; this.getData(); }, handleCurrentChange: function (val) { var _this = this; this.$data.query.page.current = val; this.getData(); }, loadTemplate: function () { var _this = this; $.ajax({ url: urlPrefix + '/webber/search/search/manage/indexTemplate/list' + '?r=' + Math.random(), data: {}, type: 'get', dataType: 'json', sync: false, success: function (response) { if (response.code == '0000') { var data = response.data; var showTemplate = '