@bytenew/bn-applet-ui 1.1.74 → 1.1.76
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.
|
@@ -29985,13 +29985,16 @@ function findParsedRegionConflict(parse, originalAddress) {
|
|
|
29985
29985
|
|
|
29986
29986
|
/**
|
|
29987
29987
|
* 本地识别错误时,使用原生 fetch 调用大模型接口重新识别
|
|
29988
|
-
*
|
|
29988
|
+
* options.platform == 'plugin'(插件端):POST /project/column/addressBychat,请求体 {content: 待识别文本}
|
|
29989
|
+
* 其他端:GET /v2/project/column/addressBychat?contents={待识别文本}
|
|
29989
29990
|
* 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
|
|
29990
29991
|
* @param {string} address 原始地址字符串
|
|
29992
|
+
* @param {object} [options] 可选配置,platform === 'plugin' 表示插件端
|
|
29991
29993
|
* @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
|
|
29992
29994
|
* 成功返回 {aiResult}(content 解析后的对象);失败返回 {failMsg}(接口 msg);不支持 fetch 返回 null
|
|
29993
29995
|
*/
|
|
29994
29996
|
function parseAddressByChat(address) {
|
|
29997
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29995
29998
|
// 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
|
|
29996
29999
|
if (typeof fetch !== 'function') {
|
|
29997
30000
|
console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
|
|
@@ -30005,10 +30008,21 @@ function parseAddressByChat(address) {
|
|
|
30005
30008
|
var isLocal = hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '0.0.0.0' || hostname === '[::1]';
|
|
30006
30009
|
baseUrl = isLocal ? '/proxyWay' : '';
|
|
30007
30010
|
}
|
|
30008
|
-
|
|
30009
|
-
|
|
30011
|
+
// 插件端走单独接口:POST /project/column/addressBychat;其他端走 v2 的 GET 接口
|
|
30012
|
+
var isPlugin = options.platform === 'plugin';
|
|
30013
|
+
var url = baseUrl + (isPlugin ? '/project/column/addressBychat' : '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address));
|
|
30014
|
+
var fetchOptions = isPlugin ? {
|
|
30015
|
+
method: 'POST',
|
|
30016
|
+
headers: {
|
|
30017
|
+
'Content-Type': 'application/json'
|
|
30018
|
+
},
|
|
30019
|
+
body: JSON.stringify({
|
|
30020
|
+
content: address
|
|
30021
|
+
})
|
|
30022
|
+
} : {
|
|
30010
30023
|
method: 'GET'
|
|
30011
|
-
}
|
|
30024
|
+
};
|
|
30025
|
+
return fetch(url, fetchOptions).then(function (r) {
|
|
30012
30026
|
return r.json();
|
|
30013
30027
|
}).then(function (res) {
|
|
30014
30028
|
if (res && !res.code && res.data && res.data.content) {
|
|
@@ -30074,10 +30088,8 @@ function _addressParse() {
|
|
|
30074
30088
|
_context.n = 2;
|
|
30075
30089
|
break;
|
|
30076
30090
|
}
|
|
30077
|
-
// 先设置本地识别错误提示,AI 识别成功/失败后覆盖为对应提示
|
|
30078
|
-
parse.msg = '自动识别识别错误:识别出的' + conflictLevel + '与输入地址不一致,请检查或手动填写';
|
|
30079
30091
|
_context.n = 1;
|
|
30080
|
-
return parseAddressByChat(address);
|
|
30092
|
+
return parseAddressByChat(address, options);
|
|
30081
30093
|
case 1:
|
|
30082
30094
|
chatResult = _context.v;
|
|
30083
30095
|
if (chatResult && chatResult.aiResult) {
|
|
@@ -30091,7 +30103,7 @@ function _addressParse() {
|
|
|
30091
30103
|
parse.street = aiResult.street || '';
|
|
30092
30104
|
parse.addr = aiResult.addr || '';
|
|
30093
30105
|
parse.Abnormal = false;
|
|
30094
|
-
parse.msg = '
|
|
30106
|
+
parse.msg = aiResult.msg || '';
|
|
30095
30107
|
} else if (chatResult && chatResult.failMsg) {
|
|
30096
30108
|
// AI 识别失败:还用原来的识别内容,把接口返回的 msg 提示上来
|
|
30097
30109
|
parse.msg = '自动识别错误,ai识别结果' + chatResult.failMsg;
|