MOApplicationTableViewCell.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. //
  2. // MOApplicationTableViewCell.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/8/9.
  6. //
  7. #import "MOApplicationTableViewCell.h"
  8. @implementation MOApplicationTableViewCell
  9. - (void)awakeFromNib {
  10. [super awakeFromNib];
  11. // Initialization code
  12. self.backgroundColor = [UIColor clearColor];
  13. self.selectionStyle = UITableViewCellSelectionStyleNone;
  14. self.headImgView.layer.cornerRadius = 46.0 / 2.0;
  15. self.headImgView.layer.masksToBounds = YES;
  16. [self.contentView addSubview:self.headBgView];
  17. [self.headBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  18. make.centerX.equalTo(self.headImgView);
  19. make.centerY.equalTo(self.headImgView);
  20. make.width.height.equalTo(@46.0);
  21. }];
  22. self.headBgView.headImgWidth = 46.0;
  23. self.applicationStackView.hidden = YES;
  24. self.connectStackView.hidden = YES;
  25. self.statusLab.hidden = YES;
  26. self.indexLab.hidden = YES;
  27. self.startView.viewHeight = MOStarNumViewNormalHeight;
  28. CGFloat startWidth = [self.startView getTheViewWidth];
  29. [self.contentView addSubview:self.startView];
  30. [self.startView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.centerY.equalTo(self.idLab.mas_centerY);
  32. make.left.equalTo(self.idLab.mas_left).offset(-10.0);
  33. make.height.equalTo(@(MOStarNumViewNormalHeight));
  34. make.width.equalTo(@(startWidth));
  35. }];
  36. self.indexLab.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
  37. self.seatNumLab.font = [MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr];
  38. self.idLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
  39. self.nameLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
  40. self.statusLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
  41. }
  42. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  43. [super setSelected:selected animated:animated];
  44. // Configure the view for the selected state
  45. }
  46. - (void)setCellModel:(MOPersonList *)cellModel{
  47. _cellModel = cellModel;
  48. if(!self.isManage){
  49. self.connectStackView.hidden = YES;
  50. if(cellModel.auditStatus == 0){
  51. self.applicationStackView.hidden = NO;
  52. self.statusLab.hidden = YES;
  53. }
  54. else if (cellModel.auditStatus == 1){
  55. self.applicationStackView.hidden = YES;
  56. self.statusLab.hidden = NO;
  57. self.statusLab.text = NSLocalString(@"mimo_voice_application_agreed");
  58. }
  59. else if (cellModel.auditStatus == 2){
  60. self.applicationStackView.hidden = YES;
  61. self.statusLab.hidden = NO;
  62. self.statusLab.text = NSLocalString(@"mimo_voice_application_rejected");
  63. }
  64. if(cellModel.position == 0){
  65. self.seatNumLab.hidden = YES;
  66. }
  67. else{
  68. self.seatNumLab.hidden = NO;
  69. self.seatNumLab.text = [NSString stringWithFormat:@"%.f",cellModel.position];
  70. }
  71. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:cellModel.userBase.userProfile.avatar] placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  72. self.nameLab.text = cellModel.userBase.userProfile.nickname;
  73. self.idLab.text = cellModel.userBase.userProfile.userNo;
  74. self.startView.idNumStr = [NSString stringWithFormat:@"%@",cellModel.userBase.userProfile.userNo];
  75. self.startView.levelNum = (NSInteger)cellModel.userBase.userProfile.beautifulLevel;
  76. if(cellModel.userBase.userProfile.beautifulLevel == 0){
  77. self.idLab.hidden = NO;
  78. self.startView.hidden = YES;
  79. }
  80. else{
  81. self.idLab.hidden = YES;
  82. self.startView.hidden = NO;
  83. }
  84. if(cellModel.userBase.userProfile.adornment.headgearRes.length > 0){
  85. self.headBgView.hidden = NO;
  86. self.headBgView.isLiving = NO;
  87. self.headBgView.effectType = cellModel.userBase.userProfile.adornment.headgearType;
  88. self.headBgView.imgUrlStr = cellModel.userBase.userProfile.adornment.headgearRes;
  89. }
  90. else{
  91. self.headBgView.hidden = YES;
  92. }
  93. }
  94. else{
  95. self.applicationStackView.hidden = YES;
  96. self.statusLab.hidden = YES;
  97. }
  98. }
  99. - (void)setApplyCellModel:(MOPersonList *)applyCellModel{
  100. _applyCellModel = applyCellModel;
  101. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:applyCellModel.userBase.userProfile.avatar] placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  102. self.nameLab.text = applyCellModel.userBase.userProfile.nickname;
  103. self.idLab.text = [NSString stringWithFormat:@"ID %@",applyCellModel.userBase.userProfile.userNo];
  104. self.startView.idNumStr = [NSString stringWithFormat:@"%@",applyCellModel.userBase.userProfile.userNo];
  105. self.startView.levelNum = (NSInteger)applyCellModel.userBase.userProfile.beautifulLevel;
  106. if(applyCellModel.userBase.userProfile.beautifulLevel == 0){
  107. self.idLab.hidden = NO;
  108. self.startView.hidden = YES;
  109. }
  110. else{
  111. self.idLab.hidden = YES;
  112. self.startView.hidden = NO;
  113. }
  114. self.indexLab.hidden = NO;
  115. self.indexLab.text = [NSString stringWithFormat:@"%zd",(self.cellIndexPath.row + 1)];
  116. self.statusLab.hidden = NO;
  117. self.statusLab.text = NSLocalString(@"mimo_voice_application_user_cell_wait");
  118. self.seatNumLab.hidden = YES;
  119. self.seatImgView.hidden = YES;
  120. if(applyCellModel.userBase.userProfile.adornment.headgearRes.length > 0){
  121. self.headBgView.hidden = NO;
  122. self.headBgView.isLiving = NO;
  123. self.headBgView.effectType = applyCellModel.userBase.userProfile.adornment.headgearType;
  124. self.headBgView.imgUrlStr = applyCellModel.userBase.userProfile.adornment.headgearRes;
  125. }
  126. else{
  127. self.headBgView.hidden = YES;
  128. }
  129. }
  130. - (void)setLinkCellModel:(MOLinkMic *)linkCellModel{
  131. _linkCellModel = linkCellModel;
  132. if(self.isManage){
  133. self.applicationStackView.hidden = YES;
  134. self.statusLab.hidden = YES;
  135. self.connectStackView.hidden = NO;
  136. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:linkCellModel.profile.avatar] placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  137. self.nameLab.text = linkCellModel.profile.nickname;
  138. self.idLab.text = linkCellModel.profile.userNo;
  139. self.startView.idNumStr = [NSString stringWithFormat:@"%@",linkCellModel.profile.userNo];
  140. self.startView.levelNum = (NSInteger)linkCellModel.profile.beautifulLevel;
  141. if(linkCellModel.profile.beautifulLevel == 0){
  142. self.idLab.hidden = NO;
  143. self.startView.hidden = YES;
  144. }
  145. else{
  146. self.idLab.hidden = YES;
  147. self.startView.hidden = NO;
  148. }
  149. if(linkCellModel.video2){
  150. self.videoBtn.selected = YES;
  151. }
  152. else{
  153. self.videoBtn.selected = NO;
  154. }
  155. if(linkCellModel.audio2){
  156. self.voiceBtn.selected = YES;
  157. }
  158. else{
  159. self.voiceBtn.selected = NO;
  160. }
  161. self.seatNumLab.text = [NSString stringWithFormat:@"%zd",linkCellModel.seatNum];
  162. self.headBgView.hidden = YES;
  163. }
  164. }
  165. - (IBAction)videoBtnClick:(id)sender {
  166. if(self.videoBtn.selected == YES){
  167. //执行关闭操作
  168. NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
  169. [self toManageTheMicWith:1 WithPositionArr:positionArr And:YES];
  170. }
  171. else{
  172. //执行打开操作
  173. NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
  174. [self toManageTheMicWith:1 WithPositionArr:positionArr And:NO];
  175. }
  176. }
  177. - (IBAction)voiceBtnClick:(id)sender {
  178. if(self.voiceBtn.selected == YES){
  179. //执行关闭操作
  180. NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
  181. [self toManageTheMicWith:2 WithPositionArr:positionArr And:YES];
  182. }
  183. else{
  184. //执行打开操作
  185. NSArray *positionArr = @[@(self.linkCellModel.seatNum)];
  186. [self toManageTheMicWith:2 WithPositionArr:positionArr And:NO];
  187. }
  188. }
  189. //type麦位类型(1=视频,2=音频,3=麦位)
  190. //lock锁定状态(true=锁定,false=解锁)
  191. - (void)toManageTheMicWith:(NSInteger)type WithPositionArr:(NSArray *)positionArr And:(BOOL)lock{
  192. if(positionArr.count == 0 || self.roomId.length == 0){
  193. return;
  194. }
  195. WEAKSELF
  196. NSDictionary *dict = @{@"roomId":self.roomId,
  197. @"positions":positionArr,
  198. @"type":@(type),
  199. @"lock":@(lock)};
  200. [kHttpManager toSwitchTheLinkMicDataWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  201. if(kCode_Success){
  202. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  203. MORoomStatus *roomStatusData = [MORoomStatus modelObjectWithDictionary:data[@"data"]];
  204. weakSelf.roomStatusChangeBlock ? weakSelf.roomStatusChangeBlock(roomStatusData) : nil;
  205. }
  206. else{
  207. MOLogV(@"toSwitchTheLinkMicDataWithParams 接口报错了");
  208. kShowNetError(data)
  209. }
  210. }];
  211. }
  212. - (IBAction)overBtnClick:(id)sender {
  213. WEAKSELF
  214. NSString *roomId = self.roomId;
  215. NSString *targetUserId = self.linkCellModel.profile.id;
  216. if(roomId.length == 0 || targetUserId.length == 0){
  217. return;
  218. }
  219. NSDictionary *dict = @{@"roomId":roomId,
  220. @"userId":targetUserId};
  221. [kHttpManager theManageToRemoveLinkMicWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  222. if(kCode_Success){
  223. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  224. NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_hud_normal_tip_host_10"),weakSelf.linkCellModel.seatNum];
  225. [MBProgressHUD showTipMessageInWindow:tipStr];
  226. //发送挂断连麦Rtm
  227. MORtmEntity *entity = [MORtmEntity prepareRtmManageAgreeLianMaiMessageAndLinkMicType:3 AndStatus:4 AndRoomId:weakSelf.roomId AndMOLinkMic:weakSelf.linkCellModel AndSeatNum:weakSelf.linkCellModel.seatNum];
  228. NSString *entityJsomString = entity.modelToJSONString;
  229. [[MOAgoraRTMManager shareManager] toSendRtmGroupMsg:entityJsomString andBlock:^(BOOL isSuccess) {
  230. if(isSuccess){
  231. }
  232. }];
  233. NSString *rtmTipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_rtm_normal_tip_3"),weakSelf.linkCellModel.profile.nickname];
  234. weakSelf.addRTMTipBlock ? weakSelf.addRTMTipBlock(rtmTipStr) : nil;
  235. weakSelf.hangUpBlock ? weakSelf.hangUpBlock(weakSelf.linkCellModel) : nil;
  236. }
  237. else{
  238. kShowNetError(data)
  239. }
  240. }];
  241. }
  242. - (IBAction)rejectBtnClick:(id)sender {
  243. [self toManageTheLinkMicWith:self.cellModel And:NO];
  244. }
  245. - (IBAction)agreeBtnClick:(id)sender {
  246. [self toManageTheLinkMicWith:self.cellModel And:YES];
  247. }
  248. //MARK: 主播端 - 同意连麦
  249. - (void)toManageTheLinkMicWith:(MOPersonList *)model And:(BOOL)pass{
  250. WEAKSELF
  251. NSString *applyId = model.id;
  252. if(applyId.length == 0 || self.roomId.length == 0) {
  253. return;
  254. }
  255. NSDictionary *dict = @{@"id":applyId,
  256. @"pass":@(pass)};
  257. [kHttpManager theManageToAuditLinkMicWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  258. if(kCode_Success){
  259. [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
  260. // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  261. if(pass){
  262. MORoomStatus *roomStatusData = [MORoomStatus modelObjectWithDictionary:data[@"data"]];
  263. MOLinkMic *currentMic;
  264. int x = 1;
  265. for (MOLinkMic *micObject in roomStatusData.linkMics) {
  266. if([micObject.profile.id isEqualToString:model.userBase.userProfile.id]){
  267. currentMic = micObject;
  268. break;
  269. }
  270. x ++;
  271. }
  272. if(currentMic){
  273. //发送上麦RTM
  274. if(currentMic.profile.nickname.length > 0){
  275. NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_hud_normal_tip_host_1"),currentMic.profile.nickname];
  276. [MBProgressHUD showTipMessageInWindow:tipStr];
  277. }
  278. MORtmEntity *entity = [MORtmEntity prepareRtmManageAgreeLianMaiMessageAndLinkMicType:3 AndStatus:2 AndRoomId:weakSelf.roomId AndMOLinkMic:currentMic AndSeatNum:x];
  279. NSString *entityJsomString = entity.modelToJSONString;
  280. [[MOAgoraRTMManager shareManager] toSendRtmGroupMsg:entityJsomString andBlock:^(BOOL isSuccess) {
  281. if(isSuccess){
  282. }
  283. }];
  284. NSString *rtmTipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_rtm_normal_tip_2"),currentMic.profile.nickname,x];
  285. weakSelf.addRTMTipBlock ? weakSelf.addRTMTipBlock(rtmTipStr) : nil;
  286. weakSelf.roomStatusChangeBlock ? weakSelf.roomStatusChangeBlock(roomStatusData) : nil;
  287. }
  288. }
  289. else{
  290. //发送拒绝RTM
  291. if(model.userBase.userProfile.nickname.length > 0){
  292. NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_voice_hud_normal_tip_host_2"),model.userBase.userProfile.nickname];
  293. [MBProgressHUD showTipMessageInWindow:tipStr];
  294. }
  295. MOLinkMic *currentMic = [[MOLinkMic alloc] init];
  296. currentMic.profile = [model.userBase.userProfile copy];
  297. MORtmEntity *entity = [MORtmEntity prepareRtmManageAgreeLianMaiMessageAndLinkMicType:3 AndStatus:3 AndRoomId:weakSelf.roomId AndMOLinkMic:currentMic AndSeatNum:0];
  298. NSString *entityJsomString = entity.modelToJSONString;
  299. [[MOAgoraRTMManager shareManager] toSendRtmGroupMsg:entityJsomString andBlock:^(BOOL isSuccess) {
  300. if(isSuccess){
  301. }
  302. }];
  303. weakSelf.roomStatusChangeBlock ? weakSelf.roomStatusChangeBlock(nil) : nil;
  304. }
  305. }
  306. else{
  307. kShowNetError(data)
  308. }
  309. }];
  310. }
  311. - (MOHeadCustomView *)headBgView{
  312. if(!_headBgView){
  313. _headBgView = [[MOHeadCustomView alloc] init];
  314. }
  315. return _headBgView;
  316. }
  317. - (MOStarNumView *)startView{
  318. if(!_startView){
  319. _startView = [[MOStarNumView alloc] init];
  320. }
  321. return _startView;
  322. }
  323. @end