prizeOrderDetailsModel.m 909 Bytes
//
//  prizeOrderDetailsModel.m
//  Lighting
//
//  Created by 曹云霄 on 2016/11/29.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "prizeOrderDetailsModel.h"

@implementation prizeOrderDetailsModel


- (CGFloat)giftHeight
{
    if (!_giftHeight) {
        _giftHeight = [self calculateGiftNeedHeight:self.details];
    }
    return _giftHeight;
}

#pragma mark - 计算礼品显示需要高度
- (CGFloat)calculateGiftNeedHeight:(NSArray<TOPrizeBillDetailsEntity *>*)gifts
{
    CGFloat height = 0;
    NSInteger count = gifts.count;
    CGFloat itemHeight = 100;
    CGFloat interval = 20;
    if (count <= 2) {
        height += itemHeight+interval *2;
    }else if (count %2 == 0 || count%2 == 1){
        if (count %2 == 1) {
            count += 1;
        }
        height += (count/2)*itemHeight + ((count/2)+1)*interval;
    }
    return height;
}

@end