RQVipCenterHeaderView.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // RQVipCenterHeaderView.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/11/21.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipCenterHeaderView.h"
  9. @interface RQVipCenterHeaderView ()
  10. @property (weak, nonatomic) IBOutlet UILabel *passRateLabel;
  11. @property (weak, nonatomic) IBOutlet UILabel *nickNameLabel;
  12. @property (weak, nonatomic) IBOutlet UIImageView *headerImageView;
  13. @end
  14. @implementation RQVipCenterHeaderView
  15. + (instancetype)rqVipCenterHeaderView {
  16. return [super rq_viewFromXib];
  17. }
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. @weakify(self)
  21. RAC(self.nickNameLabel, text) = [[RACObserve(RQ_USER_MANAGER.currentUser, nickName) deliverOnMainThread] takeUntil:self.rac_willDeallocSignal];
  22. self.headerImageView.layer.cornerRadius = RQ_FIT_HORIZONTAL(46.f) / 2.f;
  23. [[[RACObserve(RQ_USER_MANAGER.currentUser, photo) deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  24. @strongify(self)
  25. [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) {
  26. @strongify(self)
  27. if(image) {
  28. image = [image qmui_imageResizedInLimitedSize:CGSizeMake(RQ_FIT_HORIZONTAL(46.f), RQ_FIT_HORIZONTAL(46.f)) resizingMode:QMUIImageResizingModeScaleAspectFill];
  29. image = [image qmui_imageWithBorderColor:UIColor.whiteColor borderWidth:1 cornerRadius:RQ_FIT_HORIZONTAL(46.f) / 2.f];
  30. self.headerImageView.image = image;
  31. }
  32. }];
  33. }];
  34. }
  35. - (void)setHomePageSubjectType:(RQHomePageSubjectType)homePageSubjectType {
  36. @weakify(self)
  37. if (homePageSubjectType == RQHomePageSubjectType_SubjectOne || homePageSubjectType == RQHomePageSubjectType_SubjectFour) {
  38. [[RQ_HTTP_Service getPassRateWithSubject:homePageSubjectType carType:RQ_YDTQuestion_Module.carType] subscribeNext:^(NSString *str) {
  39. @strongify(self)
  40. if (RQStringIsNotEmpty(str)) {
  41. self.passRateLabel.text = [NSString stringWithFormat:@"%@%%",str];
  42. NSInteger c = str.integerValue;
  43. NSString *descStr = @"";
  44. if (c >= 0 && c <= 10) {
  45. descStr = @"想啥呢?快开始学习吧!";
  46. } else if (c > 10 && c <= 20) {
  47. descStr = @"路遥知马力,加油!";
  48. } else if (c > 20 && c <= 30) {
  49. descStr = @"征服畏惧,建立自信。";
  50. } else if (c > 30 && c <= 40) {
  51. descStr = @"学习就像爬山,目的性强爬得就快。";
  52. } else if (c > 40 && c <= 50) {
  53. descStr = @"快到半山腰了哦!";
  54. } else if (c > 50 && c <= 60) {
  55. descStr = @"不错哦,五五开了呀。";
  56. } else if (c > 60 && c <= 70) {
  57. descStr = @"努努力,希望很大!";
  58. } else if (c > 70 && c <= 80) {
  59. descStr = @"离成功不远了,加油!";
  60. } else if (c > 80 && c <= 90) {
  61. descStr = @"上升空间挺大,继线努力!";
  62. } else if (c > 90 && c <= 100) {
  63. descStr = @"十拿九稳了哦,还能审一审!";
  64. }
  65. self.passRateLabel.text = [NSString stringWithFormat:@"考试预测通过率%@%%,%@",str,descStr];
  66. }
  67. }];
  68. }
  69. }
  70. @end