省钱达人

DRCommissionHeaderView.m 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // DRCommissionHeaderView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRCommissionHeaderView.h"
  9. @interface DRCommissionHeaderView ()
  10. @property (nonatomic, strong) UILabel *blancePrice;
  11. @property (nonatomic, strong) UILabel *totalPrice;
  12. @property (nonatomic, strong) UILabel *didPrice;
  13. @property (nonatomic, strong) UIButton *didBtn;
  14. @end
  15. @implementation DRCommissionHeaderView
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.backgroundColor = [UIColor changeColor];
  20. [self initSubViews];
  21. [self request];
  22. }
  23. return self;
  24. }
  25. -(void)request{
  26. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/commisonPrice",BaseURL];
  27. [DRHttp post:url params:nil success:^(id json) {
  28. if (json[@"data"]) {
  29. NSString *blanceStr=json[@"data"][@"all"];
  30. NSString *totalStr=json[@"data"][@"notEnd"];
  31. NSString *didStr=json[@"data"][@"end"];
  32. self.blancePrice.text =[NSString stringWithFormat:@"%.2f",[blanceStr floatValue]];
  33. self.totalPrice.text =[NSString stringWithFormat:@"总收入(元):%.2f",[totalStr floatValue]];
  34. self.didPrice.text =[NSString stringWithFormat:@"已提现(元):%.2f",[didStr floatValue]];
  35. }
  36. } failure:^(NSError *error) {
  37. }];
  38. }
  39. - (void)initSubViews {
  40. UILabel *blanceTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 100, 20)];
  41. blanceTitle.textColor = [UIColor whiteColor];
  42. blanceTitle.font = [UIFont systemFontOfSize:14];
  43. blanceTitle.text = @"佣金总计(元)";
  44. [self addSubview:blanceTitle];
  45. self.blancePrice = [[UILabel alloc] initWithFrame:CGRectMake(15, blanceTitle.bottom+5, SCREEN_WIDTH-100, 40)];
  46. self.blancePrice.textColor = [UIColor whiteColor];
  47. self.blancePrice.font = [UIFont boldSystemFontOfSize:32];
  48. self.blancePrice.text = @"--.--";
  49. [self addSubview:self.blancePrice];
  50. self.totalPrice = [[UILabel alloc] initWithFrame:CGRectMake(15, self.blancePrice.bottom+10, SCREEN_WIDTH/2-20, 20)];
  51. self.totalPrice.text = @"待结算(元):--";
  52. self.totalPrice.textColor = [UIColor whiteColor];
  53. self.totalPrice.font = [UIFont systemFontOfSize:14];
  54. [self addSubview:self.totalPrice];
  55. self.didPrice = [[UILabel alloc] initWithFrame:CGRectMake(self.totalPrice.right+10, self.totalPrice.top, SCREEN_WIDTH/2-20, 20)];
  56. self.didPrice.textAlignment = NSTextAlignmentRight;
  57. self.didPrice.font = [UIFont systemFontOfSize:14];
  58. self.didPrice.textColor = [UIColor whiteColor];
  59. self.didPrice.text = @"已结算(元):--";
  60. [self addSubview:self.didPrice];
  61. self.didBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width-10-80, self.didPrice.top-23-20, 80, 20)];
  62. [self.didBtn setTitle:@"查看红包" forState:UIControlStateNormal];
  63. [self.didBtn setImage:[UIImage imageNamed:@"goto_white"] forState:UIControlStateNormal];
  64. self.didBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  65. [self.didBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  66. [self.didBtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0];
  67. [self addSubview:self.didBtn];
  68. }
  69. @end