猎豆优选

LDWithdrawUserView.m 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // LDWithdrawUserView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/31.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDWithdrawUserView.h"
  9. @interface LDWithdrawUserView ()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UILabel *nameTitle;
  12. @property (nonatomic, strong) UILabel *accountTitle;
  13. @property (nonatomic, strong) UILabel *name;
  14. @property (nonatomic, strong) UILabel *account;
  15. @property (nonatomic, strong) UIButton *updateButton;
  16. @end
  17. @implementation LDWithdrawUserView
  18. - (instancetype)initWithFrame:(CGRect)frame {
  19. self = [super initWithFrame:frame];
  20. if (self) {
  21. [self initSubViews];
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. self.backgroundColor =[UIColor whiteColor];
  27. [self addSubview:self.iconView];
  28. [self addSubview:self.nameTitle];
  29. [self addSubview:self.accountTitle];
  30. [self addSubview:self.name];
  31. [self addSubview:self.account];
  32. [self addSubview:self.updateButton];
  33. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.mas_equalTo(Fitsize(15));
  35. make.width.height.mas_equalTo(Fitsize(46));
  36. make.centerY.mas_equalTo(self.mas_centerY);
  37. }];
  38. [self.nameTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(Fitsize(20));
  40. make.top.mas_equalTo(self.iconView.mas_top);
  41. }];
  42. [self.accountTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(self.nameTitle);
  44. make.bottom.mas_equalTo(self.iconView.mas_bottom);
  45. }];
  46. [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.mas_equalTo(self.nameTitle.mas_right).mas_offset(Fitsize(44));
  48. make.centerY.mas_equalTo(self.nameTitle.mas_centerY);
  49. }];
  50. [self.account mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.mas_equalTo(self.name);
  52. make.centerY.mas_equalTo(self.accountTitle.mas_centerY);
  53. }];
  54. [self.updateButton mas_makeConstraints:^(MASConstraintMaker *make) {
  55. // make.right.mas_equalTo(-Fitsize(15));
  56. make.centerY.mas_equalTo(self.iconView.mas_centerY);
  57. make.width.mas_equalTo(SCREEN_WIDTH);
  58. make.height.mas_equalTo(self.mas_height);
  59. }];
  60. }
  61. - (void)updateClickAction {
  62. if (self.updateAction) {
  63. self.updateAction();
  64. }
  65. }
  66. - (void)setUserInfo:(NSDictionary *)dict {
  67. NSString *name = dict[@"real_name"];
  68. NSMutableString *newStr = [NSMutableString string];
  69. if (name.length > 1) {
  70. for (int i = 0; i < name.length; i++) {
  71. if (i == 0) {
  72. NSString *temp = [name substringWithRange:NSMakeRange(i,1)];
  73. [newStr appendString:temp];
  74. }else {
  75. [newStr appendString:@"*"];
  76. }
  77. }
  78. }
  79. self.name.text = newStr;
  80. NSString *accountStr = dict[@"alipay_account"];
  81. NSString *newAccountStr;
  82. if (accountStr.length == 11 && ![accountStr containsString:@"@"]) {
  83. newAccountStr = [accountStr stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
  84. }else {
  85. newAccountStr = accountStr;
  86. }
  87. self.account.text = newAccountStr;
  88. }
  89. #pragma mark ----
  90. - (UIImageView *)iconView {
  91. if (!_iconView) {
  92. _iconView = [[UIImageView alloc] init];
  93. _iconView.image = [UIImage imageNamed:@"alipay_icon"];
  94. }
  95. return _iconView;
  96. }
  97. - (UILabel *)nameTitle {
  98. if (!_nameTitle) {
  99. _nameTitle = [[UILabel alloc] init];
  100. _nameTitle.font = [UIFont systemFontOfSize:Fitsize(16)];
  101. _nameTitle.textColor = [UIColor YHColorWithHex:0x000000];
  102. _nameTitle.text = @"真实姓名";
  103. }
  104. return _nameTitle;
  105. }
  106. - (UILabel *)accountTitle {
  107. if (!_accountTitle) {
  108. _accountTitle = [[UILabel alloc] init];
  109. _accountTitle.font = [UIFont systemFontOfSize:Fitsize(16)];
  110. _accountTitle.textColor = [UIColor YHColorWithHex:0x000000];
  111. _accountTitle.text = @"支付宝账号";
  112. }
  113. return _accountTitle;
  114. }
  115. - (UILabel *)name {
  116. if (!_name) {
  117. _name = [[UILabel alloc] init];
  118. _name.font = [UIFont systemFontOfSize:Fitsize(16)];
  119. _name.textColor = [UIColor YHColorWithHex:0x3E3E3E];
  120. _name.text = @"加载中...";
  121. }
  122. return _name;
  123. }
  124. - (UILabel *)account {
  125. if (!_account) {
  126. _account = [[UILabel alloc] init];
  127. _account.font = [UIFont systemFontOfSize:Fitsize(16)];
  128. _account.textColor = [UIColor YHColorWithHex:0x3E3E3E];
  129. _account.text = @"加载中...";
  130. }
  131. return _account;
  132. }
  133. - (UIButton *)updateButton {
  134. if (!_updateButton) {
  135. _updateButton = [UIButton buttonWithType:UIButtonTypeCustom];
  136. // _updateButton.layer.cornerRadius = Fitsize(9);
  137. // _updateButton.layer.borderColor = [UIColor homeRedColor].CGColor;
  138. // _updateButton.layer.borderWidth = 1;
  139. [_updateButton setImage:[UIImage imageNamed:@"Dropdown Copy"] forState:UIControlStateNormal];
  140. // [_updateButton setTitle:@"修改" forState:UIControlStateNormal];
  141. // _updateButton.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
  142. // [_updateButton setTitleColor:[UIColor homeRedColor] forState:UIControlStateNormal];
  143. _updateButton.imageEdgeInsets=UIEdgeInsetsMake(FITSIZE(23), SCREEN_WIDTH-FITSIZE(22), FITSIZE(23), FITSIZE(15));
  144. [_updateButton addTarget:self action:@selector(updateClickAction) forControlEvents:UIControlEventTouchUpInside];
  145. }
  146. return _updateButton;
  147. }
  148. @end