版本1.1.18

This commit is contained in:
启星
2026-01-21 14:25:45 +08:00
parent 081aa5622c
commit 491b97f3cb
53 changed files with 1125 additions and 101 deletions

View File

@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface QXGroupMemberViewController : QXBaseViewController
@property (nonatomic,strong)NSString *groupId;
/// 是否为群主 1 是群主 2不是群主
/// 是否为群主 1 是群主 2管理员 3普通群成员
@property (nonatomic,strong)NSString*isOwner;
@end

View File

@@ -102,9 +102,39 @@
cell.cellType = QXBlackListCellTypeGroupMember;
cell.groupMemberModel = self.dataArray[indexPath.row];
cell.delegate = self;
cell.removeBtn.hidden = !(self.isOwner.intValue==1);
// cell.removeBtn.hidden = !(self.isOwner.intValue==1);
cell.removeBtn.hidden = YES;
return cell;
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
BOOL canEdit = self.isOwner.intValue==1 || self.isOwner.intValue==2;
return canEdit;
}
-(UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath{
QXUserHomeModel *model = self.dataArray[indexPath.row];
MJWeakSelf
UIContextualAction *deletAction = [UIContextualAction contextualActionWithStyle:(UIContextualActionStyleDestructive) title:model.is_mute.intValue==1?@"解除禁言":@"禁言" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
[weakSelf didClickGroupMemberMoreBtnWithGroupMemberModel:model];
completionHandler(YES);
}];
UIContextualAction *editAction = [UIContextualAction contextualActionWithStyle:(UIContextualActionStyleNormal) title:model.group_role.intValue==2?@"取消管理":@"设为管理" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
[weakSelf setGroupManagerWithModel:model];
completionHandler(YES);
}];
editAction.backgroundColor = RGB16(0x3665F9);
NSArray *eidtArr;
if (self.isOwner.intValue == 1) {
if (model.group_role.intValue == 1) {
eidtArr = @[deletAction];
}else{
eidtArr = @[deletAction,editAction];
}
}else if (self.isOwner.intValue == 2){
eidtArr = @[deletAction];
}
UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:eidtArr];
return config;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
QXUserHomeModel *model = self.dataArray[indexPath.row];
@@ -112,12 +142,10 @@
[self.navigationController pushViewController:vc animated:YES];
}
-(void)didClickGroupMemberMoreBtnWithGroupMemberModel:(QXUserHomeModel *)groupMemberModel{
UIAlertController*al =[UIAlertController alertControllerWithTitle:@"禁言" message:@"" preferredStyle:(UIAlertControllerStyleActionSheet)];
if (groupMemberModel.is_mute.intValue == 1) {
[al addAction:[UIAlertAction actionWithTitle:@"解禁" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
[self muteMemberWithTime:0 groupMemberModel:groupMemberModel];
}]];
[self muteMemberWithTime:0 groupMemberModel:groupMemberModel];
}else{
UIAlertController*al =[UIAlertController alertControllerWithTitle:@"禁言" message:@"" preferredStyle:(UIAlertControllerStyleActionSheet)];
[al addAction:[UIAlertAction actionWithTitle:@"禁言1天" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
[self muteMemberWithTime:86400 groupMemberModel:groupMemberModel];
}]];
@@ -130,13 +158,17 @@
[al addAction:[UIAlertAction actionWithTitle:@"禁言30天" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
[self muteMemberWithTime:86400*30 groupMemberModel:groupMemberModel];
}]];
[al addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
}]];
[self presentViewController:al animated:YES completion:nil];
}
[al addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
}]];
[self presentViewController:al animated:YES completion:nil];
}
-(void)muteMemberWithTime:(uint32_t)time groupMemberModel:(QXUserHomeModel*)groupMemberModel{
if (groupMemberModel.group_role.intValue == 4) {
showToast(@"该成员信息错误");
return;
}
[[V2TIMManager sharedInstance] muteGroupMember:self.groupId member:[NSString stringWithFormat:@"u%@",groupMemberModel.user_id] muteTime:time succ:^{
if (time == 0) {
showToast(@"解禁成功");
@@ -153,6 +185,26 @@
showToast(desc);
}];
}
-(void)setGroupManagerWithModel:(QXUserHomeModel*)groupMemberModel{
if (groupMemberModel.group_role.intValue == 4) {
showToast(@"该成员信息错误");
return;
}
uint32_t role = V2TIM_GROUP_MEMBER_ROLE_ADMIN;
if (groupMemberModel.group_role.intValue == 2) {
role = V2TIM_GROUP_MEMBER_ROLE_MEMBER;
}
[[V2TIMManager sharedInstance] setGroupMemberRole:self.groupId member:[NSString stringWithFormat:@"u%@",groupMemberModel.user_id] newRole:role succ:^{
if (self.isSearch) {
[self getMemberListWithSearch:self.textField.text];
}else{
[self getMemberListWithSearch:@""];
}
} fail:^(int code, NSString * _Nullable desc) {
showToast(desc);
}];
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.seachBgView.bottom+10, SCREEN_WIDTH, SCREEN_HEIGHT-self.seachBgView.bottom-10) style:(UITableViewStylePlain)];

