HomeHeadView.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //
  2. // HomeHeadView.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/28.
  6. //
  7. #import "HomeHeadView.h"
  8. #import "KSStarView.h"
  9. #import "UserInfoManager.h"
  10. @interface HomeHeadView ()
  11. @property (weak, nonatomic) IBOutlet UIView *authView;
  12. @property (weak, nonatomic) IBOutlet UILabel *authLabel;
  13. @property (weak, nonatomic) IBOutlet UIView *descView;
  14. @property (weak, nonatomic) IBOutlet UIButton *tipsButton;
  15. @property (weak, nonatomic) IBOutlet UIView *starbgView;
  16. @property (weak, nonatomic) IBOutlet KSStarView *starView;
  17. @property (weak, nonatomic) IBOutlet UILabel *fansCount;
  18. @property (weak, nonatomic) IBOutlet UILabel *finishCourse;
  19. @property (weak, nonatomic) IBOutlet UILabel *unfinishCourse;
  20. @property (weak, nonatomic) IBOutlet UIImageView *userAvatal;
  21. @property (weak, nonatomic) IBOutlet UILabel *userName;
  22. @property (weak, nonatomic) IBOutlet UIImageView *firstLogo;
  23. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *firstLogoWidth;
  24. @property (weak, nonatomic) IBOutlet UIImageView *secondLogo;
  25. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *secondLogoWidth;
  26. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *logoSpace;
  27. @property (nonatomic, copy) HomeHeadCallback callback;
  28. @property (nonatomic, assign) BOOL hasAuthTeacher;
  29. @property (nonatomic, assign) BOOL hasAuthMusic;
  30. @end
  31. @implementation HomeHeadView
  32. + (instancetype)shareInstance {
  33. HomeHeadView *view = [[[NSBundle mainBundle] loadNibNamed:@"HomeHeadView" owner:nil options:nil] firstObject];
  34. return view;
  35. }
  36. - (void)configMessage:(TeacherInfo *)infoMessage {
  37. if ([infoMessage.entryStatus isEqualToString:@"PASS"]) { // 审核通过
  38. self.hasAuthTeacher = YES;
  39. self.authView.hidden = YES;
  40. self.descView.hidden = NO;
  41. [self displayCount:infoMessage.fansNum inView:self.fansCount];
  42. [self displayCount:infoMessage.expTime inView:self.finishCourse];
  43. [self displayCount:infoMessage.unExpTime inView:self.unfinishCourse];
  44. self.starView.allowMark = NO;
  45. self.starView.rate = infoMessage.starGrade / 5.0f;
  46. self.tipsButton.hidden = YES;
  47. }
  48. else {
  49. self.hasAuthTeacher = NO;
  50. self.authView.hidden = NO;
  51. self.descView.hidden = YES;
  52. self.tipsButton.hidden = NO;
  53. if (USER_MANAGER.hiddenTipsButton) {
  54. self.tipsButton.hidden = YES;
  55. }
  56. else {
  57. self.tipsButton.hidden = NO;
  58. }
  59. if ([infoMessage.entryStatus isEqualToString:@"DOING"]) {
  60. self.authLabel.text = @"审核中";
  61. }
  62. else {
  63. self.authLabel.text = @"认证老师";
  64. }
  65. }
  66. if ([infoMessage.musicianAuthStatus isEqualToString:@"PASS"]) {
  67. self.hasAuthMusic = YES;
  68. }else {
  69. self.hasAuthMusic = NO;
  70. }
  71. self.starView.rate = infoMessage.starGrade / 5.0f;
  72. if (![NSString isEmptyString:infoMessage.heardUrl]) {
  73. [self.userAvatal sd_setImageWithURL:[NSURL URLWithString:infoMessage.heardUrl] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
  74. }
  75. else {
  76. [self.userAvatal setImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
  77. }
  78. if ([NSString isEmptyString:infoMessage.username]) {
  79. self.userName.text = [NSString stringWithFormat:@"游客%@",infoMessage.userId];
  80. }
  81. else {
  82. self.userName.text = [NSString returnNoNullStringWithString:infoMessage.username];
  83. }
  84. [self evaluateAuthLogo];
  85. }
  86. - (void)evaluateAuthLogo {
  87. if (self.hasAuthTeacher) {
  88. self.firstLogo.hidden = NO;
  89. self.firstLogoWidth.constant = 53.0f;
  90. }
  91. else {
  92. self.firstLogo.hidden = YES;
  93. self.firstLogoWidth.constant = 0.0f;
  94. self.logoSpace.constant = 0.0f;
  95. }
  96. if (self.hasAuthMusic) {
  97. self.secondLogo.hidden = NO;
  98. self.secondLogoWidth.constant = 61.0f;
  99. }
  100. else {
  101. self.secondLogo.hidden = YES ;
  102. self.secondLogoWidth.constant = 0.0f;
  103. }
  104. }
  105. - (void)displayCount:(NSInteger)count inView:(UILabel *)descLabel {
  106. if (count > 10000) {
  107. double descNum = count / 10000.0;
  108. descLabel.text = [NSString stringWithFormat:@"%.2f万",descNum];
  109. }
  110. else {
  111. descLabel.text = [NSString stringWithFormat:@"%ld",count];
  112. }
  113. }
  114. - (void)operationCallback:(HomeHeadCallback)callback {
  115. if (callback) {
  116. self.callback = callback;
  117. }
  118. }
  119. - (CGFloat)getViewHeight {
  120. return 180;
  121. }
  122. - (IBAction)authDetail:(id)sender {
  123. if (self.callback) {
  124. self.callback();
  125. }
  126. }
  127. - (IBAction)hideTipsButton:(id)sender {
  128. self.tipsButton.hidden = YES;
  129. USER_MANAGER.hiddenTipsButton = YES;
  130. }
  131. /*
  132. // Only override drawRect: if you perform custom drawing.
  133. // An empty implementation adversely affects performance during animation.
  134. - (void)drawRect:(CGRect)rect {
  135. // Drawing code
  136. }
  137. */
  138. @end