CYGroupSendHelperViewController.m 5.3 KB

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