LiveCourseCell.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // LiveCourseCell.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/4/2.
  6. //
  7. #import "LiveCourseCell.h"
  8. @interface LiveCourseCell ()
  9. @property (weak, nonatomic) IBOutlet UIView *statusView;
  10. @property (weak, nonatomic) IBOutlet UILabel *statusLabel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *coverImage;
  12. @property (weak, nonatomic) IBOutlet UILabel *courseName;
  13. @property (weak, nonatomic) IBOutlet UILabel *orderUser;
  14. @property (weak, nonatomic) IBOutlet UILabel *courseTime;
  15. @property (weak, nonatomic) IBOutlet UILabel *priceLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *courseCount;
  17. @property (weak, nonatomic) IBOutlet UILabel *subjectLabel;
  18. @end
  19. @implementation LiveCourseCell
  20. - (void)awakeFromNib {
  21. [super awakeFromNib];
  22. // Initialization code
  23. self.selectionStyle = UITableViewCellSelectionStyleNone;
  24. [self setupRadius];
  25. }
  26. - (void)setupRadius {
  27. _statusView.layer.cornerRadius = 10.0f;
  28. _statusView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMinXMinYCorner;
  29. }
  30. - (void)configCellWithSource:(LiveCourseModel *)model groupStatus:(COURSERSTATUS)status hideStatusView:(BOOL)hideStatusView {
  31. [self.coverImage sd_setImageWithURL:[NSURL URLWithString:[model.backgroundPic getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
  32. self.courseName.text = [NSString returnNoNullStringWithString:model.courseGroupName];
  33. if (model.coursePrice > 0) {
  34. self.orderUser.text = [NSString stringWithFormat:@"%.0f人已购买",model.studentCount];
  35. }
  36. else {
  37. self.orderUser.text = [NSString stringWithFormat:@"%.0f人已领取",model.studentCount];
  38. }
  39. if (model.coursePrice > 0) {
  40. self.priceLabel.text = [NSString stringWithFormat:@"¥%.2f",model.coursePrice];
  41. }
  42. else {
  43. self.priceLabel.text = [NSString stringWithFormat:@"免费"];
  44. }
  45. self.courseCount.text = [NSString stringWithFormat:@"/ %.0f课时",model.courseNum];
  46. // time
  47. NSDateFormatter *formatter = [NSObject getDateformatter];
  48. [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  49. NSDate *startDate = [formatter dateFromString:model.courseStartTime];
  50. [formatter setDateFormat:@"yyyy/MM/dd HH:mm"];
  51. NSString *courseBegin = [formatter stringFromDate:startDate];
  52. self.courseTime.text = [NSString returnNoNullStringWithString:courseBegin];
  53. self.subjectLabel.text = [NSString returnNoNullStringWithString:model.subjectName];
  54. switch (status) {
  55. case COURSERSTATUS_ING:
  56. {
  57. self.statusView.backgroundColor = HexRGB(0xd5fff7);
  58. self.statusLabel.textColor = HexRGB(0x2dc7aa);
  59. self.statusLabel.text = @"进行中";
  60. self.orderUser.hidden = NO;
  61. self.statusView.hidden = NO;
  62. }
  63. break;
  64. case COURSERSTATUS_NOTSALE:
  65. {
  66. self.statusView.backgroundColor = HexRGB(0xFFEEE3);
  67. self.statusLabel.textColor = HexRGB(0xFF4E19);
  68. self.statusLabel.text = @"未上架";
  69. self.orderUser.hidden = YES;
  70. }
  71. break;
  72. case COURSERSTATUS_APPLY:
  73. {
  74. self.statusView.backgroundColor = HexRGB(0xFFE7E7);
  75. self.statusLabel.textColor = HexRGB(0xFF1919);
  76. self.statusLabel.text = @"销售中";
  77. self.orderUser.hidden = NO;
  78. }
  79. break;
  80. case COURSERSTATUS_COMPLETE:
  81. {
  82. self.statusView.backgroundColor = HexRGB(0xDEF2FF);
  83. self.statusLabel.textColor = HexRGB(0x008AE0);
  84. self.statusLabel.text = @"已完成";
  85. self.orderUser.hidden = NO;
  86. }
  87. break;
  88. case COURSERSTATUS_CANCLE:
  89. {
  90. self.statusView.backgroundColor = HexRGB(0xF0F0F0);
  91. self.statusLabel.textColor = HexRGB(0x666666);
  92. self.statusLabel.text = @"已取消";
  93. self.orderUser.hidden = NO;
  94. }
  95. break;
  96. case COURSERSTATUS_OUTSALE:
  97. {
  98. self.statusView.backgroundColor = HexRGB(0xF0F0F0);
  99. self.statusLabel.textColor = HexRGB(0x666666);
  100. self.statusLabel.text = @"已下架";
  101. self.orderUser.hidden = NO;
  102. }
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  109. [super setSelected:selected animated:animated];
  110. // Configure the view for the selected state
  111. }
  112. @end