allianceListVController.m 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //
  2. // allianceListVController.m
  3. // ZhongJingLianMeng
  4. //
  5. // Created by youke on 2018/12/10.
  6. // Copyright © 2018 youke. All rights reserved.
  7. //
  8. #import "allianceListVController.h"
  9. #import "mapItemModel.h"
  10. #import "newsDetailVController.h"
  11. @interface allianceListVController ()<UITableViewDelegate,UITableViewDataSource>{
  12. int _page;
  13. }
  14. @property(nonatomic, strong)UILabel *titleLab;
  15. @property(nonatomic,strong)UITableView *tableView;
  16. @property(nonatomic,strong)NSMutableArray *listArray;
  17. @property(nonatomic,strong)NSMutableArray *dataArray;
  18. @property(nonatomic,strong)HttpRequestManger *sessionManager;
  19. @property(nonatomic,strong)UIImageView *iconImgView;
  20. @property(nonatomic,strong)UILabel *jieKuanLb;
  21. @property(nonatomic,strong)UIView *backgroundView;
  22. @end
  23. @implementation allianceListVController
  24. - (HttpRequestManger*) sessionManager{
  25. if (!_sessionManager) {
  26. _sessionManager = [[HttpRequestManger alloc]init];
  27. }
  28. return _sessionManager;
  29. }
  30. -(NSMutableArray *)listArray{
  31. if (!_listArray) {
  32. _listArray = [NSMutableArray array];
  33. }
  34. return _listArray;
  35. }
  36. -(NSMutableArray *)dataArray{
  37. if (!_dataArray) {
  38. _dataArray = [NSMutableArray array];
  39. }
  40. return _dataArray;
  41. }
  42. - (void)viewDidLoad {
  43. [super viewDidLoad];
  44. [self loadAllianceList];
  45. [self.navigationView removeAllLeftButton];
  46. self.view.backgroundColor = [UIColor colorWithHexValue:0xF7F8FA];
  47. _titleLab = [[UILabel alloc]init];
  48. _titleLab.frame = CGRectMake(0,0, kGScreenWidth-60, 30);
  49. _titleLab.textColor = [UIColor whiteColor];
  50. _titleLab.text = _allianceName;
  51. [self.navigationView setNavigationBackgroundColor:[UIColor colorWithHexValue:0x3C915C]];
  52. [self.navigationView addTitleView:_titleLab];
  53. kWeakSelf(self);
  54. [self.navigationView addLeftButtonWithImage:[UIImage imageNamed:@"whiteBack"] clickCallBack:^(UIView *view) {
  55. [weakself.navigationController popViewControllerAnimated:YES];
  56. }];
  57. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,NaviHeight, kGScreenWidth, kGScreenHeight-NaviHeight ) style:UITableViewStylePlain];
  58. _tableView.backgroundColor = [UIColor colorWithHexValue:0xFFFFFF];
  59. self.view.backgroundColor = [UIColor colorWithHexValue:0xFFFFFF];//cell不对齐
  60. [self.view addSubview:_tableView];
  61. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  62. if (@available(iOS 11.0, *)) {
  63. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  64. }else {
  65. self.automaticallyAdjustsScrollViewInsets = NO;
  66. }
  67. _dataArray = [NSMutableArray array];
  68. _tableView.delegate = self;
  69. _tableView.dataSource = self;
  70. // Do any additional setup after loading the view.
  71. }
  72. -(void)loadAllianceList{
  73. if (_backgroundView) {
  74. [_backgroundView removeFromSuperview];
  75. }
  76. NSMutableDictionary *parem =[NSMutableDictionary dictionary];
  77. parem[@"id"] = _allianceID;
  78. kWeakSelf(self);
  79. [ProgressHUD show];
  80. [self.sessionManager sendPostHttpRequestWithUrl:selectCommitteeList params:parem bodyBlock:nil progress:nil success:^(NSDictionary *response) {
  81. [ProgressHUD hide];
  82. NSLog(@"%@",response);
  83. NSArray *arr = [NSArray arrayWithArray:response[@"committeeList"]];
  84. if (arr.count != 0) {
  85. weakself.listArray = [committeeModel mj_objectArrayWithKeyValuesArray:arr];
  86. }else{
  87. _backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0,NaviHeight +44, kGScreenWidth, kGScreenHeight)];
  88. [self.view addSubview:_backgroundView];
  89. _iconImgView = [[UIImageView alloc] init];
  90. _iconImgView.image = [UIImage imageNamed:@"searchEmptyImg"];
  91. _iconImgView.contentMode = UIViewContentModeScaleAspectFit;
  92. [_backgroundView addSubview:_iconImgView];
  93. [_iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.size.mas_equalTo(CGSizeMake(167, 90));
  95. make.centerY.mas_equalTo(self.view.mas_centerY).with.offset(IS_IPHONE_4_OR_LESS?-60:-140);
  96. make.centerX.mas_equalTo(self.view.mas_centerX).with.offset(0);
  97. }];
  98. _jieKuanLb = [[UILabel alloc] init];
  99. _jieKuanLb.text = @"抱歉,暂无内容~";
  100. _jieKuanLb.font = [UIFont systemFontOfSize:15];
  101. _jieKuanLb.textAlignment = NSTextAlignmentCenter;
  102. [_backgroundView addSubview:_jieKuanLb];
  103. [_jieKuanLb mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.size.mas_equalTo(CGSizeMake(kGScreenWidth, 24));
  105. make.top.mas_equalTo(_iconImgView.mas_bottom).with.offset(10);
  106. make.centerX.mas_equalTo(self.view.mas_centerX).with.offset(0);
  107. }];
  108. }
  109. [_tableView reloadData];
  110. } failure:^(NSError *error) {
  111. [ProgressHUD hide];
  112. NSLog(@"%@",error);
  113. }];
  114. }
  115. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  116. return 1;
  117. }
  118. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  119. return _listArray.count;
  120. }
  121. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  122. return 0.001;
  123. }
  124. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  125. return 0.0001;
  126. }
  127. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  128. return 45;
  129. }
  130. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  131. committeeModel *model = self.listArray[indexPath.row];
  132. UITableViewCell *cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
  133. reuseIdentifier:@"cell12"];
  134. if (cell ==nil) {
  135. cell =
  136. [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
  137. reuseIdentifier:@"cell12"];
  138. }
  139. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  140. tableView.separatorColor = [UIColor colorWithHexValue:0xEAEAEA];
  141. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  142. UILabel *titleLa = [[UILabel alloc]initWithFrame:CGRectMake(40, 8, kGScreenWidth -100, 30)];
  143. titleLa.textColor = [UIColor blackColor];
  144. titleLa.font = TextFont(15);
  145. [cell addSubview:titleLa];
  146. titleLa.text = model.committee_name;
  147. titleLa.textAlignment = NSTextAlignmentLeft;
  148. UIView *kuangView = [[UIView alloc]init];
  149. kuangView.backgroundColor = [UIColor colorWithHexValue:0x3C915C];
  150. [cell addSubview:kuangView];
  151. [kuangView mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.left.equalTo(cell.mas_left).offset(20);
  153. make.centerY.mas_equalTo(titleLa.mas_centerY);
  154. make.size.mas_equalTo(CGSizeMake(5, 5));
  155. }];
  156. return cell;
  157. }
  158. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  159. committeeModel *model = self.listArray[indexPath.row];
  160. newsDetailVController *newsDetail = [[newsDetailVController alloc]init];
  161. newsDetail.newsId = model.committee_id;
  162. newsDetail.titleStr = model.committee_name;
  163. // newsDetail.shareTitle = model.committee_name;
  164. newsDetail.index =@"2";
  165. // newsDetail.ImgUrl =
  166. newsDetail.urlStr = [NSString stringWithFormat:@"%@/allianceTwo?id=%@&move=ios",baseH5,model.committee_id];
  167. // newsDetail.shareUrl = [NSString stringWithFormat:@"%@/newsInfo?id=%@",baseH5,model.committee_id];
  168. [self.navigationController pushViewController:newsDetail animated:YES];
  169. }
  170. - (void)didReceiveMemoryWarning {
  171. [super didReceiveMemoryWarning];
  172. // Dispose of any resources that can be recreated.
  173. }
  174. /*
  175. #pragma mark - Navigation
  176. // In a storyboard-based application, you will often want to do a little preparation before navigation
  177. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  178. // Get the new view controller using [segue destinationViewController].
  179. // Pass the selected object to the new view controller.
  180. }
  181. */
  182. @end