省钱达人

DROrderHeaderView.m 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // DROrderHeaderView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/18.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DROrderHeaderView.h"
  9. @interface DROrderHeaderView ()
  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. @property (nonatomic, copy ) NSString *money;
  15. @end
  16. @implementation DROrderHeaderView
  17. - (instancetype)initWithFrame:(CGRect)frame {
  18. self = [super initWithFrame:frame];
  19. if (self) {
  20. self.backgroundColor = [UIColor changeColor];
  21. self.money=@"0";
  22. [self initSubViews];
  23. [self request];
  24. }
  25. return self;
  26. }
  27. -(void)request{
  28. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/accountPrice",BaseURL];
  29. [DRHttp post:url params:nil success:^(id json) {
  30. if (json[@"data"]) {
  31. self.money=[NSString stringWithFormat:@"%@",json[@"data"][@"notEnd"]];
  32. self.blancePrice.text =[NSString stringWithFormat:@"¥%@",json[@"data"][@"notEnd"]];
  33. self.totalPrice.text =[NSString stringWithFormat:@"总收入:¥%@",json[@"data"][@"all"]];
  34. self.didPrice.text =[NSString stringWithFormat:@"已提现:¥%@",json[@"data"][@"end"]];
  35. }
  36. } failure:^(NSError *error) {
  37. }];
  38. }
  39. -(void)didAction{
  40. if (self.delegate && [self.delegate respondsToSelector:@selector(changeToWithdrawVCwithMoneyStr:)]) {
  41. [self.delegate changeToWithdrawVCwithMoneyStr:self.money];
  42. }
  43. }
  44. - (void)initSubViews {
  45. UILabel *blanceTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 100, 20)];
  46. blanceTitle.textColor = [UIColor whiteColor];
  47. blanceTitle.font = [UIFont systemFontOfSize:14];
  48. blanceTitle.text = @"账户余额";
  49. [self addSubview:blanceTitle];
  50. self.blancePrice = [[UILabel alloc] initWithFrame:CGRectMake(15, blanceTitle.bottom+5, SCREEN_WIDTH-100, 40)];
  51. self.blancePrice.textColor = [UIColor whiteColor];
  52. self.blancePrice.font = [UIFont boldSystemFontOfSize:32];
  53. self.blancePrice.text = @"--.--";
  54. [self addSubview:self.blancePrice];
  55. self.totalPrice = [[UILabel alloc] initWithFrame:CGRectMake(15, self.blancePrice.bottom+10, SCREEN_WIDTH/2-20, 20)];
  56. self.totalPrice.text = @"总收入(元):--";
  57. self.totalPrice.textColor = [UIColor whiteColor];
  58. self.totalPrice.font = [UIFont systemFontOfSize:14];
  59. [self addSubview:self.totalPrice];
  60. self.didPrice = [[UILabel alloc] initWithFrame:CGRectMake(self.totalPrice.right+10, self.totalPrice.top, SCREEN_WIDTH/2-20, 20)];
  61. self.didPrice.textAlignment = NSTextAlignmentRight;
  62. self.didPrice.font = [UIFont systemFontOfSize:14];
  63. self.didPrice.textColor = [UIColor whiteColor];
  64. self.didPrice.text = @"已提现(元):--";
  65. [self addSubview:self.didPrice];
  66. self.didBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width-10-44, self.didPrice.top-23-20, 44, 20)];
  67. [self.didBtn setTitle:@"提现" forState:UIControlStateNormal];
  68. self.didBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  69. [self.didBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  70. self.didBtn.layer.cornerRadius = 10;
  71. self.didBtn.layer.borderWidth = 1;
  72. self.didBtn.layer.borderColor = [UIColor whiteColor].CGColor;
  73. [self.didBtn addTarget:self action:@selector(didAction) forControlEvents:UIControlEventTouchUpInside];
  74. [self addSubview:self.didBtn];
  75. }
  76. @end