JXAddrBookFriendVc.m 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557
  1. //
  2. // JXFriendViewController.h.m
  3. //
  4. // Created by flyeagleTang on 14-4-3.
  5. // Copyright (c) 2014年 Reese. All rights reserved.
  6. //
  7. #import "JXAddrBookFriendVc.h"
  8. #import "JXChatViewController.h"
  9. #import "AppDelegate.h"
  10. #import "JXLabel.h"
  11. #import "JXImageView.h"
  12. #import "JXCell.h"
  13. #import "JXRoomPool.h"
  14. #import "JXTableView.h"
  15. #import "JXNewFriendViewController.h"
  16. #import "menuImageView.h"
  17. #import "FMDatabase.h"
  18. #import "JXProgressVC.h"
  19. #import "JXTopSiftJobView.h"
  20. #import "JXUserInfoVC.h"
  21. #import "BMChineseSort.h"
  22. #import "JXGroupViewController.h"
  23. #import "OrganizTreeViewController.h"
  24. #import "JXTabMenuView.h"
  25. #import "JXPublicNumberVC.h"
  26. #import "JXBlackFriendVC.h"
  27. #import "JX_DownListView.h"
  28. #import "JXNewRoomVC.h"
  29. #import "JXNearVC.h"
  30. #import "JXSearchUserVC.h"
  31. #import "JXScanQRViewController.h"
  32. #import "JXLabelVC.h"
  33. #import "JXAddressBookVC.h"
  34. #import "JXSearchVC.h"
  35. #import "JXLabelObject.h"
  36. #import "CYWebCustomerServiceVC.h"
  37. #import "CYGroupSendHelperViewController.h"
  38. #import "JXSelectFriendsVC.h"
  39. #import "JXSetLabelVC.h"
  40. #import "JXNewLabelVC.h"
  41. #import "JXShowLabelVc.h"
  42. #import "CYGroupSendHelperViewController.h"
  43. #define HEIGHT 54
  44. #define IMAGE_HEIGHT 45 // 图片宽高
  45. #define INSET_HEIGHT 10 // 图片文字间距
  46. @interface JXAddrBookFriendVc ()<UITextFieldDelegate,JXSelectMenuViewDelegate,UIAlertViewDelegate>
  47. @property (nonatomic, strong) JXUserObject * currentUser;
  48. //排序后的出现过的拼音首字母数组
  49. @property(nonatomic,strong)NSMutableArray *indexArray;
  50. //排序好的结果数组
  51. @property(nonatomic,strong)NSMutableArray *letterResultArr;
  52. @property (nonatomic, strong) UITextField *seekTextField;
  53. @property (nonatomic, strong) NSMutableArray *searchArray;
  54. @property (nonatomic, strong) UILabel *friendNewMsgNum;
  55. @property (nonatomic, strong) UILabel *abNewMsgNum;
  56. @property (nonatomic, strong) UIButton *moreBtn;
  57. @property (nonatomic, strong) UIView *menuView;
  58. @property (nonatomic, assign) CGFloat btnHeight; // 按钮的真实高度
  59. @property (nonatomic,copy)NSArray *customerArr; //客服信息
  60. @property (nonatomic,strong) NSIndexPath *indexPathV;
  61. @end
  62. @implementation JXAddrBookFriendVc
  63. - (id)init
  64. {
  65. self = [super init];
  66. if (self) {
  67. self.isOneInit = YES;
  68. self.heightHeader = JX_SCREEN_TOP;
  69. self.heightFooter = JX_SCREEN_BOTTOM;
  70. if (_isMyGoIn) {
  71. self.isGotoBack = YES;
  72. self.heightFooter = 0;
  73. }
  74. // self.view.frame = g_window.bounds;
  75. [self createHeadAndFoot];
  76. [self buildTop];
  77. [self defineNavChatPush:@"通讯录"];
  78. self.view.backgroundColor = HEXCOLOR(0xF2F2F2);
  79. self.tableView.backgroundColor = HEXCOLOR(0xF2F2F2);
  80. //self.tableView.frame=CGRectMake(0, JX_SCREEN_TOP+55, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-55);
  81. self.tableView.frame=CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP-55);
  82. [self customView];
  83. _table.contentInset=UIEdgeInsetsMake(55, 0, 0, 0);
  84. _selMenu = 0;
  85. // self.title = Localized(@"JXInputVC_Friend");
  86. self.title = Localized(@"JX_MailList");
  87. [g_notify addObserver:self selector:@selector(newFriend:) name:kXMPPNewFriendNotifaction object:nil];
  88. [g_notify addObserver:self selector:@selector(newRequest:) name:kXMPPNewRequestNotifaction object:nil];
  89. [g_notify addObserver:self selector:@selector(newReceipt:) name:kXMPPReceiptNotifaction object:nil];
  90. [g_notify addObserver:self selector:@selector(onSendTimeout:) name:kXMPPSendTimeOutNotifaction object:nil];
  91. [g_notify addObserver:self selector:@selector(friendRemarkNotif:) name:kFriendRemark object:nil];
  92. [g_notify addObserver:self selector:@selector(newMsgCome:) name:kXMPPNewMsgNotifaction object:nil];
  93. [g_notify addObserver:self selector:@selector(friendListRefresh:) name:kFriendListRefresh object:nil];
  94. [g_notify addObserver:self selector:@selector(refreshABNewMsgCount:) name:kRefreshAddressBookNotif object:nil];
  95. [g_notify addObserver:self selector:@selector(contactRegisterNotif:) name:kMsgComeContactRegister object:nil];
  96. [g_notify addObserver:self selector:@selector(newRequest:) name:kFriendPassNotif object:nil];
  97. [g_notify addObserver:self selector:@selector(refresh) name:kOfflineOperationUpdateUserSet object:nil];
  98. [g_notify addObserver:self selector:@selector(updateLabels:) name:kXMPPMessageUpadtePasswordNotification object:nil];
  99. // [g_server customerLinkList:self];
  100. [self setupCustomerLinkList];
  101. [self getArrayData];
  102. [self getFriend];
  103. [self refresh];
  104. }
  105. return self;
  106. }
  107. - (void)updateLabels:(NSNotification *)noti {
  108. JXMessageObject *msg = noti.object;
  109. if ([msg.objectId isEqualToString:SYNC_LABEL]) {
  110. // 同步标签
  111. [g_server friendGroupListToView:self];
  112. }
  113. }
  114. - (void)friendListRefresh:(NSNotification *)notif {
  115. [self refresh];
  116. }
  117. - (void)contactRegisterNotif:(NSNotification *)notif {
  118. JXMessageObject *msg = notif.object;
  119. NSDictionary *dict = (NSDictionary *)msg.content;
  120. if ([msg.content isKindOfClass:[NSString class]]) {
  121. SBJsonParser * resultParser = [[SBJsonParser alloc] init] ;
  122. dict = [resultParser objectWithString:msg.content];
  123. }
  124. JXAddressBook *addressBook = [[JXAddressBook alloc] init];
  125. addressBook.toUserId = [NSString stringWithFormat:@"%@",dict[@"toUserId"]];
  126. addressBook.toUserName = dict[@"toUserName"];
  127. addressBook.toTelephone = dict[@"toTelephone"];
  128. addressBook.telephone = dict[@"telephone"];
  129. addressBook.registerEd = dict[@"registerEd"];
  130. addressBook.registerTime = [NSDate dateWithTimeIntervalSince1970:[dict[@"registerTime"] longLongValue]];
  131. addressBook.isRead = [NSNumber numberWithBool:0];
  132. [addressBook insert];
  133. [self refreshABNewMsgCount:nil];
  134. }
  135. - (void)refreshABNewMsgCount:(NSNotification *)notif {
  136. [self refresh];
  137. JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
  138. newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
  139. [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
  140. }
  141. #pragma mark 接受新消息广播
  142. -(void)newMsgCome:(NSNotification *)notifacation
  143. {
  144. JXMessageObject *msg = notifacation.object;
  145. if (![msg isAddFriendMsg]) {
  146. return;
  147. }
  148. NSString* s;
  149. s = [msg getTableName];
  150. JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
  151. newobj.user = [[JXUserObject sharedInstance] getUserById:s];
  152. [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
  153. }
  154. - (void) showNewMsgCount:(NSInteger)friendNewMsgNum {
  155. if (friendNewMsgNum >= 10 && friendNewMsgNum <= 99) {
  156. self.friendNewMsgNum.font = SYSFONT(12);
  157. }else if (friendNewMsgNum > 0 && friendNewMsgNum < 10) {
  158. self.friendNewMsgNum.font = SYSFONT(13);
  159. }else if(friendNewMsgNum > 99){
  160. self.friendNewMsgNum.font = SYSFONT(9);
  161. }
  162. self.friendNewMsgNum.text = [NSString stringWithFormat:@"%ld",friendNewMsgNum];
  163. if (friendNewMsgNum <= 0) {
  164. self.friendNewMsgNum.hidden = YES;
  165. }else{
  166. self.friendNewMsgNum.hidden = NO;
  167. }
  168. NSMutableArray *abUread = [[JXAddressBook sharedInstance] doFetchUnread];
  169. if (abUread.count >= 10 && abUread.count <= 99) {
  170. self.friendNewMsgNum.font = SYSFONT(12);
  171. }else if (abUread.count > 0 && abUread.count < 10) {
  172. self.friendNewMsgNum.font = SYSFONT(13);
  173. }else if(abUread.count > 99){
  174. self.friendNewMsgNum.font = SYSFONT(9);
  175. }
  176. self.abNewMsgNum.text = [NSString stringWithFormat:@"%ld",abUread.count];
  177. if (abUread.count <= 0) {
  178. self.abNewMsgNum.hidden = YES;
  179. }else {
  180. self.abNewMsgNum.hidden = NO;
  181. }
  182. NSInteger num = friendNewMsgNum + abUread.count;
  183. // if (num <= 0) {
  184. // [g_mainVC.tb setBadge:1 title:@"0"];
  185. // }else {
  186. // [g_mainVC.tb setBadge:1 title:[NSString stringWithFormat:@"%ld", num]];
  187. // }
  188. if (num <= 0) {
  189. int number = 0;
  190. if (g_App.linkArray.count == 0) {
  191. number = 1;
  192. }else if(g_App.linkArray.count == 1){
  193. number = 2;
  194. }else if(g_App.linkArray.count == 2){
  195. number = 3;
  196. }
  197. [g_mainVC.tb setBadge:number title:@"0"];
  198. }else {
  199. int number = 0;
  200. if (g_App.linkArray.count == 0) {
  201. number = 1;
  202. }else if(g_App.linkArray.count == 1){
  203. number = 2;
  204. }else if(g_App.linkArray.count == 2){
  205. number = 3;
  206. }
  207. [g_mainVC.tb setBadge:number title:[NSString stringWithFormat:@"%ld", num]];
  208. }
  209. }
  210. -(void)newRequest:(NSNotification *)notifacation
  211. {
  212. [self getFriend];
  213. }
  214. - (void)scrollToPageUp {
  215. [self getFriend];
  216. }
  217. -(void)buildTop{
  218. //刷新好友列表
  219. // UIButton * getFriendBtn = [[UIButton alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-35, JX_SCREEN_TOP - 34, 30, 30)];
  220. // getFriendBtn.custom_acceptEventInterval = .25f;
  221. // [getFriendBtn addTarget:self action:@selector(getFriend) forControlEvents:UIControlEventTouchUpInside];
  222. //// [getFriendBtn setImage:[UIImage imageNamed:@"synchro_friends"] forState:UIControlStateNormal];
  223. // [getFriendBtn setBackgroundImage:[UIImage imageNamed:@"synchro_friends"] forState:UIControlStateNormal];
  224. // [self.tableHeader addSubview:getFriendBtn];
  225. self.moreBtn = [UIFactory createButtonWithImage:@"im_003_more_button_black"
  226. highlight:nil
  227. target:self
  228. selector:@selector(onMore:)];
  229. self.moreBtn.custom_acceptEventInterval = 1.0f;
  230. 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);
  231. [self.tableHeader addSubview:self.moreBtn];
  232. }
  233. - (void) customView {
  234. backView = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, 55)];
  235. backView.backgroundColor=kRGBColor250;
  236. //self.tableView.tableHeaderView = backView;
  237. _seekTextField = [[UITextField alloc] initWithFrame:CGRectMake(15, 10, backView.frame.size.width - 30, 35)];
  238. _seekTextField.placeholder = Localized(@"JX_Seach");
  239. _seekTextField.textColor = [UIColor blackColor];
  240. _seekTextField.textAlignment= NSTextAlignmentCenter;
  241. [_seekTextField setFont:SYSFONT(14)];
  242. _seekTextField.backgroundColor = [UIColor whiteColor];
  243. UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"card_search"]];
  244. UIView *leftView = [[UIView alloc ]initWithFrame:CGRectMake(0, 0, 30, 30)];
  245. imageView.center = leftView.center;
  246. [leftView addSubview:imageView];
  247. _seekTextField.leftView = leftView;
  248. _seekTextField.leftViewMode = UITextFieldViewModeAlways;
  249. _seekTextField.borderStyle = UITextBorderStyleNone;
  250. _seekTextField.layer.masksToBounds = YES;
  251. _seekTextField.layer.cornerRadius = 5;
  252. _seekTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  253. _seekTextField.delegate = self;
  254. _seekTextField.returnKeyType = UIReturnKeyGoogle;
  255. [backView addSubview:_seekTextField];
  256. [_seekTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  257. [backView addSubview:_menuView];
  258. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  259. JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
  260. newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
  261. [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
  262. });
  263. [self showMenuView];
  264. if (_isMyGoIn) {
  265. [self hideMenuView];
  266. }
  267. [self setFooterView];
  268. }
  269. - (void) setFooterView {
  270. if (_array.count > 0) {
  271. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 44)];
  272. label.textColor = HEXCOLOR(0x999999);
  273. label.textAlignment = NSTextAlignmentCenter;
  274. label.font = SYSFONT(16);
  275. label.text = [NSString stringWithFormat:@"%ld%@",_array.count,Localized(@"JX_ContactsNumber")];
  276. self.tableView.tableFooterView = label;
  277. }else {
  278. self.tableView.tableFooterView = nil;
  279. }
  280. }
  281. - (void)showMenuView { // 显示菜单栏
  282. // self.tableView.tableHeaderView = backView;
  283. [self.view addSubview:backView];
  284. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP+55, JX_SCREEN_WIDTH, 121)];
  285. headView.userInteractionEnabled=YES;
  286. headView.backgroundColor=[UIColor whiteColor];
  287. UIView *qunfaView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 60)];
  288. [headView addSubview:qunfaView];
  289. UIButton *groundBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 9, 42, 42)];
  290. [groundBtn setImage:[UIImage imageNamed:@"qunfazhushou"] forState:UIControlStateNormal];
  291. [groundBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  292. groundBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
  293. groundBtn.contentMode=UIViewContentModeScaleAspectFit;
  294. [qunfaView addSubview:groundBtn];
  295. [qunfaView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(grounBtnClick)]];
  296. UILabel *qunfalabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 9, 100, 42)];
  297. qunfalabel.text=@"群发助手";
  298. [qunfaView addSubview:qunfalabel];
  299. UIView *lineVIew = [[UIView alloc] initWithFrame:CGRectMake(54, 60, JX_SCREEN_WIDTH-54, 1)];
  300. lineVIew.backgroundColor=kRGBColor250;
  301. [qunfaView addSubview:lineVIew];
  302. UIView *biaqView = [[UIView alloc] initWithFrame:CGRectMake(0, 61, JX_SCREEN_WIDTH, 60)];
  303. biaqView.userInteractionEnabled=YES;
  304. [headView addSubview:biaqView];
  305. UIButton *biaoqianBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 9, 42, 42)];
  306. [biaoqianBtn setImage:[UIImage imageNamed:@"biaoqiangL"] forState:UIControlStateNormal];
  307. [biaoqianBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  308. biaoqianBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
  309. biaoqianBtn.contentMode=UIViewContentModeScaleAspectFit;
  310. [biaqView addSubview:biaoqianBtn];
  311. UILabel *biaqianL = [[UILabel alloc] initWithFrame:CGRectMake(60, 9, 100, 42)];
  312. biaqianL.text=@"标签";
  313. [biaqView addSubview:biaqianL];
  314. [biaqView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(biaqViewClick)]];
  315. self.tableView.tableHeaderView = headView;
  316. }
  317. //群发助手
  318. - (void)grounBtnClick{
  319. CYGroupSendHelperViewController *vc = [[CYGroupSendHelperViewController alloc] init];
  320. [g_navigation pushViewController:vc animated:YES];
  321. }
  322. /// 标签
  323. - (void)biaqViewClick{
  324. JXShowLabelVc *vc = [[JXShowLabelVc alloc] init];
  325. [g_navigation pushViewController:vc animated:YES];
  326. }
  327. - (void)refreshLabel:(id)arr{
  328. }
  329. - (void)hideMenuView { // 隐藏菜单栏
  330. _menuView.hidden = YES;
  331. CGRect backFrame = backView.frame;
  332. backFrame.size.height = 55;
  333. backView.frame = backFrame;
  334. self.tableView.tableHeaderView = backView;
  335. }
  336. #pragma mark 右上角更多
  337. -(void)onMore:(UIButton *)sender{
  338. NSArray *role = MY_USER_ROLE;
  339. if ([g_App.config.hideSearchByFriends intValue] == 1 && ([g_App.config.isCommonFindFriends intValue] == 0 || role.count > 0)) {
  340. [self onSearch];
  341. }else {
  342. NSMutableArray *titles = [NSMutableArray arrayWithArray:@[Localized(@"JX_LaunchGroupChat"), Localized(@"JX_Scan"), Localized(@"JXNearVC_NearPer"),Localized(@"JX_SearchPublicNumber")]];
  343. NSMutableArray *images = [NSMutableArray arrayWithArray:@[@"message_creat_group_black", @"messaeg_scnning_black", @"message_near_person_black",@"message_search_publicNumber"]];
  344. NSMutableArray *sels = [NSMutableArray arrayWithArray:@[@"onNewRoom", @"showScanViewController", @"onNear",@"searchPublicNumber"]];
  345. if ([g_App.config.isCommonCreateGroup intValue] == 1 && role.count <= 0) {
  346. [titles removeObject:Localized(@"JX_LaunchGroupChat")];
  347. [images removeObject:@"message_creat_group_black"];
  348. [sels removeObject:@"onNewRoom"];
  349. }
  350. if ([g_App.config.isOpenPositionService intValue] == 1) {
  351. [titles removeObject:Localized(@"JXNearVC_NearPer")];
  352. [images removeObject:@"message_near_person_black"];
  353. [sels removeObject:@"onNear"];
  354. }
  355. if (![g_App.config.enableMpModule boolValue]) {
  356. [titles removeObject:Localized(@"JX_SearchPublicNumber")];
  357. [images removeObject:@"message_search_publicNumber"];
  358. [sels removeObject:@"searchPublicNumber"];
  359. }
  360. JX_SelectMenuView *menuView = [[JX_SelectMenuView alloc] initWithTitle:titles image:images cellHeight:44];
  361. menuView.sels = sels;
  362. menuView.delegate = self;
  363. [g_App.window addSubview:menuView];
  364. }
  365. // _control.hidden = YES;
  366. // UIWindow *window = [[UIApplication sharedApplication].delegate window];
  367. // CGRect moreFrame = [self.tableHeader convertRect:self.moreBtn.frame toView:window];
  368. //
  369. // 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];
  370. // menuView.delegate = self;
  371. // [g_App.window addSubview:menuView];
  372. // JX_DownListView * downListView = [[JX_DownListView alloc] initWithFrame:self.view.bounds];
  373. // downListView.listContents = @[Localized(@"JX_LaunchGroupChat"), Localized(@"JX_AddFriends"), Localized(@"JX_Scan"), Localized(@"JXNearVC_NearPer")];
  374. // downListView.listImages = @[@"message_creat_group_black", @"message_add_friend_black", @"messaeg_scnning_black", @"message_near_person_black"];
  375. //
  376. // __weak typeof(self) weakSelf = self;
  377. // [downListView downlistPopOption:^(NSInteger index, NSString *content) {
  378. //
  379. // [weakSelf moreListActionWithIndex:index];
  380. //
  381. // } whichFrame:moreFrame animate:YES];
  382. // [downListView show];
  383. // self.treeView.editing = !self.treeView.editing;
  384. }
  385. - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
  386. NSString *method = MenuView.sels[index];
  387. SEL _selector = NSSelectorFromString(method);
  388. [self performSelectorOnMainThread:_selector withObject:nil waitUntilDone:YES];
  389. // NSArray *role = MY_USER_ROLE;
  390. // // 显示搜索好友
  391. // BOOL isShowSearch = [g_App.config.hideSearchByFriends boolValue] && (![g_App.config.isCommonFindFriends boolValue] || role.count > 0);
  392. // //显示创建房间
  393. // BOOL isShowRoom = [g_App.config.isCommonCreateGroup intValue] == 0 || role.count > 0;
  394. // //显示附近的人
  395. // BOOL isShowPosition = [g_App.config.isOpenPositionService intValue] == 0;
  396. // switch (index) {
  397. // case 0:
  398. // if (isShowRoom) {
  399. // [self onNewRoom];
  400. // }else {
  401. // if (isShowSearch) {
  402. // [self onSearch];
  403. // }else {
  404. // [self showScanViewController];
  405. // }
  406. // }
  407. // break;
  408. // case 1:
  409. // if (isShowRoom && isShowSearch) {
  410. // [self onSearch];
  411. // }else {
  412. // if ((isShowRoom && !isShowSearch) || (!isShowRoom && isShowSearch)) {
  413. // [self showScanViewController];
  414. // }else if (!isShowRoom && !isShowSearch) {
  415. // if (isShowPosition) {
  416. // [self onNear];
  417. // }else {
  418. // [self searchPublicNumber];
  419. // }
  420. // }
  421. // }
  422. // break;
  423. // case 2:
  424. // if (isShowSearch && isShowRoom) {
  425. // [self showScanViewController];
  426. // }else {
  427. // if ((isShowRoom && !isShowSearch) || (!isShowRoom && isShowSearch)) {
  428. // if (isShowPosition) {
  429. // [self onNear];
  430. // }else {
  431. // [self searchPublicNumber];
  432. // }
  433. // }
  434. // }
  435. // break;
  436. // case 3:
  437. // if (isShowPosition) {
  438. // [self onNear];
  439. // }else {
  440. // [self searchPublicNumber];
  441. // }
  442. // break;
  443. // case 4:
  444. // [self searchPublicNumber];
  445. // break;
  446. // default:
  447. // break;
  448. // }
  449. }
  450. // 搜索公众号
  451. - (void)searchPublicNumber {
  452. JXSearchUserVC *searchUserVC = [JXSearchUserVC alloc];
  453. searchUserVC.type = JXSearchTypePublicNumber;
  454. searchUserVC = [searchUserVC init];
  455. [g_navigation pushViewController:searchUserVC animated:YES];
  456. }
  457. - (void) moreListActionWithIndex:(NSInteger)index {
  458. }
  459. // 创建群组
  460. -(void)onNewRoom{
  461. JXNewRoomVC* vc = [[JXNewRoomVC alloc]init];
  462. [g_navigation pushViewController:vc animated:YES];
  463. }
  464. // 附近的人
  465. -(void)onNear{
  466. JXNearVC * nearVc = [[JXNearVC alloc] init];
  467. [g_navigation pushViewController:nearVc animated:YES];
  468. }
  469. //搜索好友
  470. -(void)onSearch{
  471. JXSearchUserVC* vc = [JXSearchUserVC alloc];
  472. vc.delegate = self;
  473. vc.didSelect = @selector(doSearch:);
  474. vc.type = JXSearchTypeUser;
  475. vc = [vc init];
  476. [g_navigation pushViewController:vc animated:YES];
  477. [self cancelBtnAction];
  478. }
  479. -(void)doSearch:(searchData*)p{
  480. JXNearVC *nearVC = [[JXNearVC alloc]init];
  481. nearVC.isSearch = YES;
  482. [g_navigation pushViewController:nearVC animated:YES];
  483. [nearVC doSearch:p];
  484. }
  485. // 扫一扫
  486. -(void)showScanViewController{
  487. // button.enabled = NO;
  488. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  489. // button.enabled = YES;
  490. // });
  491. AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  492. if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
  493. {
  494. [g_server showMsg:Localized(@"JX_CanNotopenCenmar")];
  495. return;
  496. }
  497. JXScanQRViewController * scanVC = [[JXScanQRViewController alloc] init];
  498. // [g_window addSubview:scanVC.view];
  499. [g_navigation pushViewController:scanVC animated:YES];
  500. }
  501. // 新朋友
  502. - (void)newFriendAction:(JXImageView *)imageView {
  503. // 清空角标
  504. JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
  505. newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
  506. newobj.message = [[JXMessageObject alloc] init];
  507. newobj.message.toUserId = FRIEND_CENTER_USERID;
  508. newobj.user.msgsNew = [NSNumber numberWithInt:0];
  509. [newobj.message updateNewMsgsTo0];
  510. NSArray *friends = [[JXFriendObject sharedInstance] fetchAllFriendsFromLocal];
  511. for (NSInteger i = 0; i < friends.count; i ++) {
  512. JXFriendObject *friend = friends[i];
  513. if ([friend.msgsNew integerValue] > 0) {
  514. [friend updateNewMsgUserId:friend.userId num:0];
  515. [friend updateNewFriendLastContent];
  516. }
  517. }
  518. [self showNewMsgCount:0];
  519. JXNewFriendViewController* vc = [[JXNewFriendViewController alloc]init];
  520. [g_navigation pushViewController:vc animated:YES];
  521. }
  522. // 群组
  523. - (void)myGroupAction:(JXImageView *)imageView {
  524. JXGroupViewController *vc = [[JXGroupViewController alloc] init];
  525. [g_navigation pushViewController:vc animated:YES];
  526. }
  527. // 我的同事
  528. - (void)myColleaguesAction:(JXImageView *)imageView {
  529. OrganizTreeViewController *vc = [[OrganizTreeViewController alloc] init];
  530. [g_navigation pushViewController:vc animated:YES];
  531. }
  532. // 公众号
  533. - (void)publicNumberAction:(JXImageView *)imageView {
  534. JXPublicNumberVC *vc = [[JXPublicNumberVC alloc] init];
  535. [g_navigation pushViewController:vc animated:YES];
  536. }
  537. // 黑名单
  538. - (void)blackFriendAction:(JXImageView *)imageView {
  539. JXBlackFriendVC *vc = [[JXBlackFriendVC alloc] init];
  540. vc.title = Localized(@"JX_BlackList");
  541. [g_navigation pushViewController:vc animated:YES];
  542. }
  543. // 我的设备
  544. - (void)myDeviceAction:(JXImageView *)imageView {
  545. JXBlackFriendVC *vc = [[JXBlackFriendVC alloc] init];
  546. vc.isDevice = YES;
  547. vc.title = Localized(@"JX_MyDevices");
  548. [g_navigation pushViewController:vc animated:YES];
  549. }
  550. // 群发助手
  551. - (void)groupHelperAction:(JXImageView *)imageView {
  552. CYGroupSendHelperViewController *vc = [[CYGroupSendHelperViewController alloc] init];
  553. [g_navigation pushViewController:vc animated:YES];
  554. }
  555. // 标签
  556. - (void)labelAction:(JXImageView *)imageView {
  557. JXLabelVC *vc = [[JXLabelVC alloc] init];
  558. [g_navigation pushViewController:vc animated:YES];
  559. }
  560. // 手机通讯录
  561. - (void)addressBookAction:(JXImageView *)imageView {
  562. JXAddressBookVC *vc = [[JXAddressBookVC alloc] init];
  563. NSMutableArray *arr = [[JXAddressBook sharedInstance] doFetchUnread];
  564. vc.abUreadArr = arr;
  565. [g_navigation pushViewController:vc animated:YES];
  566. [[JXAddressBook sharedInstance] updateUnread];
  567. JXMsgAndUserObject* newobj = [[JXMsgAndUserObject alloc]init];
  568. newobj.user = [[JXUserObject sharedInstance] getUserById:FRIEND_CENTER_USERID];
  569. [self showNewMsgCount:[newobj.user.msgsNew integerValue]];
  570. }
  571. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom icon:(NSString*)icon click:(SEL)click superView:(UIView *)superView{
  572. JXImageView* btn = [[JXImageView alloc] init];
  573. btn.backgroundColor = [UIColor whiteColor];
  574. btn.userInteractionEnabled = YES;
  575. btn.didTouch = click;
  576. btn.delegate = self;
  577. [superView addSubview:btn];
  578. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(42 + 14 + 14, 0, 200, HEIGHT)];
  579. p.text = title;
  580. p.font = g_factory.font16;
  581. p.backgroundColor = [UIColor clearColor];
  582. p.textColor = HEXCOLOR(0x323232);
  583. // p.delegate = self;
  584. // p.didTouch = click;
  585. [btn addSubview:p];
  586. if(icon){
  587. UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(14, (HEIGHT-42)/2, 42, 42)];
  588. iv.image = [UIImage imageNamed:icon];
  589. iv.layer.cornerRadius = iv.frame.size.width / 2;
  590. iv.layer.masksToBounds = YES;
  591. [btn addSubview:iv];
  592. }
  593. if(drawTop){
  594. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH,LINE_WH)];
  595. line.backgroundColor = THE_LINE_COLOR;
  596. [btn addSubview:line];
  597. }
  598. if(drawBottom){
  599. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,HEIGHT-LINE_WH,JX_SCREEN_WIDTH,LINE_WH)];
  600. line.backgroundColor = THE_LINE_COLOR;
  601. [btn addSubview:line];
  602. }
  603. // if(click){
  604. // UIImageView* iv;
  605. // iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-20-3, 16, 20, 20)];
  606. // iv.image = [UIImage imageNamed:@"set_list_next"];
  607. // [btn addSubview:iv];
  608. //
  609. // }
  610. return btn;
  611. }
  612. - (void)textFieldDidBeginEditing:(UITextField *)textField{
  613. [textField resignFirstResponder];
  614. JXSearchVC *vc = [[JXSearchVC alloc] initWithTable:@"friendsearchrecord"];
  615. [g_navigation pushViewController:vc animated:YES];
  616. }
  617. - (void) textFieldDidChange:(UITextField *)textField {
  618. if (textField.text.length <= 0) {
  619. if (!self.isMyGoIn) {
  620. [self showMenuView];
  621. }
  622. [self getArrayData];
  623. [self.tableView reloadData];
  624. return;
  625. }else {
  626. [self hideMenuView];
  627. }
  628. [_searchArray removeAllObjects];
  629. if (_selMenu == 0) {
  630. _searchArray = [[JXUserObject sharedInstance] fetchFriendsFromLocalWhereLike:textField.text];
  631. }else if (_selMenu == 1){
  632. _searchArray = [[JXUserObject sharedInstance] fetchBlackFromLocalWhereLike:textField.text];
  633. }
  634. [self.tableView reloadData];
  635. }
  636. - (void) cancelBtnAction {
  637. if (_seekTextField.text.length > 0) {
  638. _seekTextField.text = nil;
  639. [self getArrayData];
  640. }
  641. [_seekTextField resignFirstResponder];
  642. [self.tableView reloadData];
  643. }
  644. -(void)onClick:(UIButton*)sender{
  645. }
  646. //筛选点击
  647. - (void)topItemBtnClick:(UIButton *)btn{
  648. [self checkAfterScroll:(btn.tag-100)];
  649. [_topSiftView resetAllParaBtn];
  650. }
  651. - (void)checkAfterScroll:(CGFloat)offsetX{
  652. if (offsetX == 0) {
  653. _selMenu = 0;
  654. }else {
  655. _selMenu = 1;
  656. }
  657. [self scrollToPageUp];
  658. }
  659. - (void)getFriend{
  660. [g_server listAttention:10000 userId:MY_USER_ID toView:self];
  661. }
  662. //-(void)actionSegment:(UISegmentedControl*)sender{
  663. // _selMenu = (int)sender.selectedSegmentIndex;
  664. // [self refresh];
  665. //}
  666. - (void)viewDidLoad
  667. {
  668. [super viewDidLoad];
  669. _array=[[NSMutableArray alloc] init];
  670. //[self refresh];
  671. }
  672. - (void)viewDidDisappear:(BOOL)animated {
  673. [super viewDidDisappear:animated];
  674. // 离开时重置_isMyGoIn
  675. if (_isMyGoIn) {
  676. _isMyGoIn = NO;
  677. }
  678. }
  679. - (void)viewWillAppear:(BOOL)animated
  680. {
  681. [super viewWillAppear:animated];
  682. }
  683. #pragma mark ---------tableView协议----------------
  684. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  685. {
  686. if (_seekTextField.text.length > 0) {
  687. return 1;
  688. }
  689. return [self.indexArray count];
  690. }
  691. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  692. if (_seekTextField.text.length > 0) {
  693. return Localized(@"JXFriend_searchTitle");
  694. }
  695. return [self.indexArray objectAtIndex:section];
  696. }
  697. -(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
  698. UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
  699. header.tintColor = HEXCOLOR(0xF2F2F2);
  700. [header.textLabel setTextColor:HEXCOLOR(0x999999)];
  701. [header.textLabel setFont:SYSFONT(15)];
  702. }
  703. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  704. if (_seekTextField.text.length > 0) {
  705. return _searchArray.count;
  706. }
  707. return [(NSArray *)[self.letterResultArr objectAtIndex:section] count];
  708. }
  709. -(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
  710. if (_seekTextField.text.length > 0) {
  711. return nil;
  712. }
  713. return _indexArray;
  714. }
  715. - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
  716. return index;
  717. }
  718. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  719. {
  720. JXUserObject *user;
  721. if (_seekTextField.text.length > 0) {
  722. user = _searchArray[indexPath.row];
  723. }else{
  724. user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  725. }
  726. JXCell *cell=nil;
  727. NSString* cellName = [NSString stringWithFormat:@"msg_%d_%ld",_refreshCount,(long)indexPath.row];
  728. cell = [tableView dequeueReusableCellWithIdentifier:cellName];
  729. if(cell==nil){
  730. cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
  731. [_table addToPool:cell];
  732. // cell.headImage = user.userHead;
  733. // user = nil;
  734. }
  735. // cell.title = user.userNickname;
  736. cell.title = [self multipleLoginIsOnlineTitle:user];
  737. // cell.subtitle = user.userId;
  738. cell.index = (int)indexPath.row;
  739. cell.delegate = self;
  740. cell.didTouch = @selector(onHeadImage:);
  741. // cell.bottomTitle = [TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"];
  742. // [cell setForTimeLabel:[TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"]];
  743. cell.timeLabel.frame = CGRectMake(JX_SCREEN_WIDTH - 120-20, 9, 115, 20);
  744. cell.userId = user.userId;
  745. [cell.lbTitle setText:cell.title];
  746. //添加爱心标志---特别关心标志
  747. // cell.notPushImageView.image = [UIImage imageNamed:@"collection_me_simple"];
  748. if ([user.veryCare intValue] == 1) {
  749. cell.specialCareImageView.hidden = NO;
  750. }else {
  751. cell.specialCareImageView.hidden = YES;
  752. }
  753. cell.dataObj = user;
  754. // cell.headImageView.tag = (int)indexPath.row;
  755. // cell.headImageView.delegate = cell.delegate;
  756. // cell.headImageView.didTouch = cell.didTouch;
  757. cell.isSmall = YES;
  758. [cell headImageViewImageWithUserId:user.userId roomId:nil];
  759. if (indexPath.section == self.letterResultArr.count-1 && indexPath.row == [(NSArray *)[self.letterResultArr objectAtIndex:indexPath.section] count]-1) {
  760. cell.lineView.frame = CGRectMake(0, cell.lineView.frame.origin.y, JX_SCREEN_WIDTH, cell.lineView.frame.size.height);
  761. }else if (indexPath.row == [(NSArray *)[self.letterResultArr objectAtIndex:indexPath.section] count]-1) {
  762. cell.lineView.frame = CGRectMake(cell.lineView.frame.origin.x, cell.lineView.frame.origin.y, cell.lineView.frame.size.width,0);
  763. }else {
  764. cell.lineView.frame = CGRectMake(cell.lineView.frame.origin.x, cell.lineView.frame.origin.y, cell.lineView.frame.size.width,LINE_WH);
  765. }
  766. return cell;
  767. }
  768. - (NSString *)multipleLoginIsOnlineTitle:(JXUserObject *)user {
  769. NSString *isOnline;
  770. if ([user.isOnLine intValue] == 1) {
  771. isOnline = [NSString stringWithFormat:@"(%@)", Localized(@"JX_OnLine")];
  772. }else {
  773. isOnline = [NSString stringWithFormat:@"(%@)", Localized(@"JX_OffLine")];
  774. }
  775. NSString *title = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  776. if ([user.userId isEqualToString:ANDROID_USERID] || [user.userId isEqualToString:PC_USERID] || [user.userId isEqualToString:MAC_USERID]) {
  777. title = [title stringByAppendingString:isOnline];
  778. }
  779. return title;
  780. }
  781. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  782. { [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  783. JXCell * cell = [_table cellForRowAtIndexPath:indexPath];
  784. cell.selected = NO;
  785. // 黑名单列表不能点击
  786. if (_selMenu == 1) {
  787. return;
  788. }
  789. JXUserObject *user;
  790. if (_seekTextField.text.length > 0) {
  791. user = _searchArray[indexPath.row];
  792. }else{
  793. user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  794. }
  795. if([user.userId isEqualToString:FRIEND_CENTER_USERID]){
  796. JXNewFriendViewController* vc = [[JXNewFriendViewController alloc]init];
  797. // [g_App.window addSubview:vc.view];
  798. [g_navigation pushViewController:vc animated:YES];
  799. // [vc release];
  800. return;
  801. }
  802. JXChatViewC *sendView=[JXChatViewC alloc];
  803. if([user.roomFlag intValue] > 0 || user.roomId.length > 0){
  804. sendView.roomJid = user.userId;
  805. sendView.roomId = user.roomId;
  806. [[JXXMPP sharedInstance].roomPool joinRoom:user.userId title:user.userNickname lastDate:nil isNew:NO];
  807. }
  808. sendView.title = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  809. sendView.chatPerson = user;
  810. sendView = [sendView init];
  811. // [g_App.window addSubview:sendView.view];
  812. [g_navigation pushViewController:sendView animated:YES];
  813. JXMessageObject *msg = [[JXMessageObject alloc] init];
  814. msg.toUserId = user.userId;
  815. [msg updateNewMsgsTo0];
  816. [g_notify postNotificationName:kChatViewDisappear object:nil];
  817. // [sendView release];
  818. }
  819. -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
  820. if (_seekTextField.text.length <= 0){
  821. if (_selMenu == 0) {
  822. JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  823. if (user.userId.length <= 5) {
  824. return NO;
  825. }else{
  826. return YES;
  827. }
  828. }else{
  829. return YES;
  830. }
  831. }else{
  832. return NO;
  833. }
  834. }
  835. //-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
  836. // if (_selMenu == 0) {
  837. // return UITableViewCellEditingStyleDelete;
  838. // }else{
  839. // return UITableViewCellEditingStyleNone;
  840. // }
  841. //}
  842. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  843. if (_selMenu == 0) {
  844. _indexPathV=indexPath;
  845. // UIAlertView *alertShwo = [[UIAlertView alloc]initWithTitle:@"删除联系人" message:@"确认删除联系人" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
  846. //
  847. // [alertShwo show];
  848. UITableViewRowAction *deleteBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"JX_Delete") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  849. JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  850. _currentUser = user;
  851. [g_server delFriend:user.userId toView:self];
  852. }];
  853. return @[deleteBtn];
  854. }
  855. else {
  856. UITableViewRowAction *cancelBlackBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"REMOVE") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  857. JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  858. _currentUser = user;
  859. [g_server delBlacklist:user.userId toView:self];
  860. }];
  861. return @[cancelBlackBtn];
  862. }
  863. }
  864. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  865. if (buttonIndex==0) {
  866. return;
  867. }
  868. }
  869. //-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
  870. // if (_selMenu == 0 && editingStyle == UITableViewCellEditingStyleDelete) {
  871. // JXUserObject *user=_array[indexPath.row];
  872. // _currentUser = user;
  873. // [g_server delFriend:user.userId toView:self];
  874. // }
  875. //}
  876. - (void)dealloc {
  877. [g_notify removeObserver:self];
  878. // [_table release];
  879. [_array removeAllObjects];
  880. // [_array release];
  881. // [super dealloc];
  882. }
  883. -(void)getArrayData{
  884. switch (_selMenu) {
  885. case 0:{
  886. //获取好友列表
  887. // if (self.isOneInit) {//是否新建
  888. // [g_server listAttention:0 userId:MY_USER_ID toView:self];
  889. // self.isOneInit = NO;
  890. // }
  891. //从数据库获取好友staus为2且不是room的
  892. _array=[[JXUserObject sharedInstance] fetchAllFriendsFromLocal];
  893. //选择拼音 转换的 方法
  894. BMChineseSortSetting.share.sortMode = 2; // 1或2
  895. //排序 Person对象
  896. [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
  897. if (isSuccess) {
  898. self.indexArray = sectionTitleArr;
  899. self.letterResultArr = sortedObjArr;
  900. // [self.indexArray insertObject:@"🔍" atIndex:0];
  901. [_table reloadData];
  902. }
  903. }];
  904. // //根据Person对象的 name 属性 按中文 对 Person数组 排序
  905. // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
  906. // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
  907. //
  908. self.isShowFooterPull = NO;
  909. }
  910. break;
  911. case 1:{
  912. //获取黑名單列表
  913. //从数据库获取好友staus为-1的
  914. _array=[[JXUserObject sharedInstance] fetchAllBlackFromLocal];
  915. //选择拼音 转换的 方法
  916. BMChineseSortSetting.share.sortMode = 2; // 1或2
  917. //排序 Person对象
  918. [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
  919. if (isSuccess) {
  920. self.indexArray = sectionTitleArr;
  921. //[self.indexArray insertObject:@"🔍" atIndex:0];
  922. self.letterResultArr = sortedObjArr;
  923. [_table reloadData];
  924. }
  925. }];
  926. //根据Person对象的 name 属性 按中文 对 Person数组 排序
  927. // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
  928. // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
  929. }
  930. break;
  931. case 2:{
  932. _array=[[JXUserObject sharedInstance] fetchAllRoomsFromLocal];
  933. //选择拼音 转换的 方法
  934. BMChineseSortSetting.share.sortMode = 2; // 1或2
  935. //排序 Person对象
  936. [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
  937. if (isSuccess) {
  938. self.indexArray = sectionTitleArr;
  939. self.letterResultArr = sortedObjArr;
  940. [_table reloadData];
  941. }
  942. }];
  943. }
  944. // //根据Person对象的 name 属性 按中文 对 Person数组 排序
  945. // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
  946. // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
  947. break;
  948. }
  949. [self setFooterView];
  950. }
  951. //服务器返回数据
  952. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  953. //更新本地好友
  954. if ([aDownload.action isEqualToString:act_AttentionList]) {
  955. [_wait stop];
  956. [self stopLoading];
  957. JXProgressVC * pv = [JXProgressVC alloc];
  958. // 服务端不会返回新朋友 , 减去新朋友
  959. pv.dbFriends = (long)[_array count] - 1;
  960. pv.dataArray = array1;
  961. pv = [pv init];
  962. // [g_window addSubview:pv.view];
  963. }
  964. if ([aDownload.action isEqualToString:act_FriendDel]) {
  965. [_currentUser doSendMsg:XMPP_TYPE_DELALL content:nil];
  966. }
  967. if([aDownload.action isEqualToString:act_BlacklistDel]){
  968. [_currentUser doSendMsg:XMPP_TYPE_NOBLACK content:nil];
  969. }
  970. if( [aDownload.action isEqualToString:act_UserGet] ){
  971. [_wait stop];
  972. JXUserObject* user = [[JXUserObject alloc]init];
  973. [user getDataFromDict:dict];
  974. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  975. vc.user = user;
  976. vc.fromAddType = 6;
  977. vc = [vc init];
  978. // [g_window addSubview:vc.view];
  979. [g_navigation pushViewController:vc animated:YES];
  980. }
  981. // 同步标签
  982. if ([aDownload.action isEqualToString:act_FriendGroupList]) {
  983. for (NSInteger i = 0; i < array1.count; i ++) {
  984. NSDictionary *dict = array1[i];
  985. JXLabelObject *labelObj = [[JXLabelObject alloc] init];
  986. labelObj.groupId = dict[@"groupId"];
  987. labelObj.groupName = dict[@"groupName"];
  988. labelObj.userId = dict[@"userId"];
  989. NSArray *userIdList = dict[@"userIdList"];
  990. NSString *userIdListStr = [userIdList componentsJoinedByString:@","];
  991. if (userIdListStr.length > 0) {
  992. labelObj.userIdList = [NSString stringWithFormat:@"%@", userIdListStr];
  993. }
  994. [labelObj insert];
  995. }
  996. // 删除服务器上已经删除的
  997. NSArray *arr = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
  998. for (NSInteger i = 0; i < arr.count; i ++) {
  999. JXLabelObject *locLabel = arr[i];
  1000. BOOL flag = NO;
  1001. for (NSInteger j = 0; j < array1.count; j ++) {
  1002. NSDictionary * dict = array1[j];
  1003. if ([locLabel.groupId isEqualToString:dict[@"groupId"]]) {
  1004. flag = YES;
  1005. break;
  1006. }
  1007. }
  1008. if (!flag) {
  1009. [locLabel delete];
  1010. }
  1011. }
  1012. _array = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
  1013. for (JXLabelObject *labelObj in _array) {
  1014. NSString *userIdStr = labelObj.userIdList;
  1015. NSArray *userIds = [userIdStr componentsSeparatedByString:@","];
  1016. if (userIdStr.length <= 0) {
  1017. userIds = nil;
  1018. }
  1019. NSMutableArray *newUserIds = [userIds mutableCopy];
  1020. for (NSInteger i = 0; i < userIds.count; i ++) {
  1021. NSString *userId = userIds[i];
  1022. NSString *userName = [JXUserObject getUserNameWithUserId:userId];
  1023. if (!userName || userName.length <= 0) {
  1024. [newUserIds removeObject:userId];
  1025. }
  1026. }
  1027. NSString *string = [newUserIds componentsJoinedByString:@","];
  1028. labelObj.userIdList = string;
  1029. [labelObj update];
  1030. }
  1031. }
  1032. if ([aDownload.action isEqualToString:act_customerLinkList]){
  1033. self.customerArr = array1;
  1034. CGRect backFrame = backView.frame;
  1035. backFrame.size.height = backFrame.size.height + 50* self.customerArr.count;
  1036. backView.frame = backFrame ;
  1037. if (self.customerArr.count == 0) {
  1038. return;
  1039. }
  1040. int cY = _menuView.frame.origin.y + _menuView.frame.size.height;
  1041. for (int i = 0; i < self.customerArr.count; i++) {
  1042. UIView *customerView = [[UIView alloc] initWithFrame:CGRectMake(0, cY + 50 * i, self_width, 50)];
  1043. // customerView.backgroundColor = [UIColor redColor];
  1044. UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, .5)];
  1045. lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
  1046. [customerView addSubview:lineView2];
  1047. UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, lineView2.frame.origin.y+5, 40, 40)];
  1048. NSString *fileURL = self.customerArr[i][@"path"];
  1049. NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
  1050. UIImage *image = [UIImage imageWithData:data];
  1051. if (image) {
  1052. imageView2.image = image;
  1053. }else {
  1054. imageView2.image = [UIImage imageNamed:@"im_10000"];
  1055. }
  1056. [customerView addSubview:imageView2];
  1057. 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)];
  1058. // [customerBtn setTitle:@"威尼斯客服" forState:UIControlStateNormal];
  1059. if (self.customerArr[i][@"name"]) {
  1060. [customerBtn setTitle:self.customerArr[i][@"name"] forState:UIControlStateNormal];
  1061. }else {
  1062. // imageView2.image = [UIImage imageNamed:@"im_10000"];
  1063. [customerBtn setTitle:@"--" forState:UIControlStateNormal];
  1064. }
  1065. // [customerBtn ]
  1066. customerBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1067. // customerBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  1068. // customerBtn.backgroundColor = UIColor.redColor;
  1069. [customerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  1070. [customerBtn addTarget:self action:@selector(customerClick:) forControlEvents:UIControlEventTouchUpInside];
  1071. customerBtn.tag = i+1;
  1072. [customerView addSubview:customerBtn];
  1073. UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width - 40, customerBtn.frame.origin.y + customerBtn.frame.size.height - 15, 40, 15)];
  1074. if (self.customerArr[i][@"type"]) {
  1075. hintLabel.text = self.customerArr[i][@"type"];
  1076. }else{
  1077. hintLabel.text = @"--";
  1078. }
  1079. hintLabel.font = [UIFont systemFontOfSize:13];
  1080. hintLabel.backgroundColor = UIColor.clearColor;
  1081. hintLabel.textColor = UIColor.blackColor;
  1082. hintLabel.textAlignment = NSTextAlignmentCenter;
  1083. [customerView addSubview:hintLabel];
  1084. [backView addSubview:customerView];
  1085. }
  1086. }
  1087. }
  1088. //修改了
  1089. - (void)setupCustomerLinkList {
  1090. _customerArr = g_App.customerLinkListArray;
  1091. return;
  1092. CGRect backFrame = backView.frame;
  1093. backFrame.size.height = backFrame.size.height + 50* self.customerArr.count;
  1094. backView.frame = backFrame ;
  1095. if (self.customerArr.count == 0) {
  1096. return;
  1097. }
  1098. int cY = _menuView.frame.origin.y + _menuView.frame.size.height;
  1099. for (int i = 0; i < self.customerArr.count; i++) {
  1100. UIView *customerView = [[UIView alloc] initWithFrame:CGRectMake(0, cY + 50 * i, self_width, 50)];
  1101. // customerView.backgroundColor = [UIColor redColor];
  1102. UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, .5)];
  1103. lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
  1104. [customerView addSubview:lineView2];
  1105. UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, lineView2.frame.origin.y+5, 40, 40)];
  1106. NSString *fileURL = self.customerArr[i][@"path"];
  1107. NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
  1108. UIImage *image = [UIImage imageWithData:data];
  1109. if (image) {
  1110. imageView2.image = image;
  1111. }else {
  1112. imageView2.image = [UIImage imageNamed:@"im_10000"];
  1113. }
  1114. [customerView addSubview:imageView2];
  1115. 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)];
  1116. // [customerBtn setTitle:@"威尼斯客服" forState:UIControlStateNormal];
  1117. if (self.customerArr[i][@"name"]) {
  1118. [customerBtn setTitle:self.customerArr[i][@"name"] forState:UIControlStateNormal];
  1119. }else {
  1120. // imageView2.image = [UIImage imageNamed:@"im_10000"];
  1121. [customerBtn setTitle:@"--" forState:UIControlStateNormal];
  1122. }
  1123. // [customerBtn ]
  1124. customerBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1125. // customerBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  1126. // customerBtn.backgroundColor = UIColor.redColor;
  1127. [customerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  1128. [customerBtn addTarget:self action:@selector(customerClick:) forControlEvents:UIControlEventTouchUpInside];
  1129. customerBtn.tag = i+1;
  1130. [customerView addSubview:customerBtn];
  1131. UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width - 40, customerBtn.frame.origin.y + customerBtn.frame.size.height - 15, 40, 15)];
  1132. if (self.customerArr[i][@"type"]) {
  1133. hintLabel.text = self.customerArr[i][@"type"];
  1134. }else{
  1135. hintLabel.text = @"--";
  1136. }
  1137. hintLabel.font = [UIFont systemFontOfSize:13];
  1138. hintLabel.backgroundColor = UIColor.clearColor;
  1139. hintLabel.textColor = UIColor.blackColor;
  1140. hintLabel.textAlignment = NSTextAlignmentCenter;
  1141. [customerView addSubview:hintLabel];
  1142. [backView addSubview:customerView];
  1143. }
  1144. }
  1145. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  1146. [_wait hide];
  1147. [self stopLoading];
  1148. return hide_error;
  1149. }
  1150. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  1151. [_wait hide];
  1152. [self stopLoading];
  1153. return hide_error;
  1154. }
  1155. -(void) didServerConnectStart:(JXConnection*)aDownload{
  1156. // [_wait start];
  1157. }
  1158. -(void)refresh{
  1159. [self stopLoading];
  1160. _refreshCount++;
  1161. [_array removeAllObjects];
  1162. // [_array release];
  1163. [self getArrayData];
  1164. _friendArray = [g_server.myself fetchAllFriendsOrNotFromLocal];
  1165. [_table reloadData];
  1166. }
  1167. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  1168. {
  1169. return 59;
  1170. }
  1171. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  1172. [self.view endEditing:YES];
  1173. }
  1174. //-(void)scrollToPageUp{
  1175. // [self refresh];
  1176. //}
  1177. -(void)newFriend:(NSObject*)sender{
  1178. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1179. [self refresh];
  1180. });
  1181. }
  1182. -(void)onHeadImage:(id)dataObj{
  1183. JXUserObject *p = (JXUserObject *)dataObj;
  1184. if([p.userId isEqualToString:FRIEND_CENTER_USERID] || [p.userId isEqualToString:CALL_CENTER_USERID])
  1185. return;
  1186. _currentUser = p;
  1187. // [g_server getUser:p.userId toView:self];
  1188. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  1189. vc.userId = p.userId;
  1190. vc.user = p;
  1191. vc.fromAddType = 6;
  1192. vc = [vc init];
  1193. [g_navigation pushViewController:vc animated:YES];
  1194. p = nil;
  1195. }
  1196. -(void)onSendTimeout:(NSNotification *)notifacation//超时未收到回执
  1197. {
  1198. // NSLog(@"onSendTimeout");
  1199. [_wait stop];
  1200. // [g_App showAlert:Localized(@"JXAlert_SendFilad")];
  1201. // [JXMyTools showTipView:Localized(@"JXAlert_SendFilad")];
  1202. }
  1203. -(void)newReceipt:(NSNotification *)notifacation{//新回执
  1204. // NSLog(@"newReceipt");
  1205. JXMessageObject *msg = (JXMessageObject *)notifacation.object;
  1206. if(msg == nil)
  1207. return;
  1208. if(![msg isAddFriendMsg])
  1209. return;
  1210. [_wait stop];
  1211. if([msg.type intValue] == XMPP_TYPE_DELALL){
  1212. if([msg.toUserId isEqualToString:_currentUser.userId] || [msg.fromUserId isEqualToString:_currentUser.userId]){
  1213. [_array removeObject:_currentUser];
  1214. _currentUser = nil;
  1215. [self getArrayData];
  1216. [_table reloadData];
  1217. // [g_App showAlert:Localized(@"JXAlert_DeleteFirend")];
  1218. }
  1219. }
  1220. if([msg.type intValue] == XMPP_TYPE_BLACK){//拉黑
  1221. for (JXUserObject *obj in _array) {
  1222. if ([obj.userId isEqualToString:_currentUser.userId]) {
  1223. [_array removeObject:obj];
  1224. break;
  1225. }
  1226. }
  1227. [self getArrayData];
  1228. [self.tableView reloadData];
  1229. }
  1230. if([msg.type intValue] == XMPP_TYPE_NOBLACK){
  1231. // _currentUser.status = [NSNumber numberWithInt:friend_status_friend];
  1232. // int status = [_currentUser.status intValue];
  1233. // [_currentUser update];
  1234. if (!_currentUser) {
  1235. return;
  1236. }
  1237. [[JXXMPP sharedInstance].blackList removeObject:_currentUser.userId];
  1238. [JXMessageObject msgWithFriendStatus:_currentUser.userId status:friend_status_friend];
  1239. for (JXUserObject *obj in _array) {
  1240. if ([obj.userId isEqualToString:_currentUser.userId]) {
  1241. [_array removeObject:obj];
  1242. break;
  1243. }
  1244. }
  1245. [self getArrayData];
  1246. [self.tableView reloadData];
  1247. // [g_App showAlert:Localized(@"JXAlert_MoveBlackList")];
  1248. }
  1249. if([msg.type intValue] == XMPP_TYPE_PASS){//通过
  1250. [self getFriend];
  1251. }
  1252. }
  1253. - (void)friendRemarkNotif:(NSNotification *)notif {
  1254. JXUserObject *user = notif.object;
  1255. for (int i = 0; i < _array.count; i ++) {
  1256. JXUserObject *user1 = _array[i];
  1257. if ([user.userId isEqualToString:user1.userId]) {
  1258. user1.userNickname = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  1259. user1.remarkName = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  1260. [_table reloadData];
  1261. break;
  1262. }
  1263. }
  1264. }
  1265. - (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title icon:(NSString *)iconName action:(SEL)action {
  1266. UIButton *button = [[UIButton alloc] init];
  1267. button.frame = frame;
  1268. [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
  1269. UIImageView *imgV = [[UIImageView alloc] init];
  1270. imgV.frame = CGRectMake((button.frame.size.width-IMAGE_HEIGHT)/2, 20, IMAGE_HEIGHT, IMAGE_HEIGHT);
  1271. imgV.image = [UIImage imageNamed:iconName];
  1272. [button addSubview:imgV];
  1273. CGSize size = [title boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(14)} context:nil].size;
  1274. UILabel *lab = [[UILabel alloc] init];
  1275. lab.text = title;
  1276. lab.font = SYSFONT(14);
  1277. lab.textAlignment = NSTextAlignmentCenter;
  1278. lab.textColor = HEXCOLOR(0x323232);
  1279. if (size.width >= button.frame.size.width) {
  1280. size.width = button.frame.size.width-20;
  1281. }
  1282. lab.frame = CGRectMake(0, CGRectGetMaxY(imgV.frame)+INSET_HEIGHT, size.width, size.height);
  1283. CGPoint center = lab.center;
  1284. center.x = imgV.center.x;
  1285. lab.center = center;
  1286. CGRect btnFrame = button.frame;
  1287. btnFrame.size.height = CGRectGetMaxY(imgV.frame)+INSET_HEIGHT+size.height;
  1288. button.frame = btnFrame;
  1289. [button addSubview:lab];
  1290. return button;
  1291. }
  1292. -(void)customerClick:(UIButton *)sender{
  1293. // UIButton *btn = (UIButton *)[self.view viewWithTag:sender.tag];
  1294. if (self.customerArr[sender.tag - 1][@"link"]) {
  1295. CYWebCustomerServiceVC *vc = [[CYWebCustomerServiceVC alloc] init];
  1296. vc.titleName = self.customerArr[sender.tag - 1][@"name"];
  1297. vc.link = self.customerArr[sender.tag - 1][@"link"];
  1298. [self presentViewController:vc animated:YES completion:^{
  1299. }];
  1300. }else {
  1301. NSLog(@"链接不存在!!!!!!!!");
  1302. }
  1303. }
  1304. @end