Geen omschrijving

FKPersonOrderCountryCell.m 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // FKPersonOrderCountryCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/2/23.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKPersonOrderCountryCell.h"
  9. #import "FKPersonOrderViewModel.h"
  10. #import "FKOrderSupplierItem.h"
  11. #import "FKOrderBriefItem.h"
  12. #import "FKProCountryItem.h"
  13. @interface FKPersonOrderCountryCell ()
  14. @property (nonatomic, strong) UIImageView *countryImageView;
  15. @property (nonatomic, strong) UILabel *sourceLabel;
  16. @property (nonatomic, strong) UILabel *statusLabel;
  17. @end
  18. @implementation FKPersonOrderCountryCell
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. self.contentView.backgroundColor = UIColorFromRGB(0xf9f9f9);
  23. [self addAllSubviews];
  24. }
  25. return self;
  26. }
  27. #pragma mark - Layout
  28. - (void)addAllSubviews {
  29. [self.contentView addSubview:self.countryImageView];
  30. [self.countryImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.equalTo(self.contentView).offset(15);
  32. make.centerY.equalTo(self.contentView).offset(5);
  33. make.size.mas_equalTo(CGSizeMake(20, 13));
  34. }];
  35. [self.contentView addSubview:self.statusLabel];
  36. [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.right.equalTo(self.contentView).offset(-20);
  38. make.centerY.equalTo(self.countryImageView);
  39. make.width.mas_greaterThanOrEqualTo(50).with.priorityHigh();
  40. }];
  41. [self.contentView addSubview:self.sourceLabel];
  42. [self.sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.equalTo(self.countryImageView.mas_right).offset(10);
  44. make.right.equalTo(self.statusLabel.mas_left).offset(-15);
  45. make.centerY.equalTo(self.countryImageView);
  46. }];
  47. }
  48. #pragma mark - FKPersonOrderCellDelegate
  49. - (void)configPersonOrderCell:(NSIndexPath *)indexPath classify:(FKPersonOrderClassify)classify viewModel:(FKPersonOrderViewModel *)viewModel {
  50. FKOrderSupplierItem *supplierItem = [viewModel supplierItemAtIndex:indexPath classify:classify];
  51. [self.countryImageView sd_setImageWithURL:[NSURL URLWithString:supplierItem.countryItem.countryPicUrl]];
  52. self.sourceLabel.text = supplierItem.name;
  53. FKOrderStatus status = (FKOrderStatus)(supplierItem.orderItem.tradeStatus.intValue);
  54. if (status == FKOrderStatusIgnore || status == FKOrderStatusCancel || status == FKOrderStatusUnpay || status == FKOrderStatusInvalid || status == FKOrderStatusFinish) {
  55. self.statusLabel.hidden = YES;
  56. } else {
  57. self.statusLabel.hidden = NO;
  58. if (status == FKOrderStatusWaitDeliver || status == FKOrderStatusWaitReceipt || status == FKOrderStatusUngroup) {
  59. self.statusLabel.text = [FKPersonOrderViewModel getDetailPaymentStatusText:status];
  60. }
  61. FKRefundStatus refundStatus = (FKRefundStatus)(supplierItem.orderItem.refundStatus.intValue);
  62. NSString *refundString = [FKPersonOrderViewModel getRefundStatusText:refundStatus];
  63. if (status == FKOrderStatusDenied || status == FKOrderStatusRefund) {
  64. self.statusLabel.text = refundString;
  65. } else if (refundString.length > 0) {
  66. NSString *string = self.statusLabel.text;
  67. self.statusLabel.text = [NSString stringWithFormat:@"%@:%@", string, refundString];
  68. }
  69. }
  70. }
  71. #pragma mark - Property
  72. - (UIImageView*)countryImageView {
  73. if (!_countryImageView) {
  74. _countryImageView = [UIImageView new];
  75. _countryImageView.contentMode = UIViewContentModeScaleAspectFit;
  76. _countryImageView.backgroundColor = [UIColor whiteColor];
  77. }
  78. return _countryImageView;
  79. }
  80. - (UILabel *)sourceLabel {
  81. if (!_sourceLabel) {
  82. _sourceLabel = [UILabel new];
  83. _sourceLabel.textColor = UIColorFromRGB(0x666666);
  84. _sourceLabel.font = [UIFont systemFontOfSize:14];
  85. }
  86. return _sourceLabel;
  87. }
  88. - (UILabel *)statusLabel {
  89. if (!_statusLabel) {
  90. _statusLabel = [UILabel new];
  91. _statusLabel.textColor = UIColorFromRGB(0xff624a);
  92. _statusLabel.font = [UIFont systemFontOfSize:14];
  93. _statusLabel.textAlignment = NSTextAlignmentRight;
  94. }
  95. return _statusLabel;
  96. }
  97. @end