会话群调整
This commit is contained in:
parent
6d4e28a0dc
commit
740e676971
@ -67,7 +67,9 @@ export default {
|
||||
textContent: '',
|
||||
currentAudioList:[],
|
||||
currentMessage: {},
|
||||
trainingDesign: false
|
||||
trainingDesign: false,
|
||||
contentDom: '',
|
||||
isBottom: false
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
@ -104,20 +106,37 @@ export default {
|
||||
this.trainingDesign = val.trainingDesign;
|
||||
},
|
||||
lastMessage(newVal, oldVal) {
|
||||
if (newVal && oldVal && (newVal.id != oldVal.id)) {
|
||||
if (newVal !== oldVal && this.isBottom) {
|
||||
this.scrollTop();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.trainingDesign = this.$store.state.training.domConfig ? this.$store.state.training.domConfig.trainingDesign : false;
|
||||
this.contentDom = document.querySelector('.chat-box-content');
|
||||
this.contentDom.onscroll = () => {
|
||||
this.setIsBottomFn();
|
||||
};
|
||||
this.isBottom = true;
|
||||
this.scrollTop();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.contentDom.onscroll = null;
|
||||
},
|
||||
methods: {
|
||||
setIsBottomFn() {
|
||||
const scrollTop = this.contentDom.scrollHeight - this.contentDom.clientHeight;
|
||||
if (scrollTop == 0 || this.contentDom.scrollTop >= scrollTop) {
|
||||
this.isBottom = true;
|
||||
} else {
|
||||
this.isBottom = false;
|
||||
}
|
||||
},
|
||||
scrollTop() {
|
||||
this.$nextTick(() => {
|
||||
const scrollTop = this.messageList.length * 62;
|
||||
document.querySelector('.chat-box-content').scrollTop = scrollTop;
|
||||
// const scrollTop = this.messageList.length * 62;
|
||||
const scrollTop = this.contentDom.scrollHeight - this.contentDom.clientHeight;
|
||||
this.contentDom.scrollTop = scrollTop;
|
||||
});
|
||||
},
|
||||
playAllAudio() {
|
||||
|
Loading…
Reference in New Issue
Block a user