feat: ai问答
This commit is contained in:
@@ -10,6 +10,7 @@ Page({
|
||||
_counter: 0,
|
||||
quotaRemaining: -1,
|
||||
quotaLimit: 0,
|
||||
_pendingPrefill: '',
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -23,8 +24,9 @@ Page({
|
||||
this.setData({ messages: msgs, _counter: 2 }, () => this.scrollToBottom());
|
||||
});
|
||||
} else if (options && options.prefillQuestion) {
|
||||
const q = decodeURIComponent(options.prefillQuestion);
|
||||
this.setData({ inputValue: q }, () => this.onSend());
|
||||
// Only save the question; actual send waits for quota check in onShow
|
||||
this._pendingPrefill = decodeURIComponent(options.prefillQuestion);
|
||||
this.setData({ inputValue: this._pendingPrefill });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -38,6 +40,16 @@ Page({
|
||||
quotaRemaining: res.remaining,
|
||||
quotaLimit: res.limit,
|
||||
});
|
||||
// Auto-send prefill question only after quota is confirmed
|
||||
if (this._pendingPrefill) {
|
||||
const q = this._pendingPrefill;
|
||||
this._pendingPrefill = '';
|
||||
if (res.remaining > 0) {
|
||||
this.onSend();
|
||||
} else {
|
||||
wx.showToast({ title: '今日问答次数已用完,明天再来吧', icon: 'none', duration: 2500 });
|
||||
}
|
||||
}
|
||||
}).catch(() => {});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user