|
|
@@ -31,6 +31,7 @@ interface MessageType {
|
|
|
Component({
|
|
|
lifetimes: {
|
|
|
attached: function () {
|
|
|
+
|
|
|
let isAnalysis: number;
|
|
|
isAnalysis = wx.getStorageSync("isAnalysis");
|
|
|
if (isAnalysis === 3 || isAnalysis === 4) {
|
|
|
@@ -67,6 +68,8 @@ Component({
|
|
|
} as AnyObject,
|
|
|
|
|
|
_timestamp: Date.now(),
|
|
|
+ // 防止 _next 被并发/重复触发(例如 classify === 'tongue' 时)
|
|
|
+ _requesting: false,
|
|
|
},
|
|
|
observers: {
|
|
|
"messages.**"(messages) {
|
|
|
@@ -180,9 +183,13 @@ Component({
|
|
|
}
|
|
|
},
|
|
|
async _next() {
|
|
|
+ // 并发与重复触发保护
|
|
|
+ if (this.data._requesting) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setData({ _requesting: true });
|
|
|
let isAnalysis: number;
|
|
|
isAnalysis = wx.getStorageSync("isAnalysis");
|
|
|
- console.log("isAnalysis", isAnalysis, this.data._next);
|
|
|
if (isAnalysis === 3 || isAnalysis === 4) {
|
|
|
// 对话管家
|
|
|
if (this.data._next.classify === "tongue") {
|
|
|
@@ -291,7 +298,6 @@ Component({
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- console.log("最后一个问题", data,isAnalysis);
|
|
|
// 对话管家
|
|
|
if (
|
|
|
(isAnalysis === 3 && data.classify === "report") ||
|
|
|
@@ -313,7 +319,6 @@ Component({
|
|
|
this.triggerEvent("to");
|
|
|
}
|
|
|
if (data.over) {
|
|
|
- console.log("结束触发", data, isAnalysis);
|
|
|
// 延迟触发滚动,确保报告消息已经渲染完成
|
|
|
setTimeout(() => {
|
|
|
this.triggerEvent("to");
|
|
|
@@ -327,7 +332,6 @@ Component({
|
|
|
[`_next.questions`]: data.nextQuestions,
|
|
|
});
|
|
|
|
|
|
- console.log("页面向上移动", data,isAnalysis);
|
|
|
this.triggerEvent("to");
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -348,6 +352,9 @@ Component({
|
|
|
});
|
|
|
this._end();
|
|
|
}
|
|
|
+ } finally {
|
|
|
+ // 恢复请求锁
|
|
|
+ this.setData({ _requesting: false });
|
|
|
}
|
|
|
},
|
|
|
|