CYGroupSendHelperViewController.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // CYGroupSendHelperViewController.m
  3. // shiku_im
  4. //
  5. // Created by JayLuo on 2019/12/13.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "CYGroupSendHelperViewController.h"
  9. #import "CYGroupSendHelperCell.h"
  10. #import "CYGroupSendMsgViewController.h"
  11. #import "JXLabelObject.h"
  12. #import "JXChatViewController.h"
  13. #import "JXGroupMessagesSelectFriendVC.h"
  14. @interface CYGroupSendHelperViewController ()<UITableViewDelegate, UITableViewDataSource>
  15. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  16. @property (nonatomic, strong) NSMutableArray *array;
  17. @end
  18. @implementation CYGroupSendHelperViewController
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. [g_notify addObserver:self selector:@selector(getRecord) name:kGroupHelperRefreshNotif object:nil];
  22. // 创建数据库
  23. NSString* myUserId = MY_USER_ID;
  24. FMDatabase* db = [[JXXMPP sharedInstance] openUserDb:myUserId];
  25. BOOL result = [JXLabelObject.sharedInstance checkGroupHelperRecordTableCreatedInDb:db];
  26. if (result) {
  27. NSLog(@"创建成功--GroupHelperRecordTable");
  28. }
  29. // Do any additional setup after loading the view from its nib.
  30. self.title = @"群发助手";
  31. self.isGotoBack = YES;
  32. self.heightFooter = 0;
  33. self.heightHeader = JX_SCREEN_TOP;
  34. //下拉刷新
  35. // self.tableView. = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(getRecord)];
  36. [self createHeadAndFoot];
  37. // _facePackages = [NSMutableArray array];
  38. [self.tableView registerNib:[UINib nibWithNibName:@"CYGroupSendHelperCell" bundle:nil] forCellReuseIdentifier:@"CYGroupSendHelperCell"];
  39. [self getRecord];
  40. }
  41. - (void)getRecord {
  42. _array = [NSMutableArray array];
  43. _array = [JXLabelObject.sharedInstance fetchAllRecordsFromLocal];
  44. [self.tableView reloadData];
  45. }
  46. - (void)dealloc {
  47. [g_notify removeObserver:self];
  48. }
  49. - (IBAction)btnClick:(UIButton *)sender {
  50. CYGroupSendMsgViewController *vc = [[CYGroupSendMsgViewController alloc] init];
  51. // JXGroupMessagesSelectFriendVC *vc = [[JXGroupMessagesSelectFriendVC alloc] init];
  52. [g_navigation pushViewController:vc animated:YES];
  53. }
  54. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  55. return _array.count;
  56. }
  57. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  58. CYGroupSendHelperCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CYGroupSendHelperCell"];
  59. JXLabelObject *obj = _array[indexPath.row];
  60. cell.model = obj;
  61. cell.resendClickCallback = ^(JXLabelObject * _Nonnull model) {
  62. // 再发送
  63. JXChatViewController *vc = [[JXChatViewController alloc] init];
  64. NSString *string = model.userNmaesWithFriend;
  65. NSArray *userNmaesWithFriend = [string componentsSeparatedByString:@","];
  66. string = model.userIds;
  67. NSArray *userIds = [string componentsSeparatedByString:@","];
  68. string = model.userNames;
  69. NSArray *userNames = [string componentsSeparatedByString:@","];
  70. string = model.userNamesWithGroup;
  71. NSArray *userNamesWithGroup = [string componentsSeparatedByString:@","];
  72. vc.userNmaesWithFriend = userNmaesWithFriend.copy;
  73. vc.userIds = userIds.copy;
  74. vc.userNames = userNames.copy;
  75. vc.userNamesWithGroup = userNamesWithGroup.copy;
  76. vc.isGroupMessages = YES;
  77. vc.isCYMSGgroupANDFriendy = YES;
  78. [g_navigation pushViewController:vc animated:YES];
  79. };
  80. return cell;
  81. }
  82. //- (void)nextBtnAction:(UIButton *)btn {
  83. // JXChatViewController *vc = [[JXChatViewController alloc] init];
  84. //
  85. // NSMutableArray *idArr = [NSMutableArray arrayWithArray:self.mode.selFriendyIdArr];
  86. // NSMutableArray *nameArr = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr];
  87. // NSMutableArray *nameArrGroup = [NSMutableArray arrayWithArray:self.mode.selGroupNameArr];
  88. //
  89. // vc.userNmaesWithFriend = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr];
  90. //
  91. // [idArr addObjectsFromArray:self.mode.selGroupIdArr];
  92. // [nameArr addObjectsFromArray:self.mode.selGroupNameArr];
  93. //
  94. //
  95. // vc.userIds = idArr;
  96. // vc.userNames = nameArr;
  97. //
  98. //
  99. // vc.userNamesWithGroup = nameArrGroup;
  100. // vc.isGroupMessages = YES;
  101. // vc.isCYMSGgroupANDFriendy = YES;
  102. // [g_navigation pushViewController:vc animated:YES];
  103. // // [g_navigation popToViewController:[CYGroupSendMsgViewController class] animated:YES];
  104. //}
  105. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  106. return 180;
  107. }
  108. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  109. return 20;
  110. }
  111. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  112. return JX_SCREEN_TOP - (THE_DEVICE_HAVE_HEAD?40:20);
  113. }
  114. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  115. UIView *header = [[UIView alloc]init];
  116. header.backgroundColor = [UIColor clearColor];
  117. return header;
  118. }
  119. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  120. UIView *footer = [[UIView alloc]init];
  121. footer.backgroundColor = [UIColor clearColor];
  122. return footer;
  123. }
  124. @end