VideoCourseCell.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // VideoCourseCell.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/29.
  6. //
  7. #import "VideoCourseCell.h"
  8. @interface VideoCourseCell ()
  9. @property (weak, nonatomic) IBOutlet UIImageView *coverImage;
  10. @property (weak, nonatomic) IBOutlet UILabel *courseTitle;
  11. @property (weak, nonatomic) IBOutlet UIImageView *teacherAvatar;
  12. @property (weak, nonatomic) IBOutlet UILabel *teacherName;
  13. @property (weak, nonatomic) IBOutlet UILabel *courseMessage;
  14. @property (weak, nonatomic) IBOutlet UIView *descView;
  15. @property (weak, nonatomic) IBOutlet UILabel *descLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *subjectLabel;
  17. @property (weak, nonatomic) IBOutlet UILabel *courseCount;
  18. @end
  19. @implementation VideoCourseCell
  20. - (void)awakeFromNib {
  21. [super awakeFromNib];
  22. // Initialization code
  23. }
  24. - (void)configSourceModel:(VideoCourseModel *)model isInCheck:(BOOL)isCheck {
  25. [self.coverImage sd_setImageWithURL:[NSURL URLWithString:[model.lessonCoverUrl getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
  26. self.courseTitle.text = [NSString returnNoNullStringWithString:model.lessonName];
  27. [self.teacherAvatar sd_setImageWithURL:[NSURL URLWithString:[model.avatar getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:TEACHER_AVATAR]];
  28. if ([NSString isEmptyString:model.username]) {
  29. self.teacherName.text = [NSString stringWithFormat:@"游客%.0f",model.teacherId];
  30. }
  31. else {
  32. self.teacherName.text = model.username;
  33. }
  34. self.subjectLabel.text = [NSString returnNoNullStringWithString:model.lessonSubjectName];
  35. if ([model.payType isEqualToString:@"VIP"]) {
  36. self.courseMessage.text = @"会员";
  37. self.courseMessage.textColor = HexRGB(0xC76E21);
  38. }
  39. else if ([model.payType isEqualToString:@"PAY"]) {
  40. if (model.lessonPrice > 0) {
  41. self.courseMessage.textColor = HexRGB(0xFF0000);
  42. NSString *text = [NSString stringWithFormat:@"¥%.2f",model.lessonPrice];
  43. NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:text attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium],NSForegroundColorAttributeName:HexRGB(0xFF0000)}];
  44. [attrs addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f weight:UIFontWeightMedium]} range:[text rangeOfString:@"¥"]];
  45. self.courseMessage.attributedText = attrs;
  46. }
  47. else {
  48. self.courseMessage.text = @"免费";
  49. self.courseMessage.textColor = HexRGB(0x20BEA0);
  50. }
  51. }
  52. else {
  53. self.courseMessage.text = @"";
  54. }
  55. self.courseCount.text = [NSString stringWithFormat:@"/ %.0f课时",model.lessonCount];
  56. self.descLabel.text = [NSString stringWithFormat:@"%.0f人学习",model.countStudent];
  57. }
  58. @end