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(() => {});
|
||||
},
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
show-scrollbar="{{false}}"
|
||||
scroll-with-animation
|
||||
>
|
||||
<!-- Floating History Button (always visible) -->
|
||||
<view class="chat-history-float" bindtap="goToHistory" wx:if="{{messages.length > 0}}">
|
||||
<t-icon name="time" size="28rpx" color="#558B2F" />
|
||||
<text>历史记录</text>
|
||||
</view>
|
||||
<!-- Welcome -->
|
||||
<view class="welcome" wx:if="{{messages.length === 0}}">
|
||||
<view class="welcome-glow"></view>
|
||||
|
||||
@@ -12,6 +12,23 @@
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.chat-history-float {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
justify-content: center;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(10px);
|
||||
padding: 12rpx 28rpx;
|
||||
border-radius: 32rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
color: #558B2F;
|
||||
width: fit-content;
|
||||
margin: 0 auto 24rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
/* ── Welcome ── */
|
||||
.welcome {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user