forked from wzc570738205/smartParsePro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
297 lines (275 loc) · 8.8 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>地址智能识别</title>
<link rel="icon" type="image/x-icon" href="img/smart.png" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<script data-ad-client="ca-pub-9729613796142547" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<style>
#value .key {
color: #ff5722;
display: inline-block;
width: 111px;
text-align: right;
}
#value .value {
color: #366500;
padding-left: 10px;
}
li {
padding: 5px;
}
li:hover {
cursor: pointer;
background: #8bc34aa1;
padding: 5px;
}
</style>
</head>
<body>
<div class="page-header">
<h1>
地址智能识别
<small>支持省市区街道/姓名/电话/邮编</small>
<a
class="github-button"
href="https://github.com/wzc570738205/smartParsePro"
data-size="large"
data-show-count="true"
aria-label="Star wzc570738205/smartParsePro on GitHub"
>Star</a
>
</h1>
</div>
<div class="alert alert-danger" role="alert">地址、姓名、电话、邮编用空格分开!!</div>
<!-- <div>
特殊字符<code>~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“’。,、?-</code>
</div> -->
<ol>
<li>广东省珠海市香洲区盘山路28号幸福茶庄,陈景勇,13593464918</li>
<li>马云,陕西省西安市雁塔区丈八沟街道高新四路南江国际 13593464918</li>
<li>陕西省西安市雁塔区丈八沟街道高新四路南江国际710061 刘国良 13593464918 </li>
<li>疆维吾尔自治区乌鲁木齐市沙依巴克区西虹东路463号 400-1808855 小红</li>
<li>
姓名:刘德华老表<br>
电话:18149428888<br>
地址:广东省珠海市香洲区盘山路28号幸福茶庄
</li>
<li>
姓名:阿克苏<br>
电话:800-8585222<br>
收货地址:新疆阿克苏温宿县博孜墩柯尔克孜族乡吾斯塘博村一组306号
</li>
<li>
姓名:马云<br>
联系电话:800-8585222<br>
所在地区:河北省石家庄市新华区<br>
详细地址:中华北大街68号鹿城商务中心6号楼1413室
</li>
</ol>
<textarea
class="form-control"
onchange="getAddress()"
onkeydown="getAddress()"
cols="50"
rows="5"
id="textarea"
placeholder="请粘贴或者输入你的地址"
></textarea>
<h4>省市区街道四级联动</h4>
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">省/直辖市</label>
<select class="form-control" id="province">
<option>请选择</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail2">市</label>
<select class="form-control" id="city">
<option>请选择</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail2">区/县</label>
<select class="form-control" id="county">
<option>请选择</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail2">镇/乡/街道</label>
<select class="form-control" id="street">
<option>请选择</option>
</select>
</div>
</form>
<div id="response"></div>
<div id="value"></div>
</body>
</html>
<script src="js/jquery.min.js"></script>
<script src="js/pcasCode.js"></script>
<script src="js/zipCode.js"></script>
<script src="js/address_parse.js"></script>
<!-- <script src="dist/address_parse.js"></script> -->
<script src="js/bootstrap.min.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script src="js/axios.js"></script>
<script>
$('li').on('click', function (e) {
$('#textarea').val($(this).text().trim())
getAddress()
})
function getAddress() {
let parse_list = smart($('#textarea').val())
let html = ''
/* for (let key in parse_list) {
if (parse_list[key]) {
html +=
`<p><span class="key">` +
key +
`</span>:<span class="value">` +
parse_list[key] +
`</span></p>`;
}
}
$("#value").html(html); */
axios({
method: 'post',
url: "https://wangzc.wang/smAddress",
data: {
address: $('#textarea').val(),
},
})
.then(function (res) {
$('#response').html(
`<span style="color:green">接口调用状态码:200;当前调用次数:` +
res.data.requestNumber +
`</span>`
)
html += `<p><span class="key">姓名</span>:<span class="value">${res.data.name}</span></p>`
html += `<p><span class="key">电话</span>:<span class="value">${res.data.phone}</span></p>`
html += `<p><span class="key">邮编</span>:<span class="value">${res.data.zipCode}</span></p>`
// html += `<p><span class="key">身份证号码</span>:<span class="value">${res.data.idCard}</span></p>`
html += `<p><span class="key">省</span>:<span class="value">${res.data.province}</span></p>`
html += `<p><span class="key">市</span>:<span class="value">${res.data.city}</span></p>`
html += `<p><span class="key">区</span>:<span class="value">${res.data.county}</span></p>`
html += `<p><span class="key">街道</span>:<span class="value">${res.data.street}</span></p>`
html += `<p><span class="key">详细地址</span>:<span class="value">${res.data.address}</span></p>`
$('#value').html(html)
})
.catch(function (err) {
$('#response').html(
`<span style="color:red">接口调用状态码:500</span>`
)
})
$('#province').val(parse_list.provinceCode)
$('#city').val(parse_list.cityCode)
$('#county').val(parse_list.countyCode)
$('#street').val(parse_list.streetCode)
getCity($('#province').val(), parse_list)
getCounty($('#city').val(), parse_list)
getStreet($('#county').val(), parse_list)
}
addressList = pcassCode
///
addressList.forEach((item) => {
formatAddresList(item, 1, '')
})
//
let province = ''
addressList.forEach((res) => {
province += ` <option value='` + res.code + `'>` + res.name + `</option>`
})
$('#province').html(province)
getCity($('#province').val())
getCounty($('#city').val())
getStreet($('#county').val())
$('#province').change((res) => {
let provinceCode = $('#province').val()
getCity(provinceCode)
getCounty($('#city').val())
getStreet($('#county').val())
})
$('#city').change((res) => {
let cityCode = $('#city').val()
getCounty(cityCode)
getStreet($('#county').val())
})
$('#county').change((res) => {
let countyCode = $('#county').val()
getStreet(countyCode)
})
function getCity(provinceCode, parse_list) {
let cityList = []
let city = ''
addressList.forEach((res) => {
if (res.code == provinceCode) {
cityList = res.children
return
}
})
cityList.forEach((res) => {
city += ` <option value='` + res.code + `'>` + res.name + `</option>`
})
$('#city').html(city)
if (parse_list) {
$('#city').val(parse_list.cityCode)
}
}
function getCounty(cityCode, parse_list) {
let countyList = []
let county = ''
addressList.forEach((el) => {
el.children.forEach((res) => {
if (res.code == cityCode) {
countyList = res.children
return
}
})
})
countyList.forEach((res) => {
county += ` <option value='` + res.code + `'>` + res.name + `</option>`
})
$('#county').html(county)
if (parse_list) {
$('#county').val(parse_list.countyCode)
}
}
function getStreet(countyCode, parse_list) {
let streetList = []
let street = ''
addressList.forEach((el) => {
el.children.forEach((element) => {
element.children.forEach((res) => {
if (res.code == countyCode) {
streetList = res.children
return
}
})
})
})
streetList.forEach((res) => {
street += ` <option value='` + res.code + `'>` + res.name + `</option>`
})
$('#street').html(street)
if (parse_list) {
$('#street').val(parse_list.streetCode)
}
}
</script>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-119026906-1"
></script>
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'UA-119026906-1')
</script>