chatmessageCell.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #import "chatmessageCell.h"
  2. //#import "chatmessageModel.h"
  3. #import "UIImage+Resize.h"
  4. #import "SDWebImage/UIButton+WebCache.h"
  5. #import "UIImageView+WebCache.h"
  6. #import "OrderDetailVC.h"
  7. #import "BuyerRefundDetailVC.h"
  8. #import "WaitSendGoodsVC.h"
  9. #import "RefundDetailVC.h"
  10. #import "OtherSellOrderDetailVC.h"
  11. @interface chatmessageCell ()
  12. {
  13. UILabel *_timeL;
  14. UIButton *_textBTN;
  15. UIButton *_iconBTN;
  16. }
  17. @end
  18. @implementation chatmessageCell
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if (self) {
  23. _timeL = [[UILabel alloc] init];
  24. _timeL.textAlignment = NSTextAlignmentCenter;
  25. _timeL.font = [UIFont systemFontOfSize:4];
  26. _timeL.textColor = Normal_TextColor;
  27. _timeL.font = [UIFont systemFontOfSize:16];
  28. // _timeL.hidden = YES;
  29. _textBTN = [[UIButton alloc] init];
  30. _textBTN.titleLabel.numberOfLines = 0;
  31. _textBTN.titleLabel.font = [UIFont systemFontOfSize:16];
  32. //设置有效的显示范围
  33. _textBTN.contentEdgeInsets = UIEdgeInsetsMake(10,15,10,15);
  34. // _textBTN.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"order_messageBack"]];
  35. _textBTN.titleLabel.textColor = [UIColor whiteColor];
  36. _iconBTN = [[UIButton alloc] init];
  37. _iconBTN.layer.masksToBounds = YES;
  38. _iconBTN.layer.cornerRadius = 20;
  39. [self.contentView addSubview:_timeL];
  40. [self.contentView addSubview:_textBTN];
  41. [self.contentView addSubview:_iconBTN];
  42. self.backgroundColor=UIColor.whiteColor;
  43. }
  44. return self;
  45. }
  46. -(void)setOrdermodel:(OrderMessageModel *)ordermodel{
  47. _ordermodel = ordermodel;
  48. //设置数据
  49. [self setorderCellData];
  50. //设置坐标
  51. [self setorderCellFrame];
  52. }
  53. +(chatmessageCell *)cellWithTableView:(UITableView *)tableView
  54. {
  55. static NSString *identifier = @"messageCell";
  56. chatmessageCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  57. if (!cell) {
  58. cell = [[chatmessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  59. }
  60. return cell;
  61. }
  62. -(void)setorderCellFrame
  63. {
  64. _textBTN.frame = _ordermodel.textR;
  65. _timeL.frame = _ordermodel.timeR;
  66. _iconBTN.frame = _ordermodel.iconR;
  67. }
  68. -(void)setorderCellData
  69. {
  70. _timeL.text = _ordermodel.time;
  71. if ([_ordermodel.is_commission isEqual:@"0"]) {
  72. NSString *clickText = YZMsg(@"点击查看");
  73. NSString *name =[NSString stringWithFormat:@"%@,%@",_ordermodel.text,clickText];
  74. NSMutableAttributedString *contentStr = [[NSMutableAttributedString alloc] initWithString:name];
  75. NSRange redRange = NSMakeRange(name.length-clickText.length, clickText.length);
  76. [contentStr addAttributes:@{NSForegroundColorAttributeName:RGB(247,205,123),NSFontAttributeName:[UIFont systemFontOfSize:14]} range:redRange];
  77. [_textBTN setAttributedTitle:contentStr forState:0];
  78. }else{
  79. NSString *name =[NSString stringWithFormat:@"%@",_ordermodel.text];
  80. NSMutableAttributedString *contentStr = [[NSMutableAttributedString alloc] initWithString:name];
  81. [_textBTN setAttributedTitle:contentStr forState:0];
  82. }
  83. [_iconBTN sd_setImageWithURL:[NSURL URLWithString:_ordermodel.icon] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"bg1"]];
  84. [_textBTN setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  85. [_textBTN setBackgroundImage:[UIImage resizableImage:@"order_messageBack"] forState:UIControlStateNormal];
  86. [_textBTN addTarget:self action:@selector(goOrderDetail) forControlEvents:UIControlEventTouchUpInside];
  87. }
  88. -(void)goOrderDetail{
  89. if ([_ordermodel.is_commission isEqual:@"1"]) {
  90. return;
  91. }
  92. //0 买家。1 卖家
  93. if ([_ordermodel.type isEqual:@"1"]) {
  94. SellOrderModel *orderModel = [SellOrderModel modelWithDic:@{}];
  95. orderModel.idStr =_ordermodel.orderid;
  96. if ([_ordermodel.status isEqual:@"1"]) {
  97. WaitSendGoodsVC *wait = [[WaitSendGoodsVC alloc]init];
  98. wait.orderModel = orderModel;
  99. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:wait animated:YES];
  100. }else if ([_ordermodel.status isEqual:@"5"]){
  101. RefundDetailVC *refund = [[RefundDetailVC alloc]init];
  102. refund.orderModel = orderModel;
  103. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:refund animated:YES];
  104. } else{
  105. OtherSellOrderDetailVC *other = [[OtherSellOrderDetailVC alloc]init];
  106. other.orderModel = orderModel;
  107. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:other animated:YES];
  108. }
  109. }else{
  110. if ([_ordermodel.status isEqual:@"5"]) {
  111. BuyerRefundDetailVC *refund = [[BuyerRefundDetailVC alloc]init];
  112. refund.orderId = _ordermodel.orderid;
  113. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:refund animated:YES];
  114. }else{
  115. OrderDetailVC *detail = [[OrderDetailVC alloc]init];
  116. detail.orderId =_ordermodel.orderid;
  117. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:detail animated:YES];
  118. }
  119. }
  120. }
  121. @end