// // LDWithdrawUserView.m // YouHuiProject // // Created by 小花 on 2018/7/31. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDWithdrawUserView.h" @interface LDWithdrawUserView () @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) UILabel *nameTitle; @property (nonatomic, strong) UILabel *accountTitle; @property (nonatomic, strong) UILabel *name; @property (nonatomic, strong) UILabel *account; @property (nonatomic, strong) UIButton *updateButton; @end @implementation LDWithdrawUserView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubViews]; } return self; } - (void)initSubViews { self.backgroundColor =[UIColor whiteColor]; [self addSubview:self.iconView]; [self addSubview:self.nameTitle]; [self addSubview:self.accountTitle]; [self addSubview:self.name]; [self addSubview:self.account]; [self addSubview:self.updateButton]; [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(Fitsize(15)); make.width.height.mas_equalTo(Fitsize(46)); make.centerY.mas_equalTo(self.mas_centerY); }]; [self.nameTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.iconView.mas_right).mas_offset(Fitsize(20)); make.top.mas_equalTo(self.iconView.mas_top); }]; [self.accountTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.nameTitle); make.bottom.mas_equalTo(self.iconView.mas_bottom); }]; [self.name mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.nameTitle.mas_right).mas_offset(Fitsize(44)); make.centerY.mas_equalTo(self.nameTitle.mas_centerY); }]; [self.account mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.name); make.centerY.mas_equalTo(self.accountTitle.mas_centerY); }]; [self.updateButton mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.mas_equalTo(-Fitsize(15)); make.centerY.mas_equalTo(self.iconView.mas_centerY); make.width.mas_equalTo(SCREEN_WIDTH); make.height.mas_equalTo(self.mas_height); }]; } - (void)updateClickAction { if (self.updateAction) { self.updateAction(); } } - (void)setUserInfo:(NSDictionary *)dict { NSString *name = dict[@"real_name"]; NSMutableString *newStr = [NSMutableString string]; if (name.length > 1) { for (int i = 0; i < name.length; i++) { if (i == 0) { NSString *temp = [name substringWithRange:NSMakeRange(i,1)]; [newStr appendString:temp]; }else { [newStr appendString:@"*"]; } } } self.name.text = newStr; NSString *accountStr = dict[@"alipay_account"]; NSString *newAccountStr; if (accountStr.length == 11 && ![accountStr containsString:@"@"]) { newAccountStr = [accountStr stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"]; }else { newAccountStr = accountStr; } self.account.text = newAccountStr; } #pragma mark ---- - (UIImageView *)iconView { if (!_iconView) { _iconView = [[UIImageView alloc] init]; _iconView.image = [UIImage imageNamed:@"alipay_icon"]; } return _iconView; } - (UILabel *)nameTitle { if (!_nameTitle) { _nameTitle = [[UILabel alloc] init]; _nameTitle.font = [UIFont systemFontOfSize:Fitsize(16)]; _nameTitle.textColor = [UIColor YHColorWithHex:0x000000]; _nameTitle.text = @"真实姓名"; } return _nameTitle; } - (UILabel *)accountTitle { if (!_accountTitle) { _accountTitle = [[UILabel alloc] init]; _accountTitle.font = [UIFont systemFontOfSize:Fitsize(16)]; _accountTitle.textColor = [UIColor YHColorWithHex:0x000000]; _accountTitle.text = @"支付宝账号"; } return _accountTitle; } - (UILabel *)name { if (!_name) { _name = [[UILabel alloc] init]; _name.font = [UIFont systemFontOfSize:Fitsize(16)]; _name.textColor = [UIColor YHColorWithHex:0x3E3E3E]; _name.text = @"加载中..."; } return _name; } - (UILabel *)account { if (!_account) { _account = [[UILabel alloc] init]; _account.font = [UIFont systemFontOfSize:Fitsize(16)]; _account.textColor = [UIColor YHColorWithHex:0x3E3E3E]; _account.text = @"加载中..."; } return _account; } - (UIButton *)updateButton { if (!_updateButton) { _updateButton = [UIButton buttonWithType:UIButtonTypeCustom]; // _updateButton.layer.cornerRadius = Fitsize(9); // _updateButton.layer.borderColor = [UIColor homeRedColor].CGColor; // _updateButton.layer.borderWidth = 1; [_updateButton setImage:[UIImage imageNamed:@"Dropdown Copy"] forState:UIControlStateNormal]; // [_updateButton setTitle:@"修改" forState:UIControlStateNormal]; // _updateButton.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)]; // [_updateButton setTitleColor:[UIColor homeRedColor] forState:UIControlStateNormal]; _updateButton.imageEdgeInsets=UIEdgeInsetsMake(FITSIZE(23), SCREEN_WIDTH-FITSIZE(22), FITSIZE(23), FITSIZE(15)); [_updateButton addTarget:self action:@selector(updateClickAction) forControlEvents:UIControlEventTouchUpInside]; } return _updateButton; } @end