MineBodyView.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // MineBodyView.m
  3. // KulexiuForStudent
  4. //
  5. // Created by Kyle on 2022/3/21.
  6. //
  7. #import "MineBodyView.h"
  8. @interface MineBodyView ()
  9. @property (nonatomic, assign) BOOL isMember;
  10. @property (weak, nonatomic) IBOutlet UIView *memberView;
  11. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *memberViewHeight;
  12. @property (weak, nonatomic) IBOutlet UILabel *finishCourseLabel;
  13. @property (weak, nonatomic) IBOutlet UILabel *residueCourseLabel;
  14. @property (weak, nonatomic) IBOutlet UILabel *followTeacherLabel;
  15. @property (weak, nonatomic) IBOutlet UIView *dealView;
  16. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *dealViewHeight;
  17. @property (weak, nonatomic) IBOutlet UIImageView *userAvatar;
  18. @property (weak, nonatomic) IBOutlet UILabel *userName;
  19. @property (weak, nonatomic) IBOutlet UILabel *userIdLabel;
  20. @property (weak, nonatomic) IBOutlet UILabel *memberCountLabel;
  21. @property (nonatomic, copy) MineViewCallback callback;
  22. @end
  23. @implementation MineBodyView
  24. + (instancetype)shareInstance {
  25. MineBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"MineBodyView" owner:nil options:nil] firstObject];
  26. return view;
  27. }
  28. - (void)operationCallback:(MineViewCallback)callback {
  29. if (callback) {
  30. self.callback = callback;
  31. }
  32. }
  33. - (void)configWithSource:(StudentInfoModel *)sourceModel {
  34. self.finishCourseLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.finshClassHours];
  35. self.residueCourseLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.unfinshClassHours];
  36. self.followTeacherLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.starTeacherNum];
  37. NSString *userName = @"";
  38. if (![NSString isEmptyString:sourceModel.username]) {
  39. userName = sourceModel.username;
  40. }
  41. else {
  42. userName = [NSString stringWithFormat:@"游客%@",sourceModel.userId];
  43. }
  44. self.userName.text = userName;
  45. self.userIdLabel.text = [NSString stringWithFormat:@"学号:%@",sourceModel.userId];
  46. self.memberCountLabel.text = [NSString stringWithFormat:@"会员有效期剩余%.0f天",sourceModel.membershipDays];
  47. [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:sourceModel.heardUrl] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
  48. }
  49. - (IBAction)toMemberDetail:(id)sender {
  50. if (self.callback) {
  51. self.callback(MINEVIEWTYPE_MEMBER);
  52. }
  53. }
  54. - (IBAction)clickAction:(UITapGestureRecognizer *)sender {
  55. NSInteger index = sender.view.tag;
  56. if (self.callback) {
  57. self.callback(index);
  58. }
  59. }
  60. - (CGFloat)getViewHeight {
  61. return 80 + 15 + (self.memberViewHeight.constant) / 2 + 10 + 100 + 12 + 93 + 15 + 220;
  62. }
  63. /*
  64. // Only override drawRect: if you perform custom drawing.
  65. // An empty implementation adversely affects performance during animation.
  66. - (void)drawRect:(CGRect)rect {
  67. // Drawing code
  68. }
  69. */
  70. @end