暂无描述

FKProductDetailItem.m 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // FKProductDetailItem.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/1/20.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProductDetailItem.h"
  9. @implementation FKProductDetailItem
  10. - (instancetype)init{
  11. if (self = [super init]) {
  12. _hasShowSycAnim = NO;
  13. }
  14. return self;
  15. }
  16. + (NSDictionary *)mts_mapping{
  17. return @{
  18. @"product": mts_key(productInfo),
  19. @"product_pics": mts_key(productShowArray),
  20. @"recommend": mts_key(recommendInfo),
  21. @"supplier": mts_key(supplier),
  22. @"sale_rule": mts_key(saleRule),
  23. @"current_user": mts_key(currentUser),
  24. @"share_wx": mts_key(shareInfo),
  25. @"share_info": mts_key(shareTargetItem),
  26. @"theme_activity": mts_key(themeItem),
  27. @"promotion": mts_key(promotionItem),
  28. @"last_faq": mts_key(lastQA),
  29. @"country": mts_key(countryInfoItem),
  30. @"service_user": mts_key(serveUser),
  31. @"brand": mts_key(brandInfo),
  32. @"url": mts_key(webUrl),
  33. @"server_time": mts_key(serverTime),
  34. };
  35. }
  36. + (BOOL)mts_shouldSetUndefinedKeys{
  37. return NO;
  38. }
  39. + (NSDictionary *)mts_arrayClassMapping{
  40. return @{mts_key(productShowArray) : ProductShowItem.class};
  41. }
  42. - (NSArray *)allProductImgUrlArray{
  43. NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:self.productShowArray.count];
  44. for (ProductShowItem *item in self.productShowArray) {
  45. if (item.imageUrl) [arrayM addObject:item.imageUrl];
  46. }
  47. return arrayM;
  48. }
  49. - (BOOL)hasRecommend{
  50. if ([self.recommendInfo isKindOfClass:[FKRecommendInfoItem class]] && self.recommendInfo.userID.length > 0){
  51. return YES;
  52. }
  53. return NO;
  54. }
  55. - (ProductShowItem *)productShowItemForIndex:(NSUInteger)index{
  56. if (index < self.productShowArray.count) {
  57. return self.productShowArray[index];
  58. }
  59. return nil;
  60. }
  61. - (NSString *)getTotalPrice{
  62. return [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:self.productInfo.price]];
  63. }
  64. - (ProductShowItem *)getSizePicItem{
  65. for (ProductShowItem *item in self.productShowArray) {
  66. if ([item isSizeImg]) return item;
  67. }
  68. return nil;
  69. }
  70. - (BOOL)isExistActivityBanner {
  71. if (self.themeItem || self.promotionItem) {
  72. return YES;
  73. }
  74. return NO;
  75. }
  76. - (kActivityBannerType)activityBannerType {
  77. if (self.themeItem.photoURL.length > 0) {
  78. return kActivityBannerTypeTheme;
  79. }
  80. NSTimeInterval serverTime = [FLStringHelper timeIntervalFromString:self.serverTime];
  81. NSTimeInterval beginTime = [FLStringHelper timeIntervalFromString:self.promotionItem.beginTime];
  82. NSTimeInterval endTime = [FLStringHelper timeIntervalFromString:self.promotionItem.endTime];
  83. if (serverTime < beginTime && self.promotionItem.stock.intValue > 0) {
  84. return kActivityBannerTypeForeshow;
  85. }
  86. if (serverTime >= beginTime && serverTime < endTime) {
  87. return kActivityBannerTypeInProgress;
  88. }
  89. return kActivityBannerTypeNone;
  90. }
  91. @end