// // CYGroupSendHelperViewController.m // shiku_im // // Created by JayLuo on 2019/12/13. // Copyright © 2019 Reese. All rights reserved. // #import "CYGroupSendHelperViewController.h" #import "CYGroupSendHelperCell.h" #import "CYGroupSendMsgViewController.h" #import "JXLabelObject.h" #import "JXChatViewController.h" #import "JXChatViewC.h" #import "JXGroupMessagesSelectFriendVC.h" @interface CYGroupSendHelperViewController () @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (nonatomic, strong) NSMutableArray *array; @end @implementation CYGroupSendHelperViewController - (void)viewDidLoad { [super viewDidLoad]; [g_notify addObserver:self selector:@selector(getRecord) name:kGroupHelperRefreshNotif object:nil]; // 创建数据库 NSString* myUserId = MY_USER_ID; FMDatabase* db = [[JXXMPP sharedInstance] openUserDb:myUserId]; BOOL result = [JXLabelObject.sharedInstance checkGroupHelperRecordTableCreatedInDb:db]; if (result) { NSLog(@"创建成功--GroupHelperRecordTable"); } // Do any additional setup after loading the view from its nib. self.title = @"群发助手"; self.isGotoBack = YES; self.heightFooter = 0; self.heightHeader = JX_SCREEN_TOP; //下拉刷新 // self.tableView. = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(getRecord)]; [self createHeadAndFoot]; // _facePackages = [NSMutableArray array]; [self.tableView registerNib:[UINib nibWithNibName:@"CYGroupSendHelperCell" bundle:nil] forCellReuseIdentifier:@"CYGroupSendHelperCell"]; [self getRecord]; } - (void)getRecord { _array = [NSMutableArray array]; _array = [JXLabelObject.sharedInstance fetchAllRecordsFromLocal]; [self.tableView reloadData]; } - (void)dealloc { [g_notify removeObserver:self]; } - (IBAction)btnClick:(UIButton *)sender { CYGroupSendMsgViewController *vc = [[CYGroupSendMsgViewController alloc] init]; // JXGroupMessagesSelectFriendVC *vc = [[JXGroupMessagesSelectFriendVC alloc] init]; [g_navigation pushViewController:vc animated:YES]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _array.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CYGroupSendHelperCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CYGroupSendHelperCell"]; JXLabelObject *obj = _array[indexPath.row]; cell.model = obj; cell.resendClickCallback = ^(JXLabelObject * _Nonnull model) { // 再发送 JXChatViewC *vc = [[JXChatViewC alloc] init]; NSString *string = model.userNmaesWithFriend; NSArray *userNmaesWithFriend = [string componentsSeparatedByString:@","]; string = model.userIds; NSArray *userIds = [string componentsSeparatedByString:@","]; string = model.userNames; NSArray *userNames = [string componentsSeparatedByString:@","]; string = model.userNamesWithGroup; NSArray *userNamesWithGroup = [string componentsSeparatedByString:@","]; vc.userNmaesWithFriend = userNmaesWithFriend.copy; vc.userIds = userIds.copy; vc.userNames = userNames.copy; vc.userNamesWithGroup = userNamesWithGroup.copy; vc.isGroupMessages = YES; vc.isCYMSGgroupANDFriendy = YES; [g_navigation pushViewController:vc animated:YES]; }; return cell; } //- (void)nextBtnAction:(UIButton *)btn { // JXChatViewController *vc = [[JXChatViewController alloc] init]; // // NSMutableArray *idArr = [NSMutableArray arrayWithArray:self.mode.selFriendyIdArr]; // NSMutableArray *nameArr = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr]; // NSMutableArray *nameArrGroup = [NSMutableArray arrayWithArray:self.mode.selGroupNameArr]; // // vc.userNmaesWithFriend = [NSMutableArray arrayWithArray:self.mode.selFriendyNameArr]; // // [idArr addObjectsFromArray:self.mode.selGroupIdArr]; // [nameArr addObjectsFromArray:self.mode.selGroupNameArr]; // // // vc.userIds = idArr; // vc.userNames = nameArr; // // // vc.userNamesWithGroup = nameArrGroup; // vc.isGroupMessages = YES; // vc.isCYMSGgroupANDFriendy = YES; // [g_navigation pushViewController:vc animated:YES]; // // [g_navigation popToViewController:[CYGroupSendMsgViewController class] animated:YES]; //} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 180; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 20; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return JX_SCREEN_TOP - (THE_DEVICE_HAVE_HEAD?40:20); } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *header = [[UIView alloc]init]; header.backgroundColor = [UIColor clearColor]; return header; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footer = [[UIView alloc]init]; footer.backgroundColor = [UIColor clearColor]; return footer; } @end