123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // FKPersonOrderCountryCell.m
- // FirstLink
- //
- // Created by ascii on 16/2/23.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKPersonOrderCountryCell.h"
- #import "FKPersonOrderViewModel.h"
- #import "FKOrderSupplierItem.h"
- #import "FKOrderBriefItem.h"
- #import "FKProCountryItem.h"
- @interface FKPersonOrderCountryCell ()
- @property (nonatomic, strong) UIImageView *countryImageView;
- @property (nonatomic, strong) UILabel *sourceLabel;
- @property (nonatomic, strong) UILabel *statusLabel;
- @end
- @implementation FKPersonOrderCountryCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = UIColorFromRGB(0xf9f9f9);
-
- [self addAllSubviews];
- }
- return self;
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self.contentView addSubview:self.countryImageView];
- [self.countryImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.centerY.equalTo(self.contentView).offset(5);
- make.size.mas_equalTo(CGSizeMake(20, 13));
- }];
-
- [self.contentView addSubview:self.statusLabel];
- [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-20);
- make.centerY.equalTo(self.countryImageView);
- make.width.mas_greaterThanOrEqualTo(50).with.priorityHigh();
- }];
-
- [self.contentView addSubview:self.sourceLabel];
- [self.sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.countryImageView.mas_right).offset(10);
- make.right.equalTo(self.statusLabel.mas_left).offset(-15);
- make.centerY.equalTo(self.countryImageView);
- }];
- }
- #pragma mark - FKPersonOrderCellDelegate
- - (void)configPersonOrderCell:(NSIndexPath *)indexPath classify:(FKPersonOrderClassify)classify viewModel:(FKPersonOrderViewModel *)viewModel {
- FKOrderSupplierItem *supplierItem = [viewModel supplierItemAtIndex:indexPath classify:classify];
-
- [self.countryImageView sd_setImageWithURL:[NSURL URLWithString:supplierItem.countryItem.countryPicUrl]];
- self.sourceLabel.text = supplierItem.name;
-
- FKOrderStatus status = (FKOrderStatus)(supplierItem.orderItem.tradeStatus.intValue);
- if (status == FKOrderStatusIgnore || status == FKOrderStatusCancel || status == FKOrderStatusUnpay || status == FKOrderStatusInvalid || status == FKOrderStatusFinish) {
- self.statusLabel.hidden = YES;
- } else {
- self.statusLabel.hidden = NO;
-
- if (status == FKOrderStatusWaitDeliver || status == FKOrderStatusWaitReceipt || status == FKOrderStatusUngroup) {
- self.statusLabel.text = [FKPersonOrderViewModel getDetailPaymentStatusText:status];
- }
-
- FKRefundStatus refundStatus = (FKRefundStatus)(supplierItem.orderItem.refundStatus.intValue);
- NSString *refundString = [FKPersonOrderViewModel getRefundStatusText:refundStatus];
-
- if (status == FKOrderStatusDenied || status == FKOrderStatusRefund) {
- self.statusLabel.text = refundString;
- } else if (refundString.length > 0) {
- NSString *string = self.statusLabel.text;
- self.statusLabel.text = [NSString stringWithFormat:@"%@:%@", string, refundString];
- }
- }
- }
- #pragma mark - Property
- - (UIImageView*)countryImageView {
- if (!_countryImageView) {
- _countryImageView = [UIImageView new];
- _countryImageView.contentMode = UIViewContentModeScaleAspectFit;
- _countryImageView.backgroundColor = [UIColor whiteColor];
- }
- return _countryImageView;
- }
- - (UILabel *)sourceLabel {
- if (!_sourceLabel) {
- _sourceLabel = [UILabel new];
- _sourceLabel.textColor = UIColorFromRGB(0x666666);
- _sourceLabel.font = [UIFont systemFontOfSize:14];
- }
- return _sourceLabel;
- }
- - (UILabel *)statusLabel {
- if (!_statusLabel) {
- _statusLabel = [UILabel new];
- _statusLabel.textColor = UIColorFromRGB(0xff624a);
- _statusLabel.font = [UIFont systemFontOfSize:14];
- _statusLabel.textAlignment = NSTextAlignmentRight;
- }
- return _statusLabel;
- }
- @end
|