YOUPAILZUnionsPopularizeVC.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. //
  2. // YOUPAILZUnionsPopularizeVC.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/4/12.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZUnionsPopularizeVC.h"
  9. @interface YOUPAILZUnionsPopularizeVC ()
  10. @property (nonatomic,strong) NSDictionary *youpaipnetworkData;
  11. @end
  12. @implementation YOUPAILZUnionsPopularizeVC
  13. - (void)viewWillAppear:(BOOL)animated{
  14. [super viewWillAppear:animated];
  15. [self.navigationController.navigationBar setClearBar];
  16. }
  17. - (void)viewWillDisappear:(BOOL)animated{
  18. [super viewWillDisappear:animated];
  19. [self.navigationController.navigationBar setDefaultBar];
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. self.title = @"我的等级";
  24. [self youpaifrequestData];
  25. }
  26. - (void)youpaifsetupUI{
  27. NSInteger level = [self.youpaipnetworkData[@"level"] integerValue];
  28. NSInteger num_int = [self.youpaipnetworkData[@"num_int"] integerValue];
  29. NSArray *scales = self.youpaipnetworkData[@"table"];
  30. UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
  31. scrollView.showsVerticalScrollIndicator = NO;
  32. scrollView.showsHorizontalScrollIndicator = NO;
  33. [self.view addSubview:scrollView];
  34. UIImageView *headerV = [[UIImageView alloc] init];
  35. headerV.image = [UIImage imageNamed:@"vqu_images_ic_profile_unions_popularize_header_bg"];
  36. [scrollView addSubview:headerV];
  37. [headerV mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.centerX.equalTo(self.view);
  39. make.top.offset(0.0f);
  40. make.height.offset(208.0f);
  41. }];
  42. UIImageView *levelBigV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_ic_unions_popularize_%ld",level - 1]]];
  43. [headerV addSubview:levelBigV];
  44. [levelBigV mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.bottom.equalTo(headerV.mas_bottom).offset(0.0f);
  46. make.centerX.equalTo(headerV);
  47. make.size.mas_offset(CGSizeMake(84.0f, 84.0f));
  48. }];
  49. // UILabel *timeL = [[UILabel alloc] init];
  50. // timeL.font = LCFont12;
  51. // timeL.textColor = HexColorFromRGB(0xFF80AF);
  52. // timeL.text = @"截止时间:5月21日";
  53. // [headerInfoV addSubview:timeL];
  54. // [timeL mas_makeConstraints:^(MASConstraintMaker *make) {
  55. // make.right.offset(-16.0f);
  56. // make.top.bottom.offset(0.0f);
  57. // }];
  58. UIView *levelMinBgV = [[UIView alloc] init];
  59. [scrollView addSubview:levelMinBgV];
  60. [levelMinBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.offset(ScaleSize(22.0f));
  62. make.right.offset(-ScaleSize(22.0f));
  63. make.top.equalTo(headerV.mas_bottom).offset(20.0f);
  64. make.height.offset(60.0f);
  65. }];
  66. NSMutableArray *levelTitles = [NSMutableArray array];
  67. for (NSInteger i = 0; i < scales.count; i ++) {
  68. NSDictionary *dict = scales[i];
  69. [levelTitles addObject:[NSString stringWithFormat:@"%@/%@",@(num_int),[dict objectForKey:@"num_int"]]];
  70. }
  71. NSArray *levels = @[
  72. @{@"image":@"vqu_images_ic_unions_popularize_min_selected_0",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_0"},
  73. @{@"image":@"vqu_images_ic_unions_popularize_min_1",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_1"},
  74. @{@"image":@"vqu_images_ic_unions_popularize_min_2",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_2"},
  75. // @{@"image":@"vqu_images_ic_unions_popularize_min_3",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_3"},
  76. // @{@"image":@"vqu_images_ic_unions_popularize_min_4",@"selectedImage":@"vqu_images_ic_unions_popularize_min_selected_4"},
  77. ];
  78. CGFloat totalWidth = KScreenWidth - ScaleSize(44.0f);
  79. CGFloat width = (totalWidth - 28.0f) / (levels.count - 1);
  80. for (NSInteger i = 0; i < levels.count; i ++) {
  81. NSInteger currentIndex = level - 1;
  82. NSDictionary *dict = levels[i];
  83. UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(i * width, 6.0f, 28.0f, 28.0f)];
  84. imageV.image = [UIImage imageNamed:dict[@"image"]];
  85. [levelMinBgV addSubview:imageV];
  86. UILabel *levelV = [[UILabel alloc] init];
  87. levelV.text =levelTitles[i];
  88. levelV.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.25f];
  89. levelV.font = LCFont(11.0f);
  90. levelV.textAlignment = NSTextAlignmentCenter;
  91. [levelMinBgV addSubview:levelV];
  92. [levelV mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.centerX.equalTo(imageV);
  94. make.top.equalTo(imageV.mas_bottom).offset(4.0f);
  95. make.height.offset(16.0f);
  96. }];
  97. if (i <= currentIndex) {
  98. imageV.image = [UIImage imageNamed:dict[@"selectedImage"]];
  99. levelV.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.85f];
  100. }
  101. if (i < levels.count - 1) {
  102. UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imageV.frame) + 2.0f, (28.0f - 1.0f) / 2.0f + 6.0f, width - (imageV.mj_h + 4.0f), 1.0f)];
  103. progressView.progress = 0.0f;
  104. if (i <= currentIndex - 1) {
  105. progressView.progress = 1.0f;
  106. }
  107. progressView.progressTintColor = HexColorFromRGB(0xFF80AF);
  108. progressView.trackTintColor = [HexColorFromRGB(0xAAAAAA) colorWithAlphaComponent:0.30f];
  109. [levelMinBgV addSubview:progressView];
  110. }else{
  111. }
  112. }
  113. // UILabel *currentLevelL = [[UILabel alloc] init];
  114. // currentLevelL.font = LCFont12;
  115. // currentLevelL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8f];
  116. // currentLevelL.text = @"当前等级";
  117. // [headerV addSubview:currentLevelL];
  118. // [currentLevelL mas_makeConstraints:^(MASConstraintMaker *make) {
  119. // make.top.equalTo(levelBigV.mas_bottom).offset(4.0f);
  120. // make.centerX.equalTo(headerV);
  121. // }];
  122. UIView *headerInfoV = [[UIView alloc] init];
  123. headerInfoV.backgroundColor = HexColorFromRGB(0x2F3038);
  124. [scrollView addSubview:headerInfoV];
  125. [headerInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.left.offset(0.0f);
  127. make.top.equalTo(levelMinBgV.mas_bottom).offset(20.0f);
  128. make.width.offset(KScreenWidth);
  129. make.height.offset(40.0f);
  130. }];
  131. UILabel *moneyL = [[UILabel alloc] init];
  132. moneyL.font = LCBoldFont(14.0f);
  133. moneyL.textColor = [UIColor whiteColor];
  134. moneyL.text = [NSString stringWithFormat:@"%@%@",LCStr(word28),self.youpaipnetworkData[@"num"]];//本期贡献流水:
  135. [headerInfoV addSubview:moneyL];
  136. [moneyL mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.left.offset(16.0f);
  138. make.top.bottom.offset(0.0f);
  139. }];
  140. UILabel *descL = [[UILabel alloc] init];
  141. descL.font = LCFont14;
  142. descL.textColor = [UIColor whiteColor];
  143. descL.text = @"推广制度:";
  144. [scrollView addSubview:descL];
  145. [descL mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.left.offset(14.0f);
  147. make.top.equalTo(headerInfoV.mas_bottom).offset(40.0f);
  148. }];
  149. UILabel *contentL = [[UILabel alloc] init];
  150. contentL.font = LCFont12;
  151. contentL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.65f];;
  152. contentL.numberOfLines = 0;
  153. NSString *str = LCStr(word29); //@"1、用户邀请女神便可成为推广人,当流水达到相对应的成长值时,会自动升级,可跳级成长;\n\n2、成为相应的等级时,推广人会在未来的30天内享受对应的分成比例,若30天内没有达到当前等级的月贡献流水时,则下降一级。";
  154. NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str];
  155. NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  156. paragraphStyle1.alignment=NSTextAlignmentJustified;
  157. NSDictionary * dic =@{
  158. NSParagraphStyleAttributeName:paragraphStyle1,
  159. NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone],
  160. };
  161. [attributedString1 setAttributes:dic range:NSMakeRange(0, attributedString1.length)];
  162. [contentL setAttributedText:attributedString1];
  163. [scrollView addSubview:contentL];
  164. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  165. make.left.offset(14.0f);
  166. make.width.offset(KScreenWidth-28.0f);
  167. make.top.equalTo(descL.mas_bottom).offset(20.0f);
  168. }];
  169. NSArray *colors = @[
  170. @[HexColorFromRGB(0xE7CCB6),HexColorFromRGB(0xC47A65)],
  171. @[HexColorFromRGB(0xCCE5FF),HexColorFromRGB(0x5D93E6)],
  172. @[HexColorFromRGB(0xFFE397),HexColorFromRGB(0xDB9E2F)],
  173. ];
  174. UIView *footerV = [[UIView alloc] init];
  175. footerV.backgroundColor = HexColorFromRGB(0x2F3038);
  176. footerV.layer.cornerRadius = 20.0f;
  177. footerV.clipsToBounds = YES;
  178. [scrollView addSubview:footerV];
  179. [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
  180. make.left.offset(14.0f);
  181. make.width.offset(KScreenWidth-28.0f);
  182. make.top.equalTo(contentL.mas_bottom).offset(40.0f);
  183. make.height.offset((ScaleSize(48.0f) * (scales.count + 1)));
  184. }];
  185. UIView *fHeaderV = [[UIView alloc] init];
  186. fHeaderV.backgroundColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 28.0f, ScaleSize(48.0f)) FromColors:colors[level - 1] ByGradientType:GradientTopToBottom]];
  187. [footerV addSubview:fHeaderV];
  188. [fHeaderV mas_makeConstraints:^(MASConstraintMaker *make) {
  189. make.left.top.right.offset(0.0f);
  190. make.height.offset(ScaleSize(48.0f));
  191. }];
  192. UILabel *levelL = [[UILabel alloc] init];
  193. levelL.font = LCFont14;
  194. levelL.textColor = [UIColor whiteColor];
  195. levelL.text = @"推广等级";
  196. levelL.textAlignment = NSTextAlignmentCenter;
  197. [fHeaderV addSubview:levelL];
  198. [levelL mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.left.top.bottom.offset(0.0f);
  200. make.width.offset((KScreenWidth - 28.0f) * 0.25f);
  201. }];
  202. UILabel *scaleL = [[UILabel alloc] init];
  203. scaleL.font = LCFont14;
  204. scaleL.textColor = [UIColor whiteColor];
  205. scaleL.text = LCStr(word30);//1v1分成
  206. scaleL.textAlignment = NSTextAlignmentCenter;
  207. [fHeaderV addSubview:scaleL];
  208. [scaleL mas_makeConstraints:^(MASConstraintMaker *make) {
  209. make.top.bottom.offset(0.0f);
  210. make.left.equalTo(levelL.mas_right);
  211. make.width.offset((KScreenWidth - 28.0f) * 0.25f);
  212. }];
  213. UILabel *liveScaleL = [[UILabel alloc] init];
  214. liveScaleL.font = LCFont14;
  215. liveScaleL.textColor = [UIColor whiteColor];
  216. liveScaleL.text = LCStr(word31);//直播分成
  217. liveScaleL.textAlignment = NSTextAlignmentCenter;
  218. [fHeaderV addSubview:liveScaleL];
  219. [liveScaleL mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.top.bottom.offset(0.0f);
  221. make.left.equalTo(scaleL.mas_right);
  222. make.width.offset((KScreenWidth - 28.0f) * 0.25f);
  223. }];
  224. UILabel *priceL = [[UILabel alloc] init];
  225. priceL.font = LCFont14;
  226. priceL.textColor = [UIColor whiteColor];
  227. priceL.text = @"成长值";
  228. priceL.textAlignment = NSTextAlignmentCenter;
  229. [fHeaderV addSubview:priceL];
  230. [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  231. make.top.bottom.offset(0.0f);
  232. make.left.equalTo(liveScaleL.mas_right);
  233. make.right.offset(0.0f);
  234. }];
  235. // NSArray *levelContents = @[
  236. // @{@"level":@"0",@"scale":@"5%",@"price":@"0"},
  237. // @{@"level":@"1星",@"scale":@"8%",@"price":@"10万"},
  238. // @{@"level":@"2星",@"scale":@"12%",@"price":@"30万"},
  239. // @{@"level":@"3星",@"scale":@"16%",@"price":@"60万"},
  240. // ];
  241. for (NSInteger i = 0; i < scales.count; i ++) {
  242. NSDictionary *dict = scales[i];
  243. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, ScaleSize(48.0f) + i * ScaleSize(48.0f), KScreenWidth - 28.0f, ScaleSize(48.0f))];
  244. [footerV addSubview:view];
  245. UILabel *levelL = [[UILabel alloc] init];
  246. levelL.font = LCFont14;
  247. levelL.textColor = [UIColor whiteColor];
  248. levelL.text = [NSString stringWithFormat:@"%@级",dict[@"level"]];
  249. levelL.textAlignment = NSTextAlignmentCenter;
  250. [view addSubview:levelL];
  251. [levelL mas_makeConstraints:^(MASConstraintMaker *make) {
  252. make.left.top.bottom.offset(0.0f);
  253. make.width.offset((KScreenWidth - 28.0f) * 0.25f);
  254. }];
  255. UILabel *scaleL = [[UILabel alloc] init];
  256. scaleL.font = LCFont14;
  257. scaleL.textColor = [UIColor whiteColor];
  258. scaleL.text = dict[@"ratio2"];
  259. scaleL.textAlignment = NSTextAlignmentCenter;
  260. [view addSubview:scaleL];
  261. [scaleL mas_makeConstraints:^(MASConstraintMaker *make) {
  262. make.top.bottom.offset(0.0f);
  263. make.left.equalTo(levelL.mas_right);
  264. make.width.offset((KScreenWidth - 28.0f) * 0.25f);
  265. }];
  266. UILabel *liveScaleL = [[UILabel alloc] init];
  267. liveScaleL.font = LCFont14;
  268. liveScaleL.textColor = [UIColor whiteColor];
  269. liveScaleL.text = dict[@"ratio1"];
  270. liveScaleL.textAlignment = NSTextAlignmentCenter;
  271. [view addSubview:liveScaleL];
  272. [liveScaleL mas_makeConstraints:^(MASConstraintMaker *make) {
  273. make.top.bottom.offset(0.0f);
  274. make.left.equalTo(scaleL.mas_right);
  275. make.width.offset((KScreenWidth - 28.0f) * 0.25f);
  276. }];
  277. UILabel *priceL = [[UILabel alloc] init];
  278. priceL.font = LCFont14;
  279. priceL.textColor = [UIColor whiteColor];
  280. priceL.text = [NSString stringWithFormat:@"%@",dict[@"num_text"]];
  281. priceL.textAlignment = NSTextAlignmentCenter;
  282. [view addSubview:priceL];
  283. [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  284. make.top.bottom.right.offset(0.0f);
  285. make.left.equalTo(liveScaleL.mas_right);
  286. }];
  287. if (i == level - 1) {
  288. view.backgroundColor = [HexColorFromRGB(0x585A6A) colorWithAlphaComponent:0.47f];
  289. }
  290. }
  291. [scrollView layoutIfNeeded];
  292. scrollView.contentSize = CGSizeMake(KScreenWidth, footerV.frame.size.height + footerV.frame.origin.y + TabbarHeight);
  293. }
  294. - (void)youpaifrequestData{
  295. [LCHttpHelper requestWithURLString:UnionsPromotion parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  296. NSDictionary* dict = (NSDictionary*)responseObject;
  297. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  298. if (code == 0) {//成功
  299. self.youpaipnetworkData = [dict objectForKey:@"data"];
  300. [self youpaifsetupUI];
  301. }
  302. } failure:^(NSError *error) {
  303. }];
  304. }
  305. @end