// // RQVipCenterHeaderView.m // jiaPei // // Created by 张嵘 on 2022/11/21. // Copyright © 2022 JCZ. All rights reserved. // #import "RQVipCenterHeaderView.h" @interface RQVipCenterHeaderView () @property (weak, nonatomic) IBOutlet UILabel *passRateLabel; @property (weak, nonatomic) IBOutlet UILabel *nickNameLabel; @property (weak, nonatomic) IBOutlet UIImageView *headerImageView; @end @implementation RQVipCenterHeaderView + (instancetype)rqVipCenterHeaderView { return [super rq_viewFromXib]; } - (void)awakeFromNib { [super awakeFromNib]; @weakify(self) RAC(self.nickNameLabel, text) = [[RACObserve(RQ_USER_MANAGER.currentUser, nickName) deliverOnMainThread] takeUntil:self.rac_willDeallocSignal]; self.headerImageView.layer.cornerRadius = RQ_FIT_HORIZONTAL(46.f) / 2.f; [[[RACObserve(RQ_USER_MANAGER.currentUser, photo) deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) { @strongify(self) [self.headerImageView yy_setImageWithURL:[NSURL URLWithString:RQ_USER_MANAGER.currentUser.photo] placeholder:RQWebAvatarImagePlaceholder() options:RQWebImageOptionAutomatic completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) { @strongify(self) if(image) { image = [image qmui_imageResizedInLimitedSize:CGSizeMake(RQ_FIT_HORIZONTAL(46.f), RQ_FIT_HORIZONTAL(46.f)) resizingMode:QMUIImageResizingModeScaleAspectFill]; image = [image qmui_imageWithBorderColor:UIColor.whiteColor borderWidth:1 cornerRadius:RQ_FIT_HORIZONTAL(46.f) / 2.f]; self.headerImageView.image = image; } }]; }]; } - (void)setHomePageSubjectType:(RQHomePageSubjectType)homePageSubjectType { @weakify(self) if (homePageSubjectType == RQHomePageSubjectType_SubjectOne || homePageSubjectType == RQHomePageSubjectType_SubjectFour) { [[RQ_HTTP_Service getPassRateWithSubject:homePageSubjectType carType:RQ_YDTQuestion_Module.carType] subscribeNext:^(NSString *str) { @strongify(self) if (RQStringIsNotEmpty(str)) { self.passRateLabel.text = [NSString stringWithFormat:@"%@%%",str]; NSInteger c = str.integerValue; NSString *descStr = @""; if (c >= 0 && c <= 10) { descStr = @"想啥呢?快开始学习吧!"; } else if (c > 10 && c <= 20) { descStr = @"路遥知马力,加油!"; } else if (c > 20 && c <= 30) { descStr = @"征服畏惧,建立自信。"; } else if (c > 30 && c <= 40) { descStr = @"学习就像爬山,目的性强爬得就快。"; } else if (c > 40 && c <= 50) { descStr = @"快到半山腰了哦!"; } else if (c > 50 && c <= 60) { descStr = @"不错哦,五五开了呀。"; } else if (c > 60 && c <= 70) { descStr = @"努努力,希望很大!"; } else if (c > 70 && c <= 80) { descStr = @"离成功不远了,加油!"; } else if (c > 80 && c <= 90) { descStr = @"上升空间挺大,继线努力!"; } else if (c > 90 && c <= 100) { descStr = @"十拿九稳了哦,还能审一审!"; } self.passRateLabel.text = [NSString stringWithFormat:@"考试预测通过率%@%%,%@",str,descStr]; } }]; } } @end