123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- //
- // HomeHeadView.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/28.
- //
- #import "HomeHeadView.h"
- #import "KSStarView.h"
- #import "UserInfoManager.h"
- @interface HomeHeadView ()
- @property (weak, nonatomic) IBOutlet UIView *authView;
- @property (weak, nonatomic) IBOutlet UILabel *authLabel;
- @property (weak, nonatomic) IBOutlet UIView *descView;
- @property (weak, nonatomic) IBOutlet UIButton *tipsButton;
- @property (weak, nonatomic) IBOutlet UIView *starbgView;
- @property (weak, nonatomic) IBOutlet KSStarView *starView;
- @property (weak, nonatomic) IBOutlet UILabel *fansCount;
- @property (weak, nonatomic) IBOutlet UILabel *finishCourse;
- @property (weak, nonatomic) IBOutlet UILabel *unfinishCourse;
- @property (weak, nonatomic) IBOutlet UIImageView *userAvatal;
- @property (weak, nonatomic) IBOutlet UILabel *userName;
- @property (weak, nonatomic) IBOutlet UIImageView *firstLogo;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *firstLogoWidth;
- @property (weak, nonatomic) IBOutlet UIImageView *secondLogo;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *secondLogoWidth;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *logoSpace;
- @property (nonatomic, copy) HomeHeadCallback callback;
- @property (nonatomic, assign) BOOL hasAuthTeacher;
- @property (nonatomic, assign) BOOL hasAuthMusic;
- @end
- @implementation HomeHeadView
- + (instancetype)shareInstance {
- HomeHeadView *view = [[[NSBundle mainBundle] loadNibNamed:@"HomeHeadView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)configMessage:(TeacherInfo *)infoMessage {
- if ([infoMessage.entryStatus isEqualToString:@"PASS"]) { // 审核通过
- self.hasAuthTeacher = YES;
- self.authView.hidden = YES;
- self.descView.hidden = NO;
- [self displayCount:infoMessage.fansNum inView:self.fansCount];
- [self displayCount:infoMessage.expTime inView:self.finishCourse];
- [self displayCount:infoMessage.unExpTime inView:self.unfinishCourse];
- self.starView.allowMark = NO;
- self.starView.rate = infoMessage.starGrade / 5.0f;
- self.tipsButton.hidden = YES;
- }
- else {
- self.hasAuthTeacher = NO;
- self.authView.hidden = NO;
- self.descView.hidden = YES;
- self.tipsButton.hidden = NO;
- if (USER_MANAGER.hiddenTipsButton) {
- self.tipsButton.hidden = YES;
- }
- else {
- self.tipsButton.hidden = NO;
- }
- if ([infoMessage.entryStatus isEqualToString:@"DOING"]) {
- self.authLabel.text = @"审核中";
- }
- else {
- self.authLabel.text = @"认证老师";
- }
- }
-
- if ([infoMessage.musicianAuthStatus isEqualToString:@"PASS"]) {
- self.hasAuthMusic = YES;
- }else {
- self.hasAuthMusic = NO;
- }
-
- self.starView.rate = infoMessage.starGrade / 5.0f;
-
- if (![NSString isEmptyString:infoMessage.heardUrl]) {
- [self.userAvatal sd_setImageWithURL:[NSURL URLWithString:infoMessage.heardUrl] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- }
- else {
- [self.userAvatal setImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- }
- if ([NSString isEmptyString:infoMessage.username]) {
- self.userName.text = [NSString stringWithFormat:@"游客%@",infoMessage.userId];
- }
- else {
- self.userName.text = [NSString returnNoNullStringWithString:infoMessage.username];
- }
- [self evaluateAuthLogo];
- }
- - (void)evaluateAuthLogo {
- if (self.hasAuthTeacher) {
- self.firstLogo.hidden = NO;
- self.firstLogoWidth.constant = 53.0f;
- }
- else {
- self.firstLogo.hidden = YES;
- self.firstLogoWidth.constant = 0.0f;
- self.logoSpace.constant = 0.0f;
- }
-
- if (self.hasAuthMusic) {
- self.secondLogo.hidden = NO;
- self.secondLogoWidth.constant = 61.0f;
- }
- else {
- self.secondLogo.hidden = YES ;
- self.secondLogoWidth.constant = 0.0f;
- }
- }
- - (void)displayCount:(NSInteger)count inView:(UILabel *)descLabel {
- if (count > 10000) {
- double descNum = count / 10000.0;
- descLabel.text = [NSString stringWithFormat:@"%.2f万",descNum];
- }
- else {
- descLabel.text = [NSString stringWithFormat:@"%ld",count];
- }
- }
- - (void)operationCallback:(HomeHeadCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (CGFloat)getViewHeight {
- return 180;
- }
- - (IBAction)authDetail:(id)sender {
- if (self.callback) {
- self.callback();
- }
- }
- - (IBAction)hideTipsButton:(id)sender {
- self.tipsButton.hidden = YES;
- USER_MANAGER.hiddenTipsButton = YES;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|