《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRMyFansViewController.m 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. //
  2. // DRMyFansViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRMyFansViewController.h"
  9. #import "DROrderTableView.h"
  10. #import "MLMSegmentHead.h"
  11. #import "MLMSegmentManager.h"
  12. #import "DRChildFansViewController.h"
  13. #import "DRFansHeaderView.h"
  14. #import "DRShowFansHelpView.h"
  15. #import "CCAlertShowView.h"
  16. #import "DRPotentialFansViewController.h"
  17. #import "UILabel+ChangeLineSpaceAndWordSpace.h"
  18. #import "TopTypeHeader.h"
  19. #import "TopTypeSegmentManager.h"
  20. #import "DRWebDetailController.h"
  21. #import "DRPrivilegeReferralViewController.h"
  22. #import "DRUserInfo.h"
  23. #import "DRPrivilegeReferralViewController.h"
  24. #import "DRAdWebViewController.h"
  25. @interface DRMyFansViewController ()
  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) DROrderTableView *tableView;
  40. @property (nonatomic, strong) DRFansHeaderView *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 DRMyFansViewController
  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 = [DRUserInfoManager shareManager].userInfoDic;
  110. DRUserInfo *userInfo = [DRUserInfo yy_modelWithJSON:userDic];
  111. if ([userInfo.user_level isEqualToString:@"3"]) {
  112. DRAdWebViewController *web = [[DRAdWebViewController alloc] init];
  113. web.url = topnavDic[@"url"];
  114. [self.navigationController pushViewController:web animated:YES];
  115. return;
  116. }
  117. DRPrivilegeReferralViewController *Privilege = [[DRPrivilegeReferralViewController alloc] init];
  118. [self.navigationController pushViewController:Privilege animated:YES];
  119. }
  120. /**
  121. 特权信息
  122. */
  123. - (void)showUserType {
  124. DRPrivilegeReferralViewController *Privilege = [[DRPrivilegeReferralViewController 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. [DRHttp 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. DRChildFansViewController *childV =[[DRChildFansViewController 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. DRShowFansHelpView *popView = [[DRShowFansHelpView 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. #pragma mark ----- scroll delegete ----
  207. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  208. // CGFloat bottomCellOffset = [_tableView rectForSection:0].origin.y;
  209. // if (scrollView.contentOffset.y >= bottomCellOffset) {
  210. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  211. // if (self.canScroll) {
  212. // self.canScroll = NO;
  213. // [self setChildViewControllerCanScroll:YES];
  214. // }
  215. // }else{
  216. // if (!self.canScroll) {//子视图没到顶部
  217. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  218. // }
  219. // }
  220. //}
  221. //
  222. //- (void)setChildViewControllerCanScroll:(BOOL)childCanScroll {
  223. // for (DRChildFansViewController *childVc in self.vcList) {
  224. // childVc.childCanScroll = childCanScroll;
  225. // if (!childCanScroll) {
  226. // childVc.tableView.contentOffset = CGPointZero;
  227. // }
  228. // }
  229. //}
  230. #pragma mark ----------------
  231. - (DROrderTableView *)tableView {
  232. if (!_tableView) {
  233. _tableView = [[DROrderTableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  234. _tableView.estimatedSectionHeaderHeight = 0;
  235. _tableView.estimatedSectionFooterHeight = 0;
  236. _tableView.sectionFooterHeight = 0;
  237. _tableView.sectionHeaderHeight = 0;
  238. _tableView.estimatedRowHeight = 0;
  239. _tableView.delegate = self;
  240. _tableView.dataSource = self;
  241. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  242. _tableView.backgroundColor = [UIColor whiteColor];
  243. _tableView.bounces = NO;
  244. _tableView.showsVerticalScrollIndicator = NO;
  245. [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]];
  246. }
  247. return _tableView;
  248. }
  249. - (NSMutableArray *)vcList {
  250. if (!_vcList) {
  251. _vcList = [NSMutableArray array];
  252. }
  253. return _vcList;
  254. }
  255. - (void)didReceiveMemoryWarning {
  256. [super didReceiveMemoryWarning];
  257. // Dispose of any resources that can be recreated.
  258. }
  259. /*
  260. #pragma mark - Navigation
  261. // In a storyboard-based application, you will often want to do a little preparation before navigation
  262. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  263. // Get the new view controller using [segue destinationViewController].
  264. // Pass the selected object to the new view controller.
  265. }
  266. */
  267. @end