diff --git a/common/api/common.js b/common/api/common.js index 21c1067..e662674 100644 --- a/common/api/common.js +++ b/common/api/common.js @@ -42,5 +42,9 @@ export const getAddressById = (data = {})=> { return coreRequest(url.getAddressById, data, {}, 'GET') } +export const parseAddress = (data = {})=> { + return coreRequest(url.parseAddress, data, {}, "GET") +} + diff --git a/common/api/url.js b/common/api/url.js index 7bccdda..e6aceb2 100644 --- a/common/api/url.js +++ b/common/api/url.js @@ -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`, // 获取产品列表 diff --git a/common/manageServer.js b/common/manageServer.js index 9f824e3..8ee5e7e 100644 --- a/common/manageServer.js +++ b/common/manageServer.js @@ -74,7 +74,7 @@ function handleResponse({ }); } setTimeout(() => { - showToast(`网络错误`) + showToast(msg || `网络错误`) }, 0) reject({ code: {} diff --git a/common/util.js b/common/util.js index 3b4ae14..323627c 100644 --- a/common/util.js +++ b/common/util.js @@ -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, diff --git a/pages/address/edit.vue b/pages/address/edit.vue index a36eb18..fe8c334 100644 --- a/pages/address/edit.vue +++ b/pages/address/edit.vue @@ -3,7 +3,7 @@