MineBodyView.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 (weak, nonatomic) IBOutlet UIView *subjectView;
  10. @property (weak, nonatomic) IBOutlet UILabel *subjectLabel;
  11. @property (nonatomic, assign) BOOL isMember;
  12. @property (weak, nonatomic) IBOutlet UIView *memberView;
  13. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *memberViewHeight;
  14. @property (weak, nonatomic) IBOutlet UILabel *finishCourseLabel;
  15. @property (weak, nonatomic) IBOutlet UILabel *residueCourseLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *followTeacherLabel;
  17. @property (weak, nonatomic) IBOutlet UIView *dealView;
  18. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *dealViewHeight;
  19. @property (weak, nonatomic) IBOutlet UIImageView *userAvatar;
  20. @property (weak, nonatomic) IBOutlet UILabel *userName;
  21. @property (weak, nonatomic) IBOutlet UILabel *userIdLabel;
  22. @property (weak, nonatomic) IBOutlet UILabel *memberCountLabel;
  23. @property (nonatomic, copy) MineViewCallback callback;
  24. @end
  25. @implementation MineBodyView
  26. + (instancetype)shareInstance {
  27. MineBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"MineBodyView" owner:nil options:nil] firstObject];
  28. return view;
  29. }
  30. - (void)operationCallback:(MineViewCallback)callback {
  31. if (callback) {
  32. self.callback = callback;
  33. }
  34. }
  35. - (void)configWithSource:(StudentInfoModel *)sourceModel {
  36. self.finishCourseLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.finshClassHours];
  37. self.residueCourseLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.unfinshClassHours];
  38. self.followTeacherLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.starTeacherNum];
  39. NSString *userName = @"";
  40. if (![NSString isEmptyString:sourceModel.username]) {
  41. userName = sourceModel.username;
  42. }
  43. else {
  44. userName = [NSString stringWithFormat:@"游客%@",sourceModel.userId];
  45. }
  46. self.userName.text = userName;
  47. self.userIdLabel.text = [NSString stringWithFormat:@"学号:%@",sourceModel.userId];
  48. self.memberCountLabel.text = [NSString stringWithFormat:@"会员有效期剩余%.0f天",sourceModel.membershipDays];
  49. [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:[sourceModel.heardUrl getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
  50. if ([NSString isEmptyString:sourceModel.subjectName]) {
  51. self.subjectLabel.text = @"";
  52. self.subjectView.hidden = YES;
  53. }
  54. else {
  55. self.subjectLabel.text = sourceModel.subjectName;
  56. self.subjectView.hidden = NO;
  57. }
  58. }
  59. - (IBAction)toMemberDetail:(id)sender {
  60. if (self.callback) {
  61. self.callback(MINEVIEWTYPE_MEMBER);
  62. }
  63. }
  64. - (IBAction)clickAction:(UITapGestureRecognizer *)sender {
  65. NSInteger index = sender.view.tag;
  66. if (self.callback) {
  67. self.callback(index);
  68. }
  69. }
  70. - (IBAction)finishCourse:(id)sender {
  71. if (self.callback) {
  72. self.callback(MINEVIEWTYPE_FINISHCOURSE);
  73. }
  74. }
  75. - (IBAction)unfinishCourse:(id)sender {
  76. if (self.callback) {
  77. self.callback(MINEVIEWTYPE_UNFINISHCOURSE);
  78. }
  79. }
  80. - (IBAction)followTeacher:(id)sender {
  81. if (self.callback) {
  82. self.callback(MINEVIEWTYPE_FOLLOW);
  83. }
  84. }
  85. - (CGFloat)getViewHeight {
  86. return 80 + 15 + (self.memberViewHeight.constant) / 2 + 10 + 100 + 12 + 93 + 15 + 220;
  87. }
  88. - (IBAction)modifyUser:(id)sender {
  89. if (self.callback) {
  90. self.callback(MINEVIEWTYPE_USER);
  91. }
  92. }
  93. /*
  94. // Only override drawRect: if you perform custom drawing.
  95. // An empty implementation adversely affects performance during animation.
  96. - (void)drawRect:(CGRect)rect {
  97. // Drawing code
  98. }
  99. */
  100. @end