聊天列表自动到底,如果列表数据较短的时候,还没有好办法实现

This commit is contained in:
2022-02-18 17:02:32 +08:00
parent 0deef8bc6a
commit e957217635
2 changed files with 69 additions and 65 deletions

View File

@@ -374,7 +374,10 @@
"path": "pages/im/private/chat",
"style": {
"navigationBarTitleText": "聊天",
"navigationBarBackgroundColor": "#F3F6FB"
"navigationBarBackgroundColor": "#F3F6FB",
"app-plus": {
"bounce": "none"
}
}
},
{

View File

@@ -1,7 +1,9 @@
<template>
<view class="chat">
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
<!-- chat -->
<view class="body">
<view class="scroll">
<view class="cell" v-for="(item, index) in messages" :key="index">
<view class="time">{{ item.sentTime|timeCustomCN }}</view>
<view :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
@@ -23,7 +25,7 @@
</view>
</view>
</view>
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
</view>
</view>
</template>
@@ -109,9 +111,8 @@
1,
false,
(messages) => {
console.log(messages);
this.messages.unshift(...messages)
// this.scrollBottom()
this.scrollBottom()
})
},
// 获取消息列表
@@ -124,7 +125,7 @@
true,
(messages) => {
this.messages = messages
// this.scrollBottom()
this.scrollBottom()
})
},
// 展示好友信息, type 1 是自己, 2 是对方
@@ -145,13 +146,6 @@
// 更新badge提醒数量
im.setNotifyBadge()
}
setTimeout(() => {
let el = this.$refs.chatBottom
ChatList.scrollToElement(el, {
offset: 0,
animated: false
})
}, 50)
}
}
}
@@ -160,13 +154,19 @@
<style scoped lang="scss">
/* 窗口 */
.chat {
background: $window-color;
height: 100vh;
display: flex;
flex-direction: column;
overflow: scroll;
flex-direction: column-reverse;
.body {
overflow: scroll;
flex: 1;
height: 0;
display: flex;
flex-direction: column-reverse;
.scroll {
display: flex;
flex-direction: column-reverse;
justify-content: flex-end;
@@ -223,4 +223,5 @@
}
}
}
}
</style>