完善报价业务问答与连续追问,补齐订单列表和人工转接
This commit is contained in:
+12
-2
@@ -1227,13 +1227,14 @@ window.showHuman = async function(){
|
||||
if(humanRequestToken !== token || token.version !== conversationVersion) return;
|
||||
const data = await humanRequest('/api/visitor/human/request', {conv_id:cid});
|
||||
if(humanRequestToken !== token || token.version !== conversationVersion) return;
|
||||
if(data.closed){ await leaveOfflineMessage(); return; }
|
||||
if(data.closed) return await leaveOfflineMessage();
|
||||
if(!data.ok || !data.session_id) throw new Error('Human session failed');
|
||||
window.humanSid = data.session_id;
|
||||
humanConvId = cid;
|
||||
humanStatus = 'waiting';
|
||||
addMsg(t('humanWaiting'), false);
|
||||
startHumanPoll();
|
||||
return true;
|
||||
}catch(error){
|
||||
if(humanRequestToken === token && token.version === conversationVersion) setComposerStatus(t('humanConnectFailed'), true);
|
||||
}finally{
|
||||
@@ -1298,7 +1299,7 @@ async function leaveOfflineMessage(){
|
||||
try{
|
||||
const data = await humanRequest('/api/ticket', {content:message, phone:''});
|
||||
if(!data.ok) throw new Error('Ticket failed');
|
||||
if(version === conversationVersion) addMsg(t('offlineSaved'), false);
|
||||
if(version === conversationVersion){ addMsg(t('offlineSaved'), false); return true; }
|
||||
}catch(error){
|
||||
if(version !== conversationVersion) return;
|
||||
if(!inputDom.value){ inputDom.value = message; autoGrow(); }
|
||||
@@ -1653,6 +1654,15 @@ async function doSend(retryText, showQuestion){
|
||||
if(window.humanSid) stopHumanMode();
|
||||
|
||||
if(sendPreparing || (window.__busy && !retryText)) return; // 防连点
|
||||
const humanCommand = sendWord.replace(/[\s,,。.!!??]/g, '');
|
||||
if(!imgUrl && /^(?:(?:请|麻烦)?(?:帮我)?)?(?:转(?:接|到)?|联系|找)(?:一下|个)?人工(?:客服)?(?:吧|谢谢)?$/.test(humanCommand)){
|
||||
const version = conversationVersion;
|
||||
const connected = await window.showHuman();
|
||||
if(connected && version === conversationVersion && !isRetry && inputDom.value === draft){
|
||||
inputDom.value = ''; autoGrow(); flushDraft();
|
||||
}
|
||||
return !!connected;
|
||||
}
|
||||
if(cancelActive){ cancelActive(); cancelActive = null; }
|
||||
|
||||
sendPreparing = true;
|
||||
|
||||
Reference in New Issue
Block a user