Açıklama Yok

FKMyVipViewModel.m 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // FKMyVipViewModel.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/9/14.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKMyVipViewModel.h"
  9. @interface FKMyVipViewModel ()
  10. @property (nonatomic, strong) NSArray *imageNames;
  11. @property (nonatomic, strong) NSArray *titles;
  12. @end
  13. @implementation FKMyVipViewModel
  14. - (instancetype)init {
  15. self = [super init];
  16. if (self) {
  17. _segmentType = kCardSegmentTypeVip;
  18. }
  19. return self;
  20. }
  21. - (FKVipBuyRuleItem *)itemAtIndexPath:(NSIndexPath *)indexPath {
  22. NSInteger index = indexPath.row - 1;
  23. if (index >= 0 && index < self.ruleItemArray.count) {
  24. return self.ruleItemArray[index];
  25. }
  26. return nil;
  27. }
  28. - (UIImage *)imageAtIndex:(NSInteger)index {
  29. if (index >=0 && index < self.imageNames.count) {
  30. return [UIImage imageNamed:self.imageNames[index]];
  31. }
  32. return nil;
  33. }
  34. - (NSAttributedString *)attributedTitleAtIndex:(NSInteger)index {
  35. NSMutableArray *mutArray = [NSMutableArray arrayWithArray:self.titles];
  36. if (kCardSegmentTypeVip == self.segmentType) {
  37. [mutArray insertObject:@"会员9.5折" atIndex:2];
  38. } else if (kCardSegmentTypeSuperVip == self.segmentType) {
  39. [mutArray insertObject:@"会员9.3折" atIndex:2];
  40. }
  41. if (index >=0 && index < mutArray.count) {
  42. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:mutArray[index]];
  43. if (index == 2) {
  44. [attrString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xff5656) range:NSMakeRange(2, 3)];
  45. return attrString;
  46. }
  47. return attrString;
  48. }
  49. return nil;
  50. }
  51. #pragma mark - Property
  52. - (NSArray *)imageNames {
  53. if (!_imageNames) {
  54. _imageNames = @[@"vip_icon_free_postage", @"vip_icon_exdusive", @"vip_icon_discount",
  55. @"vip_icon_postage", @"vip_icon_priority", @"vip_icon_firstheavyfree"];
  56. }
  57. return _imageNames;
  58. }
  59. - (NSArray *)titles {
  60. if (!_titles) {
  61. _titles = @[@"包邮券", @"会员专享商品 ", @"会员运费", @"转运优先", @"首重抹零"];
  62. }
  63. return _titles;
  64. }
  65. @end