| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- //
- // PromoteController.m
- // model
- //
- // Created by Drew on 2018/10/29.
- // Copyright © 2018 Mine. All rights reserved.
- //
- #import "PromoteController.h"
- #import "ShareViewController.h"
- #import "ChooseShareController.h"
- #import "MyTeamController.h"
- @interface PromoteController ()<ShareProtocol>{
- double total;
- double available;
- }
- @property (weak, nonatomic) IBOutlet UILabel *rewardLabel;
- @property (weak, nonatomic) IBOutlet UILabel *descLabel;
- @property (weak, nonatomic) IBOutlet UIView *contentView;
- @end
- @implementation PromoteController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(0, 0, 40, 40);
- UIImage *image = [[UIImage imageNamed:@"backBtn"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
- [btn setImage:image forState:UIControlStateNormal];
- btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
- btn.tintColor = [UIColor whiteColor];
- [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
- UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
- self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
-
- UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"推广明细" style:UIBarButtonItemStylePlain target:self action:@selector(detail)];
- [rightBtn setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:16],NSFontAttributeName, nil] forState:UIControlStateNormal];
- [rightBtn setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:16],NSFontAttributeName, nil] forState:UIControlStateSelected];
- [rightBtn setTintColor:[UIColor whiteColor]];
- self.navigationItem.rightBarButtonItem = rightBtn;
-
- NSString *str = @"用户端\n1:所有用户都可参与推广奖励\n2:通过分享自己的专属“推广链接”或“二维码”下载千模通告及注册的用户,才算做“我的推广用户”\n3:用户充值分成比例为10%\n4:分成金额可用于提现或兑换服务\n\n模特端\n1:推荐并通过审核以后,总数达到30人以上,即可申请成为“经纪人”\n2:经纪人享有所有推荐模特视频面试交易金额的10%作为奖励及其他奖励\n3:奖励可用于提现或购买平台服务";
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str];
- [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:[str rangeOfString:@"用户端"]];
- [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:[str rangeOfString:@"模特端"]];
- NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:2];
- [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, str.length)];
- self.descLabel.attributedText = attrStr;
-
- total = 0.0;
- available = 0.0;
- [self getData];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
- [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
- [self.navigationController.navigationBar setShadowImage:[UIImage new]];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
- [self.navigationController.navigationBar setShadowImage:nil];
- self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- }
- - (void)viewDidLayoutSubviews {
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = self.view.bounds;
- gl.startPoint = CGPointMake(0.5, 0);
- gl.endPoint = CGPointMake(0.5, 0.98);
- 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];
- gl.locations = @[@(0), @(1.0f)];
- [self.view.layer insertSublayer:gl atIndex:0];
- // gradient
- CAGradientLayer *gl1 = [CAGradientLayer layer];
- gl1.frame = self.contentView.bounds;
- gl1.startPoint = CGPointMake(0.5, 0);
- gl1.endPoint = CGPointMake(0.5, 0.97);
- 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];
- gl1.locations = @[@(0), @(1.0f)];
- self.contentView.layer.cornerRadius = 24;
- self.contentView.clipsToBounds = YES;
- [self.contentView.layer insertSublayer:gl1 atIndex:0];
- }
- - (void)backClick {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)detail {
- MyTeamController *vc = [[MyTeamController alloc] init];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)getData {
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].pk, @"memberpk", nil];
- [YanCNetWorkManager requestPostWithURLStr:Url_getCurrentShareCoin(PublicUrl)
- parameters:dic
- finish:^(id response) {
- BOOL success = [response[@"success"] intValue];
- if (success) {
- total = [response[@"total"] doubleValue];
- available = [response[@"available"] doubleValue];
- self.rewardLabel.text = [response[@"total"] stringValue];
- } else {
- [MBProgressHUD showInfo:@"请求失败!"];
- }
- }
- enError:^(NSError *error) {
- }];
- }
- - (IBAction)transfer:(id)sender {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认转到M币?" preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self transferCoin];
- }]];
- [self.navigationController presentViewController:alert animated:YES completion:nil];
- }
- - (void)transferCoin {
- __weak PromoteController *this = self;
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].pk, @"memberpk", nil];
- [YanCNetWorkManager requestPostWithURLStr:Url_transferCoin(PublicUrl)
- parameters:dic
- finish:^(id response) {
- BOOL success = [response[@"success"] intValue] == 1;
- if (success) {
- [MBProgressHUD showSuccess:@"转出成功"];
- } else {
- [MBProgressHUD showInfo:response[@"error"]];
- }
- [this getData];
- }
- enError:^(NSError *error) {
- }];
- }
- - (IBAction)invite:(id)sender {
- ChooseShareController* vc = [[ChooseShareController alloc] init];
- vc.delegate = self;
- [self.tabBarController presentViewController:vc animated:NO completion:nil];
- }
- -(void)shareMember{
- ShareViewController *vc = [[ShareViewController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- vc.type = 1;
- [self.navigationController pushViewController:vc animated:YES];
- }
- -(void)shareModel{
- ShareViewController *vc = [[ShareViewController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- vc.type = 2;
- [self.navigationController pushViewController:vc animated:YES];
- }
- @end
|