Revert "群消息已读"

This reverts commit 0805383f
This commit is contained in:
fan 2023-05-06 10:52:15 +08:00
parent c563fe8efa
commit 204aef1583
3 changed files with 38 additions and 59 deletions

View File

@ -172,18 +172,3 @@ export function sendBase64(groupId, data) {
data
});
}
/**
* 设置群消息已读
* @param {String} groupId 房间号
* @param {Object} data
* @param {Number} data.id 群组id
* @returns
*/
export function setGroupReadMessage(groupId, data) {
return request({
url: `/simulation/${groupId}/operate/Conversation_Group_Read_Message`,
method: 'post',
data
});
}

View File

@ -40,12 +40,9 @@
</div>
<div class="middleMain">
<div v-for="(item, index) in groupList" :key="index" class="row pointer" :class="{active: item.id === id}" @click="groupClick(item)">
<div v-show="false" class="groupIcon">
<img :src="getImgUrl(item.imageUrl)" alt="">
</div>
<el-badge :value="getBadge(item.messageList)" :hidden="!getBadge(item.messageList)" :max="99" class="badge" />
<div v-show="item.imageUrl" class="groupIcon"><img :src="getImgUrl(item.imageUrl)" alt=""></div>
<div class="groupInfo">
<div class="text"><b>{{ getGroupName(item) }}</b></div>
<div class="text"><b>{{ item.name }}</b></div>
<div class="text">{{ getLastMsg(item.messageList) }}</div>
</div>
<div class="groupMarke">
@ -56,6 +53,12 @@
</div>
</div>
<div class="right">
<!-- <div v-for="(item, index) in activeMessageList" :key="index">
<span>{{ item.time }}</span>
<span>{{ item.content }}</span>
</div>
<el-input v-model="inputMsg" />
<el-button @click="sendMsg">发送</el-button> -->
<chat-content :id="id" :message-list="activeMessageList" />
</div>
</div>
@ -63,13 +66,13 @@
<div v-else-if="tabActive==2">工作台</div>
<div v-else-if="tabActive==3">通讯录</div>
</div>
<edit-group ref="editGroup" />
<EditGroup ref="editGroup" />
</el-dialog>
</template>
<script>
import {mapGetters} from 'vuex';
import { getGroupList, setGroupReadMessage } from '@/api/newChat';
import { getGroupList, sendText } from '@/api/newChat';
import { timestampFormat } from '@/utils/date';
import ChatContent from './chatContent';
import EditGroup from './editGroup';
@ -84,6 +87,7 @@ export default {
},
data() {
return {
inputMsg: '',
logoImgUrl: '',
dialogVisible: false,
tabs: [
@ -116,9 +120,6 @@ export default {
myMemberId() {
return this.$store.state.training.myMemberId;
},
memberData() {
return this.$store.state.training.memberData;
},
activeMessageList() {
let list = [];
const find = this.groupList.find(item => {
@ -142,13 +143,24 @@ export default {
});
if (find) {
find.messageList.push(val.message);
if (this.id == val.id) {
this.setReadGroup();
}
}
},
'$store.state.socket.conversationGroup.MESSAGE_STATUS': function(val) {
this.getMessageStatus(val);
const find = this.groupList.find(item => {
return item.id == val.id;
});
if (find) {
const index = find.messageList.findIndex(item => {
return item.id == val.message.id;
});
if (index > -1) {
const obj = {
...find.messageList[index],
...val.message
};
find.messageList.splice(index, 1, obj);
}
}
},
'$store.state.socket.conversationGroup.JOIN': function(val) {
if (val.messageTips) {
@ -210,6 +222,14 @@ export default {
createGroup() {
this.$refs.editGroup.doShow();
},
sendMsg() {
sendText(this.groupId, {id: this.id, content:this.inputMsg}).then(res => {
console.log(res, '--res--');
this.inputMsg = '';
}).catch(err => {
console.log(err, '--err--');
});
},
getLastMsg(list) {
let msg = '';
if (list.length) {
@ -273,24 +293,6 @@ export default {
},
groupClick(item) {
this.id = item.id;
this.setReadGroup();
},
setReadGroup() {
const id = this.id;
setGroupReadMessage(this.groupId, {id}).then(res => {
console.log(res, '设置已读res');
res.data.forEach(item => {
const obj = {
id: id,
message: {
...item
}
};
this.getMessageStatus(obj);
});
}).catch(err => {
console.log(err, 'err设置已读失败');
});
},
handleClose() {
this.$store.dispatch('training/setChatBoxMin', true);
@ -413,12 +415,11 @@ export default {
overflow-y: auto;
height: calc(100% - 40px);
.row {
padding: 10px 5px;
padding: 5px;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 5px;
position: relative;
&:hover {
background: #ddd;
}
@ -426,16 +427,10 @@ export default {
width: 40px;
height: 40px;
img {
border-radius: 5px;
width: 100%;
height: 100%;
}
}
.badge {
position: absolute;
top: 5px;
left: 1px;
}
.groupInfo {
display: flex;
flex-direction: column;
@ -443,7 +438,6 @@ export default {
overflow: hidden;
.text {
height: 22px;
line-height: 22px;
padding: 3px 5px;
overflow: hidden;
text-overflow: ellipsis;

View File

@ -50,13 +50,13 @@
<el-form-item label="群名称:" prop="name">
<el-input v-model="form.name" />
</el-form-item>
<!-- <el-form-item label="群头像:" prop="imageUrl">
<el-form-item label="群头像:" prop="imageUrl">
<div class="uploadImgDiv">
<img v-if="form.imageUrl" :src="getImgUrl(form.imageUrl)" :alt="getImgUrl(form.imageUrl)">
<i class="el-icon-plus" />
<input id="upload_file_group" ref="files" type="file" class="input_file_box" accept="image/jpeg,image/png" @change="uploadLogo()">
</div>
</el-form-item> -->
</el-form-item>
<el-form-item>
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="onSubmit">确定</el-button>
@ -538,7 +538,7 @@ $imgHeight: 70px;
.tagBox {
margin: 10px;
overflow-y: auto;
height: 400px;
height: 300px;
.tag {
margin: 5px 10px;
}