MOChatViewController+MoreMenu.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //
  2. // MOChatViewController+MoreMenu.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2025/6/5.
  6. //
  7. #import "MOChatViewController+MoreMenu.h"
  8. #import "MOChooseTimeAlertView.h"
  9. #import "MONormalRightAlertView.h"
  10. #import "MOAddBlackAlertView.h"
  11. @implementation MOChatViewController (MoreMenu)
  12. - (void)updateRightBarItem{
  13. WEAKSELF
  14. if(!(self.isHalfShow || self.isLiveRoom)){
  15. [self setNavRightItemWithImage:[UIImage imageNamed:@"v_2_chat_more"]];
  16. }
  17. }
  18. - (void)RightBarItemClick:(UIButton *)sender{
  19. //更多按钮
  20. [self moreBtnClick];
  21. }
  22. - (void)moreBtnClick{
  23. NSMutableArray *dataArr = [NSMutableArray array];
  24. NSDictionary *setDict = [self addItemWithTitle:NSLocalString(@"mimo_2_chat_right_user_info") andSel:@selector(toPushUserHomePageh)];
  25. [dataArr addObject:setDict];
  26. NSDictionary *reportDict = [self addItemWithTitle:NSLocalString(@"mimo_report_title") andSel:@selector(reportBtnClick)];
  27. [dataArr addObject:reportDict];
  28. if(self.userData.blacklist){
  29. //移除黑名单
  30. NSDictionary *ruleDict = [self addItemWithTitle:NSLocalString(@"mimo_blacklist_remove") andSel:@selector(toDeleteBlackList)];
  31. [dataArr addObject:ruleDict];
  32. }
  33. else{
  34. //增加黑名单
  35. NSDictionary *ruleDict = [self addItemWithTitle:NSLocalString(@"mimo_blacklist_add") andSel:@selector(showBlackConfirmAlertView)];
  36. [dataArr addObject:ruleDict];
  37. }
  38. MONormalRightAlertView *view = [MONormalRightAlertView moNormalRightAlertView];
  39. UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
  40. [keyWindow addSubview:view];
  41. [view showVipMenuView];
  42. view.target = self;
  43. view.dataArr = dataArr;
  44. CGFloat statusBarHeight = STATUS_BAR_HEIGHT;
  45. view.menuVIewTop.constant = statusBarHeight + 12.0 + 30.0 + 5.0;
  46. view.menuViewRight.constant = 12.0;
  47. }
  48. - (NSDictionary *)addItemWithTitle:(NSString *)title andSel:(SEL)sel{
  49. NSDictionary *itemDic = @{@"name":title,@"sel":NSStringFromSelector(sel)};
  50. return itemDic;
  51. }
  52. - (void)toPushUserHomePageh{
  53. //查看资料
  54. [self toPushUserHomePageWith:self.userData.userProfile.id];
  55. }
  56. - (void)reportBtnClick{
  57. //举报
  58. [self showReportView];
  59. }
  60. - (void)toDeleteBlackList{
  61. NSString *userId = self.otherUserId;
  62. if(userId.length == 0){
  63. return;
  64. }
  65. WEAKSELF
  66. NSDictionary *dict = @{@"duration":@(5),
  67. @"target":userId};
  68. [kHttpManager toRemoveBlockWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  69. if(kCode_Success){
  70. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  71. [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
  72. //移除黑名单
  73. [weakSelf toGetUserSetData];
  74. }
  75. else{
  76. MOLogV(@"toDeleteBlackList 接口报错了");
  77. kShowNetError(data)
  78. }
  79. }];
  80. }
  81. - (void)showBlackConfirmAlertView{
  82. // NSArray *dataArr = @[@"30Min",@"24H",@"3Day",@"7Day",@"forever"];
  83. //
  84. // WEAKSELF
  85. // MOChooseTimeAlertView *view = [MOChooseTimeAlertView moChooseTimeAlertView];
  86. // view.topTipText = [NSString stringWithFormat:NSLocalString(@"mimo_blacklist_set_time"),self.userData.userProfile.nickname];
  87. // view.bottomTipText = NSLocalString(@"mimo_blacklist_set_black_result");
  88. // view.dataArr = dataArr;
  89. // [view showChooseTimeAlertView];
  90. // view.confirmBtnBlock = ^(NSInteger index) {
  91. // [weakSelf toAddBlackListWith:index];
  92. // };
  93. MOAddBlackAlertView *alertView = [[MOAddBlackAlertView alloc] init];
  94. WEAKSELF
  95. alertView.addBlackConfirmBlock = ^(NSInteger timeIndex) {
  96. [weakSelf toAddBlackListWith:timeIndex];
  97. };
  98. [alertView show];
  99. }
  100. - (void)toAddBlackListWith:(NSInteger)index{
  101. NSString *userId = self.otherUserId;
  102. if(userId.length == 0){
  103. return;
  104. }
  105. WEAKSELF
  106. //时长(1=30分钟,2=24小时,3=3天,4=7天,5=永久) ps:新增黑名单时,字段非空
  107. NSDictionary *dict = @{@"duration":@(index),
  108. @"target":userId};
  109. [kHttpManager toAddSomeOneForBlockWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  110. if(kCode_Success){
  111. [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
  112. [weakSelf toGetUserSetData];
  113. }
  114. else{
  115. kShowNetError(data)
  116. }
  117. }];
  118. }
  119. @end