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. //获取最近的好友
  660. - (void)getFriend{
  661. [g_server listAttention:10000 userId:MY_USER_ID toView:self];
  662. }
  663. //-(void)actionSegment:(UISegmentedControl*)sender{
  664. // _selMenu = (int)sender.selectedSegmentIndex;
  665. // [self refresh];
  666. //}
  667. - (void)viewDidLoad
  668. {
  669. [super viewDidLoad];
  670. _array=[[NSMutableArray alloc] init];
  671. //[self refresh];
  672. }
  673. - (void)viewDidDisappear:(BOOL)animated {
  674. [super viewDidDisappear:animated];
  675. // 离开时重置_isMyGoIn
  676. if (_isMyGoIn) {
  677. _isMyGoIn = NO;
  678. }
  679. }
  680. - (void)viewWillAppear:(BOOL)animated
  681. {
  682. [super viewWillAppear:animated];
  683. }
  684. #pragma mark ---------tableView协议----------------
  685. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  686. {
  687. if (_seekTextField.text.length > 0) {
  688. return 1;
  689. }
  690. return [self.indexArray count];
  691. }
  692. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  693. if (_seekTextField.text.length > 0) {
  694. return Localized(@"JXFriend_searchTitle");
  695. }
  696. return [self.indexArray objectAtIndex:section];
  697. }
  698. -(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
  699. UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
  700. header.tintColor = HEXCOLOR(0xF2F2F2);
  701. [header.textLabel setTextColor:HEXCOLOR(0x999999)];
  702. [header.textLabel setFont:SYSFONT(15)];
  703. }
  704. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  705. if (_seekTextField.text.length > 0) {
  706. return _searchArray.count;
  707. }
  708. return [(NSArray *)[self.letterResultArr objectAtIndex:section] count];
  709. }
  710. -(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
  711. if (_seekTextField.text.length > 0) {
  712. return nil;
  713. }
  714. return _indexArray;
  715. }
  716. - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
  717. return index;
  718. }
  719. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  720. {
  721. JXUserObject *user;
  722. if (_seekTextField.text.length > 0) {
  723. user = _searchArray[indexPath.row];
  724. }else{
  725. user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  726. }
  727. JXCell *cell=nil;
  728. NSString* cellName = [NSString stringWithFormat:@"msg_%d_%ld",_refreshCount,(long)indexPath.row];
  729. cell = [tableView dequeueReusableCellWithIdentifier:cellName];
  730. if(cell==nil){
  731. cell = [[JXCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
  732. [_table addToPool:cell];
  733. // cell.headImage = user.userHead;
  734. // user = nil;
  735. }
  736. // cell.title = user.userNickname;
  737. cell.title = [self multipleLoginIsOnlineTitle:user];
  738. // cell.subtitle = user.userId;
  739. cell.index = (int)indexPath.row;
  740. cell.delegate = self;
  741. cell.didTouch = @selector(onHeadImage:);
  742. // cell.bottomTitle = [TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"];
  743. // [cell setForTimeLabel:[TimeUtil formatDate:user.timeCreate format:@"MM-dd HH:mm"]];
  744. cell.timeLabel.frame = CGRectMake(JX_SCREEN_WIDTH - 120-20, 9, 115, 20);
  745. cell.userId = user.userId;
  746. [cell.lbTitle setText:cell.title];
  747. //添加爱心标志---特别关心标志
  748. // cell.notPushImageView.image = [UIImage imageNamed:@"collection_me_simple"];
  749. if ([user.veryCare intValue] == 1) {
  750. cell.specialCareImageView.hidden = NO;
  751. }else {
  752. cell.specialCareImageView.hidden = YES;
  753. }
  754. cell.dataObj = user;
  755. // cell.headImageView.tag = (int)indexPath.row;
  756. // cell.headImageView.delegate = cell.delegate;
  757. // cell.headImageView.didTouch = cell.didTouch;
  758. cell.isSmall = YES;
  759. [cell headImageViewImageWithUserId:user.userId roomId:nil];
  760. if (indexPath.section == self.letterResultArr.count-1 && indexPath.row == [(NSArray *)[self.letterResultArr objectAtIndex:indexPath.section] count]-1) {
  761. cell.lineView.frame = CGRectMake(0, cell.lineView.frame.origin.y, JX_SCREEN_WIDTH, cell.lineView.frame.size.height);
  762. }else if (indexPath.row == [(NSArray *)[self.letterResultArr objectAtIndex:indexPath.section] count]-1) {
  763. cell.lineView.frame = CGRectMake(cell.lineView.frame.origin.x, cell.lineView.frame.origin.y, cell.lineView.frame.size.width,0);
  764. }else {
  765. cell.lineView.frame = CGRectMake(cell.lineView.frame.origin.x, cell.lineView.frame.origin.y, cell.lineView.frame.size.width,LINE_WH);
  766. }
  767. return cell;
  768. }
  769. - (NSString *)multipleLoginIsOnlineTitle:(JXUserObject *)user {
  770. NSString *isOnline;
  771. if ([user.isOnLine intValue] == 1) {
  772. isOnline = [NSString stringWithFormat:@"(%@)", Localized(@"JX_OnLine")];
  773. }else {
  774. isOnline = [NSString stringWithFormat:@"(%@)", Localized(@"JX_OffLine")];
  775. }
  776. NSString *title = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  777. if ([user.userId isEqualToString:ANDROID_USERID] || [user.userId isEqualToString:PC_USERID] || [user.userId isEqualToString:MAC_USERID]) {
  778. title = [title stringByAppendingString:isOnline];
  779. }
  780. return title;
  781. }
  782. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  783. { [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  784. JXCell * cell = [_table cellForRowAtIndexPath:indexPath];
  785. cell.selected = NO;
  786. // 黑名单列表不能点击
  787. if (_selMenu == 1) {
  788. return;
  789. }
  790. JXUserObject *user;
  791. if (_seekTextField.text.length > 0) {
  792. user = _searchArray[indexPath.row];
  793. }else{
  794. user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  795. }
  796. if([user.userId isEqualToString:FRIEND_CENTER_USERID]){
  797. JXNewFriendViewController* vc = [[JXNewFriendViewController alloc]init];
  798. // [g_App.window addSubview:vc.view];
  799. [g_navigation pushViewController:vc animated:YES];
  800. // [vc release];
  801. return;
  802. }
  803. JXChatViewC *sendView=[JXChatViewC alloc];
  804. if([user.roomFlag intValue] > 0 || user.roomId.length > 0){
  805. sendView.roomJid = user.userId;
  806. sendView.roomId = user.roomId;
  807. [[JXXMPP sharedInstance].roomPool joinRoom:user.userId title:user.userNickname lastDate:nil isNew:NO];
  808. }
  809. sendView.title = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  810. sendView.chatPerson = user;
  811. sendView = [sendView init];
  812. // [g_App.window addSubview:sendView.view];
  813. [g_navigation pushViewController:sendView animated:YES];
  814. JXMessageObject *msg = [[JXMessageObject alloc] init];
  815. msg.toUserId = user.userId;
  816. [msg updateNewMsgsTo0];
  817. [g_notify postNotificationName:kChatViewDisappear object:nil];
  818. // [sendView release];
  819. }
  820. -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
  821. if (_seekTextField.text.length <= 0){
  822. if (_selMenu == 0) {
  823. JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  824. if (user.userId.length <= 5) {
  825. return NO;
  826. }else{
  827. return YES;
  828. }
  829. }else{
  830. return YES;
  831. }
  832. }else{
  833. return NO;
  834. }
  835. }
  836. //-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
  837. // if (_selMenu == 0) {
  838. // return UITableViewCellEditingStyleDelete;
  839. // }else{
  840. // return UITableViewCellEditingStyleNone;
  841. // }
  842. //}
  843. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  844. if (_selMenu == 0) {
  845. _indexPathV=indexPath;
  846. // UIAlertView *alertShwo = [[UIAlertView alloc]initWithTitle:@"删除联系人" message:@"确认删除联系人" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
  847. //
  848. // [alertShwo show];
  849. UITableViewRowAction *deleteBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"JX_Delete") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  850. JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  851. _currentUser = user;
  852. [g_server delFriend:user.userId toView:self];
  853. }];
  854. return @[deleteBtn];
  855. }
  856. else {
  857. UITableViewRowAction *cancelBlackBtn = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"REMOVE") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  858. JXUserObject *user = [[self.letterResultArr objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
  859. _currentUser = user;
  860. [g_server delBlacklist:user.userId toView:self];
  861. }];
  862. return @[cancelBlackBtn];
  863. }
  864. }
  865. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  866. if (buttonIndex==0) {
  867. return;
  868. }
  869. }
  870. //-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
  871. // if (_selMenu == 0 && editingStyle == UITableViewCellEditingStyleDelete) {
  872. // JXUserObject *user=_array[indexPath.row];
  873. // _currentUser = user;
  874. // [g_server delFriend:user.userId toView:self];
  875. // }
  876. //}
  877. - (void)dealloc {
  878. [g_notify removeObserver:self];
  879. // [_table release];
  880. [_array removeAllObjects];
  881. // [_array release];
  882. // [super dealloc];
  883. }
  884. -(void)getArrayData{
  885. switch (_selMenu) {
  886. case 0:{
  887. //获取好友列表
  888. // if (self.isOneInit) {//是否新建
  889. // [g_server listAttention:0 userId:MY_USER_ID toView:self];
  890. // self.isOneInit = NO;
  891. // }
  892. //从数据库获取好友staus为2且不是room的
  893. _array=[[JXUserObject sharedInstance] fetchAllFriendsFromLocal];
  894. //选择拼音 转换的 方法
  895. BMChineseSortSetting.share.sortMode = 2; // 1或2
  896. //排序 Person对象
  897. [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
  898. if (isSuccess) {
  899. self.indexArray = sectionTitleArr;
  900. self.letterResultArr = sortedObjArr;
  901. // [self.indexArray insertObject:@"🔍" atIndex:0];
  902. [_table reloadData];
  903. }
  904. }];
  905. // //根据Person对象的 name 属性 按中文 对 Person数组 排序
  906. // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
  907. // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
  908. //
  909. self.isShowFooterPull = NO;
  910. }
  911. break;
  912. case 1:{
  913. //获取黑名單列表
  914. //从数据库获取好友staus为-1的
  915. _array=[[JXUserObject sharedInstance] fetchAllBlackFromLocal];
  916. //选择拼音 转换的 方法
  917. BMChineseSortSetting.share.sortMode = 2; // 1或2
  918. //排序 Person对象
  919. [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
  920. if (isSuccess) {
  921. self.indexArray = sectionTitleArr;
  922. //[self.indexArray insertObject:@"🔍" atIndex:0];
  923. self.letterResultArr = sortedObjArr;
  924. [_table reloadData];
  925. }
  926. }];
  927. //根据Person对象的 name 属性 按中文 对 Person数组 排序
  928. // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
  929. // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
  930. }
  931. break;
  932. case 2:{
  933. _array=[[JXUserObject sharedInstance] fetchAllRoomsFromLocal];
  934. //选择拼音 转换的 方法
  935. BMChineseSortSetting.share.sortMode = 2; // 1或2
  936. //排序 Person对象
  937. [BMChineseSort sortAndGroup:_array key:@"userNickname" finish:^(bool isSuccess, NSMutableArray *unGroupArr, NSMutableArray *sectionTitleArr, NSMutableArray<NSMutableArray *> *sortedObjArr) {
  938. if (isSuccess) {
  939. self.indexArray = sectionTitleArr;
  940. self.letterResultArr = sortedObjArr;
  941. [_table reloadData];
  942. }
  943. }];
  944. }
  945. // //根据Person对象的 name 属性 按中文 对 Person数组 排序
  946. // self.indexArray = [BMChineseSort IndexWithArray:_array Key:@"userNickname"];
  947. // self.letterResultArr = [BMChineseSort sortObjectArray:_array Key:@"userNickname"];
  948. break;
  949. }
  950. [self setFooterView];
  951. }
  952. //服务器返回数据
  953. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  954. //更新本地好友
  955. if ([aDownload.action isEqualToString:act_AttentionList]) {
  956. [_wait stop];
  957. [self stopLoading];
  958. JXProgressVC * pv = [JXProgressVC alloc];
  959. // 服务端不会返回新朋友 , 减去新朋友
  960. pv.dbFriends = (long)[_array count] - 1;
  961. pv.dataArray = array1;
  962. pv = [pv init];
  963. // [g_window addSubview:pv.view];
  964. }
  965. if ([aDownload.action isEqualToString:act_FriendDel]) {
  966. [_currentUser doSendMsg:XMPP_TYPE_DELALL content:nil];
  967. }
  968. if([aDownload.action isEqualToString:act_BlacklistDel]){
  969. [_currentUser doSendMsg:XMPP_TYPE_NOBLACK content:nil];
  970. }
  971. if( [aDownload.action isEqualToString:act_UserGet] ){
  972. [_wait stop];
  973. JXUserObject* user = [[JXUserObject alloc]init];
  974. [user getDataFromDict:dict];
  975. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  976. vc.user = user;
  977. vc.fromAddType = 6;
  978. vc = [vc init];
  979. // [g_window addSubview:vc.view];
  980. [g_navigation pushViewController:vc animated:YES];
  981. }
  982. // 同步标签
  983. if ([aDownload.action isEqualToString:act_FriendGroupList]) {
  984. for (NSInteger i = 0; i < array1.count; i ++) {
  985. NSDictionary *dict = array1[i];
  986. JXLabelObject *labelObj = [[JXLabelObject alloc] init];
  987. labelObj.groupId = dict[@"groupId"];
  988. labelObj.groupName = dict[@"groupName"];
  989. labelObj.userId = dict[@"userId"];
  990. NSArray *userIdList = dict[@"userIdList"];
  991. NSString *userIdListStr = [userIdList componentsJoinedByString:@","];
  992. if (userIdListStr.length > 0) {
  993. labelObj.userIdList = [NSString stringWithFormat:@"%@", userIdListStr];
  994. }
  995. [labelObj insert];
  996. }
  997. // 删除服务器上已经删除的
  998. NSArray *arr = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
  999. for (NSInteger i = 0; i < arr.count; i ++) {
  1000. JXLabelObject *locLabel = arr[i];
  1001. BOOL flag = NO;
  1002. for (NSInteger j = 0; j < array1.count; j ++) {
  1003. NSDictionary * dict = array1[j];
  1004. if ([locLabel.groupId isEqualToString:dict[@"groupId"]]) {
  1005. flag = YES;
  1006. break;
  1007. }
  1008. }
  1009. if (!flag) {
  1010. [locLabel delete];
  1011. }
  1012. }
  1013. _array = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
  1014. for (JXLabelObject *labelObj in _array) {
  1015. NSString *userIdStr = labelObj.userIdList;
  1016. NSArray *userIds = [userIdStr componentsSeparatedByString:@","];
  1017. if (userIdStr.length <= 0) {
  1018. userIds = nil;
  1019. }
  1020. NSMutableArray *newUserIds = [userIds mutableCopy];
  1021. for (NSInteger i = 0; i < userIds.count; i ++) {
  1022. NSString *userId = userIds[i];
  1023. NSString *userName = [JXUserObject getUserNameWithUserId:userId];
  1024. if (!userName || userName.length <= 0) {
  1025. [newUserIds removeObject:userId];
  1026. }
  1027. }
  1028. NSString *string = [newUserIds componentsJoinedByString:@","];
  1029. labelObj.userIdList = string;
  1030. [labelObj update];
  1031. }
  1032. }
  1033. if ([aDownload.action isEqualToString:act_customerLinkList]){
  1034. self.customerArr = array1;
  1035. CGRect backFrame = backView.frame;
  1036. backFrame.size.height = backFrame.size.height + 50* self.customerArr.count;
  1037. backView.frame = backFrame ;
  1038. if (self.customerArr.count == 0) {
  1039. return;
  1040. }
  1041. int cY = _menuView.frame.origin.y + _menuView.frame.size.height;
  1042. for (int i = 0; i < self.customerArr.count; i++) {
  1043. UIView *customerView = [[UIView alloc] initWithFrame:CGRectMake(0, cY + 50 * i, self_width, 50)];
  1044. // customerView.backgroundColor = [UIColor redColor];
  1045. UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, .5)];
  1046. lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
  1047. [customerView addSubview:lineView2];
  1048. UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, lineView2.frame.origin.y+5, 40, 40)];
  1049. NSString *fileURL = self.customerArr[i][@"path"];
  1050. NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
  1051. UIImage *image = [UIImage imageWithData:data];
  1052. if (image) {
  1053. imageView2.image = image;
  1054. }else {
  1055. imageView2.image = [UIImage imageNamed:@"im_10000"];
  1056. }
  1057. [customerView addSubview:imageView2];
  1058. 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)];
  1059. // [customerBtn setTitle:@"威尼斯客服" forState:UIControlStateNormal];
  1060. if (self.customerArr[i][@"name"]) {
  1061. [customerBtn setTitle:self.customerArr[i][@"name"] forState:UIControlStateNormal];
  1062. }else {
  1063. // imageView2.image = [UIImage imageNamed:@"im_10000"];
  1064. [customerBtn setTitle:@"--" forState:UIControlStateNormal];
  1065. }
  1066. // [customerBtn ]
  1067. customerBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1068. // customerBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  1069. // customerBtn.backgroundColor = UIColor.redColor;
  1070. [customerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  1071. [customerBtn addTarget:self action:@selector(customerClick:) forControlEvents:UIControlEventTouchUpInside];
  1072. customerBtn.tag = i+1;
  1073. [customerView addSubview:customerBtn];
  1074. UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width - 40, customerBtn.frame.origin.y + customerBtn.frame.size.height - 15, 40, 15)];
  1075. if (self.customerArr[i][@"type"]) {
  1076. hintLabel.text = self.customerArr[i][@"type"];
  1077. }else{
  1078. hintLabel.text = @"--";
  1079. }
  1080. hintLabel.font = [UIFont systemFontOfSize:13];
  1081. hintLabel.backgroundColor = UIColor.clearColor;
  1082. hintLabel.textColor = UIColor.blackColor;
  1083. hintLabel.textAlignment = NSTextAlignmentCenter;
  1084. [customerView addSubview:hintLabel];
  1085. [backView addSubview:customerView];
  1086. }
  1087. }
  1088. }
  1089. //修改了
  1090. - (void)setupCustomerLinkList {
  1091. _customerArr = g_App.customerLinkListArray;
  1092. return;
  1093. CGRect backFrame = backView.frame;
  1094. backFrame.size.height = backFrame.size.height + 50* self.customerArr.count;
  1095. backView.frame = backFrame ;
  1096. if (self.customerArr.count == 0) {
  1097. return;
  1098. }
  1099. int cY = _menuView.frame.origin.y + _menuView.frame.size.height;
  1100. for (int i = 0; i < self.customerArr.count; i++) {
  1101. UIView *customerView = [[UIView alloc] initWithFrame:CGRectMake(0, cY + 50 * i, self_width, 50)];
  1102. // customerView.backgroundColor = [UIColor redColor];
  1103. UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, .5)];
  1104. lineView2.backgroundColor = HEXCOLOR(0xdcdcdc);
  1105. [customerView addSubview:lineView2];
  1106. UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(15, lineView2.frame.origin.y+5, 40, 40)];
  1107. NSString *fileURL = self.customerArr[i][@"path"];
  1108. NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
  1109. UIImage *image = [UIImage imageWithData:data];
  1110. if (image) {
  1111. imageView2.image = image;
  1112. }else {
  1113. imageView2.image = [UIImage imageNamed:@"im_10000"];
  1114. }
  1115. [customerView addSubview:imageView2];
  1116. 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)];
  1117. // [customerBtn setTitle:@"威尼斯客服" forState:UIControlStateNormal];
  1118. if (self.customerArr[i][@"name"]) {
  1119. [customerBtn setTitle:self.customerArr[i][@"name"] forState:UIControlStateNormal];
  1120. }else {
  1121. // imageView2.image = [UIImage imageNamed:@"im_10000"];
  1122. [customerBtn setTitle:@"--" forState:UIControlStateNormal];
  1123. }
  1124. // [customerBtn ]
  1125. customerBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  1126. // customerBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  1127. // customerBtn.backgroundColor = UIColor.redColor;
  1128. [customerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  1129. [customerBtn addTarget:self action:@selector(customerClick:) forControlEvents:UIControlEventTouchUpInside];
  1130. customerBtn.tag = i+1;
  1131. [customerView addSubview:customerBtn];
  1132. UILabel *hintLabel = [[UILabel alloc] initWithFrame:CGRectMake(self_width - 40, customerBtn.frame.origin.y + customerBtn.frame.size.height - 15, 40, 15)];
  1133. if (self.customerArr[i][@"type"]) {
  1134. hintLabel.text = self.customerArr[i][@"type"];
  1135. }else{
  1136. hintLabel.text = @"--";
  1137. }
  1138. hintLabel.font = [UIFont systemFontOfSize:13];
  1139. hintLabel.backgroundColor = UIColor.clearColor;
  1140. hintLabel.textColor = UIColor.blackColor;
  1141. hintLabel.textAlignment = NSTextAlignmentCenter;
  1142. [customerView addSubview:hintLabel];
  1143. [backView addSubview:customerView];
  1144. }
  1145. }
  1146. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  1147. [_wait hide];
  1148. [self stopLoading];
  1149. return hide_error;
  1150. }
  1151. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  1152. [_wait hide];
  1153. [self stopLoading];
  1154. return hide_error;
  1155. }
  1156. -(void) didServerConnectStart:(JXConnection*)aDownload{
  1157. // [_wait start];
  1158. }
  1159. -(void)refresh{
  1160. [self stopLoading];
  1161. _refreshCount++;
  1162. [_array removeAllObjects];
  1163. // [_array release];
  1164. [self getArrayData];
  1165. _friendArray = [g_server.myself fetchAllFriendsOrNotFromLocal];
  1166. [_table reloadData];
  1167. }
  1168. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  1169. {
  1170. return 59;
  1171. }
  1172. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  1173. [self.view endEditing:YES];
  1174. }
  1175. //-(void)scrollToPageUp{
  1176. // [self refresh];
  1177. //}
  1178. -(void)newFriend:(NSObject*)sender{
  1179. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1180. [self refresh];
  1181. });
  1182. }
  1183. -(void)onHeadImage:(id)dataObj{
  1184. JXUserObject *p = (JXUserObject *)dataObj;
  1185. if([p.userId isEqualToString:FRIEND_CENTER_USERID] || [p.userId isEqualToString:CALL_CENTER_USERID])
  1186. return;
  1187. _currentUser = p;
  1188. // [g_server getUser:p.userId toView:self];
  1189. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  1190. vc.userId = p.userId;
  1191. vc.user = p;
  1192. vc.fromAddType = 6;
  1193. vc = [vc init];
  1194. [g_navigation pushViewController:vc animated:YES];
  1195. p = nil;
  1196. }
  1197. -(void)onSendTimeout:(NSNotification *)notifacation//超时未收到回执
  1198. {
  1199. // NSLog(@"onSendTimeout");
  1200. [_wait stop];
  1201. // [g_App showAlert:Localized(@"JXAlert_SendFilad")];
  1202. // [JXMyTools showTipView:Localized(@"JXAlert_SendFilad")];
  1203. }
  1204. -(void)newReceipt:(NSNotification *)notifacation{//新回执
  1205. // NSLog(@"newReceipt");
  1206. JXMessageObject *msg = (JXMessageObject *)notifacation.object;
  1207. if(msg == nil)
  1208. return;
  1209. if(![msg isAddFriendMsg])
  1210. return;
  1211. [_wait stop];
  1212. if([msg.type intValue] == XMPP_TYPE_DELALL){
  1213. if([msg.toUserId isEqualToString:_currentUser.userId] || [msg.fromUserId isEqualToString:_currentUser.userId]){
  1214. [_array removeObject:_currentUser];
  1215. _currentUser = nil;
  1216. [self getArrayData];
  1217. [_table reloadData];
  1218. // [g_App showAlert:Localized(@"JXAlert_DeleteFirend")];
  1219. }
  1220. }
  1221. if([msg.type intValue] == XMPP_TYPE_BLACK){//拉黑
  1222. for (JXUserObject *obj in _array) {
  1223. if ([obj.userId isEqualToString:_currentUser.userId]) {
  1224. [_array removeObject:obj];
  1225. break;
  1226. }
  1227. }
  1228. [self getArrayData];
  1229. [self.tableView reloadData];
  1230. }
  1231. if([msg.type intValue] == XMPP_TYPE_NOBLACK){
  1232. // _currentUser.status = [NSNumber numberWithInt:friend_status_friend];
  1233. // int status = [_currentUser.status intValue];
  1234. // [_currentUser update];
  1235. if (!_currentUser) {
  1236. return;
  1237. }
  1238. [[JXXMPP sharedInstance].blackList removeObject:_currentUser.userId];
  1239. [JXMessageObject msgWithFriendStatus:_currentUser.userId status:friend_status_friend];
  1240. for (JXUserObject *obj in _array) {
  1241. if ([obj.userId isEqualToString:_currentUser.userId]) {
  1242. [_array removeObject:obj];
  1243. break;
  1244. }
  1245. }
  1246. [self getArrayData];
  1247. [self.tableView reloadData];
  1248. // [g_App showAlert:Localized(@"JXAlert_MoveBlackList")];
  1249. }
  1250. if([msg.type intValue] == XMPP_TYPE_PASS){//通过
  1251. [self getFriend];
  1252. }
  1253. }
  1254. - (void)friendRemarkNotif:(NSNotification *)notif {
  1255. JXUserObject *user = notif.object;
  1256. for (int i = 0; i < _array.count; i ++) {
  1257. JXUserObject *user1 = _array[i];
  1258. if ([user.userId isEqualToString:user1.userId]) {
  1259. user1.userNickname = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  1260. user1.remarkName = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  1261. [_table reloadData];
  1262. break;
  1263. }
  1264. }
  1265. }
  1266. - (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title icon:(NSString *)iconName action:(SEL)action {
  1267. UIButton *button = [[UIButton alloc] init];
  1268. button.frame = frame;
  1269. [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
  1270. UIImageView *imgV = [[UIImageView alloc] init];
  1271. imgV.frame = CGRectMake((button.frame.size.width-IMAGE_HEIGHT)/2, 20, IMAGE_HEIGHT, IMAGE_HEIGHT);
  1272. imgV.image = [UIImage imageNamed:iconName];
  1273. [button addSubview:imgV];
  1274. CGSize size = [title boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(14)} context:nil].size;
  1275. UILabel *lab = [[UILabel alloc] init];
  1276. lab.text = title;
  1277. lab.font = SYSFONT(14);
  1278. lab.textAlignment = NSTextAlignmentCenter;
  1279. lab.textColor = HEXCOLOR(0x323232);
  1280. if (size.width >= button.frame.size.width) {
  1281. size.width = button.frame.size.width-20;
  1282. }
  1283. lab.frame = CGRectMake(0, CGRectGetMaxY(imgV.frame)+INSET_HEIGHT, size.width, size.height);
  1284. CGPoint center = lab.center;
  1285. center.x = imgV.center.x;
  1286. lab.center = center;
  1287. CGRect btnFrame = button.frame;
  1288. btnFrame.size.height = CGRectGetMaxY(imgV.frame)+INSET_HEIGHT+size.height;
  1289. button.frame = btnFrame;
  1290. [button addSubview:lab];
  1291. return button;
  1292. }
  1293. -(void)customerClick:(UIButton *)sender{
  1294. // UIButton *btn = (UIButton *)[self.view viewWithTag:sender.tag];
  1295. if (self.customerArr[sender.tag - 1][@"link"]) {
  1296. CYWebCustomerServiceVC *vc = [[CYWebCustomerServiceVC alloc] init];
  1297. vc.titleName = self.customerArr[sender.tag - 1][@"name"];
  1298. vc.link = self.customerArr[sender.tag - 1][@"link"];
  1299. [self presentViewController:vc animated:YES completion:^{
  1300. }];
  1301. }else {
  1302. NSLog(@"链接不存在!!!!!!!!");
  1303. }
  1304. }
  1305. @end