TopicesVC.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. #import "TopicesVC.h"
  2. #import "CommunityCell.h"
  3. #import "TopicVC.h"
  4. #import "LoginViewController.h"
  5. #import "PostTopicVC.h"
  6. #import "EXButton.h"
  7. #import <MJRefresh.h>
  8. typedef NS_ENUM(NSInteger, MyGetDataType) {
  9. //正常请求数据
  10. MyGetDataTypeNomal=0,
  11. //下拉刷新请求数据
  12. MyGetDataTypeHeaderRefresh,
  13. //上拉加载更多请求数据
  14. MyGetDataTypeFooterRefresh
  15. };
  16. @interface TopicesVC ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate,CommunityCellDelegate>
  17. {
  18. /**多个topic
  19. */
  20. NSMutableArray* models;
  21. UITableView* myTableView;
  22. UILabel* lblTopicCnt,* lblStuCnt;
  23. UIView* moodV;
  24. UIButton* moodBg;
  25. //记录页书
  26. NSInteger _currentPageNum;
  27. //加载数据的类型
  28. MyGetDataType _getDataType;
  29. //正在加载的状态
  30. BOOL _IS_LOADING;
  31. }
  32. @end
  33. @implementation TopicesVC
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. [self myInit];
  37. [self setRefreshAction];
  38. [self getModelsAsyc];
  39. }
  40. - (void)didReceiveMemoryWarning {
  41. [super didReceiveMemoryWarning];
  42. }
  43. -(void)viewDidAppear:(BOOL)animated
  44. {
  45. [super viewDidAppear:animated];
  46. }
  47. #pragma mark -
  48. /**注意这里是导航栏带来的Y值偏移
  49. */
  50. -(void)myInit
  51. {
  52. [self configNavigationBar];
  53. self.navigationController.navigationBar.translucent = NO;
  54. [self.view setBackgroundColor:[UIColor whiteColor]];
  55. _currentPageNum = 0;
  56. _getDataType = MyGetDataTypeNomal;
  57. _IS_LOADING = NO;
  58. models = [NSMutableArray array];
  59. CGFloat x,y,w,h,bd;
  60. //最好是。它们的tag值不要变。
  61. NSArray* arr = @[@"最新话题",@"吐槽",@"晒图",@"找驾校",@"科目一",
  62. @"科目二",@"科目三",@"科目四",@"下证",@"许愿",
  63. @"科目一学员",@"科目一考试",@"科目二学员",@"科目二考试",@"科目三学员",
  64. @"科目三考试",@"科目四学员",@"下证学员",@"报名学员",@"unknown",@"unknown",@"unknown"];
  65. if (1 == _type.intValue || 2 == _type.intValue)
  66. {
  67. if ([_groupId isEqualToString:@"-1"]) {
  68. if (_jxjc.length == 0)
  69. {
  70. if (defUser.userSchDict) {
  71. NSString* str = [defUser.userSchDict objectForKey:@"shortName"];
  72. [self setTitle:str];
  73. }
  74. }
  75. else
  76. {
  77. [self setTitle:_jxjc];
  78. }
  79. }else{
  80. [self setTitle:arr[_groupId.intValue]];
  81. }
  82. }
  83. if( 2 == [_type intValue]){
  84. [self setTitle:@"学车记录"];
  85. }
  86. if( 3 == [_type intValue]){
  87. [self setTitle:@"学车直播"];
  88. }
  89. if (4 == _type.intValue) {
  90. [self setTitle:@"学车问答"];
  91. }
  92. y = 0;
  93. x = 0;
  94. w = kSize.width;
  95. h = kSize.width*201/721;
  96. UIImageView* imgV = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  97. [imgV setImage:[UIImage imageNamed:@"subject_main_banner.jpg"]];
  98. [imgV setContentMode:UIViewContentModeScaleAspectFill];
  99. // h += 40;
  100. UIView *header = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  101. [header addSubview:imgV];
  102. y = h-40;
  103. h = 40;
  104. w = kSize.width/2.0;
  105. x = 0;
  106. UILabel* label;
  107. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  108. [label setFont:[UIFont scaleSize:NormalFont]];
  109. [label setBackgroundColor:[UIColor colorWithWhite:.2 alpha:.6]];
  110. [label setTextAlignment:NSTextAlignmentCenter];
  111. [label setTextColor:[UIColor whiteColor]];
  112. [label setText:@"话题"];
  113. // [header addSubview:label];
  114. lblTopicCnt = label;
  115. x+=w;
  116. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  117. [label setBackgroundColor:[UIColor colorWithWhite:.2 alpha:.6]];
  118. [label setFont:[UIFont scaleSize:NormalFont]];
  119. [label setTextAlignment:NSTextAlignmentCenter];
  120. [label setTextColor:[UIColor whiteColor]];
  121. [label setText:@"驾友"];
  122. // [header addSubview:label];
  123. lblStuCnt = label;
  124. UITableView *tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - 60 - kNavOffSet - kSafeAreaBottomHeight) style:UITableViewStyleGrouped];
  125. [self.view addSubview:tv];
  126. //当把table的style设为group之后。table的背景色莫名变灰
  127. [tv setBackgroundColor:[UIColor whiteColor]];
  128. myTableView = tv;
  129. [myTableView setDelegate:self];
  130. [myTableView setDataSource:self];
  131. [myTableView setTableHeaderView:header];
  132. [myTableView setTableFooterView:[UIView new]];
  133. if ([tv respondsToSelector:@selector(setSeparatorInset:)])
  134. {
  135. [tv setSeparatorInset:UIEdgeInsetsZero];
  136. }
  137. if ([tv respondsToSelector:@selector(setLayoutMargins:)])
  138. {
  139. [tv setLayoutMargins:UIEdgeInsetsZero];
  140. }
  141. x = 0;
  142. w = kSize.width;
  143. h = 60;
  144. y = kSize.height - h - kNavOffSet - kSafeAreaBottomHeight;
  145. UIView* vi;
  146. vi = [UIView new];
  147. [vi setFrame:CGRectMake(x, y, w, h)];
  148. [vi setBackgroundColor:backGroundColor];
  149. [self.view addSubview:vi];
  150. NSInteger tag = 0;
  151. STButton* stBtn;
  152. y = 0;
  153. w = 80;
  154. x = (kSize.width - w)/2.0;
  155. stBtn = [STButton new];
  156. [stBtn setFrame:CGRectMake(x, y, w, h)];
  157. [vi addSubview:stBtn];
  158. arr = @[@"placeHolder",@"发布话题",@"我要记录",@"我要直播",@"我要提问",@"unknown"];
  159. [stBtn setImage:[UIImage imageNamed:@"community2.png"] withTitle:arr[_type.intValue] Font:13 forState:UIControlStateNormal];
  160. [stBtn setTag:tag++];
  161. [stBtn target:self];
  162. [stBtn setStyle:1];
  163. [stBtn setTitleColor:contentTextColor forState:UIControlStateNormal];
  164. UIButton* btn;
  165. btn = [[UIButton alloc] initWithFrame:kFrame];
  166. if ( 3 == _type.intValue) {
  167. [[UIApplication sharedApplication].keyWindow addSubview:btn];
  168. }
  169. [btn setBackgroundColor:[UIColor colorWithWhite:.01 alpha:.5]];
  170. [btn setTag:tag++];
  171. [btn target:self];
  172. moodBg = btn;
  173. [moodBg setHidden:YES];
  174. bd = 25;
  175. w = kSize.width - bd*2;
  176. h = w / 3.0 * 2.77;
  177. vi = [[UIView alloc] initWithFrame:CGRectMake(bd, -h, w, h)];
  178. [vi borderColor:[UIColor whiteColor] width:.01 cornorRadios:13];
  179. [btn addSubview:vi];
  180. moodV = vi;
  181. [vi setBackgroundColor:[UIColor whiteColor]];
  182. h = w*.3*.57;//.57 + .2
  183. label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, w, h)];
  184. [label setTextAlignment:NSTextAlignmentCenter];
  185. [label setText:@"你是什么心情?"];
  186. [label setTextColor:contentTextColor];
  187. [vi addSubview:label];
  188. btn = [[UIButton alloc] initWithFrame:CGRectMake(w - 40,10,30,30)];
  189. [btn setImage:[UIImage imageNamed:@"drawer_img08.png"] forState:UIControlStateNormal];
  190. [vi addSubview:btn];
  191. [btn setTag:tag++];
  192. [btn target:self];
  193. y += h;
  194. w /= 3.0;
  195. h = w;
  196. NSArray *images;
  197. images = @[@"mood0.png",@"mood1.png",@"mood2.png",@"mood3.png",@"mood4.png",@"mood5.png"];
  198. for (int i=0; i<images.count; i++) {
  199. btn = [[UIButton alloc] initWithFrame:CGRectMake(w*(i%3),y+h*(i/3), w-1, h-1)];
  200. [btn setImage:[UIImage imageNamed:images[i] ] forState:UIControlStateNormal];
  201. [vi addSubview:btn];
  202. [btn setTag:tag++];
  203. [btn target:self];
  204. }
  205. [RACObserve(RQ_SHARE_FUNCTION, shieldTopicIDArr) subscribeNext:^(NSArray *arr) {
  206. if (arr.count > 0 && models.count >0) {
  207. NSMutableArray *arrs = [NSMutableArray array];
  208. [[models.rac_sequence.signal filter:^BOOL(NSDictionary *dic) {
  209. return ![arr containsObject:dic[@"ID"]];
  210. }] subscribeNext:^(NSDictionary *dic) {
  211. [arrs addObject:dic];
  212. } completed:^{
  213. models = arrs;
  214. dispatch_sync(dispatch_get_main_queue(), ^{
  215. [myTableView reloadData];
  216. });
  217. }];
  218. }
  219. }];
  220. [RACObserve(RQ_SHARE_FUNCTION, shieldPeopleIDArr) subscribeNext:^(NSArray *arr) {
  221. if (arr.count > 0 && models.count >0) {
  222. NSMutableArray *arrs = [NSMutableArray array];
  223. [[models.rac_sequence.signal filter:^BOOL(NSDictionary *dic) {
  224. return ![arr containsObject:dic[@"TI_CRUSER"]];
  225. }] subscribeNext:^(NSDictionary *dic) {
  226. [arrs addObject:dic];
  227. } completed:^{
  228. models = arrs;
  229. dispatch_sync(dispatch_get_main_queue(), ^{
  230. [myTableView reloadData];
  231. });
  232. }];
  233. }
  234. }];
  235. }
  236. -(void)btnClick:(UIButton*)sender
  237. {
  238. NSInteger tag = sender.tag;
  239. //NSLog(@"btnClick %d",(int)sender.tag);
  240. if (0 == tag ) {
  241. if (!myDelegate.isLogin) {
  242. [LoginViewController loginFromVC:self];
  243. return;
  244. }
  245. }
  246. if (0 == tag && 3 == _type.intValue ) {
  247. //show MOOD
  248. [moodBg setHidden:NO];
  249. [UIView animateWithDuration:.3 animations:^{
  250. moodV.center = CGPointMake(moodBg.middleX, moodBg.middleY + 39);
  251. } completion:^(BOOL finished) {
  252. [UIView animateWithDuration:.2 animations:^{
  253. moodV.center = moodBg.center;
  254. } completion:^(BOOL finished) {
  255. }];
  256. }];
  257. return;
  258. }
  259. [self hideMood];
  260. if ( 1 == tag || 2 == tag) {
  261. //阴影背景。和关闭按钮。
  262. return;
  263. }
  264. PostTopicVC* vc = [PostTopicVC new];
  265. [vc complete:^{
  266. [self headerRefresh];
  267. }];
  268. vc.type = _type;
  269. vc.groupId = _groupId;
  270. vc.childID = _childID;
  271. vc.mood = tag - 2;
  272. [self navPushHideTabbarToVC:vc];
  273. }
  274. -(void)hideMood
  275. {
  276. if (moodBg.hidden) {
  277. return;
  278. }
  279. [UIView animateWithDuration:.3 animations:^{
  280. moodBg.alpha = 0;
  281. } completion:^(BOOL finished) {
  282. [moodBg setHidden:YES];
  283. [moodBg setAlpha:1];
  284. moodV.y = -moodV.height;
  285. }];
  286. }
  287. -(void)gotoComment:(NSString *)comId
  288. {
  289. if (!myDelegate.isLogin) {
  290. LoginViewController* vc = [[LoginViewController alloc] init];
  291. vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  292. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  293. [self presentViewController:vc animated:YES completion:nil];
  294. }else{
  295. TopicVC* vc = [[TopicVC alloc] init];
  296. [vc setTopicId:comId];
  297. [vc setTextViewActive:YES];
  298. [self navPushHideTabbarToVC:vc];
  299. }
  300. }
  301. #pragma mark 表的编辑
  302. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  303. {
  304. return communityCellHeight(models[indexPath.row] , 0);
  305. }
  306. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  307. {
  308. return models.count;
  309. }
  310. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  311. {
  312. CommunityCell* cell = [CommunityCell cellForTableView:tableView Style:0];
  313. //用于通知VC跳转到评论
  314. [cell setDelegate:self];
  315. if (models.count > 0) {
  316. [cell setModel:models[indexPath.row]];//崩溃 index 3 beyond bounds for empty array,出现次数3次
  317. if ([[models[indexPath.row] objectForKey:@"TI_TYPE"] integerValue] == 4) {
  318. if ([[models[indexPath.row] objectForKey:@"TI_IS_FINISH"] integerValue] > 0) {
  319. cell.acceptLabel.text = @"已解决";
  320. cell.acceptLabel.textColor = defGreen;
  321. cell.acceptLabel.layer.borderWidth = 1;
  322. cell.acceptLabel.layer.borderColor = defGreen.CGColor;
  323. }else{
  324. cell.acceptLabel.text = @"未解决";
  325. cell.acceptLabel.textColor = [UIColor redColor];
  326. cell.acceptLabel.layer.borderWidth = 1;
  327. cell.acceptLabel.layer.borderColor = [[UIColor redColor] CGColor];
  328. }
  329. }else{
  330. cell.acceptLabel.hidden = YES;
  331. }
  332. }
  333. return cell;
  334. }
  335. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  336. {
  337. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  338. NSDictionary* dict = models[indexPath.row];
  339. TopicVC* vc = [[TopicVC alloc] init];
  340. [vc setTopicId:dict[@"ID"]];
  341. [self navPushHideTabbarToVC:vc];
  342. }
  343. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  344. {
  345. if ([cell respondsToSelector:@selector(setSeparatorInset:)])
  346. {
  347. [cell setSeparatorInset:UIEdgeInsetsZero];
  348. }
  349. if ([cell respondsToSelector:@selector(setLayoutMargins:)])
  350. {
  351. [cell setLayoutMargins:UIEdgeInsetsZero];
  352. }
  353. }
  354. #pragma mark - 下拉刷新,上拉加载 -
  355. -(void)setRefreshAction{
  356. // 下拉刷新
  357. __weak typeof(self) weakSelf = self;
  358. MJRefreshNormalHeader *mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  359. [weakSelf headerRefresh];
  360. }];
  361. myTableView.mj_header = mj_header;
  362. MJRefreshBackNormalFooter *mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  363. [weakSelf footerRefresh];
  364. }];
  365. myTableView.mj_footer = mj_footer;
  366. }
  367. -(void)headerRefresh{
  368. //设置获取数据的方式
  369. _getDataType=MyGetDataTypeHeaderRefresh;
  370. //加载数据
  371. [self getModelsAsyc];
  372. }
  373. -(void)footerRefresh{
  374. //设置获取数据的方式
  375. _getDataType=MyGetDataTypeFooterRefresh;
  376. //加载数据
  377. [self getModelsAsyc];
  378. }
  379. #pragma mark cell代理
  380. -(void)didPoint:(NSDictionary *)dict
  381. {
  382. // NSLog(@"didPoint->%@",dict);
  383. [self uploadTopicCommentPoints:dict];
  384. }
  385. -(void)uploadTopicCommentPoints:(NSDictionary*)obj
  386. {
  387. if (![Util connectedToNetWork]) {
  388. showMsgUnconnect();
  389. return;
  390. }
  391. NSMutableArray* arr = [NSMutableArray array];
  392. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  393. [arr addPro:@"topicId" Value:obj[@"ID"]];
  394. NSString* method = @"uploadTopicCommentPoints";
  395. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  396. if (!root) {
  397. ShowMsgFailed();
  398. return;
  399. }
  400. }];
  401. }
  402. -(void)didDePoint:(NSDictionary *)dict
  403. {
  404. // NSLog(@"didDePoint->%@",dict);
  405. [self deleteTopicCommentPoints:dict];
  406. }
  407. -(void)deleteTopicCommentPoints:(NSDictionary*)obj
  408. {
  409. if (![Util connectedToNetWork]) {
  410. showMsgUnconnect();
  411. return;
  412. }
  413. NSMutableArray* arr = [NSMutableArray array];
  414. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  415. [arr addPro:@"topicId" Value:obj[@"ID"]];
  416. NSString* method = @"deleteTopicCommentPoints";
  417. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  418. if (!root) {
  419. ShowMsgFailed();
  420. return;
  421. }
  422. }];
  423. }
  424. #pragma mark -
  425. -(void)getModelsAsyc
  426. {
  427. if (_IS_LOADING) {
  428. return;
  429. }
  430. _IS_LOADING=YES;
  431. NSInteger needLoadPage;
  432. needLoadPage=_currentPageNum+1;
  433. if (_getDataType==MyGetDataTypeHeaderRefresh) {
  434. needLoadPage=1;
  435. }else if (_getDataType == MyGetDataTypeNomal){
  436. [MBProgressHUD showLoadToView:self.view];
  437. }
  438. //-1就是驾校。
  439. if ([_groupId isEqualToString:@"-1"]) {
  440. [self getTopicByJxbhWithPage:needLoadPage];
  441. }else{
  442. [self getTopicInfosWithPage:needLoadPage];
  443. }
  444. }
  445. -(void)getTopicInfosWithPage:(NSInteger)needLoadPage
  446. {
  447. NSMutableArray *arr=[NSMutableArray array];
  448. [arr addPro:@"groupId" Value:_groupId];
  449. [arr addPro:@"type" Value:_type];
  450. [arr addPro:@"crUser" Value:defUser.userDict[@"id"]];
  451. [arr addPro:@"isPage" Value:@"1"];
  452. [arr addPro:@"pageSize" Value:@"7"];
  453. [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)needLoadPage]];
  454. if ([_type isEqualToString:@"2"])
  455. {
  456. [arr addPro:@"childGroupId" Value:_childID];
  457. }
  458. NSString* method = @"getTopicInfos";
  459. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  460. _IS_LOADING = NO;
  461. if (_getDataType == MyGetDataTypeNomal) {
  462. [MBProgressHUD hideHUDForView:self.view];
  463. }else if (_getDataType == MyGetDataTypeFooterRefresh){
  464. [myTableView.mj_footer endRefreshing];
  465. }else{
  466. [myTableView.mj_header endRefreshing];
  467. }
  468. if (!dict) {
  469. ShowMsgFailed();
  470. return;
  471. }
  472. if ( [dict[@"code"] isEqualToString:@"1"]) {
  473. ShowMsg(dict[@"body"]);
  474. return;
  475. }
  476. NSArray *arr = dict[@"body"];
  477. if (arr.count > 0) {
  478. if (_getDataType == MyGetDataTypeHeaderRefresh){
  479. [models removeAllObjects];
  480. }
  481. [[arr.rac_sequence.signal filter:^BOOL(NSDictionary *dic) {
  482. return ![RQ_SHARE_FUNCTION.shieldTopicIDArr containsObject:dic[@"ID"]] && ![RQ_SHARE_FUNCTION.shieldPeopleIDArr containsObject:dic[@"TI_CRUSER"]] ;
  483. }] subscribeNext:^(NSDictionary *dic) {
  484. [models addObject:dic];
  485. } completed:^{
  486. dispatch_sync(dispatch_get_main_queue(), ^{
  487. [myTableView reloadData];
  488. _currentPageNum=needLoadPage;
  489. _getDataType=MyGetDataTypeNomal;
  490. [lblTopicCnt setText:[NSString stringWithFormat:@"话题 %d",(int)models.count]];
  491. });
  492. }];
  493. }else{
  494. ShowMsg(@"已加载全部");
  495. }
  496. }];
  497. }
  498. -(void)getTopicByJxbhWithPage:(NSInteger)needLoadPage
  499. {
  500. if ([_jxbh isEqualToString:@""])
  501. {
  502. _jxbh = defUser.userSchoolId;
  503. }
  504. NSMutableArray *arr=[NSMutableArray array];
  505. [arr addPro:@"jxbh" Value: _jxbh];
  506. [arr addPro:@"isPage" Value:@"1"];
  507. [arr addPro:@"pageSize" Value:@"10"];
  508. [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)needLoadPage]];
  509. NSString* method = @"getTopicByJxbh";
  510. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  511. _IS_LOADING = NO;
  512. if (_getDataType == MyGetDataTypeNomal) {
  513. [MBProgressHUD hideHUDForView:self.view];
  514. }else if (_getDataType == MyGetDataTypeFooterRefresh){
  515. [myTableView.mj_footer endRefreshing];
  516. }else{
  517. [myTableView.mj_header endRefreshing];
  518. }
  519. if (!dict) {
  520. ShowMsgFailed();
  521. return;
  522. }
  523. if ( [dict[@"code"] isEqualToString:@"1"]) {
  524. ShowMsg(dict[@"body"]);
  525. return;
  526. }
  527. NSArray *arr = dict[@"body"];
  528. if (arr.count > 0) {
  529. if (_getDataType==MyGetDataTypeHeaderRefresh){
  530. [models removeAllObjects];
  531. }
  532. [[arr.rac_sequence.signal filter:^BOOL(NSDictionary *dic) {
  533. return ![RQ_SHARE_FUNCTION.shieldTopicIDArr containsObject:dic[@"ID"]] && ![RQ_SHARE_FUNCTION.shieldPeopleIDArr containsObject:dic[@"TI_CRUSER"]] ;
  534. }] subscribeNext:^(NSDictionary *dic) {
  535. [models addObject:dic];
  536. } completed:^{
  537. dispatch_sync(dispatch_get_main_queue(), ^{
  538. [myTableView reloadData];
  539. _currentPageNum=needLoadPage;
  540. _getDataType=MyGetDataTypeNomal;
  541. [lblTopicCnt setText:[NSString stringWithFormat:@"话题 %d",(int)models.count]];
  542. });
  543. }];
  544. }else{
  545. ShowMsg(@"已加载全部");
  546. }
  547. }];
  548. }
  549. @end