25
This commit is contained in:
@@ -45,6 +45,11 @@
|
||||
created() {
|
||||
this.init(this.src);
|
||||
},
|
||||
watch: {
|
||||
src(newVal) {
|
||||
this.init(newVal);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
init(nv){
|
||||
const _this = this;
|
||||
|
||||
@@ -361,7 +361,7 @@
|
||||
if (_this.storeCurrentUserID == data.sendID && diff < 120000) {
|
||||
menu.push('撤回')
|
||||
}
|
||||
if(_this.isAdmin | _this.isOwner){
|
||||
if(_this.isAdmin || _this.isOwner){
|
||||
menu.push('撤回(管理员功能)')
|
||||
}
|
||||
uni.showActionSheet({
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
load_status:"loadmore",
|
||||
param: {
|
||||
groupID: "",
|
||||
offset: 0,
|
||||
offset: 999999999999,
|
||||
limit: 10,
|
||||
trace: 1,
|
||||
}
|
||||
@@ -120,9 +120,11 @@
|
||||
this.getList(true);
|
||||
},
|
||||
getList(isFirstPage = false) {
|
||||
this.param.offset = 21;
|
||||
if (isFirstPage === true) {
|
||||
this.list = [];
|
||||
this.param.offset = 0;
|
||||
this.param.offset = 20;
|
||||
this.param.offset = 999999999999;
|
||||
}
|
||||
this.load_status = 'loading';
|
||||
uni.$u.http.post('/group/album_list', this.param).then(res => {
|
||||
@@ -258,7 +260,8 @@
|
||||
|
||||
}
|
||||
});
|
||||
if(data.code == 0){
|
||||
console.log(result);
|
||||
if(result.code == 0){
|
||||
_this.fileList[i].status = 1;
|
||||
_this.list.unshift(result.data);
|
||||
}else{
|
||||
|
||||
+75
-119
@@ -120,6 +120,11 @@ export const parseMessageByType = (pmsg) => {
|
||||
switch (pmsg.contentType) {
|
||||
case MessageType.TextMessage:
|
||||
return pmsg.textElem.content;
|
||||
case MessageType.AtTextMessage:
|
||||
return pmsg.AtElem.text;
|
||||
//atUsersInfo
|
||||
//isAtSelf
|
||||
//isAtAll
|
||||
case MessageType.PictureMessage:
|
||||
return `[图片]`;
|
||||
case MessageType.VoiceMessage:
|
||||
@@ -144,100 +149,40 @@ export const parseMessageByType = (pmsg) => {
|
||||
return `[FaceMessage]`;
|
||||
case MessageType.MarkdownMessage:
|
||||
return `[MarkdownMessage]`;
|
||||
case MessageType.FriendAdded:
|
||||
return "你们已经是好友了,开始聊天吧~";
|
||||
case MessageType.MemberEnter:
|
||||
const enterDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const enterUser = enterDetails.entrantUser;
|
||||
return `${getName(enterUser)}进入了群聊`;
|
||||
case MessageType.OANotification:
|
||||
return `[OANotification]`;
|
||||
case MessageType.GroupCreated:
|
||||
const groupCreatedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
const groupCreatedUser = groupCreatedDetail.opUser;
|
||||
return `${getName(groupCreatedUser)}创建了群聊`;
|
||||
case MessageType.MemberInvited:
|
||||
const inviteDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const inviteOpUser = inviteDetails.opUser;
|
||||
const invitedUserList = inviteDetails.invitedUserList ?? [];
|
||||
let inviteStr = "";
|
||||
invitedUserList.find(
|
||||
(user, idx) => (inviteStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
inviteStr = inviteStr.slice(0, -1);
|
||||
return `${getName(inviteOpUser)}邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}进入群聊`;
|
||||
|
||||
case MessageType.MemberKicked:
|
||||
const kickDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const kickOpUser = kickDetails.opUser;
|
||||
const kickdUserList = kickDetails.kickedUserList ?? [];
|
||||
let kickStr = "";
|
||||
kickdUserList.find(
|
||||
(user, idx) => (kickStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
kickStr = kickStr.slice(0, -1);
|
||||
return `${getName(kickOpUser)}踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`;
|
||||
case MessageType.GroupMemberMuted:
|
||||
//群成员禁言通知
|
||||
const groupMemberMutedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
return `${getName(groupMemberMutedDetail.opUser)}禁言了${getName(groupMemberMutedDetail.mutedUser)}`;
|
||||
|
||||
case MessageType.GroupMemberCancelMuted:
|
||||
//取消群成员禁言通知
|
||||
const groupMemberCancelMutedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
return `${getName(groupMemberCancelMutedDetail.opUser)}取消了${getName(groupMemberCancelMutedDetail.mutedUser)}的禁言`;
|
||||
case MessageType.GroupMuted:
|
||||
//群禁言通知
|
||||
const groupGroupMutedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
return `${getName(groupGroupMutedDetail.opUser)}设置了全员禁言`;
|
||||
case MessageType.GroupCancelMuted:
|
||||
//取消群禁言通知
|
||||
const groupGroupCancelMutedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
return `${getName(groupGroupCancelMutedDetail.opUser)}取消了全员禁言`;
|
||||
case MessageType.MemberQuit:
|
||||
const quitDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const quitUser = quitDetails.quitUser;
|
||||
return `${getName(quitUser)}退出了群聊`;
|
||||
case MessageType.GroupInfoUpdated:
|
||||
const groupUpdateDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
const groupUpdateUser = groupUpdateDetail.opUser;
|
||||
return `${getName(groupUpdateUser)}修改了群信息`;
|
||||
case MessageType.GroupOwnerTransferred:
|
||||
const transferDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const transferOpUser = transferDetails.opUser;
|
||||
const newOwner = transferDetails.newGroupOwner;
|
||||
return `${getName(transferOpUser)}将群主转让给${getName(newOwner)}`;
|
||||
case MessageType.GroupDismissed:
|
||||
const dismissDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const dismissUser = dismissDetails.opUser;
|
||||
return `${getName(dismissUser)}解散了群聊`;
|
||||
case MessageType.GroupNameUpdated:
|
||||
const groupNameUpdateDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
const groupNameUpdateUser = groupNameUpdateDetail.opUser;
|
||||
return `${getName(groupNameUpdateUser)}修改了群名称为${groupNameUpdateDetail.group.groupName}`;
|
||||
case MessageType.GroupAnnouncementUpdated:
|
||||
//群公告更新
|
||||
const groupAnnouncementUpdatedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
return `${getName(groupAnnouncementUpdatedDetail.opUser)}更新了群公告`;
|
||||
case MessageType.BurnMessageChange:
|
||||
//阅后即焚开启或关闭通知
|
||||
//console.log(pmsg);
|
||||
return `[BurnMessageChange]`;
|
||||
case MessageType.RevokeMessage:
|
||||
let notificationElem = JSON.parse(pmsg.notificationElem.detail);
|
||||
return `${notificationElem.revokerNickname}撤回了一条消息`;
|
||||
case MessageType.MsgPinned:
|
||||
//消息置顶
|
||||
return `[MsgPinned]`;
|
||||
case MessageType.BurnMessageChange:
|
||||
//阅后即焚开启或关闭通知
|
||||
//console.log(pmsg);
|
||||
return `阅后即焚已经开启`;
|
||||
case MessageType.OANotification:
|
||||
return `[OANotification]`;
|
||||
case MessageType.FriendAdded:
|
||||
case MessageType.GroupCreated:
|
||||
case MessageType.GroupInfoUpdated:
|
||||
case MessageType.MemberQuit:
|
||||
case MessageType.GroupOwnerTransferred:
|
||||
case MessageType.MemberKicked:
|
||||
case MessageType.MemberInvited:
|
||||
case MessageType.MemberEnter:
|
||||
case MessageType.GroupMemberMuted:
|
||||
case MessageType.GroupMemberCancelMuted:
|
||||
case MessageType.GroupMuted:
|
||||
case MessageType.GroupCancelMuted:
|
||||
case MessageType.GroupDismissed:
|
||||
case MessageType.GroupAnnouncementUpdated:
|
||||
case MessageType.GroupNameUpdated:
|
||||
case MessageType.RevokeMessage:
|
||||
case 2001:
|
||||
const body = JSON.parse(pmsg.notificationElem.detail);
|
||||
body.data = JSON.parse(body.data);
|
||||
return parseMessageByType(body.data);
|
||||
return tipMessaggeFormat(pmsg,store.getters.storeCurrentUserID);
|
||||
default:
|
||||
//console.log(pmsg);
|
||||
return "[暂未支持的消息类型]";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const formatConversionTime = (timestemp) => {
|
||||
const fromNowStr = dayjs(timestemp).fromNow();
|
||||
|
||||
@@ -273,62 +218,73 @@ export const bytesToSize = (bytes) => {
|
||||
return (bytes / Math.pow(k, i)).toPrecision(3) + " " + sizes[i];
|
||||
};
|
||||
export const tipMessaggeFormat = (msg, currentUserID) => {
|
||||
|
||||
const getName = (user) =>
|
||||
user.userID === currentUserID ? "你" : user.nickname;
|
||||
|
||||
let notificationDetail = {};
|
||||
if(msg?.notificationElem?.detail){
|
||||
notificationDetail = JSON.parse(msg.notificationElem.detail);
|
||||
}
|
||||
switch (msg.contentType) {
|
||||
case MessageType.FriendAdded:
|
||||
return `你们已经是好友了~`;
|
||||
case MessageType.GroupCreated:
|
||||
const groupCreatedDetail = JSON.parse(msg.notificationElem.detail);
|
||||
const groupCreatedUser = groupCreatedDetail.opUser;
|
||||
return `${getName(groupCreatedUser)}创建了群聊`;
|
||||
return `${getName(notificationDetail.opUser)}创建了群聊`;
|
||||
case MessageType.GroupInfoUpdated:
|
||||
const groupUpdateDetail = JSON.parse(msg.notificationElem.detail);
|
||||
const groupUpdateUser = groupUpdateDetail.opUser;
|
||||
return `${getName(groupUpdateUser)}修改了群信息`;
|
||||
case MessageType.GroupOwnerTransferred:
|
||||
const transferDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const transferOpUser = transferDetails.opUser;
|
||||
const newOwner = transferDetails.newGroupOwner;
|
||||
return `${getName(transferOpUser)}转让群主给${getName(newOwner)}`;
|
||||
return `${getName(notificationDetail.opUser)}修改了群信息`;
|
||||
case MessageType.MemberQuit:
|
||||
const quitDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const quitUser = quitDetails.quitUser;
|
||||
const quitUser = notificationDetail.quitUser;
|
||||
return `${getName(quitUser)}退出了群组`;
|
||||
case MessageType.MemberInvited:
|
||||
const inviteDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const inviteOpUser = inviteDetails.opUser;
|
||||
const invitedUserList = inviteDetails.invitedUserList ?? [];
|
||||
let inviteStr = "";
|
||||
invitedUserList.find(
|
||||
(user, idx) => (inviteStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
inviteStr = inviteStr.slice(0, -1);
|
||||
return `${getName(inviteOpUser)} 邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}加入群聊`; case MessageType.MemberKicked:
|
||||
const kickDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const kickOpUser = kickDetails.opUser;
|
||||
const kickdUserList = kickDetails.kickedUserList ?? [];
|
||||
case MessageType.GroupOwnerTransferred:
|
||||
const transferOpUser = notificationDetail.opUser;
|
||||
const newOwner = notificationDetail.newGroupOwner;
|
||||
return `${getName(transferOpUser)}转让群主给${getName(newOwner)}`;
|
||||
case MessageType.MemberKicked:
|
||||
const kickOpUser = notificationDetail.opUser;
|
||||
const kickdUserList = notificationDetail.kickedUserList ?? [];
|
||||
let kickStr = "";
|
||||
kickdUserList.find(
|
||||
(user, idx) => (kickStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
kickStr = kickStr.slice(0, -1);
|
||||
return `${getName(kickOpUser)} 踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`;
|
||||
case MessageType.MemberInvited:
|
||||
const inviteOpUser = notificationDetail.opUser;
|
||||
const invitedUserList = notificationDetail.invitedUserList ?? [];
|
||||
let inviteStr = "";
|
||||
invitedUserList.find(
|
||||
(user, idx) => (inviteStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
inviteStr = inviteStr.slice(0, -1);
|
||||
return `${getName(inviteOpUser)} 邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}加入群聊`;
|
||||
case MessageType.MemberEnter:
|
||||
const enterDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const enterUser = enterDetails.entrantUser;
|
||||
return `${getName(enterUser)}加入了群聊`;
|
||||
return `${getName(notificationDetail.entrantUser)}加入了群聊`;
|
||||
case MessageType.GroupDismissed:
|
||||
const dismissDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const dismissUser = dismissDetails.opUser;
|
||||
return `${getName(dismissUser)}解散了群聊`;
|
||||
return `${getName(notificationDetail.opUser)}解散了群聊`;
|
||||
case MessageType.GroupMemberMuted:
|
||||
return `${getName(notificationDetail.opUser)}禁言了${getName(notificationDetail.mutedUser)}`;
|
||||
case MessageType.GroupMemberCancelMuted:
|
||||
return `${getName(notificationDetail.opUser)}取消了${getName(notificationDetail.mutedUser)}的禁言`;
|
||||
case MessageType.GroupMuted:
|
||||
return `${getName(notificationDetail.opUser)}设置了全员禁言`;
|
||||
case MessageType.GroupCancelMuted:
|
||||
return `${getName(notificationDetail.opUser)}取消了全员禁言`;
|
||||
case MessageType.GroupAnnouncementUpdated:
|
||||
return `${getName(notificationDetail.opUser)}更新了群公告`;
|
||||
case MessageType.GroupNameUpdated:
|
||||
return `${getName(notificationDetail.opUser)}修改了群名称为${notificationDetail.group.groupName}`;
|
||||
case MessageType.RevokeMessage:
|
||||
return `${notificationDetail.revokerNickname}撤回了一条消息`;
|
||||
case 2001:
|
||||
let data = JSON.parse(notificationDetail.data);
|
||||
return parseMessageByType(data);
|
||||
default:
|
||||
return "";
|
||||
console.log(msg.contentType,notificationDetail);
|
||||
return `[不支持的消息类型: ${msg.contentType}]`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const markConversationAsRead = (conversation, fromChating = false) => {
|
||||
if (conversation.unreadCount !== 0) {
|
||||
IMSDK.asyncApi(
|
||||
|
||||
Reference in New Issue
Block a user