PromoteController.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. // PromoteController.m
  3. // model
  4. //
  5. // Created by Drew on 2018/10/29.
  6. // Copyright © 2018 Mine. All rights reserved.
  7. //
  8. #import "PromoteController.h"
  9. #import "ShareViewController.h"
  10. #import "ChooseShareController.h"
  11. #import "MyTeamController.h"
  12. @interface PromoteController () <ShareProtocol> {
  13. double total;
  14. double available;
  15. }
  16. @property(weak, nonatomic) IBOutlet UILabel *rewardLabel;
  17. @property(weak, nonatomic) IBOutlet UILabel *descLabel;
  18. @property(weak, nonatomic) IBOutlet UIView *contentView;
  19. @end
  20. @implementation PromoteController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  24. btn.frame = CGRectMake(0, 0, 40, 40);
  25. UIImage *image = [[UIImage imageNamed:@"backBtn"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  26. [btn setImage:image forState:UIControlStateNormal];
  27. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
  28. btn.tintColor = [UIColor whiteColor];
  29. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  30. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  31. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  32. nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  33. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  34. UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"推广明细" style:UIBarButtonItemStylePlain target:self action:@selector(detail)];
  35. [rightBtn setTitleTextAttributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:16]} forState:UIControlStateNormal];
  36. [rightBtn setTitleTextAttributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:16]} forState:UIControlStateSelected];
  37. [rightBtn setTintColor:[UIColor whiteColor]];
  38. self.navigationItem.rightBarButtonItem = rightBtn;
  39. NSString *str = @"用户端\n1:所有用户都可参与推广奖励\n2:通过分享自己的专属“推广链接”或“二维码”下载千模通告及注册的用户,才算做“我的推广用户”\n3:用户充值分成比例为10%\n4:分成金额可用于提现或兑换服务\n\n模特端\n1:推荐并通过审核以后,总数达到9人以上,即可申请成为“经纪人”\n2:经纪人享有所有推荐模特视频面试交易金额的10%作为奖励及其他奖励\n3:奖励可用于提现或购买平台服务";
  40. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str];
  41. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:[str rangeOfString:@"用户端"]];
  42. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:[str rangeOfString:@"模特端"]];
  43. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  44. [paragraphStyle setLineSpacing:2];
  45. [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, str.length)];
  46. self.descLabel.attributedText = attrStr;
  47. total = 0.0;
  48. available = 0.0;
  49. [self getData];
  50. }
  51. - (void)viewWillAppear:(BOOL)animated {
  52. [super viewWillAppear:animated];
  53. self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
  54. self.navigationController.navigationBar.translucent = YES;
  55. [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  56. [self.navigationController.navigationBar setShadowImage:[UIImage new]];
  57. }
  58. - (void)viewWillDisappear:(BOOL)animated {
  59. [super viewWillDisappear:animated];
  60. self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  61. [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  62. [self.navigationController.navigationBar setShadowImage:nil];
  63. }
  64. - (void)viewDidLayoutSubviews {
  65. CAGradientLayer *gl = [CAGradientLayer layer];
  66. gl.frame = self.view.bounds;
  67. gl.startPoint = CGPointMake(0.5, 0);
  68. gl.endPoint = CGPointMake(0.5, 0.98);
  69. gl.colors = @[(__bridge id) [UIColor colorWithRed:251 / 255.0 green:92 / 255.0 blue:163 / 255.0 alpha:1].CGColor, (__bridge id) [UIColor colorWithRed:253 / 255.0 green:127 / 255.0 blue:141 / 255.0 alpha:1].CGColor];
  70. gl.locations = @[@(0), @(1.0f)];
  71. [self.view.layer insertSublayer:gl atIndex:0];
  72. // gradient
  73. CAGradientLayer *gl1 = [CAGradientLayer layer];
  74. gl1.frame = self.contentView.bounds;
  75. gl1.startPoint = CGPointMake(0.5, 0);
  76. gl1.endPoint = CGPointMake(0.5, 0.97);
  77. gl1.colors = @[(__bridge id) [UIColor colorWithRed:255 / 255.0 green:216 / 255.0 blue:134 / 255.0 alpha:1].CGColor, (__bridge id) [UIColor colorWithRed:252 / 255.0 green:136 / 255.0 blue:149 / 255.0 alpha:1].CGColor];
  78. gl1.locations = @[@(0), @(1.0f)];
  79. self.contentView.layer.cornerRadius = 24;
  80. self.contentView.clipsToBounds = YES;
  81. [self.contentView.layer insertSublayer:gl1 atIndex:0];
  82. }
  83. - (UIStatusBarStyle)preferredStatusBarStyle {
  84. return UIStatusBarStyleLightContent;
  85. }
  86. - (void)backClick {
  87. [self.navigationController popViewControllerAnimated:YES];
  88. }
  89. - (void)detail {
  90. MyTeamController *vc = [[MyTeamController alloc] init];
  91. [self.navigationController pushViewController:vc animated:YES];
  92. }
  93. - (void)getData {
  94. NSDictionary *dic = @{@"memberpk": [ModelUser user].pk};
  95. [YanCNetWorkManager requestPostWithURLStr:Url_getCurrentShareCoin(PublicUrl)
  96. parameters:dic
  97. finish:^(id response) {
  98. BOOL success = [response[@"success"] intValue];
  99. if (success) {
  100. total = [response[@"total"] doubleValue];
  101. available = [response[@"available"] doubleValue];
  102. self.rewardLabel.text = [response[@"total"] stringValue];
  103. } else {
  104. [MBProgressHUD showInfo:@"请求失败!"];
  105. }
  106. }
  107. enError:^(NSError *error) {
  108. }];
  109. }
  110. - (IBAction)transfer:(id)sender {
  111. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认转到M币?" preferredStyle:UIAlertControllerStyleAlert];
  112. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  113. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
  114. [self transferCoin];
  115. }]];
  116. [self.navigationController presentViewController:alert animated:YES completion:nil];
  117. }
  118. - (void)transferCoin {
  119. __weak PromoteController *this = self;
  120. NSDictionary *dic = @{@"memberpk": [ModelUser user].pk};
  121. [YanCNetWorkManager requestPostWithURLStr:Url_transferCoin(PublicUrl)
  122. parameters:dic
  123. finish:^(id response) {
  124. BOOL success = [response[@"success"] intValue] == 1;
  125. if (success) {
  126. [MBProgressHUD showSuccess:@"转出成功"];
  127. } else {
  128. [MBProgressHUD showInfo:response[@"error"]];
  129. }
  130. [this getData];
  131. }
  132. enError:^(NSError *error) {
  133. }];
  134. }
  135. - (IBAction)invite:(id)sender {
  136. ChooseShareController *vc = [[ChooseShareController alloc] init];
  137. vc.delegate = self;
  138. [self.tabBarController presentViewController:vc animated:NO completion:nil];
  139. }
  140. - (void)shareMember {
  141. ShareViewController *vc = [[ShareViewController alloc] init];
  142. vc.hidesBottomBarWhenPushed = YES;
  143. vc.type = 1;
  144. [self.navigationController pushViewController:vc animated:YES];
  145. }
  146. - (void)shareModel {
  147. ShareViewController *vc = [[ShareViewController alloc] init];
  148. vc.hidesBottomBarWhenPushed = YES;
  149. vc.type = 2;
  150. [self.navigationController pushViewController:vc animated:YES];
  151. }
  152. @end