123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // FKProductDetailItem.m
- // FirstLink
- //
- // Created by jack on 16/1/20.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProductDetailItem.h"
- @implementation FKProductDetailItem
- - (instancetype)init{
- if (self = [super init]) {
- _hasShowSycAnim = NO;
- }
- return self;
- }
- + (NSDictionary *)mts_mapping{
- return @{
- @"product": mts_key(productInfo),
- @"product_pics": mts_key(productShowArray),
- @"recommend": mts_key(recommendInfo),
- @"supplier": mts_key(supplier),
- @"sale_rule": mts_key(saleRule),
- @"current_user": mts_key(currentUser),
- @"share_wx": mts_key(shareInfo),
- @"share_info": mts_key(shareTargetItem),
- @"theme_activity": mts_key(themeItem),
- @"promotion": mts_key(promotionItem),
- @"last_faq": mts_key(lastQA),
- @"country": mts_key(countryInfoItem),
- @"service_user": mts_key(serveUser),
- @"brand": mts_key(brandInfo),
- @"url": mts_key(webUrl),
- @"server_time": mts_key(serverTime),
- };
- }
- + (BOOL)mts_shouldSetUndefinedKeys{
- return NO;
- }
- + (NSDictionary *)mts_arrayClassMapping{
- return @{mts_key(productShowArray) : ProductShowItem.class};
- }
- - (NSArray *)allProductImgUrlArray{
- NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:self.productShowArray.count];
- for (ProductShowItem *item in self.productShowArray) {
- if (item.imageUrl) [arrayM addObject:item.imageUrl];
- }
- return arrayM;
- }
- - (BOOL)hasRecommend{
- if ([self.recommendInfo isKindOfClass:[FKRecommendInfoItem class]] && self.recommendInfo.userID.length > 0){
- return YES;
- }
- return NO;
- }
- - (ProductShowItem *)productShowItemForIndex:(NSUInteger)index{
- if (index < self.productShowArray.count) {
- return self.productShowArray[index];
- }
- return nil;
- }
- - (NSString *)getTotalPrice{
- return [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:self.productInfo.price]];
- }
- - (ProductShowItem *)getSizePicItem{
- for (ProductShowItem *item in self.productShowArray) {
- if ([item isSizeImg]) return item;
- }
- return nil;
- }
- - (BOOL)isExistActivityBanner {
- if (self.themeItem || self.promotionItem) {
- return YES;
- }
- return NO;
- }
- - (kActivityBannerType)activityBannerType {
- if (self.themeItem.photoURL.length > 0) {
- return kActivityBannerTypeTheme;
- }
-
- NSTimeInterval serverTime = [FLStringHelper timeIntervalFromString:self.serverTime];
- NSTimeInterval beginTime = [FLStringHelper timeIntervalFromString:self.promotionItem.beginTime];
- NSTimeInterval endTime = [FLStringHelper timeIntervalFromString:self.promotionItem.endTime];
-
- if (serverTime < beginTime && self.promotionItem.stock.intValue > 0) {
- return kActivityBannerTypeForeshow;
- }
-
- if (serverTime >= beginTime && serverTime < endTime) {
- return kActivityBannerTypeInProgress;
- }
-
- return kActivityBannerTypeNone;
- }
- @end
|