//
//  OrderDetailTopView.m
//  ALand
//
//  Created by Z on 16/3/30.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "OrderDetailTopView.h"

@interface OrderDetailTopView ()
@property (weak, nonatomic) IBOutlet UIView *viewExpress;
@property (weak, nonatomic) IBOutlet UIImageView *imgIcon;
@property (weak, nonatomic) IBOutlet UILabel *labelState;

@end
@implementation OrderDetailTopView
- (void)awakeFromNib {
    
       
}

- (void)updateByOrderType {
    
    if (self.orderType == ORDERTOPTYPE_TRANSPORTED || self.orderType == ORDERTOPTYPE_COMMPLETE) {
    }else{
        [self.viewExpress removeFromSuperview];

    }
    
    switch (self.orderType) {
        case ORDERTOPTYPE_NOPAYMENT:
        {
            self.imgIcon.image = [UIImage imageNamed:@"orderDetail_waitforpay"];
            self.labelState.text = @"等待付款";
        }
            break;
        case ORDERTOPTYPE_WAITFORDISPATCH:
        {
            self.imgIcon.image = [UIImage imageNamed:@"orderDetail_waitefortransport"];
            self.labelState.text = @"等待发货";
        }
            break;
        case ORDERTOPTYPE_TRANSPORTED:
        {
            self.imgIcon.image = [UIImage imageNamed:@"orderDetail_transported"];
            self.labelState.text = @"已发货";
        }
            break;
        case ORDERTOPTYPE_COMMPLETE:
        {
            self.imgIcon.image = [UIImage imageNamed:@"orderDetail_completed"];
            self.labelState.text = @"已完成";
        }
            break;
        case ORDERTOPTYPE_CANCELED:
        {
            self.imgIcon.image = [UIImage imageNamed:@"orderDetail_canceled"];
            self.labelState.text = @"已取消";
        }
            break;
        default:
            break;
    }
}
- (void)updateHeight {
    
    self.height = self.bottomView.bottom;
}

- (void)viewWithModel:(JavenOrderModel *)model {
    self.labelName.text = model.address.name;
    JavenAddress *address = model.address;
    self.labelAddress.text = [NSString stringWithFormat:@"%@%@%@%@%@", address.nation ? address.nation : @"", address.province, address.city, address.country, address.address];
    self.labelPhoneNumber.text = model.consumer.code;
    [[HTTPCilent shareCilent] GET:[NSString stringWithFormat:@"order/getLogistics/%@", model.uuid] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

- (void)getLogistics {
}


- (IBAction)actionCall:(id)sender {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", self.labelPhoneNumber.text]]];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
