//
//  NSString+OrderState.m
//  ALand
//
//  Created by Z on 16/5/21.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "NSString+OrderState.h"
#define kStateCodes @[@"toBePaid",@"toBeShipped",@"shipped",@"paid",@"cancelled"]
#define kTitles @[@"待支付",@"待发货",@"配送中",@"已支付",@"已取消"]
#define kImages @[@"orderDetail_waitforpay",@"orderDetail_waitefortransport",@"orderDetail_transported",@"orderDetail_completed",@"orderDetail_canceled"]

@implementation NSString (OrderState)

- (NSString *)getOrderStateString
{

    for (int i = 0; i < kStateCodes.count; i++) {
        if ([kStateCodes[i] isEqualToString:self]) {
            return kTitles[i];
        }
    }
    return nil;
}
- (NSString *)getOrderState {

    for (int i = 0; i < kTitles.count; i++) {
        if ([kTitles[i] isEqualToString:self]) {
            NSString *state = kStateCodes[i];
            return state;
        }
    }
    return nil;
}

- (NSString *)getOrderStateImage
{

    for (int i = 0; i < kStateCodes.count; i++) {
        if ([kStateCodes[i] isEqualToString:self]) {
            return kImages[i];
        }
    }
    
    for (int i = 0; i < kTitles.count; i++) {
        if ([kTitles[i] isEqualToString:self]) {
            return kImages[i];
        }
    }

    return [NSString string];
}


@end
