diff --git a/pages/fun/AiDrama.vue b/pages/fun/AiDrama.vue index 99957a5..c0555c2 100644 --- a/pages/fun/AiDrama.vue +++ b/pages/fun/AiDrama.vue @@ -530,16 +530,30 @@ export default { scrollToBottom() { this.$nextTick(() => { setTimeout(() => { - const query = uni.createSelectorQuery().in(this); - query.select('#scroll-bottom-anchor').boundingClientRect(data => { - if (data) { - // Scroll to anchor element position - uni.pageScrollTo({ - selector: '#scroll-bottom-anchor', - duration: 100 - }); - } - }).exec(); + this.$nextTick(() => { + const query = uni.createSelectorQuery() + query.select('.chat-content').boundingClientRect() + query.select('.message-wrapper-box').boundingClientRect() + query.exec(res => { + const scrollViewHeight = res[0].height + const scrollContentHeight = res[1].height + if (scrollContentHeight > scrollViewHeight) { + const scrollTop = scrollContentHeight - scrollViewHeight + this.scrollTop = scrollTop + } + }) + }) + + // const query = uni.createSelectorQuery().in(this); + // query.select('#scroll-bottom-anchor').boundingClientRect(data => { + // if (data) { + // // Scroll to anchor element position + // uni.pageScrollTo({ + // selector: '#scroll-bottom-anchor', + // duration: 100 + // }); + // } + // }).exec(); }, 100); }); },