313ce84a
songchongxian
创建h5 app项目
|
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>搜索停车场</title>
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<link rel="stylesheet" href="../iconfont/iconfont.css" />
<link rel="stylesheet" href="map.css" />
</head>
<style>
.mapsearch{
width: 100%;
padding: 10px;
box-sizing: border-box;
border-bottom: 1px solid #CCCCCC;
height: 58px;
position: fixed;
top: 0;left: 0;
}
.mapsearch .filter{
width: 100%;
height: 58px;
position: fixed;
top: 0;left: 0;
filter: blur(3px);
-webkit-filter:blur(3px);
z-index: 10;
background: rgba(255,255,255,1);
}
.mapsearch .stext{
border: 1px solid #CCCCCC;
border-radius: 4px;
width: 100%;
height: 35px;
line-height: 35px;
overflow: hidden;
position: relative;
z-index: 111;
}
.mapsearch .stext .inputxc,.search .stext .sbutton{
float: left;
height: 35px;
}
.mapsearch .stext .inputxc{
width: 80%;
box-sizing: border-box;
border: 0;
border-right: 1px solid #ccc;
padding-right: 10px;
}
.mapsearch .stext .sbutton{
width: 20%;
display: inline-block;
text-align: center;
}
.mapsearch .stext .inputxc input{
height: 100%;
width: 88%;
float: left;
border: 0;
outline: none;
}
.mapsearch .stext .inputxc i{
display: inline-block;
text-align: center;
float: right;
color: #9B9B9B;
}
.maphis,.sresults{
margin-top: 58px;
}
.maphis ul li,.maphis .clearhs{
padding: 6px 10px;
border-bottom: 1px solid #ccc;
}
.maphis ul li,.sresults ul li{
list-style: none;
}
.maphis ul li i,.maphis .clearhs i{
font-size: 18px;
color: #C0C0C0;
padding-right: 12px;
}
.maphis .clearhs{
color: #C0C0C0;
font-size: 13px;
}
.sresults ul li{
padding: 10px;
border-bottom: 1px solid #ccc;
}
.sresults ul li table{
margin: 0;
}
.sresults ul li table td i{
padding-right: 10px;
font-size: 18px;
color: #C0C0C0;
}
.sresults ul li table td.fontaddre{
color: #C0C0C0;
font-size: 12px;
}
</style>
<body onclick="">
<div class="mapsearch" id="mapsearch">
<div class="filter"></div>
<div class="stext">
<div class="inputxc">
<input type="text" id="ssearch" v-model="keyy"/>
<i class="icon iconfont" style="display: none;" onclick="clearinput();"></i>
</div>
<span class="sbutton">搜索</span>
</div>
</div>
<div class="maphis" style="display: none;">
<ul class="mh">
<li>
<i class="icon iconfont"></i>1
</li>
</ul>
<div class="clearhs" onclick="clearhis()">
<i class="icon iconfont"></i>
清除历史
</div>
</div>
<div class="sresults" style="display: none;">
<ul>
<!--<li>
<table>
<tr>
<td rowspan="2">
<i class="icon iconfont"></i>
</td>
<td>名字名字名字名字</td>
</tr>
<tr>
<td class="fontaddre">地址地址</td>
</tr>
</table>
</li>-->
</ul>
</div>
<div class="nomoredata" style="width: 50%;margin: 28% auto 0;">
<div style="width: 100%;text-align: center;"><i class="icon iconfont" style="font-size: 50px;color: #B2B2B2;"></i></div>
<p style="text-align: center;color: #B2B2B2;font-size: 13px;">未搜索到相关停车场</p>
</div>
</body>
</html>
<script src="../js/jquery-3.2.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<!--md5 start-->
<script src="../js/md5.min.js"></script>
<!--md5 end-->
<script src="../js/url.js"></script>
<script src="../js/ajax.js"></script>
<script>
var app = new Vue({
el: '#mapsearch',
data: {
keyy:''
},
watch:{
keyy:function(val){
results(val);
}
}
})
var hisdata = [];
$(function(){
gethisearch();
$("#ssearch").on('blur',function(){
var val = $(this).val();
if(val==''){
$(this).next('i').css('display','none');
}
});
$("#ssearch").on('focus',function(){
$(this).next('i').css('display','inline');
});
//点击搜索按钮
$('body').on('click','#sbutton',function(){
var val = $("#ssearch").val();
if(val&&val!=''){
results(val);
}
});
//点击搜索结果li
$("body").on('click','.sresults ul li',function(){
var lng = $(this).attr('data-longitude');
var lat = $(this).attr('data-latitude');
var name = $(this).attr('data-name');
var pklNo = $(this).attr('data-pklNo');
var data = {
lng:lng,
lat:lat,
name:name,
pklNo:pklNo
};
sethisearch(data);
$("#ssearch").val(name);
tzmap(lng,lat);
});
//点击历史记录项
$("body").on('click','.maphis .mh li',function(){
var lng = $(this).attr('data-longitude');
var lat = $(this).attr('data-latitude');
var name = $(this).attr('data-name');
var pklNo = $(this).attr('data-pklNo');
$("#ssearch").val(name);
$('#ssearch').next('i').css('display','inline');
tzmap(lng,lat);
});
});
//获取历史记录
function gethisearch(){
var his = localStorage.getItem('hissearchresults');
console.log("历史 "+his);
if(his&&his!=null&&his!=''){
his = JSON.parse(his);
if(his.data.length>0){
$(".maphis ul").html('');
for(var i =0;i<his.data.length;i++){
var li = document.createElement('li');
li.setAttribute('data-longitude',his.data[i].lng);
li.setAttribute('data-latitude',his.data[i].lat);
li.setAttribute('data-name',his.data[i].name);
li.setAttribute('data-pklNo',his.data[i].pklNo);
li.setAttribute('onclick','');
li.innerHTML = '<i class="icon iconfont"></i>'+his.data[i].name; //maphis
document.querySelector('.maphis ul').appendChild(li);
}
$(".maphis").css('display','block');
}else{
$(".maphis").css('display','none');
}
}else{
$(".maphis").css('display','none');
}
}
//设置历史
function sethisearch(b){
var his = {};
var data = [];
var chongf = false;
var historys = localStorage.getItem('hissearchresults');
console.log('00 '+b.pklNo);
if(historys&&historys!=''){
var a = JSON.parse(historys);
for(var i=0;i<a.data.length;i++){
if(b.pklNo==a.data[i].pklNo){
chongf = true;
}
}
data = a.data;
}
if(!chongf){
data.push(b);
}
his.data = data;
localStorage.setItem('hissearchresults',JSON.stringify(his));
}
//清除历史
function clearhis(){
localStorage.setItem('hissearchresults','');
gethisearch();
}
//清除文本域
function clearinput(){
$("#ssearch").val('');
$('#ssearch').next('i').css('display','none');
results('');
}
//点击地图导航页面
function tzmap(lng,lat){
//console.log('newmap1.html?lng='+lng+"&lat="+lat);
window.location.href = 'map.html?lng='+lng+"&lat="+lat;//index
}
//搜索结果
function results(key){
if(!key&&key==''){
gethisearch();
$(".sresults").css('display','none');
$(".nomoredata").css('display','block');
}else{
$(".maphis").css('display','none');
$(".sresults").css('display','block');
var salt = jsajax.salt(32);
var sortd = [
{keyname:'app_id',value:'0eca8f5373ca4866aec2f8e9d9367104'},
{keyname:'deviceInfo',value:'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E'},
{keyname:'salt',value:salt},
{keyname:'sign_type',value:'md5'},
{keyname:'parkName',value:key}
];
var mdsign = jsajax.getsign(sortd);
var jsoandata = {
app_id:'0eca8f5373ca4866aec2f8e9d9367104',
deviceInfo:'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E',
salt:salt,
sign_type:'md5',
parkName:key,
sign:mdsign
};
jsajax.defaultReq(
mUrl.Searchpark,
JSON.stringify(jsoandata),
function(data){
//console.log(JSON.stringify(data));
if(data.code==0){
document.querySelector('.sresults ul').innerHTML = '';
var datas = data.data;
if(datas.length>0){
for(var i=0;i<datas.length;i++){
var address = datas[i].address;
var latitude = datas[i].latitude;
var longitude = datas[i].longitude;
var name = datas[i].name;
var pklNo = datas[i].pklNo;
var li = document.createElement('li');
li.setAttribute('data-name',name);
li.setAttribute('data-pklNo',pklNo);
li.setAttribute('data-latitude',latitude);
li.setAttribute('data-longitude',longitude);
li.setAttribute('onclick','');
li.innerHTML = '<table> <tr> <td rowspan="2"> <i class="icon iconfont"></i> </td> <td>'+name+'</td> </tr> <tr> <td class="fontaddre">'+address+'</td> </tr> </table>';//sresults
document.querySelector('.sresults ul').appendChild(li);
}
$(".nomoredata").css('display','none');
}else{
$(".nomoredata").css('display','block');
}
}else{
$(".nomoredata").css('display','block');
}
}
);
}
}
</script>
|