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.

168 lines
3.1 KiB

<template>
2 years ago
<div class="chat-item" :class="active ? 'active' : ''" @contextmenu.prevent="showRightMenu($event)">
<div class="chat-left">
<head-image :url="chat.headImage" :size="50" :id="chat.type=='PRIVATE'?chat.targetId:0"></head-image>
<div v-show="chat.unreadCount>0" class="unread-text">{{chat.unreadCount}}</div>
</div>
2 years ago
<div class="chat-right">
<div class="chat-name">
{{ chat.showName}}
</div>
<div class="chat-content">
<div class="chat-content-text" v-html="$emo.transform(chat.lastContent)"></div>
<div class="chat-time">{{showTime}}</div>
</div>
</div>
2 years ago
<right-menu v-show="rightMenu.show" :pos="rightMenu.pos" :items="rightMenu.items"
@close="rightMenu.show=false" @select="handleSelectMenu"></right-menu>
</div>
</template>
<script>
import HeadImage from '../common/HeadImage.vue';
2 years ago
import RightMenu from '../common/RightMenu.vue';
export default {
name: "chatItem",
components: {
2 years ago
HeadImage,
RightMenu
},
data() {
2 years ago
return {
rightMenu: {
show: false,
pos: {
x: 0,
y: 0
},
items: [{
key: 'TOP',
name: '置顶',
icon: 'el-icon-top'
}, {
key: 'DELETE',
name: '删除',
icon: 'el-icon-delete'
}]
}
}
},
props: {
chat: {
type: Object
},
active: {
type: Boolean
},
index: {
type: Number
}
},
methods: {
2 years ago
showRightMenu(e) {
this.rightMenu.pos = {
x: e.x,
y: e.y
};
this.rightMenu.show = "true";
},
handleSelectMenu(item) {
this.$emit(item.key.toLowerCase(), this.msgInfo);
}
},
computed: {
showTime() {
return this.$date.toTimeText(this.chat.lastSendTime, true)
}
}
}
</script>
2 years ago
<style lang="scss">
.chat-item {
2 years ago
height: 65px;
display: flex;
margin-bottom: 1px;
position: relative;
2 years ago
padding-left: 10px;
align-items: center;
padding-right: 5px;
background-color: #fafafa;
white-space: nowrap;
2 years ago
color: black;
cursor: pointer;
&:hover {
background-color: #eeeeee;
}
&.active {
2 years ago
background-color: #e8e8f0;
}
2 years ago
.chat-left {
position: relative;
display: flex;
2 years ago
width: 50px;
height: 50px;
.unread-text {
position: absolute;
background-color: #f56c6c;
2 years ago
right: -5px;
top: -5px;
color: white;
border-radius: 30px;
2 years ago
padding: 1px 5px;
font-size: 10px;
text-align: center;
white-space: nowrap;
border: 1px solid #f1e5e5;
}
}
2 years ago
.chat-right {
flex: 1;
display: flex;
flex-direction: column;
2 years ago
padding-left: 10px;
text-align: left;
2 years ago
.chat-name {
2 years ago
font-size: 16px;
2 years ago
font-weight: 600;
line-height: 30px;
white-space: nowrap;
2 years ago
overflow: hidden;
}
2 years ago
.chat-content {
display: flex;
2 years ago
.chat-content-text {
flex: 2;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
2 years ago
img {
width: 30px !important;
height: 30px !important;
}
}
.chat-time {
flex: 1;
font-size: 13px;
text-align: right;
color: #888888;
white-space: nowrap;
overflow: hidden;
}
}
}
}
2 years ago
</style>