No Description

FKExploreTopicListItem.m 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // FKExploreTopicListItem.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/2/16.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKExploreTopicListItem.h"
  9. @implementation FKExploreTopicListSubItem
  10. + (NSDictionary*)mts_mapping {
  11. return @{@"id": mts_key(itemID),
  12. @"user_id": mts_key(userID),
  13. @"tag_pic": mts_key(categoryURL),
  14. @"name": mts_key(name),
  15. @"index_pic": mts_key(indexPic),
  16. @"title": mts_key(title),
  17. @"first_pic": mts_key(firstPic),
  18. @"price": mts_key(price),
  19. @"refer_price": mts_key(referPrice),
  20. @"is_new": mts_key(isNew),
  21. };
  22. }
  23. + (BOOL)mts_shouldSetUndefinedKeys {
  24. return NO;
  25. }
  26. @end
  27. @implementation FKExploreTopicListItem
  28. - (NSString *)subItemImageURLStringAtIndex:(NSInteger)index {
  29. if (index < self.subItemArray.count) {
  30. if ([self.objectType isEqualToString:@"10"]) {
  31. return ((FKExploreTopicListSubItem *)(self.subItemArray[index])).indexPic;
  32. } else {
  33. return ((FKExploreTopicListSubItem *)(self.subItemArray[index])).firstPic;
  34. }
  35. }
  36. return nil;
  37. }
  38. - (NSString *)subItemTitleAtIndex:(NSInteger)index {
  39. if (index < self.subItemArray.count) {
  40. if ([self.objectType isEqualToString:@"10"]) {
  41. return ((FKExploreTopicListSubItem *)(self.subItemArray[index])).name;
  42. } else {
  43. return ((FKExploreTopicListSubItem *)(self.subItemArray[index])).title;
  44. }
  45. }
  46. return nil;
  47. }
  48. - (NSAttributedString *)priceAttributedStringAtIndex:(NSInteger)index {
  49. if (index < self.subItemArray.count) {
  50. FKExploreTopicListSubItem *item = self.subItemArray[index];
  51. NSString *price = item.price ? [NSString stringWithFormat:@"¥%d ", [[FLStringHelper convertFenToYuan:item.price] intValue]] : nil;
  52. NSString *originalPrice = item.referPrice ? [NSString stringWithFormat:@"¥%d", [[FLStringHelper convertFenToYuan:item.referPrice] intValue]] : nil;
  53. NSAttributedString *attributeString = [FLStringHelper attStringWithText:price
  54. color:UIColorFromRGB(0xff624a)
  55. font:[UIFont systemFontOfSize:14]
  56. subText:originalPrice
  57. subColor:UIColorFromRGB(0x999999)
  58. subFont:[UIFont systemFontOfSize:10]];
  59. return attributeString;
  60. }
  61. return nil;
  62. }
  63. + (NSDictionary*)mts_mapping {
  64. return @{@"object_type": mts_key(objectType),
  65. @"id": mts_key(topicID),
  66. @"pic_url": mts_key(photoURL),
  67. @"target_url": mts_key(targetURL),
  68. };
  69. }
  70. + (BOOL)mts_shouldSetUndefinedKeys {
  71. return NO;
  72. }
  73. @end