1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- require('./../css/homeStatic.less');
- const $ = require("jquery");
- const {post, config,} = require('./promise.js');
- const {toggleWarnBox} = require('./util.js');
- let searchType = 0;
- require('./../images/staticBgS.png').replace(/^undefined/g, '')
- require('./../images/staticLogo.png').replace(/^undefined/g, '')
- require('./../images/staticBg.png').replace(/^undefined/g, '')
- require('./../images/word.png').replace(/^undefined/g, '')
- $(function(){
- getAllTypes()
- goSearchList()
- });
- //tab
- function renderTab(data){
- let str = '';
- for (let i = 0; i < data.length; i++) {
- const element = data[i];
- str += `<li class="${i==0?'tabFst':''}" data-id="${element.val}">${element.name}</li>`
- }
- $('.staticTopTab ul').html(str)
- $(".staticTopTab li").click(function(){
- searchType = $(this).attr('data-id')
- $(this).css({borderColor:'#fff'}).siblings().css({borderColor:'#2A9BD5'})
- })
- }
- //搜索跳转
- function goSearchList(){
- $(".searchBtn").click(function(){
- let vals = $('.searchStr').val().replace(/(^\s*)|(\s*$)/g, "")
- if (!vals) {
- $(".staticResult .loading").hide();
- toggleWarnBox('检索词不能为空!');
- return;
- }
- window.location.href = './searchStaticList.html?type='+searchType+'&inputStr='+vals
- })
- }
- //获取字典信息
- function getAllTypes(){
- const allTypes = localStorage.getItem('allTypes')&&JSON.parse(localStorage.getItem('allTypes'))||[];
- if(allTypes.length>0){
- renderTab(allTypes)
- return
- }
- post(config.dictionaryInfo, {}).then((res) => {
- const result = res.data
- if(result.code==='0'){
- const data = result.data[7]||[];
- localStorage.setItem('allTypes',JSON.stringify(data))
- renderTab(data)
- }
- })
- }
- $(function () {
- $(".warning-box .confirm,.warning-box .close").click(function () {
- toggleWarnBox();
- })
- });
|