UserInfoView.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // UserInfoView.m
  3. // FunSDKDemo
  4. //
  5. // Created by wujiangbo on 2018/11/1.
  6. // Copyright © 2018年 wujiangbo. All rights reserved.
  7. //
  8. #import "UserInfoView.h"
  9. #import <Masonry/Masonry.h>
  10. #import "UserInfoCell.h"
  11. #import "Header.h"
  12. @interface UserInfoView()<UITableViewDelegate,UITableViewDataSource>
  13. @end
  14. @implementation UserInfoView
  15. -(instancetype)initWithFrame:(CGRect)frame
  16. {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.backgroundColor = [UIColor whiteColor];
  20. [self addSubview:self.tbUserInfo];
  21. //布局
  22. [self configSubView];
  23. }
  24. return self;
  25. }
  26. #pragma mark - 控件布局
  27. -(void)configSubView
  28. {
  29. [self.tbUserInfo mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.width.equalTo(self);
  31. make.height.equalTo(self);
  32. make.top.equalTo(@64);
  33. make.left.equalTo(self);
  34. }];
  35. }
  36. #pragma mark - tableViewDataSource/Delegate
  37. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  38. return 4;
  39. }
  40. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  41. return 50;
  42. }
  43. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  44. UserInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UserInfoCell"];
  45. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  46. switch (indexPath.row) {
  47. case 0:
  48. {
  49. cell.mainTitle.text = TS("username");
  50. cell.descriptionTitle.text = [[LoginShowControl getInstance] getLoginUserName];
  51. }
  52. break;
  53. case 1:
  54. {
  55. cell.mainTitle.text = TS("password");
  56. cell.descriptionTitle.text = [[LoginShowControl getInstance] getLoginPassword];
  57. }
  58. break;
  59. case 2:
  60. {
  61. cell.mainTitle.text = TS("bind_phoneNumber");
  62. if (self.infoDic) {
  63. cell.descriptionTitle.text = [self.infoDic objectForKey:@"phone"];
  64. }
  65. //判断当前是否有显示绑定手机,没有则显示跳转箭头
  66. if ([cell.descriptionTitle.text isEqualToString:@""]) {
  67. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  68. }
  69. else{
  70. cell.accessoryType = UITableViewCellAccessoryNone;
  71. }
  72. }
  73. break;
  74. case 3:
  75. {
  76. cell.mainTitle.text = TS("bind_email_address");
  77. if (self.infoDic) {
  78. cell.descriptionTitle.text = [self.infoDic objectForKey:@"mail"];
  79. }
  80. //判断当前是否有显示绑定邮箱,没有则显示跳转箭头
  81. if ([cell.descriptionTitle.text isEqualToString:@""]) {
  82. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  83. }
  84. else{
  85. cell.accessoryType = UITableViewCellAccessoryNone;
  86. }
  87. }
  88. break;
  89. default:
  90. break;
  91. }
  92. return cell;
  93. }
  94. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  95. {
  96. NSString *title = @"";
  97. if (indexPath.row == 2) { //点击绑定手机
  98. if (self.infoDic) {
  99. title = [self.infoDic objectForKey:@"phone"];
  100. if ([title isEqualToString:@""]) {
  101. if (self.clickBindAccount) {
  102. self.clickBindAccount(TS("bind_phoneNumber"));
  103. }
  104. }
  105. }
  106. }
  107. else if (indexPath.row == 3) //点击绑定邮箱
  108. {
  109. if (self.infoDic) {
  110. title = [self.infoDic objectForKey:@"mail"];
  111. if ([title isEqualToString:@""]) {
  112. if (self.clickBindAccount) {
  113. self.clickBindAccount(TS("bind_email_address"));
  114. }
  115. }
  116. }
  117. }
  118. }
  119. #pragma mark -lazyLoad
  120. -(UITableView *)tbUserInfo
  121. {
  122. if (!_tbUserInfo) {
  123. _tbUserInfo = [[UITableView alloc] init];
  124. _tbUserInfo.delegate = self;
  125. _tbUserInfo.dataSource = self;
  126. _tbUserInfo.scrollEnabled = NO;
  127. [_tbUserInfo registerClass:[UserInfoCell class] forCellReuseIdentifier:@"UserInfoCell"];
  128. _tbUserInfo.tableFooterView = [[UIView alloc] init];
  129. }
  130. return _tbUserInfo;
  131. }
  132. @end