You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
3.7 KiB

<template>
<view class="chat-item" :class="active?'active':''">
<!--rich-text中的表情包会屏蔽事件所以这里用一个遮罩层捕获点击事件 -->
<view class="mask" @tap="showChatBox()"></view>
<view class="left">
1 year ago
<head-image :url="chat.headImage" :name="chat.showName"></head-image>
</view>
2 years ago
<view class="chat-right">
<view class="chat-name">
<view class="chat-name-text">
<view>{{chat.showName}}</view>
1 year ago
<uni-tag v-if="chat.type=='GROUP'" circle text="群" size="small" type="primary"></uni-tag>
</view>
<view class="chat-time">{{$date.toTimeText(chat.lastSendTime,true)}}</view>
2 years ago
</view>
<view class="chat-content">
2 years ago
<view class="chat-at-text">{{atText}}</view>
<view class="chat-send-name" v-if="isShowSendName">{{chat.sendNickName+':&nbsp;'}}</view>
<rich-text class="chat-content-text" :nodes="$emo.transform(chat.lastContent)"></rich-text>
1 year ago
<uni-badge v-if="chat.unreadCount>0" :max-num="99" :text="chat.unreadCount" />
</view>
</view>
</view>
</template>
<script>
export default {
name: "chatItem",
data() {
return {}
},
props: {
chat: {
type: Object
},
index: {
type: Number
},
active: {
type: Boolean,
default: false
}
},
methods: {
2 years ago
showChatBox() {
uni.navigateTo({
2 years ago
url: "/pages/chat/chat-box?chatIdx=" + this.index
})
}
2 years ago
},
computed: {
isShowSendName() {
if (!this.chat.sendNickName) {
return false;
}
let size = this.chat.messages.length;
if (size == 0) {
return false;
}
// 只有群聊的普通消息需要显示名称
let lastMsg = this.chat.messages[size - 1];
return this.$msgType.isNormal(lastMsg.type)
},
2 years ago
atText() {
if (this.chat.atMe) {
return "[有人@我]"
} else if (this.chat.atAll) {
return "[@全体成员]"
}
return "";
}
}
}
</script>
2 years ago
<style scoped lang="scss">
.chat-item {
1 year ago
height: 96rpx;
display: flex;
1 year ago
margin-bottom: 2rpx;
position: relative;
1 year ago
padding: 18rpx 20rpx;
align-items: center;
background-color: white;
white-space: nowrap;
2 years ago
&:hover {
1 year ago
background-color: $im-bg-active;
}
&.active {
1 year ago
background-color: $im-bg-active;
}
.mask {
position: absolute;
width: 100%;
height: 100%;
1 year ago
left: 0;
right: 0;
z-index: 99;
}
.left {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 100rpx;
height: 100rpx;
}
2 years ago
.chat-right {
1 year ago
height: 100%;
2 years ago
flex: 1;
display: flex;
flex-direction: column;
1 year ago
justify-content: center;
2 years ago
padding-left: 20rpx;
text-align: left;
2 years ago
overflow: hidden;
2 years ago
.chat-name {
display: flex;
2 years ago
2 years ago
.chat-name-text {
2 years ago
flex: 1;
1 year ago
font-size: $im-font-size-large;
2 years ago
white-space: nowrap;
overflow: hidden;
1 year ago
display: flex;
align-items: center;
1 year ago
.uni-tag {
text-align: center;
1 year ago
margin-left: 5rpx;
border: 0;
padding: 1px 5px;
1 year ago
//opacity: 0.8;
1 year ago
}
2 years ago
}
.chat-time {
1 year ago
font-size: $im-font-size-smaller-extra;
color: $im-text-color-lighter;
text-align: right;
2 years ago
white-space: nowrap;
overflow: hidden;
}
}
2 years ago
.chat-content {
display: flex;
1 year ago
font-size: $im-font-size-smaller;
color: $im-text-color-lighter;
padding-top: 8rpx;
2 years ago
.chat-at-text {
1 year ago
color: $im-color-danger;
}
2 years ago
.chat-send-name {
1 year ago
font-size: $im-font-size-smaller;
2 years ago
}
.chat-content-text {
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
1 year ago
img {
width: 40rpx !important;
height: 40rpx !important;
}
2 years ago
}
2 years ago
2 years ago
}
2 years ago
}
}
2 years ago
</style>