HomeLiveCouseCell.m 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // HomeLiveCouseCell.m
  3. // KulexiuForStudent
  4. //
  5. // Created by 王智 on 2022/4/22.
  6. //
  7. #import "HomeLiveCouseCell.h"
  8. @interface HomeLiveCouseCell ()
  9. @property (weak, nonatomic) IBOutlet UIImageView *coverImage;
  10. @property (weak, nonatomic) IBOutlet UILabel *courseName;
  11. @property (weak, nonatomic) IBOutlet UILabel *teacherName;
  12. @property (weak, nonatomic) IBOutlet UIImageView *teacherAvatar;
  13. @property (weak, nonatomic) IBOutlet UILabel *courseBegin;
  14. @property (weak, nonatomic) IBOutlet UILabel *priceLabel;
  15. @property (weak, nonatomic) IBOutlet UILabel *descLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *subjectLabel;
  17. @end
  18. @implementation HomeLiveCouseCell
  19. - (void)awakeFromNib {
  20. [super awakeFromNib];
  21. // Initialization code
  22. self.selectionStyle = UITableViewCellSelectionStyleNone;
  23. }
  24. - (void)configWithSource:(HomeLiveGroupModel *)source {
  25. [self.coverImage sd_setImageWithURL:[NSURL URLWithString:[source.backgroundPic getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
  26. self.courseName.text = [NSString returnNoNullStringWithString:source.courseGroupName];
  27. if ([NSString isEmptyString:source.teacherName]) {
  28. self.teacherName.text = [NSString stringWithFormat:@"游客%@",source.teacherId];
  29. }
  30. else {
  31. self.teacherName.text = [NSString stringWithFormat:@"%@",source.teacherName];
  32. }
  33. [self.teacherAvatar sd_setImageWithURL:[NSURL URLWithString:[source.avatar getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
  34. if (source.courseGroupPrice > 0) {
  35. NSString *mountMsg = [NSString formatDoubleNum:source.courseGroupPrice];
  36. NSString *descMsg = [NSString stringWithFormat:@"¥%@",mountMsg];
  37. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:descMsg attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f],NSForegroundColorAttributeName:HexRGB(0xfa6400)}];
  38. [attr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0f weight:UIFontWeightSemibold]} range:[descMsg rangeOfString:mountMsg]];
  39. self.priceLabel.attributedText = attr;
  40. }
  41. else {
  42. self.priceLabel.text = @"免费";
  43. }
  44. NSString *courseMsg = [NSString stringWithFormat:@"%zd课时",source.courseNum];
  45. self.descLabel.text = courseMsg;
  46. // 时间
  47. if ([NSString isEmptyString:source.courseStartTime]) {
  48. self.courseBegin.text = @"";
  49. }
  50. else {
  51. NSDateFormatter *dateFormatter = [NSObject getDateformatter];
  52. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  53. NSDate *beginDate = [dateFormatter dateFromString:source.courseStartTime];
  54. [dateFormatter setDateFormat:@"MM月dd日 HH:mm"];
  55. self.courseBegin.text = [NSString returnNoNullStringWithString:[dateFormatter stringFromDate:beginDate]];
  56. }
  57. self.subjectLabel.text = [NSString returnNoNullStringWithString:source.subjectName];
  58. }
  59. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  60. [super setSelected:selected animated:animated];
  61. // Configure the view for the selected state
  62. }
  63. @end