INSSettingBodyView.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // INSSettingBodyView.m
  3. // KulexiuForStudent
  4. //
  5. // Created by 王智 on 2023/9/11.
  6. //
  7. #import "INSSettingBodyView.h"
  8. #import "UIImageView+DisplayImage.h"
  9. @interface INSSettingBodyView ()
  10. @property (weak, nonatomic) IBOutlet UILabel *tenantGroupName;
  11. @property (weak, nonatomic) IBOutlet UILabel *userName;
  12. @property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
  13. @property (nonatomic, copy) SettingActionBlock callback;
  14. @property (nonatomic, strong) UIImage *preDisplayImage;
  15. @end
  16. @implementation INSSettingBodyView
  17. + (instancetype)shareInstance {
  18. INSSettingBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"INSSettingBodyView" owner:nil options:nil] firstObject];
  19. return view;
  20. }
  21. - (void)configUserWithUserInfo:(UserInfo *)info {
  22. if (![NSString isEmptyString:info.heardUrl]) {
  23. if (self.preDisplayImage == nil) {
  24. self.preDisplayImage = [UIImage imageNamed:CLIENT_USERDEFAULT_LOGO];
  25. }
  26. [self.uesrAvatar displayImageWithUrl:[NSURL URLWithString:[info.heardUrl getUrlEndcodeString]] placeholder:self.preDisplayImage defaultImage:[UIImage imageNamed:CLIENT_USERDEFAULT_LOGO] callback:^(UIImage * _Nonnull image) {
  27. self.preDisplayImage = image;
  28. }];
  29. }
  30. else {
  31. [self.uesrAvatar setImage:[UIImage imageNamed:CLIENT_USERDEFAULT_LOGO]];
  32. self.preDisplayImage = [UIImage imageNamed:CLIENT_USERDEFAULT_LOGO];
  33. }
  34. self.userName.text = [NSString returnNoNullStringWithString:info.username];
  35. self.phoneLabel.text = [NSString returnNoNullStringWithString:info.phone];
  36. if ([NSString isEmptyString:info.birthdate]) {
  37. self.birthdayLabel.text = @"未设置";
  38. }
  39. else {
  40. self.birthdayLabel.text = [[info.birthdate componentsSeparatedByString:@" "] firstObject];
  41. }
  42. NSString *userSex = @"";
  43. if (info.gender == 1) {
  44. userSex = @"男";
  45. }
  46. else {
  47. userSex = @"女";
  48. }
  49. self.userSex.text = userSex;
  50. NSString *subjectName = info.subjectName;
  51. if ([NSString isEmptyString:info.subjectName]) {
  52. subjectName = @"请选择乐器";
  53. }
  54. self.subjectLabel.text = subjectName;
  55. self.tenantGroupName.text = [NSString returnNoNullStringWithString:info.tenantGroupName];
  56. }
  57. - (void)refreshSubject:(NSString *)subjectName {
  58. if ([NSString isEmptyString:subjectName]) {
  59. subjectName = @"请选择乐器";
  60. }
  61. self.subjectLabel.text = subjectName;
  62. }
  63. - (void)settingCallback:(SettingActionBlock)callback {
  64. if (callback) {
  65. self.callback = callback;
  66. }
  67. }
  68. - (IBAction)tapAction:(UITapGestureRecognizer *)sender {
  69. NSInteger index = sender.view.tag;
  70. if (self.callback) {
  71. self.callback(index);
  72. }
  73. }
  74. - (CGFloat)getViewHeight {
  75. return 58 * 8 + 12 + 12 + 78;
  76. }
  77. /*
  78. // Only override drawRect: if you perform custom drawing.
  79. // An empty implementation adversely affects performance during animation.
  80. - (void)drawRect:(CGRect)rect {
  81. // Drawing code
  82. }
  83. */
  84. @end