123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #import "MineBodyView.h"
- @interface MineBodyView ()
- @property (weak, nonatomic) IBOutlet UIView *subjectView;
- @property (weak, nonatomic) IBOutlet UILabel *subjectLabel;
- @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 getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- if ([NSString isEmptyString:sourceModel.subjectName]) {
- self.subjectLabel.text = @"";
- self.subjectView.hidden = YES;
- }
- else {
- self.subjectLabel.text = sourceModel.subjectName;
- self.subjectView.hidden = NO;
- }
- }
- - (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);
- }
- }
- - (IBAction)finishCourse:(id)sender {
- if (self.callback) {
- self.callback(MINEVIEWTYPE_FINISHCOURSE);
- }
- }
- - (IBAction)unfinishCourse:(id)sender {
- if (self.callback) {
- self.callback(MINEVIEWTYPE_UNFINISHCOURSE);
- }
- }
- - (IBAction)followTeacher:(id)sender {
- if (self.callback) {
- self.callback(MINEVIEWTYPE_FOLLOW);
- }
- }
- - (CGFloat)getViewHeight {
- return 80 + 15 + (self.memberViewHeight.constant) / 2 + 10 + 100 + 12 + 93 + 15 + 220;
- }
- - (IBAction)modifyUser:(id)sender {
- if (self.callback) {
- self.callback(MINEVIEWTYPE_USER);
- }
- }
- @end
|