| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- //
- // MOApplicationTableViewCell.m
- // MiMoLive
- //
- // Created by SuperC on 2024/8/9.
- //
- #import "MOApplicationTableViewCell.h"
- @implementation MOApplicationTableViewCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
-
- self.backgroundColor = [UIColor clearColor];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- self.headImgView.layer.cornerRadius = 46.0 / 2.0;
- self.headImgView.layer.masksToBounds = YES;
-
- [self.contentView addSubview:self.headBgView];
- [self.headBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.headImgView);
- make.centerY.equalTo(self.headImgView);
- make.width.height.equalTo(@46.0);
- }];
- self.headBgView.headImgWidth = 46.0;
-
- self.applicationStackView.hidden = YES;
- self.connectStackView.hidden = YES;
- self.statusLab.hidden = YES;
-
- self.indexLab.hidden = YES;
-
- self.startView.viewHeight = MOStarNumViewNormalHeight;
- CGFloat startWidth = [self.startView getTheViewWidth];
- [self.contentView addSubview:self.startView];
- [self.startView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.idLab.mas_centerY);
- make.left.equalTo(self.idLab.mas_left).offset(-10.0);
- make.height.equalTo(@(MOStarNumViewNormalHeight));
- make.width.equalTo(@(startWidth));
- }];
-
- self.indexLab.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
- self.seatNumLab.font = [MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr];
- self.idLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
- self.nameLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
- self.statusLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)setCellModel:(MOPersonList *)cellModel{
- _cellModel = cellModel;
-
- if(!self.isManage){
- self.connectStackView.hidden = YES;
-
- if(cellModel.auditStatus == 0){
- self.applicationStackView.hidden = NO;
- self.statusLab.hidden = YES;
- }
- else if (cellModel.auditStatus == 1){
- self.applicationStackView.hidden = YES;
- self.statusLab.hidden = NO;
- self.statusLab.text = NSLocalString(@"mimo_voice_application_agreed");
- }
- else if (cellModel.auditStatus == 2){
- self.applicationStackView.hidden = YES;
- self.statusLab.hidden = NO;
- self.statusLab.text = NSLocalString(@"mimo_voice_application_rejected");
- }
-
- if(cellModel.position == 0){
- self.seatNumLab.hidden = YES;
- }
- else{
- self.seatNumLab.hidden = NO;
- self.seatNumLab.text = [NSString stringWithFormat:@"%.f",cellModel.position];
- }
-
- [self.headImgView sd_setImageWithURL:[NSURL URLWithString:cellModel.userBase.userProfile.avatar] placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- self.nameLab.text = cellModel.userBase.userProfile.nickname;
-
- self.idLab.text = cellModel.userBase.userProfile.userNo;
- self.startView.idNumStr = [NSString stringWithFormat:@"%@",cellModel.userBase.userProfile.userNo];
- self.startView.levelNum = (NSInteger)cellModel.userBase.userProfile.beautifulLevel;
-
- if(cellModel.userBase.userProfile.beautifulLevel == 0){
- self.idLab.hidden = NO;
- self.startView.hidden = YES;
- }
- else{
- self.idLab.hidden = YES;
- self.startView.hidden = NO;
- }
-
- if(cellModel.userBase.userProfile.adornment.headgearRes.length > 0){
- self.headBgView.hidden = NO;
- self.headBgView.isLiving = NO;
- self.headBgView.effectType = cellModel.userBase.userProfile.adornment.headgearType;
- self.headBgView.imgUrlStr = cellModel.userBase.userProfile.adornment.headgearRes;
- }
- else{
- self.headBgView.hidden = YES;
- }
-
- }
- else{
- self.applicationStackView.hidden = YES;
- self.statusLab.hidden = YES;
- }
- }
- - (void)setApplyCellModel:(MOPersonList *)applyCellModel{
- _applyCellModel = applyCellModel;
-
- [self.headImgView sd_setImageWithURL:[NSURL URLWithString:applyCellModel.userBase.userProfile.avatar] placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- self.nameLab.text = applyCellModel.userBase.userProfile.nickname;
-
- self.idLab.text = [NSString stringWithFormat:@"ID %@",applyCellModel.userBase.userProfile.userNo];
- self.startView.idNumStr = [NSString stringWithFormat:@"%@",applyCellModel.userBase.userProfile.userNo];
- self.startView.levelNum = (NSInteger)applyCellModel.userBase.userProfile.beautifulLevel;
-
- if(applyCellModel.userBase.userProfile.beautifulLevel == 0){
- self.idLab.hidden = NO;
- self.startView.hidden = YES;
- }
- else{
- self.idLab.hidden = YES;
- self.startView.hidden = NO;
- }
-
- self.indexLab.hidden = NO;
- self.indexLab.text = [NSString stringWithFormat:@"%zd",(self.cellIndexPath.row + 1)];
-
- self.statusLab.hidden = NO;
- self.statusLab.text = NSLocalString(@"mimo_voice_application_user_cell_wait");
-
- self.seatNumLab.hidden = YES;
- self.seatImgView.hidden = YES;
-
- if(applyCellModel.userBase.userProfile.adornment.headgearRes.length > 0){
- self.headBgView.hidden = NO;
- self.headBgView.isLiving = NO;
- self.headBgView.effectType = applyCellModel.userBase.userProfile.adornment.headgearType;
- self.headBgView.imgUrlStr = applyCellModel.userBase.userProfile.adornment.headgearRes;
- }
- else{
- self.headBgView.hidden = YES;
- }
- }
- - (void)setLinkCellModel:(MOLinkMic *)linkCellModel{
- _linkCellModel = linkCellModel;
-
- if(self.isManage){
- self.applicationStackView.hidden = YES;
- self.statusLab.hidden = YES;
- self.connectStackView.hidden = NO;
-
- [self.headImgView sd_setImageWithURL:[NSURL URLWithString:linkCellModel.profile.avatar] placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- self.nameLab.text = linkCellModel.profile.nickname;
-
- self.idLab.text = linkCellModel.profile.userNo;
- self.startView.idNumStr = [NSString stringWithFormat:@"%@",linkCellModel.profile.userNo];
- self.startView.levelNum = (NSInteger)linkCellModel.profile.beautifulLevel;
-
- if(linkCellModel.profile.beautifulLevel == 0){
- self.idLab.hidden = NO;
- self.startView.hidden = YES;
- }
- else{
- self.idLab.hidden = YES;
- self.startView.hidden = NO;
- }
-
- if(linkCellModel.video2){
- self.videoBtn.selected = YES;
- }
- else{
- self.videoBtn.selected = NO;
- }
-
- if(linkCellModel.audio2){
- self.voiceBtn.selected = YES;
- }
- else{
- self.voiceBtn.selected = NO;
- }
-
- self.seatNumLab.text = [NSString stringWithFormat:@"%zd",linkCellModel.seatNum];
-
- self.headBgView.hidden = YES;
- }
- }
- - (IBAction)videoBtnClick:(id)sender {
- if(self.videoBtn.selected == YES){
- //执行关闭操作
- NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
- [self toManageTheMicWith:1 WithPositionArr:positionArr And:YES];
- }
- else{
- //执行打开操作
- NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
- [self toManageTheMicWith:1 WithPositionArr:positionArr And:NO];
- }
- }
- - (IBAction)voiceBtnClick:(id)sender {
- if(self.voiceBtn.selected == YES){
- //执行关闭操作
- NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
- [self toManageTheMicWith:2 WithPositionArr:positionArr And:YES];
- }
- else{
- //执行打开操作
- NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
- [self toManageTheMicWith:2 WithPositionArr:positionArr And:NO];
- }
- }
- //type麦位类型(1=视频,2=音频,3=麦位)
- //lock锁定状态(true=锁定,false=解锁)
- - (void)toManageTheMicWith:(NSInteger)type WithPositionArr:(NSArray *)positionArr And:(BOOL)lock{
-
- if(positionArr.count == 0 || self.roomId.length == 0){
- return;
- }
- WEAKSELF
- NSDictionary *dict = @{@"roomId":self.roomId,
- @"positions":positionArr,
- @"type":@(type),
- @"lock":@(lock)};
-
- [kHttpManager toSwitchTheLinkMicDataWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MORoomStatus *roomStatusData = [MORoomStatus modelObjectWithDictionary:data[@"data"]];
- weakSelf.roomStatusChangeBlock ? weakSelf.roomStatusChangeBlock(roomStatusData) : nil;
-
- }
- else{
- MOLogV(@"toSwitchTheLinkMicDataWithParams 接口报错了");
- kShowNetError(data)
- }
- }];
-
- }
- - (IBAction)overBtnClick:(id)sender {
- WEAKSELF
- NSString *roomId = self.roomId;
- NSString *targetUserId = self.linkCellModel.profile.id;
- if(roomId.length == 0 || targetUserId.length == 0){
- return;
- }
- NSDictionary *dict = @{@"roomId":roomId,
- @"userId":targetUserId};
- [kHttpManager theManageToRemoveLinkMicWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_hud_normal_tip_host_10"),weakSelf.linkCellModel.seatNum];
- [MBProgressHUD showTipMessageInWindow:tipStr];
-
- //发送挂断连麦Rtm
- MORtmEntity *entity = [MORtmEntity prepareRtmManageAgreeLianMaiMessageAndLinkMicType:3 AndStatus:4 AndRoomId:weakSelf.roomId AndMOLinkMic:weakSelf.linkCellModel AndSeatNum:weakSelf.linkCellModel.seatNum];
- NSString *entityJsomString = entity.modelToJSONString;
-
- [[MOAgoraRTMManager shareManager] toSendRtmGroupMsg:entityJsomString andBlock:^(BOOL isSuccess) {
- if(isSuccess){
-
- }
- }];
-
- NSString *rtmTipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_rtm_normal_tip_3"),weakSelf.linkCellModel.profile.nickname];
- weakSelf.addRTMTipBlock ? weakSelf.addRTMTipBlock(rtmTipStr) : nil;
-
- weakSelf.hangUpBlock ? weakSelf.hangUpBlock(weakSelf.linkCellModel) : nil;
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (IBAction)rejectBtnClick:(id)sender {
- [self toManageTheLinkMicWith:self.cellModel And:NO];
- }
- - (IBAction)agreeBtnClick:(id)sender {
- [self toManageTheLinkMicWith:self.cellModel And:YES];
- }
- //MARK: 主播端 - 同意连麦
- - (void)toManageTheLinkMicWith:(MOPersonList *)model And:(BOOL)pass{
- WEAKSELF
- NSString *applyId = model.id;
- if(applyId.length == 0 || self.roomId.length == 0) {
- return;
- }
-
- NSDictionary *dict = @{@"id":applyId,
- @"pass":@(pass)};
-
- [kHttpManager theManageToAuditLinkMicWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- if(pass){
- MORoomStatus *roomStatusData = [MORoomStatus modelObjectWithDictionary:data[@"data"]];
-
- MOLinkMic *currentMic;
- int x = 1;
- for (MOLinkMic *micObject in roomStatusData.linkMics) {
- if([micObject.profile.id isEqualToString:model.userBase.userProfile.id]){
- currentMic = micObject;
- break;
- }
- x ++;
- }
-
- if(currentMic){
- //发送上麦RTM
-
- if(currentMic.profile.nickname.length > 0){
- NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_hud_normal_tip_host_1"),currentMic.profile.nickname];
- [MBProgressHUD showTipMessageInWindow:tipStr];
- }
-
- MORtmEntity *entity = [MORtmEntity prepareRtmManageAgreeLianMaiMessageAndLinkMicType:3 AndStatus:2 AndRoomId:weakSelf.roomId AndMOLinkMic:currentMic AndSeatNum:x];
- NSString *entityJsomString = entity.modelToJSONString;
-
- [[MOAgoraRTMManager shareManager] toSendRtmGroupMsg:entityJsomString andBlock:^(BOOL isSuccess) {
- if(isSuccess){
-
- }
- }];
-
- NSString *rtmTipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_rtm_normal_tip_2"),currentMic.profile.nickname,x];
- weakSelf.addRTMTipBlock ? weakSelf.addRTMTipBlock(rtmTipStr) : nil;
-
- weakSelf.roomStatusChangeBlock ? weakSelf.roomStatusChangeBlock(roomStatusData) : nil;
- }
- }
- else{
- //发送拒绝RTM
-
- if(model.userBase.userProfile.nickname.length > 0){
- NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_hud_normal_tip_host_2"),model.userBase.userProfile.nickname];
- [MBProgressHUD showTipMessageInWindow:tipStr];
- }
-
- MOLinkMic *currentMic = [[MOLinkMic alloc] init];
- currentMic.profile = [model.userBase.userProfile copy];
-
- MORtmEntity *entity = [MORtmEntity prepareRtmManageAgreeLianMaiMessageAndLinkMicType:3 AndStatus:3 AndRoomId:weakSelf.roomId AndMOLinkMic:currentMic AndSeatNum:0];
- NSString *entityJsomString = entity.modelToJSONString;
-
- [[MOAgoraRTMManager shareManager] toSendRtmGroupMsg:entityJsomString andBlock:^(BOOL isSuccess) {
- if(isSuccess){
-
- }
- }];
-
- weakSelf.roomStatusChangeBlock ? weakSelf.roomStatusChangeBlock(nil) : nil;
- }
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (MOHeadCustomView *)headBgView{
- if(!_headBgView){
- _headBgView = [[MOHeadCustomView alloc] init];
- }
- return _headBgView;
- }
- - (MOStarNumView *)startView{
- if(!_startView){
- _startView = [[MOStarNumView alloc] init];
- }
- return _startView;
- }
- @end
|