MyOrderCell.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // MyOrderCell.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/17.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 我的订单cell
  8. #import "MyOrderCell.h"
  9. @implementation MyOrderCell
  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] init];
  22. [self.contentView addSubview:self.iconImageView];
  23. //
  24. self.titleLabel = [[UILabel alloc] init];
  25. self.titleLabel.textAlignment = NSTextAlignmentLeft;
  26. self.titleLabel.textColor = RGBValueColor(0x333333, 1.0); // 默认
  27. self.titleLabel.font = [UIFont systemFontOfSize:14.0];; // 默认
  28. [self.contentView addSubview:self.titleLabel];
  29. //
  30. self.timeLabel = [[UILabel alloc] init];
  31. self.timeLabel.textAlignment = NSTextAlignmentLeft;
  32. self.timeLabel.textColor = RGBValueColor(0x999999, 1.0); // 默认
  33. self.timeLabel.font = [UIFont systemFontOfSize:13]; // 默认
  34. [self.contentView addSubview:self.timeLabel];
  35. //
  36. self.subTitleLabel = [[UILabel alloc] init];
  37. self.subTitleLabel.textAlignment = NSTextAlignmentRight;
  38. self.subTitleLabel.textColor = RGBValueColor(0xfe4086, 1.0);// 默认
  39. self.subTitleLabel.font = [UIFont systemFontOfSize:14];// 默认
  40. [self.contentView addSubview:self.subTitleLabel];
  41. //
  42. self.arrowView = [[UIImageView alloc] init];
  43. self.arrowView.image = [UIImage imageNamed:@"youjiantou"];
  44. [self.contentView addSubview:self.arrowView];
  45. //
  46. self.lineView = [[UIImageView alloc] init];
  47. self.lineView.image = [UIImage imageNamed:@"fengexian"];
  48. [self.contentView addSubview:self.lineView];
  49. self.onetitleLabel = [[UILabel alloc] init];
  50. self.onetitleLabel.textAlignment = NSTextAlignmentLeft;
  51. self.onetitleLabel.textColor = RGBValueColor(0x333333, 1.0);
  52. self.onetitleLabel.font = [UIFont systemFontOfSize:16.0];
  53. self.onetitleLabel.hidden = YES;
  54. [self.contentView addSubview:self.onetitleLabel];
  55. }
  56. - (void)layoutSubviews {
  57. [super layoutSubviews];
  58. CGFloat height = self.frame.size.height;
  59. self.iconImageView.frame = CGRectMake(20, 12.5, height - 25, height - 25);
  60. self.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, 20, ScreenWidth / 2 - 50, 14);
  61. self.timeLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, CGRectGetMaxY(self.titleLabel.frame) + 15, ScreenWidth - 100, 13);
  62. self.subTitleLabel.frame = CGRectMake(ScreenWidth / 2, 0, ScreenWidth / 2 - 20, height);
  63. self.arrowView.frame = CGRectMake(ScreenWidth - 28, height / 2 - 7, 8, 14);
  64. self.lineView.frame = CGRectMake(0, height - 1, ScreenWidth, 1);
  65. self.onetitleLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, 0, ScreenWidth / 2 - 50, height);
  66. }
  67. // 可以在赋值里面改变frame
  68. - (void)setMyOrderCellValueWithDic:(NSDictionary *)dic titleStr:(NSString *)str {
  69. if ([str isEqualToString:@"redEnvelope"]) {
  70. self.lineView.hidden = YES;
  71. self.arrowView.hidden = YES;
  72. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"shipintouxiang"]];
  73. self.titleLabel.text = dic[@"modelpk"]; //  这里名字没有
  74. self.subTitleLabel.text = [NSString stringWithFormat:@"%@元", dic[@"coin"]];
  75. NSString *timeStr = dic[@"rdate"];
  76. if ([timeStr containsString:@" "]) {
  77. NSArray *timeArr = [timeStr componentsSeparatedByString:@" "];
  78. NSArray *time = [timeArr[0] componentsSeparatedByString:@"-"];
  79. self.timeLabel.text = [NSString stringWithFormat:@"%@.%@.%@", time[0], time[1], time[1]];
  80. } else {
  81. self.timeLabel.text = timeStr;
  82. }
  83. } else if ([str isEqualToString:@"myOrder"]) {//我的订单
  84. self.onetitleLabel.hidden = NO;
  85. self.subTitleLabel.hidden = YES;
  86. self.titleLabel.hidden = YES;
  87. self.timeLabel.hidden = YES;
  88. self.iconImageView.image = [UIImage imageNamed:dic[@"iconName"]];
  89. self.onetitleLabel.text = dic[@"title"];
  90. } else if ([str isEqualToString:@"videoOrder"]) { //视频订单
  91. self.onetitleLabel.hidden = YES;
  92. self.subTitleLabel.hidden = NO;
  93. self.titleLabel.hidden = NO;
  94. self.timeLabel.hidden = NO;
  95. self.lineView.hidden = YES;
  96. self.arrowView.hidden = YES;
  97. NSString *urlStr = [NSString stringWithFormat:@"%@/%@", PublicUrl, dic[@"hphoto"]];
  98. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"shipintouxiang"]];
  99. self.titleLabel.text = dic[@"pet"];
  100. self.timeLabel.text = [NSString stringWithFormat:@"时间:%@",dic[@"begdate"]];
  101. NSString *coinStr = dic[@"coin"];
  102. NSString *durationStr = dic[@"duration"];
  103. NSString *coin = [NSString stringWithFormat:@"%@元/%@分钟", coinStr,durationStr];
  104. if (coin.length > 1) {
  105. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:coin];
  106. [attributedString addAttribute:NSForegroundColorAttributeName value:RGBValueColor(0xfe4086, 1.0) range:NSMakeRange(0,coinStr.length+1)];
  107. [attributedString addAttribute:NSForegroundColorAttributeName value:RGBValueColor(0x333333, 1.0) range:NSMakeRange(coinStr.length+1,durationStr.length+3)];
  108. self.subTitleLabel.attributedText = attributedString;
  109. }
  110. }
  111. }
  112. /*
  113. {
  114. coin = "99.99";
  115. memberpk = 1;
  116. modelpk = 1;
  117. pk = 93;
  118. rdate = "2018-07-09 15:39:42";
  119. rstate = 1;
  120. }
  121. video
  122. {
  123. begdate = "2018-06-13 00:00:00";
  124. coin = "";
  125. duration = "";
  126. hphoto = "upload/hphoto/2018-07-13/h1.png";
  127. memberpk = 8;
  128. modelpk = 2;
  129. pet = "刘德华";
  130. pk = 2;
  131. }
  132. **/
  133. @end