1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // FKMyVipViewModel.m
- // FirstLink
- //
- // Created by jack on 15/9/14.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "FKMyVipViewModel.h"
- @interface FKMyVipViewModel ()
- @property (nonatomic, strong) NSArray *imageNames;
- @property (nonatomic, strong) NSArray *titles;
- @end
- @implementation FKMyVipViewModel
- - (instancetype)init {
- self = [super init];
- if (self) {
- _segmentType = kCardSegmentTypeVip;
- }
- return self;
- }
- - (FKVipBuyRuleItem *)itemAtIndexPath:(NSIndexPath *)indexPath {
- NSInteger index = indexPath.row - 1;
- if (index >= 0 && index < self.ruleItemArray.count) {
- return self.ruleItemArray[index];
- }
- return nil;
- }
- - (UIImage *)imageAtIndex:(NSInteger)index {
- if (index >=0 && index < self.imageNames.count) {
- return [UIImage imageNamed:self.imageNames[index]];
- }
- return nil;
- }
- - (NSAttributedString *)attributedTitleAtIndex:(NSInteger)index {
-
- NSMutableArray *mutArray = [NSMutableArray arrayWithArray:self.titles];
- if (kCardSegmentTypeVip == self.segmentType) {
- [mutArray insertObject:@"会员9.5折" atIndex:2];
- } else if (kCardSegmentTypeSuperVip == self.segmentType) {
- [mutArray insertObject:@"会员9.3折" atIndex:2];
- }
-
- if (index >=0 && index < mutArray.count) {
- NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:mutArray[index]];
- if (index == 2) {
- [attrString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xff5656) range:NSMakeRange(2, 3)];
- return attrString;
- }
- return attrString;
- }
-
- return nil;
- }
- #pragma mark - Property
- - (NSArray *)imageNames {
- if (!_imageNames) {
- _imageNames = @[@"vip_icon_free_postage", @"vip_icon_exdusive", @"vip_icon_discount",
- @"vip_icon_postage", @"vip_icon_priority", @"vip_icon_firstheavyfree"];
- }
- return _imageNames;
- }
- - (NSArray *)titles {
- if (!_titles) {
- _titles = @[@"包邮券", @"会员专享商品 ", @"会员运费", @"转运优先", @"首重抹零"];
- }
- return _titles;
- }
- @end
|