猎豆优选

LDCommissionMainViewController.m 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //
  2. // LDCommissionMainViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDCommissionMainViewController.h"
  9. #import "MLMSegmentHead.h"
  10. #import "MLMSegmentManager.h"
  11. #import "LDOrderTableView.h"
  12. #import "LDChildCommissionController.h"
  13. #import "LDCommissionHeaderView.h"
  14. #import "LDChildCommissionController.h"
  15. #import "LDCalendarView.h"
  16. #import "CCAlertShowView.h"
  17. #import "TopTypeHeader.h"
  18. #import "TopTypeSegmentManager.h"
  19. #import "LDCommissionHeaderModel.h"
  20. #import "LDCommissionMainViewController.h"
  21. #import "LDPrivilegeReferralViewController.h"
  22. @interface LDCommissionMainViewController ()
  23. @property (nonatomic, strong) LDOrderTableView *tableView;
  24. @property (nonatomic, strong) LDCommissionHeaderView *headerView;
  25. @property (nonatomic, strong) TopTypeHeader *titleView;
  26. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  27. @property (nonatomic, strong) NSMutableArray *vcList;
  28. @property (nonatomic, assign) BOOL canScroll;
  29. @property (nonatomic, strong) LDCalendarView *calendarView ;
  30. @property (nonatomic, strong) CCAlertShowView *alertShowView;
  31. @end
  32. @implementation LDCommissionMainViewController
  33. - (void)dealloc {
  34. }
  35. - (void)viewWillDisappear:(BOOL)animated {
  36. [super viewWillDisappear:animated];
  37. [LoadingView dismiss];
  38. }
  39. - (void)viewDidLoad {
  40. [super viewDidLoad];
  41. [self configNavigationBar];
  42. [self loadTitleData];
  43. }
  44. -(void)viewWillAppear:(BOOL)animated{
  45. [super viewWillAppear:animated];
  46. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  47. }
  48. - (void)configNavigationBar {
  49. [self.navigationBar setNavTitle:@"订单明细"];
  50. self.navigationBar.backgroundColor = [UIColor changeColor];
  51. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  52. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  53. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  54. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  55. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  56. UIButton *calendar = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  57. [calendar setImage:[UIImage imageNamed:@"white_canlendar"] forState:UIControlStateNormal];
  58. [calendar addTarget:self action:@selector(showCalendar) forControlEvents:UIControlEventTouchUpInside];
  59. [self.navigationBar setCustomRightButtons:@[calendar]];
  60. self.view.backgroundColor = [UIColor backgroudColor];
  61. }
  62. - (void)backAction {
  63. [self.navigationController popViewControllerAnimated:YES];
  64. }
  65. - (void)showCalendar {
  66. if (self.alertShowView) {
  67. [self.alertShowView show];
  68. return;
  69. }
  70. CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:self.calendarView backgroundDismissEnable:YES];
  71. self.alertShowView = showView;
  72. [self.alertShowView show];
  73. }
  74. - (void)loadTitleData {
  75. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/getOrderTop",BaseURL];
  76. [LoadingView show];
  77. [LDHttp post:url params:nil success:^(id json) {
  78. [LoadingView dismiss];
  79. NSArray *arr = [NSArray yy_modelArrayWithClass:[LDCommissionHeaderModel class] json:json[@"data"]];
  80. [self creatHeaderViewAndFooterView:arr];
  81. } failure:^(NSError *error) {
  82. }];
  83. }
  84. - (void)creatHeaderViewAndFooterView:(NSArray *)modelArr {
  85. NSMutableArray *titleArr = [NSMutableArray array];
  86. NSMutableArray *subTitles = [NSMutableArray array];
  87. NSInteger counts =0;
  88. for (int i = 0; i < modelArr.count; i++) {
  89. LDCommissionHeaderModel *model = modelArr[i];
  90. LDChildCommissionController *child = [[LDChildCommissionController alloc] init];
  91. child.type = [model.type integerValue];
  92. [titleArr addObject:model.title];
  93. [subTitles addObject:model.count];
  94. [self.vcList addObject:child];
  95. if (model.type.integerValue == 4) {
  96. counts =model.count.integerValue;//全部订单数量
  97. }
  98. }
  99. CGFloat height =0;
  100. //取值(key值同名的时候会覆盖的)
  101. NSDictionary * userinfoDic =[LDUserInfoManager shareManager].userInfoDic;
  102. if ([userinfoDic[@"user_level"] integerValue ] == 1) {//会员
  103. UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(30))];
  104. [accountBtn setImage:[UIImage imageNamed:@"goto_detail"] forState:UIControlStateNormal];
  105. [accountBtn setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7.5), SCREEN_WIDTH-FITSIZE(30), FITSIZE(7.5), FITSIZE(15))];
  106. accountBtn.backgroundColor =[UIColor whiteColor];
  107. [self.view addSubview:accountBtn];
  108. [accountBtn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
  109. UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), FITSIZE(7.5), FITSIZE(15), FITSIZE(15))];
  110. imgv.image =[UIImage imageNamed:@"order_notice"];
  111. [accountBtn addSubview:imgv];
  112. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, FITSIZE(300), FITSIZE(30))];
  113. label.text=@"你还不是超级会员,成为超级会员就能购物有收益啦";
  114. label.textColor=[UIColor YHColorWithHex:0xFB6526];
  115. label.font=[UIFont systemFontOfSize:FITSIZE(12)];
  116. [accountBtn addSubview:label];
  117. label.tag = 1234;
  118. [self.view addSubview:accountBtn];
  119. height =FITSIZE(40);
  120. }else{
  121. if (counts !=0) {
  122. UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(30))];
  123. [accountBtn setImage:[UIImage imageNamed:@"order_cancel"] forState:UIControlStateNormal];
  124. [accountBtn setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7.5), SCREEN_WIDTH-FITSIZE(30), FITSIZE(7.5), FITSIZE(15))];
  125. accountBtn.backgroundColor =[UIColor whiteColor];
  126. [self.view addSubview:accountBtn];
  127. [accountBtn addTarget:self action:@selector(clickCloseBtn) forControlEvents:UIControlEventTouchUpInside];
  128. UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), FITSIZE(7.5), FITSIZE(15), FITSIZE(15))];
  129. imgv.image =[UIImage imageNamed:@"order_notice"];
  130. [accountBtn addSubview:imgv];
  131. accountBtn.tag = 1111;
  132. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, FITSIZE(300), FITSIZE(30))];
  133. label.text=@"订单收益一般10分钟内同步,最迟3小时,请稍等一会儿~";
  134. label.textColor=[UIColor YHColorWithHex:0xFB6526];
  135. label.font=[UIFont systemFontOfSize:FITSIZE(12)];
  136. [accountBtn addSubview:label];
  137. label.tag = 1234;
  138. [self.view addSubview:accountBtn];
  139. height =FITSIZE(40);
  140. }
  141. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+70+height, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70-height) vcOrViews:self.vcList];
  142. self.segScroll.bounces = NO;
  143. self.segScroll.loadAll = YES;
  144. self.titleView = [[TopTypeHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight+height, SCREEN_WIDTH, 70) titles:titleArr headStyle:TopTypeHeadStyleDefault layoutStyle:TopTypeLayoutDefault];
  145. self.titleView.headColor = [UIColor whiteColor];
  146. self.titleView.bottomLineHeight = 1;
  147. self.titleView.subTitles = subTitles;
  148. self.titleView.bottomLineColor = [UIColor yhGrayColor];
  149. self.titleView.fontScale = 1;
  150. self.titleView.fontSize = 14;
  151. self.titleView.equalSize = YES;
  152. self.titleView.showIndex = _showIndex;
  153. self.titleView.selectColor = [UIColor homeRedColor];
  154. self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
  155. [TopTypeSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  156. [self.view addSubview:self.titleView];
  157. [self.view addSubview:self.segScroll];
  158. }];
  159. }
  160. }
  161. -(void)clickCloseBtn
  162. {
  163. UIButton *accountB =[self.view viewWithTag:1111];
  164. [accountB removeFromSuperview];
  165. self.segScroll.frame=CGRectMake(0, NavBarHeight+70, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70);
  166. self.titleView.frame=CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 70);
  167. }
  168. -(void)clickBtn
  169. {
  170. LDPrivilegeReferralViewController *Privilege = [[LDPrivilegeReferralViewController alloc] init];
  171. [self.navigationController pushViewController:Privilege animated:YES];
  172. }
  173. #pragma mark ----- nofi -----
  174. //- (void)changeScrollStatus {
  175. // self.canScroll = YES;
  176. // for (LDChildCommissionController *childVc in self.vcList) {
  177. // childVc.childCanScroll = NO;
  178. // }
  179. //}
  180. - (NSMutableArray *)vcList {
  181. if (!_vcList) {
  182. _vcList = [NSMutableArray array];
  183. }
  184. return _vcList;
  185. }
  186. - (LDCalendarView *)calendarView {
  187. if (!_calendarView) {
  188. __weak typeof(self) weakSelf = self;
  189. _calendarView = [[LDCalendarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-40, 0)];
  190. _calendarView.cancelBlock = ^{
  191. [weakSelf.alertShowView dismiss];
  192. };
  193. _calendarView.makeSureBlock = ^(NSString *dateStr) {
  194. for (LDChildCommissionController *child in weakSelf.vcList) {
  195. [child refreshWithDate:dateStr];
  196. }
  197. [weakSelf.alertShowView dismiss];
  198. };
  199. }
  200. return _calendarView;
  201. }
  202. - (void)didReceiveMemoryWarning {
  203. [super didReceiveMemoryWarning];
  204. // Dispose of any resources that can be recreated.
  205. }
  206. /*
  207. #pragma mark - Navigation
  208. // In a storyboard-based application, you will often want to do a little preparation before navigation
  209. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  210. // Get the new view controller using [segue destinationViewController].
  211. // Pass the selected object to the new view controller.
  212. }
  213. */
  214. @end