123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- //
- // FKPersonOrderSummaryCell.m
- // FirstLink
- //
- // Created by ascii on 16/2/23.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKPersonOrderSummaryCell.h"
- #import "FKPersonOrderViewModel.h"
- #import "FKOrderPaymentItem.h"
- @interface FKPersonOrderSummaryCell ()
- @property (nonatomic, strong) UILabel *totalPriceTipLabel;
- @property (nonatomic, strong) UILabel *totalPriceLabel;
- @end
- @implementation FKPersonOrderSummaryCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = [UIColor whiteColor];
-
- [self addAllSubviews];
- }
- return self;
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self.contentView addSubview:self.paymentButton];
- [self.paymentButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-15);
- make.centerY.equalTo(self.contentView).offset(-1);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
-
- [self.contentView addSubview:self.cancelButton];
- [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.paymentButton);
- make.right.equalTo(self.paymentButton.mas_left).offset(-10);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
-
- [self.contentView addSubview:self.deleteButton];
- [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-15);
- make.centerY.equalTo(self.contentView).offset(-1);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
-
- [self.contentView addSubview:self.uploadIDCardButton];
- [self.uploadIDCardButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-15);
- make.centerY.equalTo(self.contentView).offset(-1);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
-
- [self.contentView addSubview:self.shareButton];
- [self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.uploadIDCardButton);
- make.right.equalTo(self.uploadIDCardButton.mas_left).offset(-10);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
-
- [self.contentView addSubview:self.totalPriceTipLabel];
- [self.totalPriceTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).with.offset(15);
- make.centerY.equalTo(self.paymentButton);
- }];
-
- [self.contentView addSubview:self.totalPriceLabel];
- [self.totalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.totalPriceTipLabel.mas_right);
- make.centerY.equalTo(self.paymentButton);
- }];
- }
- #pragma mark - FKPersonOrderCellDelegate
- - (void)configPersonOrderCell:(NSIndexPath *)indexPath classify:(FKPersonOrderClassify)classify viewModel:(FKPersonOrderViewModel *)viewModel {
- FKOrderPaymentItem *paymentItem = [viewModel paymentItemAtIndex:indexPath.section classify:classify];
-
- self.totalPriceLabel.text = [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:paymentItem.totalFee]];
-
- /**
- * 根据状态显示按钮
- */
- [self hideAllActionButton];
- switch ((FKOrderStatus)([paymentItem.status intValue])) {
- case FKOrderStatusUnpay: {
- self.paymentButton.hidden = NO;
- self.cancelButton.hidden = NO;
- break;
- }
- case FKOrderStatusCancel:
- case FKOrderStatusIgnore:
- case FKOrderStatusInvalid: {
- self.deleteButton.hidden = NO;
- break;
- }
- case FKOrderStatusFinish:
- case FKOrderStatusRefund:
- case FKOrderStatusWaitDeliver:
- case FKOrderStatusWaitReceipt:
- case FKOrderStatusDenied:
- if (![paymentItem hasContainPindan]) self.shareButton.hidden = NO;
- break;
- default:
- break;
- }
- self.uploadIDCardButton.hidden = ![paymentItem isIDCardInvailid];
-
- if (self.uploadIDCardButton.hidden){
- [self.shareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-15);
- make.centerY.equalTo(self.contentView).offset(-1);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
- } else {
- [self.shareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.uploadIDCardButton);
- make.right.equalTo(self.uploadIDCardButton.mas_left).offset(-10);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(28);
- }];
- }
-
- [self.contentView setNeedsLayout];
- [self.contentView layoutIfNeeded];
- }
- #pragma mark - Method
- - (void)hideAllActionButton {
- self.paymentButton.hidden = YES;
- self.cancelButton.hidden = YES;
- self.deleteButton.hidden = YES;
- self.uploadIDCardButton.hidden = YES;
- self.shareButton.hidden = YES;
- }
- #pragma mark - Property
- - (UIButton *)paymentButton {
- if (!_paymentButton) {
- _paymentButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_paymentButton setTitle:@"立即付款" forState:UIControlStateNormal];
- [_paymentButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
- [_paymentButton setTitleColor:UIColorFromRGB(0xffffff)
- forState:UIControlStateNormal];
- [_paymentButton setBackgroundColor:UIColorFromRGB(0xff6362)];
- _paymentButton.layer.cornerRadius = 2;
- }
- return _paymentButton;
- }
- - (UIButton *)cancelButton {
- if (!_cancelButton) {
- _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_cancelButton setTitle:@"取消订单" forState:UIControlStateNormal];
- [_cancelButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
- [_cancelButton setTitleColor:UIColorFromRGB(0x666666)
- forState:UIControlStateNormal];
- _cancelButton.layer.cornerRadius = 2;
- _cancelButton.layer.borderWidth = 1;
- _cancelButton.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
- }
- return _cancelButton;
- }
- - (UIButton *)deleteButton {
- if (!_deleteButton) {
- _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_deleteButton setTitle:@"删除订单" forState:UIControlStateNormal];
- [_deleteButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
- [_deleteButton setTitleColor:UIColorFromRGB(0x666666)
- forState:UIControlStateNormal];
- _deleteButton.layer.cornerRadius = 2;
- _deleteButton.layer.borderWidth = 1;
- _deleteButton.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
- }
- return _deleteButton;
- }
- - (UIButton *)uploadIDCardButton {
- if (!_uploadIDCardButton) {
- _uploadIDCardButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_uploadIDCardButton setTitle:@"完善身份证" forState:UIControlStateNormal];
- [_uploadIDCardButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
- [_uploadIDCardButton setTitleColor:UIColorFromRGB(0xffffff)
- forState:UIControlStateNormal];
- [_uploadIDCardButton setBackgroundColor:UIColorFromRGB(0xff6362)];
- _uploadIDCardButton.layer.cornerRadius = 2;
- }
- return _uploadIDCardButton;
- }
- - (UIButton *)shareButton{
- if (_shareButton == nil) {
- _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_shareButton setTitle:@"分享赚积分" forState:UIControlStateNormal];
- [_shareButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
- [_shareButton setTitleColor:UIColorFromRGB(0x666666)
- forState:UIControlStateNormal];
- _shareButton.layer.cornerRadius = 2;
- _shareButton.layer.borderWidth = 1;
- _shareButton.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
- }
- return _shareButton;
- }
- - (UILabel *)totalPriceTipLabel {
- if (!_totalPriceTipLabel) {
- _totalPriceTipLabel = [UILabel new];
- _totalPriceTipLabel.textColor = UIColorFromRGB(0x666666);
- _totalPriceTipLabel.font = [UIFont systemFontOfSize:14.0];
- _totalPriceTipLabel.text = @"合计:";
- }
- return _totalPriceTipLabel;
- }
- - (UILabel *)totalPriceLabel {
- if (!_totalPriceLabel) {
- _totalPriceLabel = [UILabel new];
- _totalPriceLabel.textColor = UIColorFromRGB(0x333333);
- _totalPriceLabel.font = [UIFont boldSystemFontOfSize:14];
- }
- return _totalPriceLabel;
- }
- @end
|