PlatformActivityCell.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // PlatformActivityCell.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/17.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 平台活动cell
  8. #import "PlatformActivityCell.h"
  9. @implementation PlatformActivityCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. //
  14. self.selectionStyle = UITableViewCellSelectionStyleNone;
  15. [self creatCellSubViews];
  16. }
  17. return self;
  18. }
  19. - (void)creatCellSubViews {
  20. //
  21. self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 18, 80, 80)];
  22. [self.contentView addSubview:self.iconImageView];
  23. //
  24. self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, 18, ScreenWidth - 135, 15)];
  25. self.titleLabel.textAlignment = NSTextAlignmentLeft;
  26. self.titleLabel.textColor = RGBValueColor(0x333333, 1.0);
  27. self.titleLabel.font = [UIFont systemFontOfSize:15];
  28. [self.contentView addSubview:self.titleLabel];
  29. //
  30. self.subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, CGRectGetMaxY(self.titleLabel.frame) + 5, ScreenWidth - 135, 34)];
  31. self.subTitleLabel.textAlignment = NSTextAlignmentLeft;
  32. self.subTitleLabel.numberOfLines = 0;
  33. self.subTitleLabel.textColor = RGBValueColor(0x333333, 1.0); //
  34. self.subTitleLabel.font = [UIFont systemFontOfSize:13];
  35. [self.contentView addSubview:self.subTitleLabel];
  36. //
  37. self.childTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, CGRectGetMaxY(self.subTitleLabel.frame) + 5, ScreenWidth - 135, 13)];
  38. self.childTitleLabel.textAlignment = NSTextAlignmentLeft;
  39. self.childTitleLabel.textColor = RGBValueColor(0x999999, 1.0); //333333
  40. self.childTitleLabel.font = [UIFont systemFontOfSize:13];
  41. [self.contentView addSubview:self.childTitleLabel];
  42. //
  43. self.lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.iconImageView.frame) + 18, ScreenWidth, 0.5)];
  44. self.lineView.backgroundColor = RGBValueColor(0xdfdfdf, 1.0);
  45. [self.contentView addSubview:self.lineView];
  46. //
  47. UIButton *statusBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  48. statusBtn.frame = CGRectMake(ScreenWidth - 95, CGRectGetMaxY(self.lineView.frame) + 8, 75, 24);
  49. [statusBtn setBackgroundImage:[UIImage imageNamed:@"yibaoming"] forState:UIControlStateNormal];
  50. [statusBtn setTitle:@"已报名" forState:UIControlStateNormal];
  51. [statusBtn setTitleColor:RGBValueColor(0xffffff, 1.0) forState:UIControlStateNormal];
  52. statusBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
  53. [self.contentView addSubview:statusBtn];
  54. self.statusBtn = statusBtn;
  55. }
  56. - (void)setPlatformActivityCellValueWithDic:(NSDictionary *)dic titleStr:(NSString *)titleStr {
  57. NSString *url = [NSString stringWithFormat:@"%@/%@", PublicUrl, dic[@"pic"]];
  58. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"jiazai"]];
  59. self.titleLabel.text = dic[@"caption"];
  60. self.subTitleLabel.text = dic[@"intro"];
  61. NSString *timeStr = [NSString stringWithFormat:@"%@", dic[@"endt"]];
  62. if ([timeStr containsString:@" "]) {
  63. NSArray *timeArr = [timeStr componentsSeparatedByString:@" "];
  64. NSArray *dateArr = [timeArr[0] componentsSeparatedByString:@"-"];
  65. self.childTitleLabel.text = [NSString stringWithFormat:@"结束时间:%@.%@.%@", dateArr[0], dateArr[1], dateArr[2]];
  66. }
  67. if ([dic[@"issign"] isEqualToString:@"1"]) { // 这里假如有字段区分 未报名 已报名
  68. [self.statusBtn setBackgroundImage:[UIImage imageNamed:@"yibaoming"] forState:UIControlStateNormal];
  69. [self.statusBtn setTitle:@"已报名" forState:UIControlStateNormal];
  70. // } else if ([dic[@"issign"] isEqualToString:@"0"]) {
  71. // [self.statusBtn setBackgroundImage:[UIImage imageNamed:@"yibaoming"] forState:UIControlStateNormal];
  72. // [self.statusBtn setTitle:@"已报名" forState:UIControlStateNormal];
  73. } else if ([dic[@"issign"] isEqualToString:@"0"]) {
  74. [self.statusBtn setBackgroundImage:[UIImage imageNamed:@"jinxingzhong"] forState:UIControlStateNormal];
  75. [self.statusBtn setTitle:@"未报名" forState:UIControlStateNormal];
  76. }
  77. }
  78. /*
  79. {
  80. beg = "2018-07-31 16:08:51";
  81. brprice = "500.0";
  82. caption = "51欢乐趴集结号";
  83. endt = "2018-08-01 16:09:03";
  84. intro = "阿斯顿飞";
  85. meprice = "120.0";
  86. moprice = "250.0";
  87. pic = "upload/activity/2018-06-15/451123138753678023.jpg";
  88. pk = 2;
  89. sbeg = "2018-10-01 16:08:25";
  90. sendt = "2018-06-16 16:08:47";
  91. term = "";
  92. }
  93. */
  94. @end