123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // MyOrderTableViewCell.m
- // DSH
- //
- // Created by 张毅成 on 2018/10/8.
- // Copyright © 2018 WZX. All rights reserved.
- //
- #import "MyOrderTableViewCell.h"
- @implementation MyOrderTableViewCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- self.backgroundColor = kBackgroundColor;
- self.translatesAutoresizingMaskIntoConstraints = false;
- [self.viewBG setCorner];
- [self.arrayButtonBottom enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- UIButton *button = obj;
- if (button.tag == 0) {
- [button setShadow];
- }else
- [button setCorner];
- [button addEventHandler:^(id sender) {
- switch (idx) {
- case 0:
- if (self.blockDidTouchButton0) {
- self.blockDidTouchButton0();
- }
- break;
- case 1:
- if (self.blockDidTouchButton1) {
- self.blockDidTouchButton1();
- }
- break;
- case 2:
- if (self.blockDidTouchButton2) {
- self.blockDidTouchButton2();
- }
- break;
- default:
- break;
- }
- } forControlEvents:(UIControlEventTouchUpInside)];
- }];
- self.backgroundColor = [UIColor whiteColor];
- [self.buttonDelete addEventHandler:^(id sender) {
- if (self.blockDidTouchButtonDelete) {
- self.blockDidTouchButtonDelete();
- }
- } forControlEvents:(UIControlEventTouchUpInside)];
- }
- - (void)setModel:(MyOrderModel *)model {
- if (model.orderType == 2) {
- [self setButtonBottomWithType:4];
- }else if (model.orderType == 3) {
- [self setButtonBottomWithType:5];
- }else
- [self setButtonBottomWithType:model.orderType];
- self.labelType.text = model.arrayTypeTitle[model.orderType]?:@"暂无";
- self.labelBookName.text = model.productName?:@"暂无";
- // [self.imageViewIcon sd_setImageWithURL:model.coverImgUrl placeholderImage:[UIImage imageNamed:@"加载中"]];
- self.labelAuthor.text = model.author?:@"暂无";
- self.labelMoney.text = [NSString stringWithFormat:@"¥%0.2f",model.totalPrice];
- }
- - (void)setButtonBottomWithType:(NSInteger)type {
- [self.arrayButtonBottom enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- UIButton *button = obj;
- switch (type) {
- case MyOrderTableViewCellTypeAll:
- if (button.tag == 0) {
- [button setTitle:@"付款" forState:(UIControlStateNormal)];
- }else if (button.tag == 1) {
- [button setTitle:@"取消" forState:(UIControlStateNormal)];
- button.hidden = true;
- }else if (button.tag == 2) {
- button.hidden = true;
- }
- break;
- case MyOrderTableViewCellTypeObligation:
- if (button.tag == 0) {
- [button setTitle:@"付款" forState:(UIControlStateNormal)];
- }else if (button.tag == 1) {
- [button setTitle:@"取消" forState:(UIControlStateNormal)];
- button.hidden = true;
- }else if (button.tag == 2) {
- button.hidden = true;
- }
- break;
- case MyOrderTableViewCellTypeSendGoods:
- if (button.tag == 0) {
- [button setTitle:@"物流" forState:(UIControlStateNormal)];
- }else if (button.tag == 1) {
- [button setTitle:@"退款" forState:(UIControlStateNormal)];
- }else if (button.tag == 2) {
- button.hidden = true;
- }
- break;
- case MyOrderTableViewCellTypeForTheGoods:
- if (button.tag == 0) {
- [button setTitle:@"收货" forState:(UIControlStateNormal)];
- }else if (button.tag == 1) {
- [button setTitle:@"物流" forState:(UIControlStateNormal)];
- }else if (button.tag == 2) {
- [button setTitle:@"退款" forState:(UIControlStateNormal)];
- button.hidden = false;
- }
- break;
- case MyOrderTableViewCellTypeEvaluate:
- if (button.tag == 0) {
- [button setTitle:@"评价" forState:(UIControlStateNormal)];
- }else if (button.tag == 1) {
- button.hidden = true;
- }else if (button.tag == 2) {
- button.hidden = true;
- }
- break;
- case MyOrderTableViewCellTypeCancel:
- if (button.tag == 0) {
- [button setTitle:@"再次购买" forState:(UIControlStateNormal)];
- }else if (button.tag == 1) {
- button.hidden = true;
- }else if (button.tag == 2) {
- button.hidden = true;
- }
- break;
- default:
- break;
- }
- }];
- }
- + (instancetype)cellWithTableView:(UITableView *)tableView AndIndex:(NSInteger)index {
- NSString *ID = [NSString stringWithFormat:@"MyOrderTableViewCell%ld",(long)index];
- MyOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- if (cell == nil) {
- cell = [[NSBundle mainBundle] loadNibNamed:@"MyOrderTableViewCell" owner:self options:nil][index];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|