cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!doctype html>
<html>
<head>
<meta charset="utf-8">
[#include "/business/wechat/include/title.html" /]
[#include "/business/wechat/include/wheader.html" /]
<script type="text/javascript" src="${common_static}/static/wechat/style/js/wsingle.js"></script>
 
</head>
 
<body>
<header class="worklistsearch">
    <span id="showName" v="1">知识</span><label><input type="text" name="kw" id="kw" value="${kw}"/><input type="button" onclick="query();" /></label>
    
    <div class="wlsdrop">
            <a href="javascript:void(0);" v="1"><p>知识</p></a>
            <a href="javascript:void(0);" v="2"><p>工单</p></a>
    </div>
</header>
 
<div id="history" style="display:none;">
<h2 class="wlstit">搜索历史</h2>
<section class="wlslist" id="historyItem">
</section>
<a href="#"><div class="wlsclear" onclick="clearHistory()">清除搜索记录</div></a>
</div>
 
 
<div id="main"></div>
<div id="pagination" class="loadmore"></div>
 
</body>
 
 
<script type="text/javascript">
    
    var key = "historySearch";
    
    function changeKw(msg) {
        $("#kw").val(msg);
        query();
    }
 
    //获取存储信息
    function getStorage() {
        var v = localStorage.getItem(key);
        return v;
    }
    
    //设置存储信息
    function setStorage(msg) {
        var v = getStorage();
        if(v != null && !$.util.isEmpty(v)) {
            var pos = v.indexOf(msg);
            if(pos<0) {
                var array = v.split(",");
                array.push(msg);
                localStorage.setItem(key,array);
            }
        } else {
            localStorage.setItem(key,msg);
        }
    }
    
    //显示搜索历史
    function showHistory() {
        var msg = getStorage();
        if(msg != null && !$.util.isEmpty(msg)) {
            var array = msg.split(",");
            array.reverse();
            var historyHtml = "";
            $.each(array, function(i, n){
               if(i<5) {
                   historyHtml += '<a href="javascript:changeKw(\''+n+'\')"><p>'+n+'</p></a>';
               }
            });
            
            $("#historyItem").html(historyHtml);
            $("#history").show();
        }
    }
    
    //清除历史记录
    function clearHistory() {
        localStorage.setItem(key,"");
        $("#history").hide();
    }
 
    showHistory();
 
    var kw = $.trim($("#kw").val());
    if(!$.util.isEmpty(kw) && kw.length > 1) {
        query();
    }
    
    function query() {
        $("#main").empty();
        var kw = $.trim($("#kw").val());
        
        if($.util.isEmpty(kw) || kw.length == 1) {
            popupTips("关键词至少为2个字");
            return;
        }
        $("#history").hide();
        setStorage(kw);
        
        
        var bigCategory = $("#showName").attr("v");
        
        var params = {"kw":kw,"pageSize":5,"type":bigCategory};
          $("#pagination").wsinglePagination({
              base:"${base}",
            durl:"${base}/ewyw/ewfulltext/ewOrderData.html",
            pdiv:"pagination",
            mdiv:"main",
            perPage : 10,
            param:params
        });
    }
    
/*下拉*/
$(function(){
    var searchBtn = $('.worklistsearch span'),
        searchCon = $('div.wlsdrop');
    searchBtn.click(function(){
        searchCon.animate({height:'toggle'});
        return false;
    });
    searchCon.children('a').click(function(){
        var v = $(this).attr("v");
        var showName = $(this).text();
    
        $("#showName").attr("v",v).text(showName);
        searchCon.slideUp();
    });
    $(document).click(function(){
        searchCon.slideUp();
    });
    
    
})
</script>
 
 
</html>