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
<!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>
 
<style>
#main span {
    background:none;
    width:auto;
    margin-right:0;
}
 
</style>
 
</head>
 
<body>
 
<header class="kltit tcenter"><a href="javascript:history.go(-1);"><span></span></a>知识库</header>
 
<div class="worklistsearch second">
    <label class="small3">
    <input type="text" name="kw" id="kw" value="${kw}"/>
    <input type="button" onclick="query();" />
    </label>
    
</div>
 
<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 = "historyKw";
    
    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 params = {"kw":kw,"type":1,"pageSize":5};
          $("#pagination").wsinglePagination({
              base:"${base}",
            durl:"${base}/ewyw/ewfulltext/ewOrderData.html",
            pdiv:"pagination",
            mdiv:"main",
            perPage : 10,
            param:params,
            dataHandler:function(data) {
                $(".key").click(function() {
                    var kw = $(this).text();
                    $("#kw").val(kw);
                    query();
                });
            }
        });
    }
    
    
    
    
</script>
 
 
</html>