一折买app------返利---------返利宝

YZMAChildFansViewController.m 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. //
  2. // YZMAChildFansViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMAChildFansViewController.h"
  9. #import "YZMAChildFansCell.h"
  10. #import "YZMAChildFansModel.h"
  11. #import "YZMAFanRecommendController.h"
  12. @interface YZMAChildFansViewController ()
  13. <
  14. UITableViewDelegate,
  15. UITableViewDataSource,
  16. YHChildFansDelegate
  17. >
  18. @property (nonatomic,strong) UIView *headerView;
  19. @property (nonatomic, strong) NSMutableArray *dataArr;
  20. @property (nonatomic) NSInteger page;
  21. @property (nonatomic) NSInteger member_type;
  22. @end
  23. @implementation YZMAChildFansViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [self configTableView];
  27. [self request:NO];
  28. }
  29. - (void)configTableView {
  30. self.page = 1;
  31. [self.view addSubview:self.headerView];
  32. [self.view addSubview:self.tableView];
  33. if (@available(iOS 11.0, *)) {
  34. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  35. }else {
  36. self.automaticallyAdjustsScrollViewInsets = NO;
  37. }
  38. }
  39. #pragma mark -------- UITableView Delegate -----
  40. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  41. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  42. [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
  43. }
  44. }
  45. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  46. return self.dataArr.count;
  47. }
  48. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  49. return 67;
  50. }
  51. //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  52. // return self.headerView;
  53. //}
  54. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  55. return 0.1;
  56. }
  57. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  58. return 0.1;
  59. }
  60. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  61. YZMAChildFansCell *cell = [YZMAChildFansCell cellWithTableView:tableView];
  62. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  63. cell.updateAction = ^(YZMAChildFansModel *fanModel) {
  64. [self updateVipToSVip:fanModel];
  65. };
  66. YZMAChildFansModel *model = self.dataArr[indexPath.row];
  67. cell.model = model;
  68. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  69. cell.delegate = self;
  70. if (self.type == 0) {
  71. cell.sencondFansSumBtn.hidden = YES;
  72. }
  73. if (self.type == 0 || self.type == 2) {
  74. cell.updateBtn.hidden = YES;
  75. }
  76. return cell;
  77. }
  78. #pragma mark ------ private -----
  79. - (void)updateVipToSVip:(YZMAChildFansModel *)fansModel {
  80. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/upUserLevel",BaseURL];
  81. NSDictionary *para = @{@"user_id":fansModel.user_id};
  82. [YZMAHttp post:url params:para success:^(id json) {
  83. NSNumber *flag = json[@"data"][@"flag"];
  84. if (flag.integerValue == 1) {
  85. [self request:YES];
  86. }
  87. [MBProgressHUD showMessage:json[@"data"][@"info"]];
  88. } failure:^(NSError *error) {
  89. [MBProgressHUD showMessage:@"加载失败,请稍后再试"];
  90. }];
  91. }
  92. #pragma mark -代理 YHChildFansDelegate
  93. - (void)recommendFansByUserID:(NSString *)userId withUserName:(NSString *)userName{
  94. YZMAFanRecommendController *vc=[[YZMAFanRecommendController alloc]init];
  95. vc.userId=userId;
  96. vc.userName=userName;
  97. [self.navigationController pushViewController:vc animated:YES];
  98. }
  99. #pragma mark -网络请求
  100. #pragma mark - request
  101. - (void)request:(BOOL)isChange {
  102. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/fansList",BaseURL];
  103. NSDictionary *dic=@{
  104. @"type":@(self.type),
  105. @"page":@(self.page),
  106. @"member_type":@(self.member_type)
  107. };
  108. [YZMAHttp post:url params:dic success:^(id json) {
  109. NSArray *arr = [NSArray yy_modelArrayWithClass:[YZMAChildFansModel class] json:json[@"data"]];
  110. if (isChange) {
  111. [self.dataArr removeAllObjects];
  112. }
  113. if (arr.count>0) {
  114. [self.dataArr addObjectsFromArray:arr];
  115. [self.tableView reloadData];
  116. [self.tableView.mj_footer endRefreshing];
  117. }else {
  118. [self setUpNoDataView];
  119. [self noMoreDataWithArray:arr];
  120. if (self.page==1) {
  121. [self.tableView reloadData];
  122. }
  123. }
  124. UISegmentedControl *seg=[self.headerView viewWithTag:10001];
  125. [seg setTitle:[NSString stringWithFormat:@"全部:%@位",json[@"fans_all"]] forSegmentAtIndex:0];
  126. [seg setTitle:[NSString stringWithFormat:@"超级会员:%@位",json[@"fans_super"]] forSegmentAtIndex:1];
  127. [seg setTitle:[NSString stringWithFormat:@"会员:%@位",json[@"fans_simple"]] forSegmentAtIndex:2];
  128. [self.tableView.mj_header endRefreshing];
  129. } failure:^(NSError *error) {
  130. [self.tableView.mj_footer endRefreshing];
  131. }];
  132. }
  133. - (void)noMoreDataWithArray:(NSArray *)array {
  134. if (array==nil || array.count <= 0) {
  135. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  136. }
  137. }
  138. - (void)setUpNoDataView {
  139. self.tableView.showNoDataView = YES;
  140. self.tableView.noDataImageOffsetY = -70;
  141. self.tableView.defaultNoDataText = @"您还没有粉丝记录";
  142. self.tableView.defaultNoDataImage = [UIImage imageNamed:@"noData"];
  143. }
  144. #pragma mark -事件
  145. -(void)segAction{
  146. UISegmentedControl *segment=[self.headerView viewWithTag:10001];
  147. self.member_type=segment.selectedSegmentIndex;
  148. [self request:YES];
  149. }
  150. - (void)refreshData {
  151. self.page = 1;
  152. [self request:YES];
  153. }
  154. #pragma mark ------- layzer ------
  155. - (UITableView *)tableView {
  156. if (!_tableView) {
  157. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 48, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-88) style:UITableViewStylePlain];
  158. _tableView.estimatedSectionHeaderHeight = 0;
  159. _tableView.estimatedSectionFooterHeight = 0;
  160. _tableView.sectionFooterHeight = 0;
  161. _tableView.sectionHeaderHeight = 0;
  162. _tableView.estimatedRowHeight = 0;
  163. _tableView.delegate = self;
  164. _tableView.dataSource = self;
  165. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  166. _tableView.backgroundColor = [UIColor yhGrayColor];
  167. _tableView.bounces = YES;
  168. _tableView.showsVerticalScrollIndicator = NO;
  169. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  170. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  171. MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
  172. [self refreshData];
  173. }];
  174. header.lastUpdatedTimeLabel.hidden = YES;
  175. header.stateLabel.hidden = YES;
  176. //正在刷新的图片
  177. NSArray *imgArr = @[[UIImage imageNamed:@"ant1"],[UIImage imageNamed:@"ant2"]];
  178. [header setImages:imgArr duration:0.3 forState:MJRefreshStateRefreshing];
  179. [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStateWillRefresh];
  180. [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStatePulling];
  181. _tableView.mj_header = header;
  182. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  183. self.page ++;
  184. [self request:NO];
  185. }];
  186. }
  187. return _tableView;
  188. }
  189. -(NSMutableArray *)dataArr{
  190. if (!_dataArr) {
  191. _dataArr=[NSMutableArray array];
  192. }
  193. return _dataArr;
  194. }
  195. -(UIView *)headerView{
  196. if (!_headerView) {
  197. _headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 48)];
  198. _headerView.backgroundColor=[UIColor yhGrayColor];
  199. NSArray *array = [NSArray arrayWithObjects:@"全部:--位",@"超级会员:--位",@"会员:--位", nil];
  200. UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:array];
  201. segment.frame=CGRectMake(0, 0, _headerView.width-2*FITSIZE(20), 28);
  202. segment.center=CGPointMake(_headerView.width/2, _headerView.height/2);
  203. segment.layer.borderColor=[UIColor YHColorWithHex:0xFF8600].CGColor;
  204. segment.layer.borderWidth=1;
  205. segment.layer.cornerRadius = 15.0f;
  206. segment.layer.masksToBounds = YES;
  207. segment.tag=10001;
  208. // [segment addTarget:self action:@selector(segAction) forControlEvents:UIControlEventTouchUpInside];
  209. [[segment rac_signalForControlEvents:UIControlEventValueChanged] subscribeNext:^(id x) {
  210. UISegmentedControl *segment=(UISegmentedControl *)x;
  211. if (self.member_type!=segment.selectedSegmentIndex) {
  212. self.page=1;
  213. [self.dataArr removeAllObjects];
  214. }
  215. self.member_type=segment.selectedSegmentIndex;
  216. [self request:YES];
  217. }];
  218. //选中的颜色
  219. segment.tintColor=[UIColor YHColorWithHex:0xFF8600];
  220. [segment setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateSelected];
  221. //未选中的颜色
  222. segment.selectedSegmentIndex=0;
  223. [segment setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];
  224. [segment setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f]} forState:UIControlStateNormal];
  225. [_headerView addSubview:segment];
  226. }
  227. return _headerView;
  228. }
  229. -(void)aUK6ji4:(UIBarButtonItem*) aUK6ji4 aTYcI42UF:(UISearchBar*) aTYcI42UF a5iIaA6F0:(UIVisualEffectView*) a5iIaA6F0 aL7kzN:(UIEvent*) aL7kzN aTkKHv2:(UIBarButtonItem*) aTkKHv2 a1eVo0SfLc6:(UIBarButtonItem*) a1eVo0SfLc6 at9CQv:(UIControlEvents*) at9CQv aRgAQWN3V:(UIDocument*) aRgAQWN3V aWOmh:(UISwitch*) aWOmh aRyZqkBz:(UITableView*) aRyZqkBz a8UrbpZo6t:(UIDocument*) a8UrbpZo6t aFl3x:(UIUserInterfaceIdiom*) aFl3x aw0NGT:(UIBarButtonItem*) aw0NGT au9k1D4iLc:(UIMenuItem*) au9k1D4iLc az8uw:(UIKeyCommand*) az8uw {
  230. NSLog(@"wuNkCylOQbLg6FH4");
  231. NSLog(@"PzCpWmchnfaiOTUe9VHIR");
  232. NSLog(@"eqAUH8kaDu0mY7Zc6M4TLCrh2sE1Q");
  233. NSLog(@"oeLCgubPMK9RXtHjNv1WzE6Ui8");
  234. NSLog(@"NBfMRsclLDS");
  235. NSLog(@"sACoM3H2LKx65Bb");
  236. NSLog(@"w49oZMi3EtySUKuJh");
  237. NSLog(@"sNP5mAk2Oc7uwUfMhiXqYBK1RCdQ0ISnDrJo");
  238. NSLog(@"LKRth3d7pcX0ONi5kBwMxymaoTzbu86I2W1P9EH");
  239. NSLog(@"bYznatNlo6vA40");
  240. NSLog(@"l8rOhtR4eA1MgEQ3qCIV7");
  241. NSLog(@"ZdqBbn6YkpauDMTwI");
  242. }
  243. -(void)aAf2qpBl:(UIEvent*) aAf2qpBl ab2pCa:(UIUserInterfaceIdiom*) ab2pCa aSv1u25j:(UIImageView*) aSv1u25j abJ5BZAMah:(UIMenuItem*) abJ5BZAMah asTOoM:(UIEvent*) asTOoM aAM8b:(UIUserInterfaceIdiom*) aAM8b a3RuXWpV:(UIFontWeight*) a3RuXWpV a04WUcZ39:(UIKeyCommand*) a04WUcZ39 aZo6MBzqU:(UIFontWeight*) aZo6MBzqU aOvQ81Je:(UITableView*) aOvQ81Je a1pqC:(UIScreen*) a1pqC a5VuJRgzw:(UIViewController*) a5VuJRgzw aSLnlfWG:(UICollectionView*) aSLnlfWG an2475C:(UIVisualEffectView*) an2475C anVNLR:(UISwitch*) anVNLR ahnEFJ:(UIAlertView*) ahnEFJ aRKZI1D:(UISearchBar*) aRKZI1D aQYItNogPR:(UIApplication*) aQYItNogPR aSRlr:(UIControlEvents*) aSRlr aWJqACGEB:(UITableView*) aWJqACGEB {
  244. NSLog(@"r5jTlBDx8Ag10PwkdO3GeEHXJQR");
  245. NSLog(@"p1sIoqXQGMv746n0er9UyxJS8luHVCYPaNhDmL");
  246. NSLog(@"QHc5MEkXjPS71dhnaGNVqAC6o38fLe4mU");
  247. NSLog(@"d2zB8Zrpmt");
  248. NSLog(@"SHz87Ogeu5ynUoFMY9");
  249. NSLog(@"i3E19KH8TQLdaSCFD0UxckBOgN");
  250. NSLog(@"a5fUvDNOrL3nzR");
  251. NSLog(@"Eta1TMQKcV9SkA");
  252. NSLog(@"jkpXx4AnJMNlE8zchUCe");
  253. NSLog(@"0XuS9erhoMdn");
  254. NSLog(@"PFuO2I608LGeBZzjUK1lR9E5JMv");
  255. NSLog(@"ouY4AXe7JSONGqTptZCb2iLlgD9kmjIf031Q6");
  256. NSLog(@"C0Yd3XEwolO");
  257. NSLog(@"dgDe4EtUXK7iN3");
  258. NSLog(@"S3JQNznxuL14dg7B");
  259. }
  260. -(void)a7wovdaZYr9:(UIBezierPath*) a7wovdaZYr9 ahqGAr:(UIView*) ahqGAr adcFt:(UIButton*) adcFt atrAQnSHGkw:(UIVisualEffectView*) atrAQnSHGkw a84Pr:(UIViewController*) a84Pr aLPRtjAdDHz:(UIKeyCommand*) aLPRtjAdDHz aGSLJxl:(UIMotionEffect*) aGSLJxl ak7CVuE:(UIImageView*) ak7CVuE a8orL9O0S:(UIMenuItem*) a8orL9O0S aoZuvgyq0:(UIControlEvents*) aoZuvgyq0 ayU5PXaR:(UIButton*) ayU5PXaR aQT82A7tJuo:(UILabel*) aQT82A7tJuo abjnEo7keV:(UIFontWeight*) abjnEo7keV aI0X7q:(UIBarButtonItem*) aI0X7q aAWLgt5vBo1:(UIActivity*) aAWLgt5vBo1 apVAPLv:(UIDocument*) apVAPLv arIgZe:(UILabel*) arIgZe {
  261. NSLog(@"vqRrPCtYHJxN6BiWTz81lUh3XOIgw");
  262. NSLog(@"nxMGmiwXa71W6o3yECeF4sjzPVdKtrkfg");
  263. NSLog(@"rPvTWbH4VU1A8tqd9ygOZxIhaQK706cBus5F");
  264. NSLog(@"k10b5L7ZAWGwNXfugUExQ9pYMy");
  265. NSLog(@"kxfKaCjwS7EFYT");
  266. NSLog(@"UH0ycBxYpEJsDfGguN6IiFjA5WPlkb");
  267. NSLog(@"emAkudi2wVGRY0aM1ZFgvTnjqE5PHOtDLS");
  268. NSLog(@"bW8D6K3NSjgUGFpkHdu1rRmzJIiycEt");
  269. NSLog(@"QiIY6Mt03agA7pTPjCBsUlkEuK2Vobm81hDSd9N5");
  270. NSLog(@"cERGDF8YCxZLJz9PSXI");
  271. NSLog(@"6qyO2WsKab1t7vpSC5r");
  272. NSLog(@"2HXVO0AxWh5TU4RQtZ8FaM3SqYEkbClucvPGg9BN");
  273. NSLog(@"OW1oFSTLMhCbv47tX6ZDuz3pHsel");
  274. }
  275. @end