|
|
|
|
# 收货地址解析、快递地址解析、物流地址解析自动识别 支持pc、h5、微信小程序,自动提取姓名、电话、地址信息,自动识别出省、市、区、街道、姓名、手机号等
|
|
|
|
|
# Winglau14-address-auto-parse
|
|
|
|
|
|
|
|
|
|
## 支持以下数据格式与(淘宝、拼多多、1688的电商网站地址格式)
|
|
|
|
|
|
|
|
|
|
1. 北京市朝阳区xx路姚家园x楼x单元3305上官飞雪15000000000
|
|
|
|
|
2. 北京市朝阳区xx路姚家园x楼x单元3305上官飞雪15000000000邮编038300
|
|
|
|
|
3. 上官飞雪
|
|
|
|
|
1351111111
|
|
|
|
|
浙江省 杭州市 上城区 xx路x号x幢x楼(靠近x幢)
|
|
|
|
|
4. 上官飞雪,1351111111,北京市朝阳区富康路姚家园3楼邮编038300
|
|
|
|
|
5. 上官飞雪1351111111北京市朝阳区富康路姚家园3楼0
|
|
|
|
|
6. 北京市朝阳区xx路姚家园x楼1351111111上官飞雪
|
|
|
|
|
7. 北京市朝阳区xx路姚家园x楼150-0000-0000上官飞雪
|
|
|
|
|
|
|
|
|
|
## 不支持的数据格式
|
|
|
|
|
|
|
|
|
|
不支持富康路姚家园3号楼5单元3301后直接加电话
|
|
|
|
|
ex.北京市朝阳区富康路姚家园3号楼5单元330115000000000邮编038300
|
|
|
|
|
|
|
|
|
|
## 地址切分规则
|
|
|
|
|
|
|
|
|
|
1. `省市区(县)`+`详细地址(不包括楼、单元、室等等)`+`电话`+`邮编`+`姓名`
|
|
|
|
|
2. `省市区(县)`+`详细地址+楼+单元+室等`+`姓名`+`电话`+`邮编`
|
|
|
|
|
|
|
|
|
|
## 生成数据格式
|
|
|
|
|
|
|
|
|
|
```ini
|
|
|
|
|
{
|
|
|
|
|
"province": "北京",
|
|
|
|
|
"city": "北京市",
|
|
|
|
|
"area": "朝阳区",
|
|
|
|
|
"details": "xx路姚家园x楼 上官飞雪",
|
|
|
|
|
"name": "7.",
|
|
|
|
|
"code": "110105",
|
|
|
|
|
"__type": "parseByProvince",
|
|
|
|
|
"__parse": true,
|
|
|
|
|
"mobile": "15000000000",
|
|
|
|
|
"zip_code": "",
|
|
|
|
|
"phone": ""
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 具体使用 根据需求修改 获取到地址信息调用parse方法即可
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
<template>
|
|
|
|
|
<view class="content">
|
|
|
|
|
<view class="title">支持以下数据格式(打印结果请在控制台查看)</view>
|
|
|
|
|
<view class="title">
|
|
|
|
|
<view>最新支持数据格式:</view>
|
|
|
|
|
<view>1. 北京市朝阳区xx路姚家园x楼x单元3305上官飞雪15000000000</view>
|
|
|
|
|
<view>2. 北京市朝阳区xx路姚家园x楼x单元3305上官飞雪15000000000邮编038300</view>
|
|
|
|
|
<view>
|
|
|
|
|
3. 上官飞雪<br/>
|
|
|
|
|
1351111111<br/>
|
|
|
|
|
浙江省 杭州市 上城区 xx路x号x幢x楼(靠近x幢)
|
|
|
|
|
</view>
|
|
|
|
|
<view>4. 上官飞雪,1351111111,北京市朝阳区富康路姚家园3楼邮编038300</view>
|
|
|
|
|
<view>5. 上官飞雪1351111111北京市朝阳区富康路姚家园3楼0</view>
|
|
|
|
|
<view>6. 北京市朝阳区xx路姚家园x楼1351111111上官飞雪</view>
|
|
|
|
|
<view>7. 北京市朝阳区xx路姚家园x楼150-0000-0000上官飞雪</view>
|
|
|
|
|
</view>
|
|
|
|
|
<textarea @change="autoParse" cols="50" rows="10" v-model="address" placeholder="请粘贴您需要识别的地址"></textarea>
|
|
|
|
|
<button @click="autoParse">自动识别</button>
|
|
|
|
|
<view v-if="value" class="title">自动识别结果:</view>
|
|
|
|
|
<!-- <view style="padding-top:30rpx;" v-html="value"></view> -->
|
|
|
|
|
<view v-if="value" style="padding: 30rpx;background: #fafafa;border: 1px solid #eaeefb;margin-top: 30rpx;word-break: break-all;">
|
|
|
|
|
<code v-text="value"></code>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import {AddressParse} from './lib/addressParseBundle.js';
|
|
|
|
|
export default{
|
|
|
|
|
data(){
|
|
|
|
|
return{
|
|
|
|
|
value:'',
|
|
|
|
|
address:''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
autoParse(){
|
|
|
|
|
if(!this.address){
|
|
|
|
|
return uni.showToast({
|
|
|
|
|
title: '请粘贴您需要识别的地址',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const address = this.address
|
|
|
|
|
const result = AddressParse.parse(address)
|
|
|
|
|
if(result && result.length){
|
|
|
|
|
let html = ''
|
|
|
|
|
for(let key in result[0]){
|
|
|
|
|
if(result[0][key]){
|
|
|
|
|
html+=key+`:`+result[0][key]+`<br/>`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.value = JSON.stringify(result[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.content{
|
|
|
|
|
padding:40rpx;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
textarea{
|
|
|
|
|
border: 1px solid #dbdbdb;
|
|
|
|
|
padding:20rpx;
|
|
|
|
|
width:100%;
|
|
|
|
|
margin:30rpx 0;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
.title{
|
|
|
|
|
font-size:30rpx;
|
|
|
|
|
font-weight:600;
|
|
|
|
|
padding-top: 30rpx;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
```
|