@bytenew/bn-applet-ui 1.1.71 → 1.1.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bn-applet-ui.umd.js
CHANGED
|
@@ -28749,6 +28749,13 @@ var es_array_sort = __webpack_require__(6910);
|
|
|
28749
28749
|
|
|
28750
28750
|
|
|
28751
28751
|
|
|
28752
|
+
|
|
28753
|
+
|
|
28754
|
+
|
|
28755
|
+
|
|
28756
|
+
|
|
28757
|
+
|
|
28758
|
+
|
|
28752
28759
|
|
|
28753
28760
|
|
|
28754
28761
|
|
|
@@ -29995,28 +30002,117 @@ function findParsedRegionConflict(parse, originalAddress) {
|
|
|
29995
30002
|
return '';
|
|
29996
30003
|
}
|
|
29997
30004
|
|
|
30005
|
+
/**
|
|
30006
|
+
* 本地识别错误时,使用原生 fetch 调用大模型接口重新识别
|
|
30007
|
+
* GET /v2/project/column/addressBychat?contents={待识别文本}
|
|
30008
|
+
* 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
|
|
30009
|
+
* @param {string} address 原始地址字符串
|
|
30010
|
+
* @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
|
|
30011
|
+
* 成功返回 {aiResult}(content 解析后的对象);失败返回 {failMsg}(接口 msg);不支持 fetch 返回 null
|
|
30012
|
+
*/
|
|
30013
|
+
function parseAddressByChat(address) {
|
|
30014
|
+
// 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
|
|
30015
|
+
if (typeof fetch !== 'function') {
|
|
30016
|
+
console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
|
|
30017
|
+
return Promise.resolve(null);
|
|
30018
|
+
}
|
|
30019
|
+
var url = '/v2/project/column/addressBychat?contents=' + address;
|
|
30020
|
+
return fetch(url, {
|
|
30021
|
+
method: 'GET'
|
|
30022
|
+
}).then(function (r) {
|
|
30023
|
+
return r.json();
|
|
30024
|
+
}).then(function (res) {
|
|
30025
|
+
if (res && !res.code && res.data && res.data.content) {
|
|
30026
|
+
try {
|
|
30027
|
+
return {
|
|
30028
|
+
aiResult: JSON.parse(res.data.content)
|
|
30029
|
+
};
|
|
30030
|
+
} catch (e) {
|
|
30031
|
+
console.error('大模型识别结果解析失败:', res.data.content);
|
|
30032
|
+
return {
|
|
30033
|
+
failMsg: '识别结果解析失败'
|
|
30034
|
+
};
|
|
30035
|
+
}
|
|
30036
|
+
}
|
|
30037
|
+
// 接口失败(如未开通 address_aIautorecognition 功能):返回接口 msg
|
|
30038
|
+
return {
|
|
30039
|
+
failMsg: res ? res.msg : '请求失败'
|
|
30040
|
+
};
|
|
30041
|
+
})["catch"](function (error) {
|
|
30042
|
+
console.error('大模型地址识别接口调用失败:', error);
|
|
30043
|
+
return {
|
|
30044
|
+
failMsg: error && error.message ? error.message : '请求异常'
|
|
30045
|
+
};
|
|
30046
|
+
});
|
|
30047
|
+
}
|
|
30048
|
+
|
|
29998
30049
|
/**
|
|
29999
30050
|
* 自动识别地址信息,格式化为省市区街道和收件人等信息
|
|
30000
30051
|
* @param {string} address 原始地址字符串(可含空格、姓名、手机号等)
|
|
30001
30052
|
* @param {object} [sourceData] 组件 sourceData,用于四级地址等配置(extraInfo.isFourAddress)
|
|
30002
30053
|
* @param {object} [options] 可选配置
|
|
30003
30054
|
* @param {array} [options.areaList] 地址库原始数据,默认从全局 areaList 获取
|
|
30004
|
-
* @returns {{name: string, mobile: string, phone: string, zip_code: string, extensionNumber: string, province: string, city: string, area: string, street: string, addr: string, Abnormal?: boolean,
|
|
30055
|
+
* @returns {Promise<{name: string, mobile: string, phone: string, zip_code: string, extensionNumber: string, province: string, city: string, area: string, street: string, addr: string, Abnormal?: boolean, msg?: string}>}
|
|
30056
|
+
* 本地识别错误时会 await 大模型接口重新识别:
|
|
30057
|
+
* AI 识别成功则用其结果覆盖省市区等字段,msg 为「自动识别错误,已使用ai重新识别」;
|
|
30058
|
+
* AI 识别失败则保留原识别内容,msg 为「自动识别错误,ai识别结果+接口msg」
|
|
30005
30059
|
*/
|
|
30006
|
-
function addressParse(
|
|
30007
|
-
|
|
30008
|
-
|
|
30009
|
-
|
|
30010
|
-
|
|
30011
|
-
|
|
30012
|
-
|
|
30013
|
-
|
|
30014
|
-
|
|
30015
|
-
|
|
30016
|
-
|
|
30017
|
-
|
|
30018
|
-
|
|
30019
|
-
|
|
30060
|
+
function addressParse(_x, _x2) {
|
|
30061
|
+
return _addressParse.apply(this, arguments);
|
|
30062
|
+
}
|
|
30063
|
+
function _addressParse() {
|
|
30064
|
+
_addressParse = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(address, sourceData) {
|
|
30065
|
+
var options,
|
|
30066
|
+
list,
|
|
30067
|
+
cleanAddress,
|
|
30068
|
+
parse,
|
|
30069
|
+
conflictLevel,
|
|
30070
|
+
chatResult,
|
|
30071
|
+
aiResult,
|
|
30072
|
+
_args = arguments;
|
|
30073
|
+
return _regenerator().w(function (_context) {
|
|
30074
|
+
while (1) switch (_context.n) {
|
|
30075
|
+
case 0:
|
|
30076
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
30077
|
+
list = getGlobalAreaList(options);
|
|
30078
|
+
if (list) {
|
|
30079
|
+
parseArea(list);
|
|
30080
|
+
}
|
|
30081
|
+
cleanAddress = preprocessAddress(address);
|
|
30082
|
+
parse = parseAddressDetail(cleanAddress, sourceData || {}, address); // 识别完毕后校验:输入文本中有明确的省市区文字,但识别结果与之不一致时,调用大模型接口重新识别
|
|
30083
|
+
conflictLevel = findParsedRegionConflict(parse, address);
|
|
30084
|
+
if (!conflictLevel) {
|
|
30085
|
+
_context.n = 2;
|
|
30086
|
+
break;
|
|
30087
|
+
}
|
|
30088
|
+
// 先设置本地识别错误提示,AI 识别成功/失败后覆盖为对应提示
|
|
30089
|
+
parse.msg = '自动识别识别错误:识别出的' + conflictLevel + '与输入地址不一致,请检查或手动填写';
|
|
30090
|
+
_context.n = 1;
|
|
30091
|
+
return parseAddressByChat(address);
|
|
30092
|
+
case 1:
|
|
30093
|
+
chatResult = _context.v;
|
|
30094
|
+
if (chatResult && chatResult.aiResult) {
|
|
30095
|
+
aiResult = chatResult.aiResult;
|
|
30096
|
+
parse.name = aiResult.name || '';
|
|
30097
|
+
parse.mobile = aiResult.mobile || '';
|
|
30098
|
+
parse.phone = aiResult.tel || '';
|
|
30099
|
+
parse.province = aiResult.province || '';
|
|
30100
|
+
parse.city = aiResult.city || '';
|
|
30101
|
+
parse.area = aiResult.area || '';
|
|
30102
|
+
parse.street = aiResult.street || '';
|
|
30103
|
+
parse.addr = aiResult.addr || '';
|
|
30104
|
+
parse.Abnormal = false;
|
|
30105
|
+
parse.msg = '自动识别错误,已使用ai重新识别';
|
|
30106
|
+
} else if (chatResult && chatResult.failMsg) {
|
|
30107
|
+
// AI 识别失败:还用原来的识别内容,把接口返回的 msg 提示上来
|
|
30108
|
+
parse.msg = '自动识别错误,ai识别结果' + chatResult.failMsg;
|
|
30109
|
+
}
|
|
30110
|
+
case 2:
|
|
30111
|
+
return _context.a(2, parse);
|
|
30112
|
+
}
|
|
30113
|
+
}, _callee);
|
|
30114
|
+
}));
|
|
30115
|
+
return _addressParse.apply(this, arguments);
|
|
30020
30116
|
}
|
|
30021
30117
|
;// ../../packages/utils/rewriteAttachmentUrl.js
|
|
30022
30118
|
|