省钱达人

DRAccountHeader.m 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // DRAccountHeader.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/6/8.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRAccountHeader.h"
  9. @interface DRAccountHeader(){
  10. UILabel *_blanceLabel;
  11. NSString *_blance;
  12. }
  13. @end
  14. @implementation DRAccountHeader
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. self.backgroundColor = [UIColor changeColor];
  19. [self initSubViews];
  20. [self request];
  21. }
  22. return self;
  23. }
  24. - (void)initSubViews {
  25. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(25, 10, 200, 20)];
  26. title.text = @"账户余额:";
  27. title.font = [UIFont systemFontOfSize:14];
  28. title.textColor = [UIColor whiteColor];
  29. [self addSubview:title];
  30. _blanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, title.bottom+10, 200, 30)];
  31. _blanceLabel.textColor = [UIColor whiteColor];
  32. _blanceLabel.font = [UIFont boldSystemFontOfSize:35];
  33. _blanceLabel.text = @"--.--";
  34. [self addSubview:_blanceLabel];
  35. UIButton *money = [[UIButton alloc] initWithFrame:CGRectMake(self.width-20-40, 40, 40, 30)];
  36. [money setTitle:@"提现" forState:UIControlStateNormal];
  37. [money setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  38. money.titleLabel.font = [UIFont systemFontOfSize:14];
  39. [self addSubview:money];
  40. [money addTarget:self action:@selector(moneyAction) forControlEvents:UIControlEventTouchUpInside];
  41. }
  42. - (void)moneyAction {
  43. if (self.moneyBackBlcok) {
  44. self.moneyBackBlcok(_blance);
  45. }
  46. }
  47. - (void)request{
  48. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/accountPrice",BaseURL];
  49. [DRHttp post:url params:nil success:^(id json) {
  50. if (json[@"data"]) {
  51. _blance = [NSString stringWithFormat:@"%@",json[@"data"][@"notEnd"]];
  52. _blanceLabel.text = [NSString stringWithFormat:@"¥%@",_blance];
  53. }
  54. } failure:^(NSError *error) {
  55. }];
  56. }
  57. @end