View File

@@ -10,10 +10,12 @@
#import "QXMessageServices.h"
#import "QXGroupMemberViewController.h"
#import "ImSDK_Plus/V2TIMManager+Group.h"
#import "ImSDK_Plus/V2TIMManager+Conversation.h"
@interface QXIMGroupSettingVC ()<QXIMGroupSettingViewDelegate>
@property (nonatomic,strong)UIScrollView *scrollView;
@property (nonatomic,strong)QXIMGroupSettingView *settingView;
@property (nonatomic,strong)QXGroupSettingInfoModel *model;
@property (nonatomic,strong)V2TIMGroupInfoResult *groupInfo;
@end
@implementation QXIMGroupSettingVC
@@ -35,6 +37,18 @@
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight)];
self.settingView = [[QXIMGroupSettingView alloc] initWithFrame:self.scrollView.bounds];
self.settingView.delegate = self;
@weakify(self);
[[V2TIMManager sharedInstance] getGroupsInfo:@[self.groupId] succ:^(NSArray<V2TIMGroupInfoResult *> *groupResultList) {
@strongify(self);
V2TIMGroupInfoResult *groupInfo = [groupResultList firstObject];
if (groupInfo.info.recvOpt == V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE) {
self.settingView.isNotDisturb = YES;
}else{
self.settingView.isNotDisturb = NO;
}
} fail:^(int code, NSString * _Nullable desc) {
}];
[self.scrollView addSubview:self.settingView];
[self.view addSubview:self.scrollView];
[self getGroupInfo];
@@ -67,6 +81,27 @@
}
}];
}
-(void)groupMessageIsNotDisturb:(BOOL)isNotDisturb notDisturbSwitch:(UISwitch *)notDisturbSwitch{
V2TIMReceiveMessageOpt opt;
if (isNotDisturb) {
opt = V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE;
} else {
opt = V2TIM_RECEIVE_MESSAGE;
}
[V2TIMManager.sharedInstance markConversation:@[ [NSString stringWithFormat:@"group_%@", self.groupId] ]
markType:@(V2TIM_CONVERSATION_MARK_TYPE_FOLD)
enableMark:NO
succ:nil
fail:^(int code, NSString * _Nullable desc) {
if (isNotDisturb) {
notDisturbSwitch.on = NO;
}else{
notDisturbSwitch.on = YES;
}
}];
[[V2TIMManager sharedInstance] setGroupReceiveMessageOpt:self.groupId opt:opt succ:nil fail:nil];
}
-(void)getGroupInfo{
MJWeakSelf

View File

@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong,nonatomic)NSString *notification;
/// 群聊头像
@property (strong,nonatomic)NSString *guild_cover;
/// 是否为群主 1 是群主 2不是群主
/// 是否为群主 1 是群主 2管理员 3群成员
@property (strong,nonatomic)NSString *is_deacon;
/// 群成员列表
@property (strong,nonatomic)NSArray <QXUserModel*>*user_list;

View File

