JXAddrBookFriendVc.m 58 KB

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