123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557 |
- //
- // JXFriendViewController.h.m
- //
- // Created by flyeagleTang on 14-4-3.
- // Copyright (c) 2014年 Reese. All rights reserved.
- //
- #import "JXAddrBookFriendVc.h"
- #import "JXChatViewController.h"
- #import "AppDelegate.h"
- #import "JXLabel.h"
- #import "JXImageView.h"
- #import "JXCell.h"
- #import "JXRoomPool.h"
- #import "JXTableView.h"
- #import "JXNewFriendViewController.h"
- #import "menuImageView.h"
- #import "FMDatabase.h"
- #import "JXProgressVC.h"
- #import "JXTopSiftJobView.h"
- #import "JXUserInfoVC.h"
- #import "BMChineseSort.h"
- #import "JXGroupViewController.h"
- #import "OrganizTreeViewController.h"
- #import "JXTabMenuView.h"
- #import "JXPublicNumberVC.h"
- #import "JXBlackFriendVC.h"
- #import "JX_DownListView.h"
- #import "JXNewRoomVC.h"
- #import "JXNearVC.h"
- #import "JXSearchUserVC.h"
- #import "JXScanQRViewController.h"
- #import "JXLabelVC.h"
- #import "JXAddressBookVC.h"
- #import "JXSearchVC.h"
- #import "JXLabelObject.h"
- #import "CYWebCustomerServiceVC.h"
- #import "CYGroupSendHelperViewController.h"
- #import "JXSelectFriendsVC.h"
- #import "JXSetLabelVC.h"
- #import "JXNewLabelVC.h"
- #import "JXShowLabelVc.h"
- #import "CYGroupSendHelperViewController.h"
- #define HEIGHT 54
- #define IMAGE_HEIGHT 45 // 图片宽高
- #define INSET_HEIGHT 10 // 图片文字间距
- @interface JXAddrBookFriendVc ()<UITextFieldDelegate,JXSelectMenuViewDelegate,UIAlertViewDelegate>
- @property (nonatomic, strong) JXUserObject * currentUser;
- //排序后的出现过的拼音首字母数组
- @property(nonatomic,strong)NSMutableArray *indexArray;
- //排序好的结果数组
- @property(nonatomic,strong)NSMutableArray *letterResultArr;
- @property (nonatomic, strong) UITextField *seekTextField;
- @property (nonatomic, strong) NSMutableArray *searchArray;
- @property (nonatomic, strong) UILabel *friendNewMsgNum;
- @property (nonatomic, strong) UILabel *abNewMsgNum;
- @property (nonatomic, strong) UIButton *moreBtn;
- @property (nonatomic, strong) UIView *menuView;
- @property (nonatomic, assign) CGFloat btnHeight; // 按钮的真实高度
- @property (nonatomic,copy)NSArray *customerArr; //客服信息
- @property (nonatomic,strong) NSIndexPath *indexPathV;
- @end
- @implementation JXAddrBookFriendVc
- - (id)init
- {
- self = [super init];
- if (self) {
- self.isOneInit = YES;
- self.heightHeader = JX_SCREEN_TOP;
- self.heightFooter = JX_SCREEN_BOTTOM;
- if (_isMyGoIn) {
- self.isGotoBack = YES;
- self.heightFooter = 0;
- }
- // self.view.frame = g_window.bounds;
- [self createHeadAndFoot];
- [self buildTop];
- [self defineNavChatPush:@"通讯录"];
- self.view.backgroundColor = HEXCOLOR(0xF2F2F2);
- self.tableView.backgroundColor = HEXCOLOR(0xF2F2F2);
- //self.tableView.frame=CGRectMake(0, JX_SCREEN_TOP+55, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-55);
- self.tableView.frame=CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP-55);
- [self customView];
- _table.contentInset=UIEdgeInsetsMake(55, 0, 0, 0);
- _selMenu = 0;
- // self.title = Localized(@"JXInputVC_Friend");
- self.title = Localized(@"JX_MailList");
- [g_notify addObserver:self selector:@selector(newFriend:) name:kXMPPNewFriendNotifaction object:nil];
-
- [g_notify addObserver:self selector:@selector(newRequest:) name:kXMPPNewRequestNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(newReceipt:) name:kXMPPReceiptNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(onSendTimeout:) name:kXMPPSendTimeOutNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(friendRemarkNotif:) name:kFriendRemark object:nil];
-
- [g_notify addObserver:self selector:@selector(newMsgCome:) name:kXMPPNewMsgNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(friendListRefresh:) name:kFriendListRefresh object:nil];
- [g_notify addObserver:self selector:@selector(refreshABNewMsgCount:) name:kRefreshAddressBookNotif object:nil];
- [g_notify addObserver:self selector:@selector(contactRegisterNotif:) name:kMsgComeContactRegister object:nil];
- [g_notify addObserver:self selector:@selector(newRequest:) name:kFriendPassNotif object:nil];
- [g_notify addObserver:self selector:@selector(refresh) name:kOfflineOperationUpdateUserSet object:nil];
- [g_notify addObserver:self selector:@selector(updateLabels:) name:kXMPPMessageUpadtePasswordNotification object:nil];
- // [g_server customerLinkList:self];
- [self setupCustomerLinkList];
-
- [self getArrayData];
-
- [self getFriend];
- [self refresh];
- }
- return self;
- }
- - (void)updateLabels:(NSNotification *)noti {
- JXMessageObject *msg = noti.object;
- if ([msg.objectId isEqualToString:SYNC_LABEL]) {
- // 同步标签
- [g_server friendGroupListToView:self];
- }
- }
- - (void)friendListRefresh:(NSNotification *)notif {
-
- [self refresh];
- }
- - (void)contactRegisterNotif:(NSNotification *)notif {
- JXMessageObject *msg = notif.object;
-
- NSDictionary *dict = (NSDictionary *)msg.content;
- if ([msg.content isKindOfClass:[NSString class]]) {
- SBJsonParser * resultParser = [[SBJsonParser alloc] init] ;
- dict = [resultParser objectWithString:msg.content];
- }
- JXAddressBook *addressBook = [[JXAddressBook alloc] init];
- addressBook.toUserId = [NSString stringWithFormat:@"%@",dict[@"toUserId"]];
- addressBook.toUserName = dict[@"toUserName"];
- addressBook.toTelephone = dict[@"toTelephone"];
- addressBook.telephone = dict[@"telephone"];
- addressBook.registerEd = dict[@"registerEd"];
- addressBook.registerTime = [NSDate dateWithTimeIntervalSince1970:[dict[@"registerTime"] longLongValue]];
- addressBook.isRead = [NSNumber numberWithBool:0];
- [addressBook insert];
-
- [self refreshABNewMsgCount:nil];
- }
- - (void)refreshABNewMsgCount:(NSNotification *)notif {
- [self refresh];
- JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
- newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
- [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
- }
- #pragma mark 接受新消息广播
- -(void)newMsgCome:(NSNotification *)notifacation
- {
- JXMessageObject *msg = notifacation.object;
- if (![msg isAddFriendMsg]) {
- return;
- }
-
- NSString* s;
- s = [msg getTableName];
- JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
- newobj.user = [[JXUserObject sharedInstance] getUserById:s];
- [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
-
- }
- - (void) showNewMsgCount:(NSInteger)friendNewMsgNum {
- if (friendNewMsgNum >= 10 && friendNewMsgNum <= 99) {
- self.friendNewMsgNum.font = SYSFONT(12);
- }else if (friendNewMsgNum > 0 && friendNewMsgNum < 10) {
- self.friendNewMsgNum.font = SYSFONT(13);
- }else if(friendNewMsgNum > 99){
- self.friendNewMsgNum.font = SYSFONT(9);
- }
- self.friendNewMsgNum.text = [NSString stringWithFormat:@"%ld",friendNewMsgNum];
-
- if (friendNewMsgNum <= 0) {
- self.friendNewMsgNum.hidden = YES;
- }else{
- self.friendNewMsgNum.hidden = NO;
- }
-
- NSMutableArray *abUread = [[JXAddressBook sharedInstance] doFetchUnread];
- if (abUread.count >= 10 && abUread.count <= 99) {
- self.friendNewMsgNum.font = SYSFONT(12);
- }else if (abUread.count > 0 && abUread.count < 10) {
- self.friendNewMsgNum.font = SYSFONT(13);
- }else if(abUread.count > 99){
- self.friendNewMsgNum.font = SYSFONT(9);
- }
- self.abNewMsgNum.text = [NSString stringWithFormat:@"%ld",abUread.count];
- if (abUread.count <= 0) {
- self.abNewMsgNum.hidden = YES;
- }else {
- self.abNewMsgNum.hidden = NO;
- }
-
- NSInteger num = friendNewMsgNum + abUread.count;
- // if (num <= 0) {
- // [g_mainVC.tb setBadge:1 title:@"0"];
- // }else {
- // [g_mainVC.tb setBadge:1 title:[NSString stringWithFormat:@"%ld", num]];
- // }
- if (num <= 0) {
- int number = 0;
- if (g_App.linkArray.count == 0) {
- number = 1;
- }else if(g_App.linkArray.count == 1){
- number = 2;
- }else if(g_App.linkArray.count == 2){
- number = 3;
- }
- [g_mainVC.tb setBadge:number title:@"0"];
- }else {
- int number = 0;
- if (g_App.linkArray.count == 0) {
- number = 1;
- }else if(g_App.linkArray.count == 1){
- number = 2;
- }else if(g_App.linkArray.count == 2){
- number = 3;
- }
- [g_mainVC.tb setBadge:number title:[NSString stringWithFormat:@"%ld", num]];
- }
- }
- -(void)newRequest:(NSNotification *)notifacation
- {
- [self getFriend];
- }
- - (void)scrollToPageUp {
- [self getFriend];
- }
- -(void)buildTop{
- //刷新好友列表
- // UIButton * getFriendBtn = [[UIButton alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-35, JX_SCREEN_TOP - 34, 30, 30)];
- // getFriendBtn.custom_acceptEventInterval = .25f;
- // [getFriendBtn addTarget:self action:@selector(getFriend) forControlEvents:UIControlEventTouchUpInside];
- //// [getFriendBtn setImage:[UIImage imageNamed:@"synchro_friends"] forState:UIControlStateNormal];
- // [getFriendBtn setBackgroundImage:[UIImage imageNamed:@"synchro_friends"] forState:UIControlStateNormal];
- // [self.tableHeader addSubview:getFriendBtn];
-
- self.moreBtn = [UIFactory createButtonWithImage:@"im_003_more_button_black"
- highlight:nil
- target:self
- selector:@selector(onMore:)];
- self.moreBtn.custom_acceptEventInterval = 1.0f;
- self.moreBtn.frame = CGRectMake(JX_SCREEN_WIDTH - 18-BTN_RANG_UP*2, JX_SCREEN_TOP - 18-BTN_RANG_UP*2, 18+BTN_RANG_UP*2, 18+BTN_RANG_UP*2);
- [self.tableHeader addSubview:self.moreBtn];
- }
- - (void) customView {
-
- backView = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, 55)];
- backView.backgroundColor=kRGBColor250;
- //self.tableView.tableHeaderView = backView;
-
- _seekTextField = [[UITextField alloc] initWithFrame:CGRectMake(15, 10, backView.frame.size.width - 30, 35)];
- _seekTextField.placeholder = Localized(@"JX_Seach");
- _seekTextField.textColor = [UIColor blackColor];
- _seekTextField.textAlignment= NSTextAlignmentCenter;
- [_seekTextField setFont:SYSFONT(14)];
- _seekTextField.backgroundColor = [UIColor whiteColor];
- UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"card_search"]];
- UIView *leftView = [[UIView alloc ]initWithFrame:CGRectMake(0, 0, 30, 30)];
- imageView.center = leftView.center;
- [leftView addSubview:imageView];
- _seekTextField.leftView = leftView;
- _seekTextField.leftViewMode = UITextFieldViewModeAlways;
- _seekTextField.borderStyle = UITextBorderStyleNone;
- _seekTextField.layer.masksToBounds = YES;
- _seekTextField.layer.cornerRadius = 5;
- _seekTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
- _seekTextField.delegate = self;
- _seekTextField.returnKeyType = UIReturnKeyGoogle;
- [backView addSubview:_seekTextField];
- [_seekTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
-
- [backView addSubview:_menuView];
-
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
- newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
- [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
-
- });
- [self showMenuView];
- if (_isMyGoIn) {
- [self hideMenuView];
- }
-
- [self setFooterView];
-
- }
- - (void) setFooterView {
-
- if (_array.count > 0) {
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 44)];
- label.textColor = HEXCOLOR(0x999999);
- label.textAlignment = NSTextAlignmentCenter;
- label.font = SYSFONT(16);
- label.text = [NSString stringWithFormat:@"%ld%@",_array.count,Localized(@"JX_ContactsNumber")];
-
- self.tableView.tableFooterView = label;
- }else {
- self.tableView.tableFooterView = nil;
- }
- }
- - (void)showMenuView { // 显示菜单栏
-
- // self.tableView.tableHeaderView = backView;
- [self.view addSubview:backView];
-
-
- UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP+55, JX_SCREEN_WIDTH, 121)];
- headView.userInteractionEnabled=YES;
- headView.backgroundColor=[UIColor whiteColor];
- UIView *qunfaView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 60)];
- [headView addSubview:qunfaView];
- UIButton *groundBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 9, 42, 42)];
- [groundBtn setImage:[UIImage imageNamed:@"qunfazhushou"] forState:UIControlStateNormal];
- [groundBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- groundBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
- groundBtn.contentMode=UIViewContentModeScaleAspectFit;
- [qunfaView addSubview:groundBtn];
- [qunfaView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(grounBtnClick)]];
-
- UILabel *qunfalabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 9, 100, 42)];
- qunfalabel.text=@"群发助手";
- [qunfaView addSubview:qunfalabel];
-
- UIView *lineVIew = [[UIView alloc] initWithFrame:CGRectMake(54, 60, JX_SCREEN_WIDTH-54, 1)];
- lineVIew.backgroundColor=kRGBColor250;
- [qunfaView addSubview:lineVIew];
-
- UIView *biaqView = [[UIView alloc] initWithFrame:CGRectMake(0, 61, JX_SCREEN_WIDTH, 60)];
- biaqView.userInteractionEnabled=YES;
- [headView addSubview:biaqView];
- UIButton *biaoqianBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 9, 42, 42)];
- [biaoqianBtn setImage:[UIImage imageNamed:@"biaoqiangL"] forState:UIControlStateNormal];
- [biaoqianBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- biaoqianBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
- biaoqianBtn.contentMode=UIViewContentModeScaleAspectFit;
- [biaqView addSubview:biaoqianBtn];
- UILabel *biaqianL = [[UILabel alloc] initWithFrame:CGRectMake(60, 9, 100, 42)];
- biaqianL.text=@"标签";
- [biaqView addSubview:biaqianL];
-
- [biaqView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(biaqViewClick)]];
-
- self.tableView.tableHeaderView = headView;
-
- }
- //群发助手
- - (void)grounBtnClick{
-
- CYGroupSendHelperViewController *vc = [[CYGroupSendHelperViewController alloc] init];
-
- [g_navigation pushViewController:vc animated:YES];
- }
- /// 标签
- - (void)biaqViewClick{
-
- JXShowLabelVc *vc = [[JXShowLabelVc alloc] init];
-
- [g_navigation pushViewController:vc animated:YES];
- }
- - (void)refreshLabel:(id)arr{
-
-
- }
- - (void)hideMenuView { // 隐藏菜单栏
- _menuView.hidden = YES;
- CGRect backFrame = backView.frame;
- backFrame.size.height = 55;
- backView.frame = backFrame;
- self.tableView.tableHeaderView = backView;
- }
- #pragma mark 右上角更多
- -(void)onMore:(UIButton *)sender{
- NSArray *role = MY_USER_ROLE;
- if ([g_App.config.hideSearchByFriends intValue] == 1 && ([g_App.config.isCommonFindFriends intValue] == 0 || role.count > 0)) {
- [self onSearch];
- }else {
- NSMutableArray *titles = [NSMutableArray arrayWithArray:@[Localized(@"JX_LaunchGroupChat"), Localized(@"JX_Scan"), Localized(@"JXNearVC_NearPer"),Localized(@"JX_SearchPublicNumber")]];
- NSMutableArray *images = [NSMutableArray arrayWithArray:@[@"message_creat_group_black", @"messaeg_scnning_black", @"message_near_person_black",@"message_search_publicNumber"]];
- NSMutableArray *sels = [NSMutableArray arrayWithArray:@[@"onNewRoom", @"showScanViewController", @"onNear",@"searchPublicNumber"]];
- if ([g_App.config.isCommonCreateGroup intValue] == 1 && role.count <= 0) {
- [titles removeObject:Localized(@"JX_LaunchGroupChat")];
- [images removeObject:@"message_creat_group_black"];
- [sels removeObject:@"onNewRoom"];
- }
- if ([g_App.config.isOpenPositionService intValue] == 1) {
- [titles removeObject:Localized(@"JXNearVC_NearPer")];
- [images removeObject:@"message_near_person_black"];
- [sels removeObject:@"onNear"];
- }
- if (![g_App.config.enableMpModule boolValue]) {
- [titles removeObject:Localized(@"JX_SearchPublicNumber")];
- [images removeObject:@"message_search_publicNumber"];
- [sels removeObject:@"searchPublicNumber"];
- }
-
- JX_SelectMenuView *menuView = [[JX_SelectMenuView alloc] initWithTitle:titles image:images cellHeight:44];
- menuView.sels = sels;
- menuView.delegate = self;
- [g_App.window addSubview:menuView];
- }
- // _control.hidden = YES;
- // UIWindow *window = [[UIApplication sharedApplication].delegate window];
- // CGRect moreFrame = [self.tableHeader convertRect:self.moreBtn.frame toView:window];
- //
- // JX_SelectMenuView *menuView = [[JX_SelectMenuView alloc] initWithTitle:@[Localized(@"JX_LaunchGroupChat"), Localized(@"JX_AddFriends"), Localized(@"JX_Scan"), Localized(@"JXNearVC_NearPer")] image:@[@"message_creat_group_black", @"message_add_friend_black", @"messaeg_scnning_black", @"message_near_person_black"] cellHeight:45];
- // menuView.delegate = self;
- // [g_App.window addSubview:menuView];
-
- // JX_DownListView * downListView = [[JX_DownListView alloc] initWithFrame:self.view.bounds];
- // downListView.listContents = @[Localized(@"JX_LaunchGroupChat"), Localized(@"JX_AddFriends"), Localized(@"JX_Scan"), Localized(@"JXNearVC_NearPer")];
- // downListView.listImages = @[@"message_creat_group_black", @"message_add_friend_black", @"messaeg_scnning_black", @"message_near_person_black"];
- //
- // __weak typeof(self) weakSelf = self;
- // [downListView downlistPopOption:^(NSInteger index, NSString *content) {
- //
- // [weakSelf moreListActionWithIndex:index];
- //
- // } whichFrame:moreFrame animate:YES];
- // [downListView show];
-
- // self.treeView.editing = !self.treeView.editing;
- }
- - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
-
-
- NSString *method = MenuView.sels[index];
- SEL _selector = NSSelectorFromString(method);
- [self performSelectorOnMainThread:_selector withObject:nil waitUntilDone:YES];
-
- // NSArray *role = MY_USER_ROLE;
- // // 显示搜索好友
- // BOOL isShowSearch = [g_App.config.hideSearchByFriends boolValue] && (![g_App.config.isCommonFindFriends boolValue] || role.count > 0);
- // //显示创建房间
- // BOOL isShowRoom = [g_App.config.isCommonCreateGroup intValue] == 0 || role.count > 0;
- // //显示附近的人
- // BOOL isShowPosition = [g_App.config.isOpenPositionService intValue] == 0;
- // switch (index) {
- // case 0:
- // if (isShowRoom) {
- // [self onNewRoom];
- // }else {
- // if (isShowSearch) {
- // [self onSearch];
- // }else {
- // [self showScanViewController];
- // }
- // }
- // break;
- // case 1:
- // if (isShowRoom && isShowSearch) {
- // [self onSearch];
- // }else {
- // if ((isShowRoom && !isShowSearch) || (!isShowRoom && isShowSearch)) {
- // [self showScanViewController];
- // }else if (!isShowRoom && !isShowSearch) {
- // if (isShowPosition) {
- // [self onNear];
- // }else {
- // [self searchPublicNumber];
- // }
- // }
- // }
- // break;
- // case 2:
- // if (isShowSearch && isShowRoom) {
- // [self showScanViewController];
- // }else {
- // if ((isShowRoom && !isShowSearch) || (!isShowRoom && isShowSearch)) {
- // if (isShowPosition) {
- // [self onNear];
- // }else {
- // [self searchPublicNumber];
- // }
- // }
- // }
- // break;
- // case 3:
- // if (isShowPosition) {
- // [self onNear];
- // }else {
- // [self searchPublicNumber];
- // }
- // break;
- // case 4:
- // [self searchPublicNumber];
- // break;
- // default:
- // break;
- // }
- }
- // 搜索公众号
- - (void)searchPublicNumber {
- JXSearchUserVC *searchUserVC = [JXSearchUserVC alloc];
- searchUserVC.type = JXSearchTypePublicNumber;
- searchUserVC = [searchUserVC init];
- [g_navigation pushViewController:searchUserVC animated:YES];
- }
- - (void) moreListActionWithIndex:(NSInteger)index {
-
- }
- // 创建群组
- -(void)onNewRoom{
- JXNewRoomVC* vc = [[JXNewRoomVC alloc]init];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 附近的人
- -(void)onNear{
- JXNearVC * nearVc = [[JXNearVC alloc] init];
- [g_navigation pushViewController:nearVc animated:YES];
- }
- //搜索好友
- -(void)onSearch{
- JXSearchUserVC* vc = [JXSearchUserVC alloc];
- vc.delegate = self;
- vc.didSelect = @selector(doSearch:);
- vc.type = JXSearchTypeUser;
- vc = [vc init];
- [g_navigation pushViewController:vc animated:YES];
-
- [self cancelBtnAction];
- }
- -(void)doSearch:(searchData*)p{
-
- JXNearVC *nearVC = [[JXNearVC alloc]init];
- nearVC.isSearch = YES;
- [g_navigation pushViewController:nearVC animated:YES];
- [nearVC doSearch:p];
- }
- // 扫一扫
- -(void)showScanViewController{
- // button.enabled = NO;
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // button.enabled = YES;
- // });
-
- AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
- if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
- {
- [g_server showMsg:Localized(@"JX_CanNotopenCenmar")];
- return;
- }
-
- JXScanQRViewController * scanVC = [[JXScanQRViewController alloc] init];
-
- // [g_window addSubview:scanVC.view];
- [g_navigation pushViewController:scanVC animated:YES];
- }
- // 新朋友
- - (void)newFriendAction:(JXImageView *)imageView {
- // 清空角标
- JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
- newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
- newobj.message = [[JXMessageObject alloc] init];
- newobj.message.toUserId = FRIEND_CENTER_USERID;
- newobj.user.msgsNew = [NSNumber numberWithInt:0];
- [newobj.message updateNewMsgsTo0];
-
- NSArray *friends = [[JXFriendObject sharedInstance] fetchAllFriendsFromLocal];
- for (NSInteger i = 0; i < friends.count; i ++) {
- JXFriendObject *friend = friends[i];
- if ([friend.msgsNew integerValue] > 0) {
- [friend updateNewMsgUserId:friend.userId num:0];
- [friend updateNewFriendLastContent];
- }
- }
-
- [self showNewMsgCount:0];
- JXNewFriendViewController* vc = [[JXNewFriendViewController alloc]init];
- [g_navigation pushViewController:vc animated:YES];
-
- }
- // 群组
- - (void)myGroupAction:(JXImageView *)imageView {
- JXGroupViewController *vc = [[JXGroupViewController alloc] init];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 我的同事
- - (void)myColleaguesAction:(JXImageView *)imageView {
- OrganizTreeViewController *vc = [[OrganizTreeViewController alloc] init];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 公众号
- - (void)publicNumberAction:(JXImageView *)imageView {
- JXPublicNumberVC *vc = [[JXPublicNumberVC alloc] init];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 黑名单
- - (void)blackFriendAction:(JXImageView *)imageView {
- JXBlackFriendVC *vc = [[JXBlackFriendVC alloc] init];
- vc.title = Localized(@"JX_BlackList");
- [g_navigation pushViewController:vc animated:YES];
- }
- // 我的设备
- - (void)myDeviceAction:(JXImageView *)imageView {
- JXBlackFriendVC *vc = [[JXBlackFriendVC alloc] init];
- vc.isDevice = YES;
- vc.title = Localized(@"JX_MyDevices");
- [g_navigation pushViewController:vc animated:YES];
- }
- // 群发助手
- - (void)groupHelperAction:(JXImageView *)imageView {
- CYGroupSendHelperViewController *vc = [[CYGroupSendHelperViewController alloc] init];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 标签
- - (void)labelAction:(JXImageView *)imageView {
-
- JXLabelVC *vc = [[JXLabelVC alloc] init];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 手机通讯录
- - (void)addressBookAction:(JXImageView *)imageView {
-
- JXAddressBookVC *vc = [[JXAddressBookVC alloc] init];
- NSMutableArray *arr = [[JXAddressBook sharedInstance] doFetchUnread];
- vc.abUreadArr = arr;
- [g_navigation pushViewController:vc animated:YES];
- [[JXAddressBook sharedInstance] updateUnread];
-
- JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
- newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
- [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
- }
- -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom icon:(NSString*)icon click:(SEL)click superView:(UIView *)superView{
- JXImageView* btn = [[JXImageView alloc] init];
- btn.backgroundColor = [UIColor whiteColor];
- btn.userInteractionEnabled = YES;
- btn.didTouch = click;
- btn.delegate = self;
- [superView addSubview:btn];
-
- JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(42 + 14 + 14, 0, 200, HEIGHT)];
- p.text = title;
- p.font = g_factory.font16;
- p.backgroundColor = [UIColor clearColor];
- p.textColor = HEXCOLOR(0x323232);
- // p.delegate = self;
- // p.didTouch = click;
- [btn addSubview:p];
-
- if(icon){
- UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(14, (HEIGHT-42)/2, 42, 42)];
- iv.image = [UIImage imageNamed:icon];
- iv.layer.cornerRadius = iv.frame.size.width / 2;
- iv.layer.masksToBounds = YES;
- [btn addSubview:iv];
- }
-
- if(drawTop){
- UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- if(drawBottom){
- UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,HEIGHT-LINE_WH,JX_SCREEN_WIDTH,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- // if(click){
- // UIImageView* iv;
- // iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-20-3, 16, 20, 20)];
- // iv.image = [UIImage imageNamed:@"set_list_next"];
- // [btn addSubview:iv];
- //
- // }
- return btn;
- }
- - (void)textFieldDidBeginEditing:(UITextField *)textField{
- [textField resignFirstResponder];
- JXSearchVC *vc = [[JXSearchVC alloc] initWithTable:@"friendsearchrecord"];
- [g_navigation pushViewController:vc animated:YES];
- }
- - (void) textFieldDidChange:(UITextField *)textField {
-
- if (textField.text.length <= 0) {
- if (!self.isMyGoIn) {
- [self showMenuView];
- }
- [self getArrayData];
- [self.tableView reloadData];
- return;
- }else {
- [self hideMenuView];
- }
-
- [_searchArray removeAllObjects];
- if (_selMenu == 0) {
- _searchArray = [[JXUserObject sharedInstance] fetchFriendsFromLocalWhereLike:textField.text];
- }else if (_selMenu == 1){
- _searchArray = [[JXUserObject sharedInstance] fetchBlackFromLocalWhereLike:textField.text];
- }
-
- [self.tableView reloadData];
- }
- - (void) cancelBtnAction {
- if (_seekTextField.text.length > 0) {
- _seekTextField.text = nil;
- [self getArrayData];
- }
- [_seekTextField resignFirstResponder];
- [self.tableView reloadData];
- }
- -(void)onClick:(UIButton*)sender{
- }
- //筛选点击
- - (void)topItemBtnClick:(UIButton *)btn{
- [self checkAfterScroll:(btn.tag-100)];
- [_topSiftView resetAllParaBtn];
- }
- - (void)checkAfterScroll:(CGFloat)offsetX{
- if (offsetX == 0) {
- _selMenu = 0;
- }else {
- _selMenu = 1;
- }
- [self scrollToPageUp];
- }
- //获取最近的好友
- - (void)getFriend{
- [g_server listAttention:10000 userId:MY_USER_ID toView:self];
- }
- //-(void)actionSegment:(UISegmentedControl*)sender{
- // _selMenu = (int)sender.selectedSegmentIndex;
- // [self refresh];
- //}
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- _array=[[NSMutableArray alloc] init];
- //[self refresh];
-
- }
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- // 离开时重置_isMyGoIn
- if (_isMyGoIn) {
- _isMyGoIn = NO;
- }
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- }
-
- #pragma mark ---------tableView协议----------------
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- if (_seekTextField.text.length > 0) {
- return 1;
- }
- return [self.indexArray count];
- }
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- if (_seekTextField.text.length > 0) {
- return Localized(@"JXFriend_searchTitle");
- }
- return [self.indexArray objectAtIndex:section];
- }
- -(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
- UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
- header.tintColor = HEXCOLOR(0xF2F2F2);
- [header.textLabel setTextColor:HEXCOLOR(0x999999)];
- [header.textLabel setFont:SYSFONT(15)];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- if (_seekTextField.text.length > 0) {
- return _searchArray.count;
- }
- return [(NSArray *)[self.letterResultArr objectAtIndex:section] count];
- }
- -(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
- if (_seekTextField.text.length > 0) {
- return nil;
- }
- return _indexArray;
- }
- - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
- return index;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- JXUserObject *user;
- if (_seekTextField.text.length > 0) {
- user = _searchArray[indexPath.row];
- }else{
- user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
- }
-
- JXCell *cell=nil;
- NSString* cellName = [NSString stringWithFormat:@"msg_%d_%ld",_refreshCount,(long)indexPath.row];
- cell = [tableView dequeueReusableCellWithIdentifier:cellName];
-
- if(cell==nil){
-
- cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
- [_table addToPool:cell];
-
- // cell.headImage = user.userHead;
- // user = nil;
- }
-
- // cell.title = user.userNickname;
- cell.title = [self multipleLoginIsOnlineTitle:user];
- // cell.subtitle = user.userId;
- cell.index = (int)indexPath.row;
- cell.delegate = self;
- cell.didTouch = @selector(onHeadImage:);
- // cell.bottomTitle = [TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"];
- // [cell setForTimeLabel:[TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"]];
- cell.timeLabel.frame = CGRectMake(JX_SCREEN_WIDTH - 120-20, 9, 115, 20);
- cell.userId = user.userId;
- [cell.lbTitle setText:cell.title];
- //添加爱心标志---特别关心标志
- // cell.notPushImageView.image = [UIImage imageNamed:@"collection_me_simple"];
- if ([user.veryCare intValue] == 1) {
- cell.specialCareImageView.hidden = NO;
- }else {
- cell.specialCareImageView.hidden = YES;
- }
- cell.dataObj = user;
- // cell.headImageView.tag = (int)indexPath.row;
- // cell.headImageView.delegate = cell.delegate;
- // cell.headImageView.didTouch = cell.didTouch;
-
- cell.isSmall = YES;
- [cell headImageViewImageWithUserId:user.userId roomId:nil];
-
- if (indexPath.section == self.letterResultArr.count-1 && indexPath.row == [(NSArray *)[self.letterResultArr objectAtIndex:indexPath.section] count]-1) {
- cell.lineView.frame = CGRectMake(0, cell.lineView.frame.origin.y, JX_SCREEN_WIDTH, cell.lineView.frame.size.height);
- }else if (indexPath.row == [(NSArray *)[self.letterResultArr objectAtIndex:indexPath.section] count]-1) {
- cell.lineView.frame = CGRectMake(cell.lineView.frame.origin.x, cell.lineView.frame.origin.y, cell.lineView.frame.size.width,0);
- }else {
- cell.lineView.frame = CGRectMake(cell.lineView.frame.origin.x, cell.lineView.frame.origin.y, cell.lineView.frame.size.width,LINE_WH);
- }
-
- return cell;
- }
-
- - (NSString *)multipleLoginIsOnlineTitle:(JXUserObject *)user {
- NSString *isOnline;
- if ([user.isOnLine intValue] == 1) {
- isOnline = [NSString stringWithFormat:@"(%@)", Localized(@"JX_OnLine")];
- }else {
- isOnline = [NSString stringWithFormat:@"(%@)", Localized(@"JX_OffLine")];
- }
- NSString *title = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
- if ([user.userId isEqualToString:ANDROID_USERID] || [user.userId isEqualToString:PC_USERID] || [user.userId isEqualToString:MAC_USERID]) {
- title = [title stringByAppendingString:isOnline];
- }
- return title;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- { [super tableView:tableView didSelectRowAtIndexPath:indexPath];
-
- JXCell * cell = [_table cellForRowAtIndexPath:indexPath];
- cell.selected = NO;
-
- // 黑名单列表不能点击
- if (_selMenu == 1) {
- return;
- }
-
- JXUserObject *user;
- if (_seekTextField.text.length > 0) {
- user = _searchArray[indexPath.row];
- }else{
- user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
- }
-
-
- if([user.userId isEqualToString:FRIEND_CENTER_USERID]){
- JXNewFriendViewController* vc = [[JXNewFriendViewController alloc]init];
- // [g_App.window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- // [vc release];
- return;
- }
-
- JXChatViewC *sendView=[JXChatViewC alloc];
- if([user.roomFlag intValue] > 0 || user.roomId.length > 0){
- sendView.roomJid = user.userId;
- sendView.roomId = user.roomId;
- [[JXXMPP sharedInstance].roomPool joinRoom:user.userId title:user.userNickname lastDate:nil isNew:NO];
- }
- sendView.title = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
- sendView.chatPerson = user;
- sendView = [sendView init];
- // [g_App.window addSubview:sendView.view];
- [g_navigation pushViewController:sendView animated:YES];
-
- JXMessageObject *msg = [[JXMessageObject alloc] init];
- msg.toUserId = user.userId;
- [msg updateNewMsgsTo0];
- [g_notify postNotificationName:kChatViewDisappear object:nil];
-
- // [sendView release];
- }
- -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
-
- if (_seekTextField.text.length <= 0){
- if (_selMenu == 0) {
- JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
- if (user.userId.length <= 5) {
- return NO;
- }else{
- return YES;
- }
- }else{
- return YES;
- }
- }else{
- return NO;
- }
- }
- //-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
- // if (_selMenu == 0) {
- // return UITableViewCellEditingStyleDelete;
- // }else{
- // return UITableViewCellEditingStyleNone;
- // }
- //}
- - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if (_selMenu == 0) {
- _indexPathV=indexPath;
- // UIAlertView *alertShwo = [[UIAlertView alloc]initWithTitle:@"删除联系人" message:@"确认删除联系人" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
- //
- // [alertShwo show];
-
-
- UITableViewRowAction *deleteBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"JX_Delete") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
- _currentUser = user;
- [g_server delFriend:user.userId toView:self];
- }];
-
- return @[deleteBtn];
- }
- else {
- UITableViewRowAction *cancelBlackBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"REMOVE") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
- _currentUser = user;
- [g_server delBlacklist:user.userId toView:self];
- }];
-
- return @[cancelBlackBtn];
- }
-
- }
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
- if (buttonIndex==0) {
-
- return;
- }
-
- }
- //-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
- // if (_selMenu == 0 && editingStyle == UITableViewCellEditingStyleDelete) {
- // JXUserObject *user=_array[indexPath.row];
- // _currentUser = user;
- // [g_server delFriend:user.userId toView:self];
- // }
- //}
- - (void)dealloc {
- [g_notify removeObserver:self];
- // [_table release];
- [_array removeAllObjects];
- // [_array release];
- // [super dealloc];
- }
- -(void)getArrayData{
- switch (_selMenu) {
- case 0:{
- //获取好友列表
- // if (self.isOneInit) {//是否新建
- // [g_server listAttention:0 userId:MY_USER_ID toView:self];
- // self.isOneInit = NO;
- // }
-
- //从数据库获取好友staus为2且不是room的
- _array=[[JXUserObject sharedInstance] fetchAllFriendsFromLocal];
- //选择拼音 转换的 方法
- BMChineseSortSetting.share.sortMode = 2; // 1或2
- //排序 Person对象
- [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
- if (isSuccess) {
- self.indexArray = sectionTitleArr;
- self.letterResultArr = sortedObjArr;
- // [self.indexArray insertObject:@"🔍" atIndex:0];
- [_table reloadData];
- }
- }];
- // //根据Person对象的 name 属性 按中文 对 Person数组 排序
- // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
- // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
- //
- self.isShowFooterPull = NO;
- }
- break;
- case 1:{
- //获取黑名單列表
-
- //从数据库获取好友staus为-1的
- _array=[[JXUserObject sharedInstance] fetchAllBlackFromLocal];
- //选择拼音 转换的 方法
- BMChineseSortSetting.share.sortMode = 2; // 1或2
- //排序 Person对象
- [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
- if (isSuccess) {
- self.indexArray = sectionTitleArr;
- //[self.indexArray insertObject:@"🔍" atIndex:0];
- self.letterResultArr = sortedObjArr;
- [_table reloadData];
- }
- }];
- //根据Person对象的 name 属性 按中文 对 Person数组 排序
- // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
- // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
- }
- break;
- case 2:{
- _array=[[JXUserObject sharedInstance] fetchAllRoomsFromLocal];
- //选择拼音 转换的 方法
- BMChineseSortSetting.share.sortMode = 2; // 1或2
- //排序 Person对象
- [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
- if (isSuccess) {
- self.indexArray = sectionTitleArr;
- self.letterResultArr = sortedObjArr;
- [_table reloadData];
- }
- }];
- }
- // //根据Person对象的 name 属性 按中文 对 Person数组 排序
- // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
- // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
- break;
- }
-
- [self setFooterView];
- }
- //服务器返回数据
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
-
- //更新本地好友
- if ([aDownload.action isEqualToString:act_AttentionList]) {
- [_wait stop];
- [self stopLoading];
- JXProgressVC * pv = [JXProgressVC alloc];
- // 服务端不会返回新朋友 , 减去新朋友
- pv.dbFriends = (long)[_array count] - 1;
- pv.dataArray = array1;
- pv = [pv init];
- // [g_window addSubview:pv.view];
- }
-
- if ([aDownload.action isEqualToString:act_FriendDel]) {
- [_currentUser doSendMsg:XMPP_TYPE_DELALL content:nil];
- }
-
- if([aDownload.action isEqualToString:act_BlacklistDel]){
- [_currentUser doSendMsg:XMPP_TYPE_NOBLACK content:nil];
- }
-
- if( [aDownload.action isEqualToString:act_UserGet] ){
- [_wait stop];
-
- JXUserObject* user = [[JXUserObject alloc]init];
- [user getDataFromDict:dict];
-
- JXUserInfoVC* vc = [JXUserInfoVC alloc];
- vc.user = user;
- vc.fromAddType = 6;
- vc = [vc init];
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- // 同步标签
- if ([aDownload.action isEqualToString:act_FriendGroupList]) {
-
- for (NSInteger i = 0; i < array1.count; i ++) {
- NSDictionary *dict = array1[i];
- JXLabelObject *labelObj = [[JXLabelObject alloc] init];
- labelObj.groupId = dict[@"groupId"];
- labelObj.groupName = dict[@"groupName"];
- labelObj.userId = dict[@"userId"];
-
- NSArray *userIdList = dict[@"userIdList"];
- NSString *userIdListStr = [userIdList componentsJoinedByString:@","];
- if (userIdListStr.length > 0) {
- labelObj.userIdList = [NSString stringWithFormat:@"%@", userIdListStr];
- }
- [labelObj insert];
- }
-
- // 删除服务器上已经删除的
- NSArray *arr = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
- for (NSInteger i = 0; i < arr.count; i ++) {
- JXLabelObject *locLabel = arr[i];
- BOOL flag = NO;
- for (NSInteger j = 0; j < array1.count; j ++) {
- NSDictionary * dict = array1[j];
-
- if ([locLabel.groupId isEqualToString:dict[@"groupId"]]) {
- flag = YES;
- break;
- }
- }
-
- if (!flag) {
- [locLabel delete];
- }
- }
-
-
- _array = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
- for (JXLabelObject *labelObj in _array) {
- NSString *userIdStr = labelObj.userIdList;
- NSArray *userIds = [userIdStr componentsSeparatedByString:@","];
- if (userIdStr.length <= 0) {
- userIds = nil;
- }
-
- NSMutableArray *newUserIds = [userIds mutableCopy];
- for (NSInteger i = 0; i < userIds.count; i ++) {
- NSString *userId = userIds[i];
- NSString *userName = [JXUserObject getUserNameWithUserId:userId];
-
- if (!userName || userName.length <= 0) {
- [newUserIds removeObject:userId];
- }
-
- }
-
- NSString *string = [newUserIds componentsJoinedByString:@","];
-
- labelObj.userIdList = string;
-
- [labelObj update];
- }
- }
-
- if ([aDownload.action isEqualToString:act_customerLinkList]){
-
- self.customerArr = array1;
- CGRect backFrame = backView.frame;
- backFrame.size.height = backFrame.size.height + 50* self.customerArr.count;
- backView.frame = backFrame ;
- if (self.customerArr.count == 0) {
- return;
- }
-
- int cY = _menuView.frame.origin.y + _menuView.frame.size.height;
- for (int i = 0; i < self.customerArr.count; i++) {
- UIView *customerView = [[UIView alloc] initWithFrame:CGRectMake(0, cY + 50 * i, self_width, 50)];
- // customerView.backgroundColor = [UIColor redColor];
-
- UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, .5)];
- lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
- [customerView addSubview:lineView2];
-
- UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, lineView2.frame.origin.y+5, 40, 40)];
- NSString *fileURL = self.customerArr[i][@"path"];
- NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
- UIImage *image = [UIImage imageWithData:data];
- if (image) {
- imageView2.image = image;
- }else {
- imageView2.image = [UIImage imageNamed:@"im_10000"];
- }
-
- [customerView addSubview:imageView2];
- UIButton *customerBtn = [[UIButton alloc] initWithFrame:CGRectMake(imageView2.frame.origin.x+imageView2.frame.size.width + 20, imageView2.frame.origin.y, self_width-imageView2.frame.size.width-15+20, 40)];
- // [customerBtn setTitle:@"威尼斯客服" forState:UIControlStateNormal];
- if (self.customerArr[i][@"name"]) {
- [customerBtn setTitle:self.customerArr[i][@"name"] forState:UIControlStateNormal];
- }else {
- // imageView2.image = [UIImage imageNamed:@"im_10000"];
- [customerBtn setTitle:@"--" forState:UIControlStateNormal];
- }
- // [customerBtn ]
- customerBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- // customerBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
- // customerBtn.backgroundColor = UIColor.redColor;
- [customerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [customerBtn addTarget:self action:@selector(customerClick:) forControlEvents:UIControlEventTouchUpInside];
- customerBtn.tag = i+1;
- [customerView addSubview:customerBtn];
-
- UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width - 40, customerBtn.frame.origin.y + customerBtn.frame.size.height - 15, 40, 15)];
- if (self.customerArr[i][@"type"]) {
- hintLabel.text = self.customerArr[i][@"type"];
- }else{
- hintLabel.text = @"--";
- }
- hintLabel.font = [UIFont systemFontOfSize:13];
- hintLabel.backgroundColor = UIColor.clearColor;
- hintLabel.textColor = UIColor.blackColor;
- hintLabel.textAlignment = NSTextAlignmentCenter;
- [customerView addSubview:hintLabel];
-
-
- [backView addSubview:customerView];
-
- }
- }
- }
- //修改了
- - (void)setupCustomerLinkList {
-
- _customerArr = g_App.customerLinkListArray;
-
-
- return;
- CGRect backFrame = backView.frame;
- backFrame.size.height = backFrame.size.height + 50* self.customerArr.count;
- backView.frame = backFrame ;
- if (self.customerArr.count == 0) {
- return;
- }
-
- int cY = _menuView.frame.origin.y + _menuView.frame.size.height;
- for (int i = 0; i < self.customerArr.count; i++) {
- UIView *customerView = [[UIView alloc] initWithFrame:CGRectMake(0, cY + 50 * i, self_width, 50)];
- // customerView.backgroundColor = [UIColor redColor];
-
- UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, .5)];
- lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
- [customerView addSubview:lineView2];
-
- UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, lineView2.frame.origin.y+5, 40, 40)];
- NSString *fileURL = self.customerArr[i][@"path"];
- NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
- UIImage *image = [UIImage imageWithData:data];
- if (image) {
- imageView2.image = image;
- }else {
- imageView2.image = [UIImage imageNamed:@"im_10000"];
- }
-
- [customerView addSubview:imageView2];
- UIButton *customerBtn = [[UIButton alloc] initWithFrame:CGRectMake(imageView2.frame.origin.x+imageView2.frame.size.width + 20, imageView2.frame.origin.y, self_width-imageView2.frame.size.width-15+20, 40)];
- // [customerBtn setTitle:@"威尼斯客服" forState:UIControlStateNormal];
- if (self.customerArr[i][@"name"]) {
- [customerBtn setTitle:self.customerArr[i][@"name"] forState:UIControlStateNormal];
- }else {
- // imageView2.image = [UIImage imageNamed:@"im_10000"];
- [customerBtn setTitle:@"--" forState:UIControlStateNormal];
- }
- // [customerBtn ]
- customerBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- // customerBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
- // customerBtn.backgroundColor = UIColor.redColor;
- [customerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [customerBtn addTarget:self action:@selector(customerClick:) forControlEvents:UIControlEventTouchUpInside];
- customerBtn.tag = i+1;
- [customerView addSubview:customerBtn];
-
- UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width - 40, customerBtn.frame.origin.y + customerBtn.frame.size.height - 15, 40, 15)];
- if (self.customerArr[i][@"type"]) {
- hintLabel.text = self.customerArr[i][@"type"];
- }else{
- hintLabel.text = @"--";
- }
- hintLabel.font = [UIFont systemFontOfSize:13];
- hintLabel.backgroundColor = UIColor.clearColor;
- hintLabel.textColor = UIColor.blackColor;
- hintLabel.textAlignment = NSTextAlignmentCenter;
- [customerView addSubview:hintLabel];
-
-
- [backView addSubview:customerView];
-
- }
- }
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- [_wait hide];
-
- [self stopLoading];
- return hide_error;
- }
- -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
- [_wait hide];
- [self stopLoading];
- return hide_error;
- }
- -(void) didServerConnectStart:(JXConnection*)aDownload{
- // [_wait start];
- }
- -(void)refresh{
- [self stopLoading];
- _refreshCount++;
- [_array removeAllObjects];
- // [_array release];
- [self getArrayData];
- _friendArray = [g_server.myself fetchAllFriendsOrNotFromLocal];
- [_table reloadData];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 59;
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- [self.view endEditing:YES];
- }
- //-(void)scrollToPageUp{
- // [self refresh];
- //}
- -(void)newFriend:(NSObject*)sender{
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self refresh];
- });
- }
- -(void)onHeadImage:(id)dataObj{
- JXUserObject *p = (JXUserObject *)dataObj;
- if([p.userId isEqualToString:FRIEND_CENTER_USERID] || [p.userId isEqualToString:CALL_CENTER_USERID])
- return;
-
- _currentUser = p;
- // [g_server getUser:p.userId toView:self];
-
- JXUserInfoVC* vc = [JXUserInfoVC alloc];
- vc.userId = p.userId;
- vc.user = p;
- vc.fromAddType = 6;
- vc = [vc init];
- [g_navigation pushViewController:vc animated:YES];
- p = nil;
- }
- -(void)onSendTimeout:(NSNotification *)notifacation//超时未收到回执
- {
- // NSLog(@"onSendTimeout");
- [_wait stop];
- // [g_App showAlert:Localized(@"JXAlert_SendFilad")];
- // [JXMyTools showTipView:Localized(@"JXAlert_SendFilad")];
- }
- -(void)newReceipt:(NSNotification *)notifacation{//新回执
- // NSLog(@"newReceipt");
- JXMessageObject *msg = (JXMessageObject *)notifacation.object;
- if(msg == nil)
- return;
- if(![msg isAddFriendMsg])
- return;
- [_wait stop];
- if([msg.type intValue] == XMPP_TYPE_DELALL){
- if([msg.toUserId isEqualToString:_currentUser.userId] || [msg.fromUserId isEqualToString:_currentUser.userId]){
- [_array removeObject:_currentUser];
- _currentUser = nil;
- [self getArrayData];
- [_table reloadData];
- // [g_App showAlert:Localized(@"JXAlert_DeleteFirend")];
- }
- }
-
- if([msg.type intValue] == XMPP_TYPE_BLACK){//拉黑
- for (JXUserObject *obj in _array) {
- if ([obj.userId isEqualToString:_currentUser.userId]) {
- [_array removeObject:obj];
- break;
- }
- }
-
- [self getArrayData];
- [self.tableView reloadData];
- }
-
- if([msg.type intValue] == XMPP_TYPE_NOBLACK){
- // _currentUser.status = [NSNumber numberWithInt:friend_status_friend];
- // int status = [_currentUser.status intValue];
- // [_currentUser update];
-
- if (!_currentUser) {
- return;
- }
- [[JXXMPP sharedInstance].blackList removeObject:_currentUser.userId];
- [JXMessageObject msgWithFriendStatus:_currentUser.userId status:friend_status_friend];
- for (JXUserObject *obj in _array) {
- if ([obj.userId isEqualToString:_currentUser.userId]) {
- [_array removeObject:obj];
- break;
- }
- }
-
- [self getArrayData];
- [self.tableView reloadData];
- // [g_App showAlert:Localized(@"JXAlert_MoveBlackList")];
- }
-
- if([msg.type intValue] == XMPP_TYPE_PASS){//通过
- [self getFriend];
- }
- }
- - (void)friendRemarkNotif:(NSNotification *)notif {
-
- JXUserObject *user = notif.object;
- for (int i = 0; i < _array.count; i ++) {
- JXUserObject *user1 = _array[i];
- if ([user.userId isEqualToString:user1.userId]) {
- user1.userNickname = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
- user1.remarkName = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
- [_table reloadData];
- break;
- }
- }
- }
- - (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title icon:(NSString *)iconName action:(SEL)action {
- UIButton *button = [[UIButton alloc] init];
- button.frame = frame;
- [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
-
- UIImageView *imgV = [[UIImageView alloc] init];
- imgV.frame = CGRectMake((button.frame.size.width-IMAGE_HEIGHT)/2, 20, IMAGE_HEIGHT, IMAGE_HEIGHT);
- imgV.image = [UIImage imageNamed:iconName];
- [button addSubview:imgV];
-
- CGSize size = [title boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(14)} context:nil].size;
- UILabel *lab = [[UILabel alloc] init];
- lab.text = title;
- lab.font = SYSFONT(14);
- lab.textAlignment = NSTextAlignmentCenter;
- lab.textColor = HEXCOLOR(0x323232);
- if (size.width >= button.frame.size.width) {
- size.width = button.frame.size.width-20;
- }
- lab.frame = CGRectMake(0, CGRectGetMaxY(imgV.frame)+INSET_HEIGHT, size.width, size.height);
- CGPoint center = lab.center;
- center.x = imgV.center.x;
- lab.center = center;
-
- CGRect btnFrame = button.frame;
- btnFrame.size.height = CGRectGetMaxY(imgV.frame)+INSET_HEIGHT+size.height;
- button.frame = btnFrame;
-
- [button addSubview:lab];
-
- return button;
- }
- -(void)customerClick:(UIButton *)sender{
- // UIButton *btn = (UIButton *)[self.view viewWithTag:sender.tag];
-
- if (self.customerArr[sender.tag - 1][@"link"]) {
- CYWebCustomerServiceVC *vc = [[CYWebCustomerServiceVC alloc] init];
- vc.titleName = self.customerArr[sender.tag - 1][@"name"];
- vc.link = self.customerArr[sender.tag - 1][@"link"];
- [self presentViewController:vc animated:YES completion:^{
-
- }];
- }else {
- NSLog(@"链接不存在!!!!!!!!");
- }
-
- }
- @end
|