CNLiveMineModel.m 1.87 KB
//
//  CNLiveMineModel.m
//  CNLiveMineModule
//
//  Created by 153993236@qq.com on 11/12/2019.
//  Copyright © 2019 153993236@qq.com. All rights reserved.
//

#import "CNLiveMineModel.h"

@implementation CNLiveMineModel
static const NSInteger margin = 10;
+ (NSDictionary *)mj_objectClassInArray{
    return @{
             @"buttons" : @"CNLiveMineButtonModel"
             };
}

- (void)editModel:(BOOL)showMapTool{
    if ([self.style isEqualToString:@"2"]) {
        NSMutableArray *array = [NSMutableArray arrayWithArray:self.buttons];
        if (!showMapTool) {
            [array removeLastObject];
            self.buttons = [NSArray arrayWithArray:array];
        }
    }
}

- (CNLiveMineCellType)type{
    if([self.style isEqualToString:@"1"]){
        return CNLiveMineCellTypeOrder;
    }
    else if([self.style isEqualToString:@"2"]){
        return CNLiveMineCellTypeTool;
        
    }
    else if([self.style isEqualToString:@"3"]){
        return CNLiveMineCellTypeGoods;
        
    }
    else if([self.style isEqualToString:@"4"]){
        return CNLiveMineCellTypeSports;
        
    }
    return CNLiveMineCellTypeOrder;
}

- (CGFloat)height{
    CGFloat titleHeight = 50;
    CGFloat btnHeight = 60;

    //订单
    if(self.type == CNLiveMineCellTypeOrder){
        return 2*margin+titleHeight+btnHeight+margin;
    }
    //工具
    else if(self.type == CNLiveMineCellTypeTool){
        return 2*margin+titleHeight+ceilf(self.buttons.count/4.0)*(btnHeight+margin);

    }
    //商品
    else if(self.type == CNLiveMineCellTypeGoods){
        // 电票的高度  80
        return 2*margin+titleHeight+80+margin;
        
    }
    //大众体育
    else if(self.type == CNLiveMineCellTypeSports){
        return 2*margin+titleHeight+ceilf(self.buttons.count/4.0)*(btnHeight+margin);
        
    }
    return 0.0000001f;
}

@end

@implementation CNLiveMineButtonModel


@end