JXCsHomeVc.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. //
  2. // JXCsHomeVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/4/28.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. // (@"JXMainViewController_Message") PSMyViewController
  8. #import "JXCsHomeVc.h"
  9. #import "UIView+LK.h"
  10. #import "CYWebAddPointVC.h"
  11. #import "XMGMainViewController.h"
  12. #import "JXShowMainView.h"
  13. #import "YPTabBarController.h"
  14. #import "JXProgressVC.h"
  15. #import "JXLabelObject.h"
  16. #import "JXXMPP.h"
  17. #import "JXProgressVC.h"
  18. #import "JXGroupViewController.h"
  19. #import "OrganizTreeViewController.h"
  20. #import "JXLabelObject.h"
  21. #import "JXBlogRemind.h"
  22. #import "JXRoomPool.h"
  23. #import "JXDeviceAuthController.h"
  24. #import "UIColor+Util.h"
  25. #import "UIColor+XQColor.h"
  26. #import "JXBlogRemind.h"
  27. @interface JXCsHomeVc ()<UIScrollViewDelegate>
  28. /** 标签栏底部的红色指示器 */
  29. @property (nonatomic, weak) UIView *indicatorView;
  30. /** 当前选中的按钮 */
  31. @property (nonatomic, weak) UIButton *selectedButton;
  32. @property (nonatomic, weak) UIButton *button_n;
  33. @property (nonatomic,copy) NSString *linkName1;
  34. @property (nonatomic,copy) NSString *linkURL1;
  35. @property (nonatomic,copy) NSString *imgUrl1;
  36. @property (weak, nonatomic) UIView *sliderView;
  37. @property (strong, nonatomic) MASConstraint *sliderViewCenterX;
  38. @property (weak, nonatomic) UIButton *refreshButton;
  39. @property (weak, nonatomic) UIButton *homeButton;
  40. @property (nonatomic,strong) NSString *indexGhome;
  41. @end
  42. @implementation JXCsHomeVc
  43. -(instancetype)init{
  44. if (self=[super init]) {
  45. [g_notify addObserver:self selector:@selector(onXmppLoginChanged:) name:kXmppLoginNotifaction object:nil];
  46. [g_notify addObserver:self selector:@selector(newMsgCome:) name:kXMPPNewMsgNotifaction object:nil];//收到了一条新消息
  47. [g_notify addObserver:self selector:@selector(hiddenTipLabel:) name:@"hiddenTip" object:nil];//收到了一条新消息
  48. [g_notify addObserver:self selector:@selector(goBack:) name:@"longGoback" object:nil];
  49. }
  50. return self;
  51. }
  52. - (void)hiddenTipLabel:(NSNotification *)note{
  53. self.countTipL.hidden=YES;
  54. }
  55. - (void)newMsgCome:(NSNotification *)note{
  56. self.countTipL.hidden=NO;
  57. }
  58. -(void)setStrURL:(NSString *)strURL{
  59. self.countTipL.hidden=YES;
  60. }
  61. - (void)viewDidAppear:(BOOL)animated{
  62. [super viewDidAppear:animated];
  63. }
  64. - (void)viewDidLoad {
  65. [super viewDidLoad];
  66. // 获取服务器时间
  67. // [g_server getCurrentTimeToView:self];
  68. // [g_server offlineOperation:(g_server.lastOfflineTime *1000 + g_server.timeDifference)/1000 toView:self];
  69. //NSLog(@"login_%@",g_server.myself.userId);
  70. // [g_server getUser:g_server.myself.userId toView:self];
  71. //CGFloat lastOffLineTime=(g_server.lastOfflineTime *1000 + 0)/1000;
  72. // CGFloat lastOffLineTime2=(g_server.timeDifference)/1000;
  73. [self setupChildViewControllers];
  74. [self setupNavBar];
  75. [self setupContentView];
  76. [self setupTitlesView];
  77. // [self.topButton addTarget:self action:@selector(topBtnClick) forControlEvents:UIControlEventTouchUpInside];
  78. [g_notify addObserver:self selector:@selector(showAD) name:kLaunchAdShowFinishNotifaction object:nil];
  79. [g_notify addObserver:self selector:@selector(changeNodeTitle:) name:@"changeNodeTitleNotifaction" object:nil];
  80. // self.contentView.delaysContentTouches=NO;
  81. // self.contentView.canCancelContentTouches=NO;
  82. }
  83. -(void)onXmppLoginChanged:(NSNumber*)isLogin{
  84. if([JXXMPP sharedInstance].isLogined == login_status_yes){
  85. // 获取离线调用接口列表
  86. CGFloat lastOffLineTime=(g_server.lastOfflineTime *1000 + 0)/1000;
  87. CGFloat lastOffLineTime2=(g_server.timeDifference)/1000;
  88. //[g_server offlineOperation:(g_server.lastOfflineTime *1000 + g_server.timeDifference)/1000 toView:self];
  89. [self onAfterLogin];
  90. }
  91. }
  92. -(void)onAfterLogin{
  93. // [_msgVc scrollToPageUp];
  94. }
  95. - (void)showAD {
  96. [JXShowMainView showView];
  97. }
  98. - (void)dealloc {
  99. [g_notify removeObserver:self];
  100. }
  101. - (void)setupContentView
  102. {
  103. UIScrollView *contentView = [[UIScrollView alloc] init];
  104. contentView.backgroundColor = kRGBColor(250, 250, 250);
  105. contentView.frame = CGRectMake(0, JX_SCREEN_TOP, self.view.bounds.size.width, self.view.bounds.size.height-JX_SCREEN_TOP);
  106. contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  107. contentView.delegate = self;
  108. contentView.showsHorizontalScrollIndicator = NO;
  109. contentView.showsVerticalScrollIndicator = NO;
  110. contentView.pagingEnabled = YES;
  111. contentView.bounces=NO;
  112. contentView.contentSize = CGSizeMake(contentView.xmg_width * self.childViewControllers.count, 0);
  113. [self.view addSubview:contentView];
  114. self.contentView = contentView;
  115. return;
  116. id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
  117. UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil];
  118. [contentView addGestureRecognizer:pan];
  119. UISwipeGestureRecognizer * swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
  120. swipeRight.direction = UISwipeGestureRecognizerDirectionLeft;
  121. [contentView addGestureRecognizer:swipeRight];
  122. UISwipeGestureRecognizer * swipeleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
  123. swipeleft.direction = UISwipeGestureRecognizerDirectionRight;
  124. [contentView addGestureRecognizer:swipeleft];
  125. // 手势的优先级 优先响应swipe手势
  126. [pan requireGestureRecognizerToFail:swipeRight];
  127. [pan requireGestureRecognizerToFail:swipeleft];
  128. }
  129. -(void)swipeAction:(UISwipeGestureRecognizer *)sender {
  130. if (sender.direction ==UISwipeGestureRecognizerDirectionLeft) {
  131. int index =1;
  132. [self titleClick:self.titlesView.subviews[index]];
  133. [self switchController:index];
  134. }else if(sender.direction ==UISwipeGestureRecognizerDirectionRight){
  135. int index =0;
  136. [self titleClick:self.titlesView.subviews[index]];
  137. [self switchController:index];
  138. }
  139. }
  140. - (void)goBack:(NSNotification *)note{
  141. [self.contentView setContentOffset:CGPointMake(0 * JX_SCREEN_WIDTH, self.contentView.contentOffset.y) animated:YES];
  142. self.selectedButton.enabled = YES;
  143. _topButton.enabled = NO;
  144. self.selectedButton = _topButton;
  145. // 消除约束
  146. [self.sliderViewCenterX uninstall];
  147. self.sliderViewCenterX = nil;
  148. // 添加约束
  149. [self.sliderView mas_makeConstraints:^(MASConstraintMaker *make) {
  150. self.sliderViewCenterX = make.centerX.equalTo(_topButton);
  151. }];
  152. [UIView animateWithDuration:0.25 animations:^{
  153. [self.sliderView layoutIfNeeded];
  154. }];
  155. }
  156. -(void)setBlcokBTb:(shuaxinBtn)blcokBTb{
  157. //获取说有群信息
  158. // [g_server listHisRoom:0 pageSize:1000 toView:self];
  159. [self setupChildViewControllers];
  160. [self setupNavBar];
  161. [self setupContentView];
  162. [self setupTitlesView];
  163. _indexGhome=@"1";
  164. int index =0;
  165. [self titleClick:self.topButton];
  166. [self switchController:index];
  167. }
  168. - (void)goHomeWebPage {
  169. [g_notify postNotificationName:KGoHomeWebPageNotification object:nil];
  170. }
  171. - (void)goRefreshWebPage {
  172. [g_notify postNotificationName:KGoRefreshWebPageNotification object:nil];
  173. }
  174. - (void)setupTitlesView
  175. {
  176. UIView *backView = [[UIView alloc] init];
  177. backView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
  178. backView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  179. backView.frame = CGRectMake(0, 0, self.view.frame.size.width, JX_SCREEN_TOP);
  180. backView.userInteractionEnabled=YES;
  181. [self.view addSubview:backView];
  182. UIButton *homeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
  183. homeButton.frame =CGRectMake(10, JX_STATUSBAR_H, 30, 30);
  184. [homeButton setImage:[UIImage imageNamed:@"home_home"] forState:(UIControlStateNormal)];
  185. [backView addSubview:homeButton];
  186. [homeButton addTarget:self action:@selector(goHomeWebPage) forControlEvents:(UIControlEventTouchUpInside)];
  187. _homeButton = homeButton;
  188. UIButton *refreshButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
  189. refreshButton.frame =CGRectMake(JX_SCREEN_WIDTH-100, JX_STATUSBAR_H, 90, 30);
  190. [refreshButton setImage:[UIImage imageNamed:@"home_refresh"] forState:(UIControlStateNormal)];
  191. [refreshButton setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
  192. refreshButton.contentMode=UIViewContentModeScaleAspectFit;
  193. [backView addSubview:refreshButton];
  194. NSString *selectUrl = [g_default objectForKey:@"selectNodeName"];
  195. if (selectUrl.length>0) {
  196. [refreshButton setTitle:selectUrl forState:(UIControlStateNormal)];
  197. }else{
  198. [refreshButton setTitle:@" 节点1 " forState:(UIControlStateNormal)];
  199. }
  200. //[refreshButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 60, 0, 0)];
  201. //[refreshButton setImageEdgeInsets:UIEdgeInsetsMake(0, 50, 0, 0)];
  202. //[refreshButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0,0,60)];
  203. [refreshButton addTarget:self action:@selector(goRefreshWebPage) forControlEvents:(UIControlEventTouchUpInside)];
  204. _refreshButton = refreshButton;
  205. UIView *titlesView = [[UIView alloc] init];
  206. titlesView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
  207. titlesView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  208. titlesView.frame = CGRectMake(self.view.frame.size.width/3, 0, self.view.frame.size.width/3, JX_SCREEN_TOP);
  209. [backView addSubview:titlesView];
  210. self.titlesView = titlesView;
  211. // 5个按钮
  212. XMGTitleButton *button = [self setupTitleButton:@"购彩"];
  213. [self setupTitleButton:@"聊天"];
  214. [self titleClick:button];
  215. [self switchController:0];
  216. self.topButton=button;
  217. // 底部滑条
  218. UIView *sliderView = [[UIView alloc] init];
  219. sliderView.backgroundColor = [UIColor redColor];
  220. [self.titlesView addSubview:sliderView];
  221. self.sliderView = sliderView;
  222. [sliderView mas_makeConstraints:^(MASConstraintMaker *make) {
  223. make.size.mas_equalTo(CGSizeMake([[button titleForState:UIControlStateNormal] sizeWithAttributes:@{NSFontAttributeName : button.titleLabel.font}].width/1.5, 3));
  224. make.bottom.mas_equalTo(self.titlesView.mas_bottom).mas_offset(-4);
  225. self.sliderViewCenterX = make.centerX.equalTo(button);
  226. }];
  227. UILabel *tipLable=[[UILabel alloc]init];
  228. tipLable.backgroundColor=[UIColor redColor];
  229. tipLable.layer.cornerRadius=4;
  230. tipLable.layer.masksToBounds=YES;
  231. [titlesView addSubview:tipLable];
  232. tipLable.hidden=YES;
  233. self.countTipL=tipLable;
  234. [tipLable mas_makeConstraints:^(MASConstraintMaker *make) {
  235. make.width.mas_equalTo(8);
  236. make.height.mas_equalTo(8);
  237. make.top.mas_equalTo(JX_SCREEN_HEIGHT>=812?49:25);
  238. make.left.mas_equalTo(self.titlesView.xmg_width-15);
  239. }];
  240. }
  241. - (void)changeNodeTitle:(NSNotification *)note{
  242. NSString *nodeStr=note.object;
  243. _refreshButton.frame =CGRectMake(JX_SCREEN_WIDTH-100, JX_STATUSBAR_H, 90, 30);
  244. [_refreshButton setImage:[UIImage imageNamed:@"home_refresh"] forState:(UIControlStateNormal)];
  245. _refreshButton.contentMode=UIViewContentModeScaleAspectFit;
  246. [_refreshButton setTitle:[NSString stringWithFormat:@" %@ ",nodeStr] forState:(UIControlStateNormal)];
  247. }
  248. - (XMGTitleButton *)setupTitleButton:(NSString *)title
  249. {
  250. XMGTitleButton *button = [XMGTitleButton buttonWithType:UIButtonTypeCustom];
  251. [button setTitle:title forState:UIControlStateNormal];
  252. [button addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
  253. [self.titlesView addSubview:button];
  254. self.topButton=button;
  255. [button mas_makeConstraints:^(MASConstraintMaker *make) {
  256. make.width.mas_equalTo(self.titlesView.xmg_width/2);
  257. make.top.mas_equalTo(JX_SCREEN_HEIGHT>=812?44:20);
  258. NSUInteger index = self.titlesView.subviews.count - 1;
  259. if (index == 0) {
  260. make.left.mas_equalTo(self.titlesView);
  261. } else {
  262. make.left.mas_equalTo(self.titlesView.xmg_width/2);
  263. }
  264. }];
  265. return button;
  266. }
  267. - (void)titleClick:(UIButton *)button
  268. {
  269. self.selectedButton.enabled = YES;
  270. button.enabled = NO;
  271. self.selectedButton = button;
  272. // 消除约束
  273. [self.sliderViewCenterX uninstall];
  274. self.sliderViewCenterX = nil;
  275. // 添加约束
  276. [self.sliderView mas_makeConstraints:^(MASConstraintMaker *make) {
  277. self.sliderViewCenterX = make.centerX.equalTo(button);
  278. }];
  279. [UIView animateWithDuration:0.25 animations:^{
  280. [self.sliderView layoutIfNeeded];
  281. }];
  282. if ([_indexGhome isEqualToString:@"1"]) {
  283. [self.contentView setContentOffset:CGPointMake(0 * self.contentView.frame.size.width, self.contentView.contentOffset.y) animated:YES];
  284. }else{
  285. int index = (int)[self.titlesView.subviews indexOfObject:button];
  286. [self.contentView setContentOffset:CGPointMake(index * self.contentView.frame.size.width, self.contentView.contentOffset.y) animated:YES];
  287. }
  288. }
  289. - (void)setupNavBar
  290. {
  291. self.automaticallyAdjustsScrollViewInsets = NO;
  292. }
  293. - (void)setupChildViewControllers
  294. {
  295. CYWebAddPointVC *vc = [[CYWebAddPointVC alloc] init];
  296. NSString *memberAcc=[[NSUserDefaults standardUserDefaults] objectForKey:@"www_url"];
  297. NSString *selectNodeUrl=[[NSUserDefaults standardUserDefaults] objectForKey:@"selectNodeUrl"];
  298. if (selectNodeUrl.length>0) {
  299. vc.strURL=selectNodeUrl;
  300. }else{
  301. vc.strURL=memberAcc;
  302. }
  303. [self addChildViewController:vc];
  304. [self addChildViewController:[XMGMainViewController new]];
  305. return;
  306. [self setupOneChildViewController:vc];
  307. [self setupOneChildViewController:[XMGMainViewController new]];
  308. }
  309. - (void)setupOneChildViewController:(UIViewController *)type
  310. {
  311. if([type isKindOfClass:[CYWebAddPointVC class]]){
  312. CYWebAddPointVC *vc = [[CYWebAddPointVC alloc] init];
  313. NSString *memberAcc=[[NSUserDefaults standardUserDefaults] objectForKey:@"www_url"];
  314. NSString *selectNodeUrl=[[NSUserDefaults standardUserDefaults] objectForKey:@"selectNodeUrl"];
  315. if (selectNodeUrl.length>0) {
  316. vc.strURL=selectNodeUrl;
  317. }else{
  318. vc.strURL=memberAcc;
  319. }
  320. [self addChildViewController:vc];
  321. }else{
  322. // XMGTabarVC JXXMMainVc。XMGMainViewController JXXMMainVc
  323. XMGMainViewController *vc = [[XMGMainViewController alloc] init];
  324. [self addChildViewController:vc];
  325. }
  326. }
  327. - (void)switchController:(int)index
  328. {
  329. [g_notify postNotificationName:@"KOPENLONG" object:@(index)];
  330. if (index == 1) {
  331. _homeButton.hidden = YES;
  332. _refreshButton.hidden = YES;
  333. }else {
  334. _homeButton.hidden = NO;
  335. _refreshButton.hidden = NO;
  336. }
  337. CYWebAddPointVC *vc = self.childViewControllers[index];
  338. vc.view.xmg_y = 0;
  339. vc.view.xmg_width = self.contentView.xmg_width;
  340. vc.view.xmg_height = self.contentView.xmg_height;
  341. vc.view.xmg_x = vc.view.xmg_width * index;
  342. [self.contentView addSubview:vc.view];
  343. }
  344. #pragma mark - <UIScrollViewDelegate>
  345. - (void)scrollViewDidEndDecelerating:(nonnull UIScrollView *)scrollView
  346. {
  347. int index = scrollView.contentOffset.x / scrollView.frame.size.width;
  348. // NSString *msgStr=[g_default objectForKey:@"refushMsgHistoryxxx"];
  349. // if (msgStr.length>0) {
  350. //
  351. // }else{
  352. //
  353. // [g_notify postNotificationName:@"refushMsgHistoryxxx" object:nil];
  354. //
  355. // [g_default setObject:@"refushMsgHistoryxxx" forKey:@"refushMsgHistoryxxx"];
  356. // [g_default synchronize];
  357. // }
  358. [self titleClick:self.titlesView.subviews[index]];
  359. [self switchController:index];
  360. }
  361. - (void)scrollViewDidEndScrollingAnimation:(nonnull UIScrollView *)scrollView
  362. {
  363. int a=(int)(scrollView.contentOffset.x / scrollView.frame.size.width);
  364. // NSString *msgStr=[g_default objectForKey:@"refushMsgHistoryxxx"];
  365. // if (msgStr.length>0) {
  366. //
  367. // }else{
  368. //
  369. // [g_notify postNotificationName:@"refushMsgHistoryxxx" object:nil];
  370. //
  371. // [g_default setObject:@"refushMsgHistoryxxx" forKey:@"refushMsgHistoryxxx"];
  372. // [g_default synchronize];
  373. // }
  374. [self switchController:a];
  375. //
  376. }
  377. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  378. //更新本地好友
  379. if ([aDownload.action isEqualToString:act_UserGet]) {
  380. NSString *memberAcc= dict[@"membershipAccount"];
  381. [[NSUserDefaults standardUserDefaults] setObject:memberAcc forKey:@"membershipAccount_ID"];
  382. [[NSUserDefaults standardUserDefaults] synchronize];
  383. }
  384. if ([aDownload.action isEqualToString:act_AttentionList]) {
  385. JXProgressVC * pv = [JXProgressVC alloc];
  386. pv.dataArray = array1;
  387. pv = [pv init];
  388. if (array1.count > 300) {
  389. [g_navigation pushViewController:pv animated:YES];
  390. }
  391. // [self.view addSubview:pv.view];
  392. }
  393. // 同步标签
  394. if ([aDownload.action isEqualToString:act_FriendGroupList]) {
  395. for (NSInteger i = 0; i < array1.count; i ++) {
  396. NSDictionary *dict = array1[i];
  397. JXLabelObject *labelObj = [[JXLabelObject alloc] init];
  398. labelObj.groupId = dict[@"groupId"];
  399. labelObj.groupName = dict[@"groupName"];
  400. labelObj.userId = dict[@"userId"];
  401. NSArray *userIdList = dict[@"userIdList"];
  402. NSString *userIdListStr = [userIdList componentsJoinedByString:@","];
  403. if (userIdListStr.length > 0) {
  404. labelObj.userIdList = [NSString stringWithFormat:@"%@", userIdListStr];
  405. }
  406. [labelObj insert];
  407. }
  408. // 删除服务器上已经删除的
  409. NSArray *arr = [[JXLabelObject sharedInstance] fetchAllLabelsFromLocal];
  410. for (NSInteger i = 0; i < arr.count; i ++) {
  411. JXLabelObject *locLabel = arr[i];
  412. BOOL flag = NO;
  413. for (NSInteger j = 0; j < array1.count; j ++) {
  414. NSDictionary * dict = array1[j];
  415. if ([locLabel.groupId isEqualToString:dict[@"groupId"]]) {
  416. flag = YES;
  417. break;
  418. }
  419. }
  420. if (!flag) {
  421. [locLabel delete];
  422. }
  423. }
  424. }
  425. if ([aDownload.action isEqualToString:act_offlineOperation]) {
  426. for (NSDictionary *dict in array1) {
  427. if ([[dict objectForKey:@"tag"] isEqualToString:@"label"]) {
  428. [g_notify postNotificationName:kOfflineOperationUpdateLabelList object:nil];
  429. }
  430. else if ([[dict objectForKey:@"tag"] isEqualToString:@"friend"]) {
  431. [g_server getUser:[dict objectForKey:@"friendId"] toView:self];
  432. }
  433. else if ([[dict objectForKey:@"tag"] isEqualToString:@"room"]) {
  434. [g_server getRoom:[dict objectForKey:@"friendId"] toView:self];
  435. }
  436. }
  437. }
  438. if ([aDownload.action isEqualToString:act_UserGet]) {
  439. JXUserObject *user = [[JXUserObject alloc] init];
  440. [user getDataFromDict:dict];
  441. NSString *gradeIndexcc= dict[@"gradeIndex"];
  442. [[NSUserDefaults standardUserDefaults] setObject:gradeIndexcc forKey:@"gradeIndexcc"];
  443. [[NSUserDefaults standardUserDefaults] synchronize];
  444. if ([user.userId intValue] == [MY_USER_ID intValue]) {
  445. [g_server doSaveUser:dict];
  446. user.bubbleFontId = [dict objectForKey:@"bubbleFontId"];
  447. user.gradeIndex = [dict objectForKey:@"gradeIndex"];
  448. // 保存自己
  449. [user insert];
  450. [user update];
  451. }else {
  452. JXUserObject *user1 = [[JXUserObject sharedInstance] getUserById:user.userId];
  453. user.content = user1.content;
  454. user.timeSend = user1.timeSend;
  455. [user update];
  456. }
  457. [g_notify postNotificationName:kOfflineOperationUpdateUserSet object:user];
  458. }
  459. if ([aDownload.action isEqualToString:act_roomGet]) {
  460. JXUserObject *user = [[JXUserObject alloc] init];
  461. [user getDataFromDict:dict];
  462. user.userId = [dict objectForKey:@"jid"];
  463. user.roomId = [dict objectForKey:@"id"];
  464. user.userNickname = [dict objectForKey:@"name"];
  465. if(![g_xmpp.roomPool getRoom:user.userId] || ![user haveTheUser]){
  466. user.userDescription = [dict objectForKey:@"desc"];
  467. user.showRead = [dict objectForKey:@"showRead"];
  468. user.showMember = [dict objectForKey:@"showMember"];
  469. user.allowSendCard = [dict objectForKey:@"allowSendCard"];
  470. user.chatRecordTimeOut = [dict objectForKey:@"chatRecordTimeOut"];
  471. user.talkTime = [dict objectForKey:@"talkTime"];
  472. user.allowInviteFriend = [dict objectForKey:@"allowInviteFriend"];
  473. user.allowUploadFile = [dict objectForKey:@"allowUploadFile"];
  474. user.allowConference = [dict objectForKey:@"allowConference"];
  475. user.allowSpeakCourse = [dict objectForKey:@"allowSpeakCourse"];
  476. user.offlineNoPushMsg = [(NSDictionary *)[dict objectForKey:@"member"] objectForKey:@"offlineNoPushMsg"];
  477. user.isNeedVerify = [dict objectForKey:@"isNeedVerify"];
  478. user.createUserId = [dict objectForKey:@"userId"];
  479. user.content = @" ";
  480. user.topTime = nil;
  481. [user insertRoom];
  482. // [g_xmpp.roomPool joinRoom:user.userId title:user.userNickname lastDate:nil isNew:NO];
  483. }else {
  484. NSDictionary * groupDict = [user toDictionary];
  485. roomData * roomdata = [[roomData alloc] init];
  486. [roomdata getDataFromDict:groupDict];
  487. [roomdata getDataFromDict:dict];
  488. JXUserObject *user1 = [[JXUserObject sharedInstance] getUserById:roomdata.roomJid];
  489. user.content = user1.content;
  490. user.status = user1.status;
  491. user.offlineNoPushMsg = [NSNumber numberWithBool:roomdata.offlineNoPushMsg];
  492. user.msgsNew = user1.msgsNew;
  493. [user update];
  494. }
  495. [g_notify postNotificationName:kOfflineOperationUpdateUserSet object:user];
  496. }
  497. }
  498. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  499. return hide_error;
  500. }
  501. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  502. return hide_error;
  503. }
  504. @end