JXCsHomeVc.m 22 KB

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