|
@@ -190,16 +190,28 @@ export default {
|
|
|
text: option.answer,
|
|
|
options: []
|
|
|
})
|
|
|
- await this.delay(1000);
|
|
|
- h5ChatItem.messages.push(nextMsg);
|
|
|
- } else {
|
|
|
- await this.delay(1000);
|
|
|
+ }
|
|
|
+ await this.delay(1000);
|
|
|
+ // 不管有没有 answer,都添加 nextMsg(如果存在)
|
|
|
+ if (nextMsg) {
|
|
|
h5ChatItem.messages.push(nextMsg);
|
|
|
+ if(nextMsg.options){
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- while((nextMsg = h5ChatItem.agentMsg.shift()) && (!nextMsg.options || nextMsg.options.length === 0)) {
|
|
|
- await this.delay(500+(Math.random()*1000)%500);
|
|
|
- h5ChatItem.messages.push(nextMsg);
|
|
|
+ while (h5ChatItem.agentMsg.length > 0) {
|
|
|
+ nextMsg = h5ChatItem.agentMsg.shift();
|
|
|
+ if (nextMsg && (!nextMsg.options || nextMsg.options.length === 0)) {
|
|
|
+ await this.delay(500 + (Math.random() * 1000) % 500);
|
|
|
+ h5ChatItem.messages.push(nextMsg);
|
|
|
+ } else {
|
|
|
+ //重新放回去
|
|
|
+ if(nextMsg){
|
|
|
+ h5ChatItem.agentMsg.unshift(nextMsg);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (h5ChatItem.agentMsg.length === 0) {
|