web/im/src/components/chat/panel/PanelHeader.vue

328 lines
6.7 KiB
Vue
Raw Normal View History

2022-12-28 10:08:51 +08:00
<template>
<el-header id="panel-header">
<div class="module left-module">
<span
class="icon-badge"
v-show="params.is_robot == 0"
:class="{ 'red-color': params.talk_type == 1 }"
>
2025-03-12 09:20:05 +08:00
{{ params.talk_type == 1 ? "好友" : "群组" }}
2022-12-28 10:08:51 +08:00
</span>
<span class="nickname">{{ params.nickname }}</span>
<span v-show="params.talk_type == 2" class="num">({{ groupNum }})</span>
2025-03-12 09:20:05 +08:00
<el-button type="danger" @click="userGz">{{
userobj.isMutual ? "取消关注" : "关注"
}}</el-button>
2022-12-28 10:08:51 +08:00
</div>
2025-03-12 09:20:05 +08:00
<div
v-show="params.talk_type == 1 && params.is_robot == 0"
class="module center-module"
>
2022-12-28 10:08:51 +08:00
<p class="online">
<span v-show="isOnline" class="online-status"></span>
2025-03-12 09:20:05 +08:00
<span>{{ isOnline ? "在线" : "离线" }}</span>
2022-12-28 10:08:51 +08:00
</p>
<p class="keyboard-status" v-show="isKeyboard">对方正在输入 ...</p>
</div>
2025-03-12 09:20:05 +08:00
<div class="module right-module">
2022-12-28 10:08:51 +08:00
<el-tooltip content="历史消息" placement="top">
<p v-show="params.is_robot == 0">
<i class="el-icon-time" @click="triggerEvent('history')" />
</p>
</el-tooltip>
<el-tooltip content="群公告" placement="top">
<p v-show="params.talk_type == 2">
<i class="iconfont icon-gonggao2" @click="triggerEvent('notice')" />
</p>
</el-tooltip>
<el-tooltip content="群设置" placement="top">
<p v-show="params.talk_type == 2">
<i class="el-icon-setting" @click="triggerEvent('setting')" />
</p>
</el-tooltip>
</div>
</el-header>
</template>
<script>
2025-03-12 09:20:05 +08:00
import { ServeSearchuserid, ServeDelete } from "@/api/contacts";
2022-12-28 10:08:51 +08:00
export default {
2025-03-12 09:20:05 +08:00
inject: ['callGrandfatherMethod','loadChatListMethod'],
2022-12-28 10:08:51 +08:00
props: {
data: {
type: Object,
default: () => {
return {
talk_type: 0,
receiver_id: 0,
params: 0,
2025-03-12 09:20:05 +08:00
nickname: "",
};
2022-12-28 10:08:51 +08:00
},
},
2025-03-12 09:20:05 +08:00
userobj: {
type: Object,
default: false,
},
2022-12-28 10:08:51 +08:00
online: {
type: Boolean,
default: false,
},
keyboard: {
type: [Boolean, Number],
default: false,
},
},
data() {
return {
params: {
talk_type: 0,
receiver_id: 0,
params: 0,
2025-03-12 09:20:05 +08:00
nickname: "",
2022-12-28 10:08:51 +08:00
},
isOnline: false,
isKeyboard: false,
groupNum: 0,
2025-03-12 09:20:05 +08:00
};
2022-12-28 10:08:51 +08:00
},
created() {
2025-03-12 09:20:05 +08:00
this.setParamsData(this.data);
this.setOnlineStatus(this.online);
2022-12-28 10:08:51 +08:00
},
watch: {
data(value) {
2025-03-12 09:20:05 +08:00
this.setParamsData(value);
2022-12-28 10:08:51 +08:00
},
online(value) {
2025-03-12 09:20:05 +08:00
this.setOnlineStatus(value);
2022-12-28 10:08:51 +08:00
},
keyboard(value) {
2025-03-12 09:20:05 +08:00
this.isKeyboard = value;
2022-12-28 10:08:51 +08:00
setTimeout(() => {
2025-03-12 09:20:05 +08:00
this.isKeyboard = false;
}, 2000);
2022-12-28 10:08:51 +08:00
},
},
methods: {
setOnlineStatus(value) {
2025-03-12 09:20:05 +08:00
this.isOnline = value;
2022-12-28 10:08:51 +08:00
},
setParamsData(object) {
2025-03-12 09:20:05 +08:00
Object.assign(this.params, object);
2022-12-28 10:08:51 +08:00
},
setGroupNum(value) {
2025-03-12 09:20:05 +08:00
this.groupNum = value;
2022-12-28 10:08:51 +08:00
},
triggerEvent(event_name) {
2025-03-12 09:20:05 +08:00
this.$emit("event", event_name);
},
userGz() {
//关注
if (!this.userobj.isMutual) {
ServeSearchuserid(
this.userobj.userId,
)
.then((res) => {
if (res.code == 200) {
this.callGrandfatherMethod();
this.loadChatListMethod()
} else {
this.error = true;
}
})
.finally(() => {
this.loading = false;
});
} else {
// 取消
ServeDelete(this.userobj.userId|| this.userobj.friendId)
.then((res) => {
if (res.code == 200) {
this.callGrandfatherMethod();
this.loadChatListMethod()
} else {
this.error = true;
}
})
.finally(() => {
this.loading = false;
});
}
2022-12-28 10:08:51 +08:00
},
},
2025-03-12 09:20:05 +08:00
};
2022-12-28 10:08:51 +08:00
</script>
<style lang="less" scoped>
#panel-header {
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
border-bottom: 1px solid #f5eeee;
.module {
width: 100%/3;
height: 100%;
display: flex;
align-items: center;
}
.left-module {
padding-right: 5px;
.icon-badge {
background: rgb(81 139 254);
height: 18px;
line-height: 18px;
padding: 1px 3px;
font-size: 10px;
color: white;
border-radius: 3px;
margin-right: 8px;
flex-shrink: 0;
&.red-color {
background: #f97348;
}
}
.nickname {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
.center-module {
flex-direction: column;
justify-content: center;
.online {
color: #cccccc;
font-weight: 300;
font-size: 15px;
&.color {
color: #1890ff;
}
.online-status {
position: relative;
top: -1px;
display: inline-block;
width: 6px;
height: 6px;
vertical-align: middle;
border-radius: 50%;
position: relative;
background-color: #1890ff;
margin-right: 5px;
&:after {
position: absolute;
top: -1px;
left: -1px;
width: 100%;
height: 100%;
border: 1px solid #1890ff;
border-radius: 50%;
-webkit-animation: antStatusProcessing 1.2s ease-in-out infinite;
animation: antStatusProcessing 1.2s ease-in-out infinite;
2025-03-12 09:20:05 +08:00
content: "";
2022-12-28 10:08:51 +08:00
}
}
}
.keyboard-status {
height: 20px;
line-height: 18px;
font-size: 10px;
animation: inputfade 600ms infinite;
-webkit-animation: inputfade 600ms infinite;
}
}
.right-module {
display: flex;
justify-content: flex-end;
align-items: center;
p {
cursor: pointer;
margin: 0 8px;
font-size: 20px;
color: #828f95;
&:active i {
font-size: 26px;
transform: scale(1.3);
transition: ease 0.5s;
color: red;
}
}
}
}
/* css 动画 */
@keyframes inputfade {
from {
opacity: 1;
}
50% {
opacity: 0.4;
}
to {
opacity: 1;
}
}
@-webkit-keyframes inputfade {
from {
opacity: 1;
}
50% {
opacity: 0.4;
}
to {
opacity: 1;
}
}
@-webkit-keyframes antStatusProcessing {
0% {
-webkit-transform: scale(0.8);
transform: scale(0.8);
opacity: 0.5;
}
to {
-webkit-transform: scale(2.4);
transform: scale(2.4);
opacity: 0;
}
}
@keyframes antStatusProcessing {
0% {
-webkit-transform: scale(0.8);
transform: scale(0.8);
opacity: 0.5;
}
to {
-webkit-transform: scale(2.4);
transform: scale(2.4);
opacity: 0;
}
}
2025-03-12 09:20:05 +08:00
.el-button {
padding: 2px 15px;
margin-left: 10px;
}
2022-12-28 10:08:51 +08:00
</style>