uu
This commit is contained in:
parent
e2c892ef55
commit
c7137718b7
@ -42,5 +42,9 @@ export const getAddressById = (data = {})=> {
|
||||
return coreRequest(url.getAddressById, data, {}, 'GET')
|
||||
}
|
||||
|
||||
export const parseAddress = (data = {})=> {
|
||||
return coreRequest(url.parseAddress, data, {}, "GET")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ export default {
|
||||
addAddress: `/emis/emisCustomerAddress/addAddress`, // 新增地址
|
||||
editAddress: `/emis/emisCustomerAddress/editAddress`, // 编辑地址
|
||||
getAddressById: `/emis/emisCustomerAddress/getAddressById`, // 查看地址
|
||||
parseAddress: `/emis/common/parseAddress`, // 智能地址解析(仅中国)
|
||||
|
||||
getTransLineList: `/emis/emisTransLine/listSimple`, // 获取路线列表
|
||||
getTransProductList: `/emis/emisTransProduct/listSimple`, // 获取产品列表
|
||||
|
||||
@ -74,7 +74,7 @@ function handleResponse({
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
showToast(`网络错误`)
|
||||
showToast(msg || `网络错误`)
|
||||
}, 0)
|
||||
reject({
|
||||
code: {}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { addressNameCodeMap } from "./enum"
|
||||
|
||||
function formatTime(time) {
|
||||
if (typeof time !== 'number' || time < 0) {
|
||||
return time
|
||||
@ -96,8 +98,30 @@ const numberToChinese = (num)=> {
|
||||
}
|
||||
|
||||
// - 获取地址详情
|
||||
const getAddressDetail = (item= {})=> {
|
||||
return `${item.countryName||''}${item.provinceName||''}${item.cityName||''}${item.countyName||''}${item.townName||''}${item.address||''}`
|
||||
const getAddressDetail = (item= {}, showDetail = true)=> {
|
||||
let ary = []
|
||||
addressNameCodeMap.map((t)=> {
|
||||
ary.push(item[t.nameKey])
|
||||
})
|
||||
if(showDetail) {
|
||||
ary.push(item.address)
|
||||
}
|
||||
return ary.join("")
|
||||
}
|
||||
|
||||
const setAddresModalParam = (data = {})=> {
|
||||
let regIds = []
|
||||
let regNames = []
|
||||
addressNameCodeMap.map((t, index)=> {
|
||||
let name = data[t.nameKey]
|
||||
let code = data[t.codeKey]
|
||||
name && (regIds[index] = code);
|
||||
code && (regNames[index] = name);
|
||||
})
|
||||
return {
|
||||
regIds,
|
||||
regNames
|
||||
}
|
||||
}
|
||||
|
||||
// - 转换list的key val
|
||||
@ -147,6 +171,7 @@ const throttle = (fn, wait) => {
|
||||
|
||||
export {
|
||||
getAddressDetail,
|
||||
setAddresModalParam,
|
||||
numberToChinese,
|
||||
formatTime,
|
||||
formatLocation,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<template v-slot:body>
|
||||
<view class="com-jianju pos-rlt pb-30" style="padding-top: 2rpx;">
|
||||
<view class="blcok-white radius-20">
|
||||
<u-textarea v-model="submitParam.otherDes" border="none" height="110" placeholder="粘贴或输入地址,点击“智能识别”自动拆分姓名、电话和地址" custom-style="border:0;padding: 0;"></u-textarea>
|
||||
<u-textarea v-model="ansValue" border="none" height="110" placeholder="粘贴或输入地址,点击“智能识别”自动拆分姓名、电话和地址" custom-style="border:0;padding: 0;"></u-textarea>
|
||||
<u-row justify="end">
|
||||
<view class="mt-10">
|
||||
<u-button @click="handleAnsText()" type="primary" size="mini" shape="circle" custom-style="width: 130rpx;font-size: 24rpx;padding:0;">智能识别</u-button>
|
||||
@ -26,7 +26,7 @@
|
||||
</view>
|
||||
|
||||
<view class="mt-40 pos-rlt">
|
||||
<tpx-input :value="getAddressDetail(submitParam)" placeholder="所在地区"></tpx-input>
|
||||
<tpx-input :value="getAddressDetail(submitParam, false)" placeholder="所在地区"></tpx-input>
|
||||
<view @click="handleDialogClick(addressModal)" class="pos-abt-all"></view>
|
||||
</view>
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
import { getAddressModels } from "./model"
|
||||
import * as apiService from "@/common/api"
|
||||
import { addressNameCodeMap } from "@/common/enum"
|
||||
import { getAddressDetail } from "@/common/util"
|
||||
import { getAddressDetail, setAddresModalParam } from "@/common/util"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@ -103,6 +103,7 @@
|
||||
regNames: []
|
||||
}
|
||||
},
|
||||
ansValue: '',
|
||||
submitParam: {
|
||||
...getAddressModels(),
|
||||
}
|
||||
@ -129,18 +130,17 @@
|
||||
if(res.data.blDefaultFlag) {
|
||||
res.data.blDefaultFlag = [true]
|
||||
}
|
||||
this.submitParam = res.data
|
||||
// 回显 国家-省市区组件数据
|
||||
addressNameCodeMap.map((t, index)=> {
|
||||
let name = res.data[t.nameKey]
|
||||
let code = res.data[t.codeKey]
|
||||
name && (this.addressModal.values.regIds[index] = code);
|
||||
code && (this.addressModal.values.regNames[index] = name);
|
||||
})
|
||||
this.addressModal.values = setAddresModalParam(res.data);
|
||||
this.submitParam = res.data
|
||||
}
|
||||
},
|
||||
handleAnsText(){
|
||||
|
||||
|
||||
async handleAnsText(){
|
||||
let res = await apiService.parseAddress({ content: this.ansValue, _loading: true })
|
||||
let data = res.data || {}
|
||||
this.addressModal.values = setAddresModalParam(data);
|
||||
Object.assign(this.submitParam, data)
|
||||
},
|
||||
handleAddressChoose(data) {
|
||||
data.regIds.map((regId, index)=> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user