@@ -13,10 +13,13 @@ NS_ASSUME_NONNULL_BEGIN
@optional
-(void)previewMemberList;
-(void)groupSetMute:(BOOL)isMute muteSwitch:(UISwitch*)muteSwitch;
/// 消息免打扰
-(void)groupMessageIsNotDisturb:(BOOL)isNotDisturb notDisturbSwitch:(UISwitch*)notDisturbSwitch;
-(void)saveGroupInfoWithGroupId:(NSString*)groupId notice:(NSString*)notice name:(NSString*)name;
@end
@interface QXIMGroupSettingView : UIView
@property (nonatomic,strong)QXGroupSettingInfoModel*model;
@property (nonatomic,assign)BOOL isNotDisturb;
@property (nonatomic,weak)id<QXIMGroupSettingViewDelegate>delegate;
@end

View File

@@ -21,6 +21,9 @@
@property (nonatomic,strong)UILabel *noticeTitleLabel;
@property (nonatomic,strong)QXTextView *textView;
@property (nonatomic,strong)UILabel *messageDisturbLabel;
@property (nonatomic,strong)UISwitch *messageDisturbSwitch;
@property (nonatomic,strong)UILabel *muteLabel;
@property (nonatomic,strong)UISwitch *muteSwitch;
@property (nonatomic,strong)NSMutableArray *dataArray;
@@ -108,7 +111,18 @@
[self addSubview:self.textView];
self.muteLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.guildImageView.left, self.textView.bottom+10, 200, 40)];
self.messageDisturbLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.guildImageView.left, self.textView.bottom+10, 200, 40)];
self.messageDisturbLabel.text = @"消息免打扰";
self.messageDisturbLabel.textColor = RGB16(0x000000);
self.messageDisturbLabel.font = [UIFont boldSystemFontOfSize:16];
[self addSubview:self.messageDisturbLabel];
self.messageDisturbSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(self.width-60-16, self.messageDisturbLabel.top+5, 60, 40)];
[self.messageDisturbSwitch addTarget:self action:@selector(messageDisturbAction) forControlEvents:(UIControlEventValueChanged)];
[self addSubview:self.messageDisturbSwitch];
self.muteLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.guildImageView.left, self.messageDisturbLabel.bottom+10, 200, 40)];
self.muteLabel.text = @"全员禁言";
self.muteLabel.textColor = RGB16(0x000000);
self.muteLabel.font = [UIFont boldSystemFontOfSize:16];
@@ -138,20 +152,25 @@
self.textView.text = model.notification;
[self.muteSwitch setOn:model.mute_all_member.intValue==1];
[self.collectionView reloadData];
if (model.is_deacon.intValue == 2) {
self.muteSwitch.hidden = YES;
self.muteLabel.hidden = YES;
self.saveBtn.hidden = YES;
self.editGroupTextField.userInteractionEnabled = NO;
self.textView.userInteractionEnabled = NO;
}else{
if (model.is_deacon.intValue == 1 || model.is_deacon.intValue == 2) {
self.muteSwitch.hidden = NO;
self.muteLabel.hidden = NO;
self.saveBtn.hidden = NO;
self.editGroupTextField.userInteractionEnabled = YES;
self.textView.userInteractionEnabled = YES;
}else{
self.muteSwitch.hidden = YES;
self.muteLabel.hidden = YES;
self.saveBtn.hidden = YES;
self.editGroupTextField.userInteractionEnabled = NO;
self.textView.userInteractionEnabled = NO;
}
}
-(void)setIsNotDisturb:(BOOL)isNotDisturb{
_isNotDisturb = isNotDisturb;
self.messageDisturbSwitch.on = isNotDisturb;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.model.user_list.count;
}
@@ -185,6 +204,18 @@
}
}
-(void)messageDisturbAction{
if (self.messageDisturbSwitch.isOn) {
QXLOG(@"打开免打扰");
}else{
QXLOG(@"关闭免打扰");
}
if (self.delegate && [self.delegate respondsToSelector:@selector(groupMessageIsNotDisturb:notDisturbSwitch:)]) {
[self.delegate groupMessageIsNotDisturb:self.messageDisturbSwitch.isOn notDisturbSwitch:self.messageDisturbSwitch];
}
}
-(NSMutableArray *)dataArray{
if (!_dataArray) {
_dataArray = [NSMutableArray array];