群聊页面修正
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="group--chat">
|
<view class="chat">
|
||||||
<scroll-view class="body" :show-scrollbar="false">
|
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
|
||||||
|
|
||||||
|
<view class="body">
|
||||||
|
<view class="scroll">
|
||||||
<view class="cell" v-for="(item, index) in messages" :key="index">
|
<view class="cell" v-for="(item, index) in messages" :key="index">
|
||||||
<view class="cell-system" v-if="item.senderUserId === '__system__'">{{ item.content.message }}</view>
|
<view class="time" v-if="item.senderUserId === '__system__'">{{ item.content.message }}</view>
|
||||||
<view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
|
<view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
|
||||||
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
||||||
:src="contact(item.senderUserId).portraitUrl" />
|
:src="contact(item.senderUserId).portraitUrl" />
|
||||||
@@ -16,9 +19,8 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell-footer" ref="chatBottom"></view>
|
</view>
|
||||||
</scroll-view>
|
</view>
|
||||||
<sent-message-bar class="message-bar" :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -36,8 +38,6 @@
|
|||||||
import showText from '../components/showText'
|
import showText from '../components/showText'
|
||||||
import sentMessageBar from '../components/sentMessageBar'
|
import sentMessageBar from '../components/sentMessageBar'
|
||||||
|
|
||||||
const ChatList = uni.requireNativePlugin('dom')
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
showVoice,
|
showVoice,
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
computed: {
|
computed: {
|
||||||
latestMessage() {
|
latestMessage() {
|
||||||
if (this.messages.length) {
|
if (this.messages.length) {
|
||||||
return this.messages[this.messages.length - 1]
|
return this.messages[0]
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
sentTime: 0
|
sentTime: 0
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onScroll(e){
|
onScroll(e) {
|
||||||
this.$refs.messageBar.onHidePopus()
|
this.$refs.messageBar.onHidePopus()
|
||||||
},
|
},
|
||||||
toUser(item) {
|
toUser(item) {
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
this.messages = this.messages.concat(messages)
|
this.messages.unshift(...messages)
|
||||||
this.scrollBottom()
|
this.scrollBottom()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
20,
|
20,
|
||||||
true,
|
true,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
this.messages = messages.reverse()
|
this.messages = messages
|
||||||
this.scrollBottom()
|
this.scrollBottom()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -153,42 +153,44 @@
|
|||||||
// 更新badge提醒数量
|
// 更新badge提醒数量
|
||||||
im.setNotifyBadge()
|
im.setNotifyBadge()
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
let el = this.$refs.chatBottom
|
|
||||||
ChatList.scrollToElement(el, {
|
|
||||||
offset: 0,
|
|
||||||
animated: false
|
|
||||||
})
|
|
||||||
}, 50)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped lang="scss">
|
||||||
.group--chat {
|
/* 窗口 */
|
||||||
|
.chat {
|
||||||
background: $window-color;
|
background: $window-color;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column-reverse;
|
||||||
overflow: scroll;
|
|
||||||
.body {
|
.body {
|
||||||
|
overflow: scroll;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
|
||||||
|
.scroll {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
.cell {
|
.cell {
|
||||||
padding: 10rpx 30rpx;
|
padding: 10rpx 30rpx;
|
||||||
|
|
||||||
.cell-system {
|
.time {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cell-item {
|
.cell-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: flex-start;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
|
|
||||||
&.left {
|
&.left {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -203,19 +205,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 78rpx;
|
|
||||||
height: 78rpx;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.msg {
|
.msg {
|
||||||
margin: 0 20rpx;
|
margin: 0 20rpx;
|
||||||
|
|
||||||
.user {
|
.state {
|
||||||
font-size: 18rpx;
|
padding-top: 10rpx;
|
||||||
line-height: 40rpx;
|
|
||||||
|
.state-text {
|
||||||
|
font-size: $title-size-m - 2;
|
||||||
|
color: rgba($color: $main-color, $alpha: 0.3)
|
||||||
|
}
|
||||||
|
|
||||||
|
.state-text-active {
|
||||||
|
font-size: $title-size-m - 2;
|
||||||
|
color: #cecece;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,31 +229,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
|
||||||
background: white;
|
|
||||||
padding: 20rpx 30rpx;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
flex-direction: row;
|
|
||||||
|
|
||||||
.msg-type {
|
|
||||||
width: 70rpx;
|
|
||||||
height: 70rpx;
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
margin: 5rpx;
|
|
||||||
width: 60rpx;
|
|
||||||
height: 60rpx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-bar{
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -148,6 +148,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
/* 窗口 */
|
/* 窗口 */
|
||||||
.chat {
|
.chat {
|
||||||
|
|||||||
Reference in New Issue
Block a user