forked from natuka/web.puabadge.com
达人地址识别
This commit is contained in:
1 parent
88aa065296
commit
241cb53eea
2 files changed
+109
No files matched your search
Vendored
+1
@@ -22,6 +22,7 @@ declare module '@vue/runtime-core' {
|
|||||||
Tensorflow: typeof import('./src/components/arFrame/tensorflow.vue')['default']
|
Tensorflow: typeof import('./src/components/arFrame/tensorflow.vue')['default']
|
||||||
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
||||||
VanAddressEdit: typeof import('vant/es')['AddressEdit']
|
VanAddressEdit: typeof import('vant/es')['AddressEdit']
|
||||||
|
VanButton: typeof import('vant/es')['Button']
|
||||||
VanDivider: typeof import('vant/es')['Divider']
|
VanDivider: typeof import('vant/es')['Divider']
|
||||||
VanField: typeof import('vant/es')['Field']
|
VanField: typeof import('vant/es')['Field']
|
||||||
VanIcon: typeof import('vant/es')['Icon']
|
VanIcon: typeof import('vant/es')['Icon']
|
||||||
|
|||||||
@@ -113,11 +113,35 @@
|
|||||||
</block> -->
|
</block> -->
|
||||||
</block>
|
</block>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="address-box" v-if="orderStat.use_type == 2 && imageUrl && code == 'ACAYOAAC3PFCPO3CD6DVM1'">
|
||||||
|
<div class="order-title" style="padding: 0 16px;">地址识别</div>
|
||||||
|
<div class="address-item">
|
||||||
|
<van-field
|
||||||
|
v-model="addressInput"
|
||||||
|
label=""
|
||||||
|
placeholder="请输入姓名、手机号、详细地址(如:张三 13800138000 广东省深圳市南山区科技园1号)"
|
||||||
|
clearable
|
||||||
|
right-icon="search"
|
||||||
|
>
|
||||||
|
<template #button>
|
||||||
|
<van-button size="small" type="primary" @click="handleAddressInput" style="margin-left: 8px;">自动识别</van-button>
|
||||||
|
</template>
|
||||||
|
</van-field>
|
||||||
|
</div>
|
||||||
|
<div class="address-item" style="padding: 0px 16px 16px 16px;" v-if="contact_name && contact_mobile && province_name && city_name && county_name && address">
|
||||||
|
<div style="font-size: 16px;color: #387aff;text-align: left;margin-bottom: 8px;">识别结果</div>
|
||||||
|
<div style="font-size: 14px;text-align: left;">
|
||||||
|
{{ contact_name }} {{ contact_mobile }} {{ province_name }} {{ city_name }} {{ county_name }} {{ address }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="address-box" v-if="orderStat.use_type == 2 && imageUrl">
|
<div class="address-box" v-if="orderStat.use_type == 2 && imageUrl">
|
||||||
<div class="order-title" style="padding: 0 16px;">收货地址</div>
|
<div class="order-title" style="padding: 0 16px;">收货地址</div>
|
||||||
<div class="address-item">
|
<div class="address-item">
|
||||||
<van-address-edit
|
<van-address-edit
|
||||||
:area-list="areaList"
|
:area-list="areaList"
|
||||||
|
:tel-validator="true"
|
||||||
|
tel-maxlength="11"
|
||||||
show-delete
|
show-delete
|
||||||
show-search-result
|
show-search-result
|
||||||
:search-result="searchResult"
|
:search-result="searchResult"
|
||||||
@@ -184,6 +208,9 @@ const showBgCompare = ref(false)
|
|||||||
const currentIndex = ref(0)
|
const currentIndex = ref(0)
|
||||||
const imageList = ref([])
|
const imageList = ref([])
|
||||||
const imageWater = ref('')
|
const imageWater = ref('')
|
||||||
|
|
||||||
|
const code = localStorage.get('code')
|
||||||
|
|
||||||
function compare() {
|
function compare() {
|
||||||
showCompare.value = true
|
showCompare.value = true
|
||||||
}
|
}
|
||||||
@@ -346,6 +373,85 @@ const changeValue = (value: number) => {
|
|||||||
payAmount.value = value
|
payAmount.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addressInput = ref('')
|
||||||
|
const handleAddressInput = () => {
|
||||||
|
console.log('handleAddressInput', addressInput.value)
|
||||||
|
const text = addressInput.value;
|
||||||
|
if (!text) return;
|
||||||
|
// 识别手机号
|
||||||
|
const phoneRegex = /(1[3-9]\d{9})/g;
|
||||||
|
const phoneMatch = phoneRegex.exec(text);
|
||||||
|
if (phoneMatch) {
|
||||||
|
contact_mobile.value = phoneMatch[0];
|
||||||
|
}
|
||||||
|
// 简单识别姓名(2-4个中文字符)
|
||||||
|
const nameRegex = /([\u4e00-\u9fa5]{2,4})/g;
|
||||||
|
const nameMatches = text.match(nameRegex);
|
||||||
|
if (nameMatches && nameMatches.length > 0) {
|
||||||
|
// 假设第一个匹配的中文名是姓名
|
||||||
|
contact_name.value = nameMatches[0];
|
||||||
|
}
|
||||||
|
console.log('contact_name', contact_name.value)
|
||||||
|
console.log('contact_mobile', contact_mobile.value)
|
||||||
|
// 识别省份
|
||||||
|
let provinceFound = '';
|
||||||
|
for (const [provinceId, provinceName] of Object.entries(areaList.province_list)) {
|
||||||
|
if (text.includes(provinceName)) {
|
||||||
|
provinceFound = provinceName;
|
||||||
|
console.log('识别到省份ID:', provinceId);
|
||||||
|
province_id.value = provinceId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('province_id', province_id.value)
|
||||||
|
console.log('provinceFound', provinceFound)
|
||||||
|
province_name.value = provinceFound;
|
||||||
|
// 识别城市
|
||||||
|
let cityFound = '';
|
||||||
|
for (const [cityId, cityName] of Object.entries(areaList.city_list)) {
|
||||||
|
if (text.includes(cityName) && cityId !== province_id.value) {
|
||||||
|
cityFound = cityName;
|
||||||
|
city_id.value = cityId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('cityFound', cityFound)
|
||||||
|
city_name.value = cityFound;
|
||||||
|
// 提取详细地址(从文本中移除已识别的部分)
|
||||||
|
let detail = text
|
||||||
|
.replace(contact_name.value, '')
|
||||||
|
.replace(contact_mobile.value, '')
|
||||||
|
.replace(province_name.value, '')
|
||||||
|
.replace(city_name.value, '')
|
||||||
|
.trim();
|
||||||
|
// 移除可能的区级信息(简单处理)
|
||||||
|
if (detail.includes('区') || detail.includes('县')) {
|
||||||
|
const districtMatch = detail.match(/(.+?(区|县))/);
|
||||||
|
if (districtMatch) {
|
||||||
|
// 遍历区县列表,查找匹配的区县名,获取对应的区id
|
||||||
|
let foundCountyId = '';
|
||||||
|
for (const [cid, cname] of Object.entries(areaList.county_list)) {
|
||||||
|
if (districtMatch[0].includes(cname)) {
|
||||||
|
foundCountyId = cid;
|
||||||
|
county_id.value = cid;
|
||||||
|
county_name.value = cname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果没有在区县列表中找到,仍然保留原有逻辑
|
||||||
|
if (!foundCountyId) {
|
||||||
|
county_id.value = 0;
|
||||||
|
county_name.value = '';
|
||||||
|
}
|
||||||
|
detail = detail.replace(county_name.value, '').trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('county_id', county_id.value)
|
||||||
|
console.log('county_name', county_name.value)
|
||||||
|
console.log('detail', detail)
|
||||||
|
address.value = detail;
|
||||||
|
}
|
||||||
|
|
||||||
const key = ref(0)
|
const key = ref(0)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const confirm = () => {
|
const confirm = () => {
|
||||||
@@ -401,6 +507,8 @@ const confirm = () => {
|
|||||||
parms.addr_id = 0
|
parms.addr_id = 0
|
||||||
parms.country_id = 45
|
parms.country_id = 45
|
||||||
}
|
}
|
||||||
|
console.log('parms', parms)
|
||||||
|
return false;
|
||||||
badgeApi.creatOrder(parms).then((res: any) => {
|
badgeApi.creatOrder(parms).then((res: any) => {
|
||||||
console.log('creatOrder', res)
|
console.log('creatOrder', res)
|
||||||
showSuccessToast({
|
showSuccessToast({
|
||||||
|
|||||||
Reference in new issue
Block a user