猎豆优选

LDMyFansViewController.m 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. //
  2. // LDMyFansViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDMyFansViewController.h"
  9. #import "LDOrderTableView.h"
  10. #import "MLMSegmentHead.h"
  11. #import "MLMSegmentManager.h"
  12. #import "LDChildFansViewController.h"
  13. #import "LDFansHeaderView.h"
  14. #import "LDShowFansHelpView.h"
  15. #import "CCAlertShowView.h"
  16. #import "LDPotentialFansViewController.h"
  17. #import "UILabel+ChangeLineSpaceAndWordSpace.h"
  18. #import "TopTypeHeader.h"
  19. #import "TopTypeSegmentManager.h"
  20. #import "LDWebDetailController.h"
  21. #import "LDPrivilegeReferralViewController.h"
  22. #import "LDUserInfo.h"
  23. #import "LDPrivilegeReferralViewController.h"
  24. #import "LDAdWebViewController.h"
  25. @interface LDMyFansViewController ()
  26. <
  27. UITableViewDelegate,
  28. UITableViewDataSource
  29. >
  30. {
  31. UIButton *allbtn;
  32. UIButton *friendbtn;
  33. UIButton *potentialbtn;
  34. UIButton *recommbtn;
  35. NSMutableDictionary *topnavDic;//存取顶部导航
  36. NSDictionary *friendDic;//选择的顶部导航
  37. NSMutableArray *btnArray;
  38. }
  39. @property (nonatomic, strong) LDOrderTableView *tableView;
  40. @property (nonatomic, strong) LDFansHeaderView *headerView;
  41. @property (nonatomic, strong) TopTypeHeader *titleView;
  42. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  43. @property (nonatomic, strong) NSMutableArray *vcList;
  44. @property (nonatomic, assign) BOOL canScroll;
  45. @property (nonatomic, strong) UIButton *rightHelpBtn;
  46. @end
  47. @implementation LDMyFansViewController
  48. - (void)viewDidAppear:(BOOL)animated {
  49. [super viewDidAppear:animated];
  50. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  51. }
  52. - (void)viewDidLoad {
  53. [super viewDidLoad];
  54. [self configNavigationBar];
  55. [self.view addSubview:self.tableView];
  56. [self creatHeaderViewAndFooterView];
  57. [MBProgressHUD showLoadingAddedToView:self.view];
  58. [self requestTopNav];
  59. }
  60. - (void)setUpNoDataView {
  61. self.tableView.showNoDataView = YES;
  62. self.tableView.noDataImageOffsetY = -70;
  63. self.tableView.defaultNoDataText = @"您还没有好友,快去邀请吧~";
  64. self.tableView.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
  65. }
  66. - (void)configNavigationBar {
  67. [self.navigationBar setNavTitle:@"我的好友"];
  68. self.navigationBar.backgroundColor = [UIColor changeColor];
  69. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  70. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  71. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  72. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  73. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  74. self.rightHelpBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  75. [self.rightHelpBtn setImage:[UIImage imageNamed:@"helpmonth"] forState:UIControlStateNormal];
  76. [self.rightHelpBtn addTarget:self action:@selector(showHelpAlert) forControlEvents:UIControlEventTouchUpInside];
  77. self.rightHelpBtn.hidden = YES;
  78. [self.navigationBar setCustomRightButtons:@[self.rightHelpBtn]];
  79. }
  80. -(void)viewWillAppear:(BOOL)animated{
  81. [super viewWillAppear:animated];
  82. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  83. }
  84. - (void)backAction {
  85. [self.navigationController popViewControllerAnimated:YES];
  86. }
  87. - (void)creatHeaderViewAndFooterView {
  88. self.view.backgroundColor = [UIColor whiteColor];
  89. UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(30))];
  90. [accountBtn setImage:[UIImage imageNamed:@"goto_detail"] forState:UIControlStateNormal];
  91. [accountBtn setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7.5), SCREEN_WIDTH-FITSIZE(30), FITSIZE(7.5), FITSIZE(15))];
  92. accountBtn.backgroundColor =[UIColor whiteColor];
  93. [self.view addSubview:accountBtn];
  94. [accountBtn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
  95. UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), FITSIZE(7.5), FITSIZE(15), FITSIZE(15))];
  96. imgv.image =[UIImage imageNamed:@"order_notice"];
  97. [accountBtn addSubview:imgv];
  98. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, FITSIZE(300), FITSIZE(30))];
  99. label.text=@"通知消息";
  100. label.textColor=[UIColor YHColorWithHex:0xFB6526];
  101. label.font=[UIFont systemFontOfSize:FITSIZE(12)];
  102. [accountBtn addSubview:label];
  103. label.tag = 1234;
  104. [self.view addSubview:accountBtn];
  105. }
  106. #pragma mark--顶部通知
  107. -(void)clickBtn
  108. {
  109. NSDictionary *userDic = [LDUserInfoManager shareManager].userInfoDic;
  110. LDUserInfo *userInfo = [LDUserInfo yy_modelWithJSON:userDic];
  111. if ([userInfo.user_level isEqualToString:@"3"]) {
  112. LDAdWebViewController *web = [[LDAdWebViewController alloc] init];
  113. web.url = topnavDic[@"url"];
  114. [self.navigationController pushViewController:web animated:YES];
  115. return;
  116. }
  117. LDPrivilegeReferralViewController *Privilege = [[LDPrivilegeReferralViewController alloc] init];
  118. [self.navigationController pushViewController:Privilege animated:YES];
  119. }
  120. /**
  121. 特权信息
  122. */
  123. - (void)showUserType {
  124. LDPrivilegeReferralViewController *Privilege = [[LDPrivilegeReferralViewController alloc] init];
  125. [self.navigationController pushViewController:Privilege animated:YES];
  126. }
  127. #pragma mark---获取顶部导航
  128. -(void)requestTopNav
  129. {
  130. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/getTopNaiv",BaseURL];
  131. [LDHttp post:url params:nil success:^(id json) {
  132. [MBProgressHUD hideHUDForView:self.view];
  133. topnavDic =[NSMutableDictionary dictionaryWithDictionary:json[@"data"]];
  134. btnArray =[NSMutableArray array];
  135. UILabel *messageLabel =[self.view viewWithTag:1234];
  136. messageLabel.text=json[@"data"][@"top_message"];
  137. NSMutableArray *array =[NSMutableArray array];
  138. NSMutableArray *numA =[NSMutableArray array];
  139. //取值(key值同名的时候会覆盖的)
  140. for (int i =0; i<[topnavDic[@"top_friend"] count]; i++) {
  141. NSDictionary *dics= topnavDic[@"top_friend"][i];
  142. [array addObject:dics[@"top_name"]];
  143. [numA addObject:[NSString stringWithFormat:@"%@",dics[@"count"]]];
  144. LDChildFansViewController *childV =[[LDChildFansViewController alloc]init];
  145. childV.type = [dics[@"top_type"] integerValue];
  146. [self.vcList addObject:childV];
  147. }
  148. self.segScroll =[[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+70+FITSIZE(40), SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70-FITSIZE(40)) vcOrViews:self.vcList];
  149. self.segScroll.bounces = NO;
  150. self.segScroll.loadAll = YES;
  151. self.titleView = [[TopTypeHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight+FITSIZE(40), SCREEN_WIDTH, 70) titles:array headStyle:TopTypeHeadStyleDefault layoutStyle:TopTypeLayoutDefault];
  152. self.titleView.headColor = [UIColor whiteColor];
  153. self.titleView.bottomLineHeight = 1;
  154. self.titleView.subTitles = numA;
  155. self.titleView.bottomLineColor = [UIColor yhGrayColor];
  156. self.titleView.fontScale = 1;
  157. self.titleView.fontSize = 14;
  158. self.titleView.equalSize = YES;
  159. self.titleView.showIndex = _showIndex;
  160. self.titleView.selectColor = [UIColor homeRedColor];
  161. self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
  162. [TopTypeSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  163. [self.view addSubview:self.titleView];
  164. [self.view addSubview:self.segScroll];
  165. }];
  166. } failure:^(NSError *error) {
  167. [MBProgressHUD hideHUDForView:self.view];
  168. [self.tableView.mj_header endRefreshing];
  169. }];
  170. }
  171. #pragma mark ===
  172. - (void)showHelpAlert {
  173. LDShowFansHelpView *popView = [[LDShowFansHelpView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-80, 213)];
  174. CCAlertShowView *showView = [CCAlertShowView alertViewWithView:popView];
  175. popView.dismissAction = ^{
  176. [showView dismiss];
  177. };
  178. [showView show];
  179. }
  180. #pragma mark --------------------- UITableView delegate -------
  181. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  182. return 1;
  183. }
  184. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  185. return 1;
  186. }
  187. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  188. return 0.1;
  189. }
  190. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  191. return 40;
  192. }
  193. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  194. return SCREEN_HEIGHT-NavBarHeight-40;
  195. }
  196. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  197. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  198. return cell;
  199. }
  200. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  201. return self.titleView;
  202. }
  203. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  204. return self.segScroll;
  205. }
  206. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  207. {
  208. }
  209. #pragma mark ----- scroll delegete ----
  210. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  211. // CGFloat bottomCellOffset = [_tableView rectForSection:0].origin.y;
  212. // if (scrollView.contentOffset.y >= bottomCellOffset) {
  213. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  214. // if (self.canScroll) {
  215. // self.canScroll = NO;
  216. // [self setChildViewControllerCanScroll:YES];
  217. // }
  218. // }else{
  219. // if (!self.canScroll) {//子视图没到顶部
  220. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  221. // }
  222. // }
  223. //}
  224. //
  225. //- (void)setChildViewControllerCanScroll:(BOOL)childCanScroll {
  226. // for (LDChildFansViewController *childVc in self.vcList) {
  227. // childVc.childCanScroll = childCanScroll;
  228. // if (!childCanScroll) {
  229. // childVc.tableView.contentOffset = CGPointZero;
  230. // }
  231. // }
  232. //}
  233. #pragma mark ----------------
  234. - (LDOrderTableView *)tableView {
  235. if (!_tableView) {
  236. _tableView = [[LDOrderTableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  237. _tableView.estimatedSectionHeaderHeight = 0;
  238. _tableView.estimatedSectionFooterHeight = 0;
  239. _tableView.sectionFooterHeight = 0;
  240. _tableView.sectionHeaderHeight = 0;
  241. _tableView.estimatedRowHeight = 0;
  242. _tableView.delegate = self;
  243. _tableView.dataSource = self;
  244. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  245. _tableView.backgroundColor = [UIColor whiteColor];
  246. _tableView.bounces = NO;
  247. _tableView.showsVerticalScrollIndicator = NO;
  248. [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]];
  249. }
  250. return _tableView;
  251. }
  252. - (NSMutableArray *)vcList {
  253. if (!_vcList) {
  254. _vcList = [NSMutableArray array];
  255. }
  256. return _vcList;
  257. }
  258. - (void)didReceiveMemoryWarning {
  259. [super didReceiveMemoryWarning];
  260. // Dispose of any resources that can be recreated.
  261. }
  262. /*
  263. #pragma mark - Navigation
  264. // In a storyboard-based application, you will often want to do a little preparation before navigation
  265. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  266. // Get the new view controller using [segue destinationViewController].
  267. // Pass the selected object to the new view controller.
  268. }
  269. */
  270. @end