1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- //
- // MineBodyView.m
- // KulexiuForStudent
- //
- // Created by Kyle on 2022/3/21.
- //
- #import "MineBodyView.h"
- @interface MineBodyView ()
- @property (nonatomic, assign) BOOL isMember;
- @property (weak, nonatomic) IBOutlet UIView *memberView;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *memberViewHeight;
- @property (weak, nonatomic) IBOutlet UILabel *finishCourseLabel;
- @property (weak, nonatomic) IBOutlet UILabel *residueCourseLabel;
- @property (weak, nonatomic) IBOutlet UILabel *followTeacherLabel;
- @property (weak, nonatomic) IBOutlet UIView *dealView;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *dealViewHeight;
- @property (weak, nonatomic) IBOutlet UIImageView *userAvatar;
- @property (weak, nonatomic) IBOutlet UILabel *userName;
- @property (weak, nonatomic) IBOutlet UILabel *userIdLabel;
- @property (weak, nonatomic) IBOutlet UILabel *memberCountLabel;
- @property (nonatomic, copy) MineViewCallback callback;
- @end
- @implementation MineBodyView
- + (instancetype)shareInstance {
- MineBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"MineBodyView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)operationCallback:(MineViewCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (void)configWithSource:(StudentInfoModel *)sourceModel {
- self.finishCourseLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.finshClassHours];
- self.residueCourseLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.unfinshClassHours];
- self.followTeacherLabel.text = [NSString stringWithFormat:@"%.0f",sourceModel.starTeacherNum];
- NSString *userName = @"";
- if (![NSString isEmptyString:sourceModel.username]) {
- userName = sourceModel.username;
- }
- else {
- userName = [NSString stringWithFormat:@"游客%@",sourceModel.userId];
- }
- self.userName.text = userName;
- self.userIdLabel.text = [NSString stringWithFormat:@"学号:%@",sourceModel.userId];
- self.memberCountLabel.text = [NSString stringWithFormat:@"会员有效期剩余%.0f天",sourceModel.membershipDays];
- [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:sourceModel.heardUrl] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- }
- - (IBAction)toMemberDetail:(id)sender {
- if (self.callback) {
- self.callback(MINEVIEWTYPE_MEMBER);
- }
- }
- - (IBAction)clickAction:(UITapGestureRecognizer *)sender {
- NSInteger index = sender.view.tag;
-
- if (self.callback) {
- self.callback(index);
- }
- }
- - (CGFloat)getViewHeight {
- return 80 + 15 + (self.memberViewHeight.constant) / 2 + 10 + 100 + 12 + 93 + 15 + 220;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|