PromoteController.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:16],NSFontAttributeName, nil] forState:UIControlStateNormal];
  36. [rightBtn setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:16],NSFontAttributeName, nil] forState:UIControlStateSelected];
  37. [rightBtn setTintColor:[UIColor whiteColor]];
  38. self.navigationItem.rightBarButtonItem = rightBtn;
  39. NSString *str = @"用户端\n1:所有用户都可参与推广奖励\n2:通过分享自己的专属“推广链接”或“二维码”下载千模通告及注册的用户,才算做“我的推广用户”\n3:用户充值分成比例为10%\n4:分成金额可用于提现或兑换服务\n\n模特端\n1:推荐并通过审核以后,总数达到30人以上,即可申请成为“经纪人”\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 setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  55. [self.navigationController.navigationBar setShadowImage:[UIImage new]];
  56. }
  57. - (void)viewWillDisappear:(BOOL)animated {
  58. [super viewWillDisappear:animated];
  59. [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  60. [self.navigationController.navigationBar setShadowImage:nil];
  61. self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  62. }
  63. - (void)viewDidLayoutSubviews {
  64. CAGradientLayer *gl = [CAGradientLayer layer];
  65. gl.frame = self.view.bounds;
  66. gl.startPoint = CGPointMake(0.5, 0);
  67. gl.endPoint = CGPointMake(0.5, 0.98);
  68. 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];
  69. gl.locations = @[@(0), @(1.0f)];
  70. [self.view.layer insertSublayer:gl atIndex:0];
  71. // gradient
  72. CAGradientLayer *gl1 = [CAGradientLayer layer];
  73. gl1.frame = self.contentView.bounds;
  74. gl1.startPoint = CGPointMake(0.5, 0);
  75. gl1.endPoint = CGPointMake(0.5, 0.97);
  76. 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];
  77. gl1.locations = @[@(0), @(1.0f)];
  78. self.contentView.layer.cornerRadius = 24;
  79. self.contentView.clipsToBounds = YES;
  80. [self.contentView.layer insertSublayer:gl1 atIndex:0];
  81. }
  82. - (void)backClick {
  83. [self.navigationController popViewControllerAnimated:YES];
  84. }
  85. - (void)detail {
  86. MyTeamController *vc = [[MyTeamController alloc] init];
  87. [self.navigationController pushViewController:vc animated:YES];
  88. }
  89. - (void)getData {
  90. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].pk, @"memberpk", nil];
  91. [YanCNetWorkManager requestPostWithURLStr:Url_getCurrentShareCoin(PublicUrl)
  92. parameters:dic
  93. finish:^(id response) {
  94. BOOL success = [response[@"success"] intValue];
  95. if (success) {
  96. total = [response[@"total"] doubleValue];
  97. available = [response[@"available"] doubleValue];
  98. self.rewardLabel.text = [response[@"total"] stringValue];
  99. } else {
  100. [MBProgressHUD showInfo:@"请求失败!"];
  101. }
  102. }
  103. enError:^(NSError *error) {
  104. }];
  105. }
  106. - (IBAction)transfer:(id)sender {
  107. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认转到M币?" preferredStyle:UIAlertControllerStyleAlert];
  108. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  109. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  110. [self transferCoin];
  111. }]];
  112. [self.navigationController presentViewController:alert animated:YES completion:nil];
  113. }
  114. - (void)transferCoin {
  115. __weak PromoteController *this = self;
  116. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].pk, @"memberpk", nil];
  117. [YanCNetWorkManager requestPostWithURLStr:Url_transferCoin(PublicUrl)
  118. parameters:dic
  119. finish:^(id response) {
  120. BOOL success = [response[@"success"] intValue] == 1;
  121. if (success) {
  122. [MBProgressHUD showSuccess:@"转出成功"];
  123. } else {
  124. [MBProgressHUD showInfo:response[@"error"]];
  125. }
  126. [this getData];
  127. }
  128. enError:^(NSError *error) {
  129. }];
  130. }
  131. - (IBAction)invite:(id)sender {
  132. ChooseShareController* vc = [[ChooseShareController alloc] init];
  133. vc.delegate = self;
  134. [self.tabBarController presentViewController:vc animated:NO completion:nil];
  135. }
  136. -(void)shareMember{
  137. ShareViewController *vc = [[ShareViewController alloc] init];
  138. vc.hidesBottomBarWhenPushed = YES;
  139. vc.type = 1;
  140. [self.navigationController pushViewController:vc animated:YES];
  141. }
  142. -(void)shareModel{
  143. ShareViewController *vc = [[ShareViewController alloc] init];
  144. vc.hidesBottomBarWhenPushed = YES;
  145. vc.type = 2;
  146. [self.navigationController pushViewController:vc animated:YES];
  147. }
  148. @end