//
//  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 isEqualToString: @"配送中"] || [self.orderType isEqualToString:@""]) {
    }else{
        [self.viewExpress removeFromSuperview];

    }
    
}
- (void)updateHeight {
    
    self.height = self.bottomView.bottom;
}

- (void)viewWithModel:(JavenOrderModel *)model {
    self.labelState.text = [model.state getOrderStateString];
    self.imgIcon.image = [UIImage imageNamed:[model.state getOrderStateImage]];
    self.labelName.text = model.address.name;
    JavenAddress *address = model.address;
    self.labelAddress.text = [NSString stringWithFormat:@"%@%@%@%@%@", SAFE_STRING(address.nation), SAFE_STRING(address.province), SAFE_STRING(address.city), SAFE_STRING(address.country), SAFE_STRING(address.address)];
    if ([model.shipType isEqualToString:@"selfpick"]) {
        self.labelAddress.text = @"自提";
         self.labelName.text = @"自提";
    }
    self.labelPhoneNumber.text = [model.shipType isEqualToString:@"selfpick"] ? model.consumer.code : model.address.telephone;
    self.labelExpressTime.text = model.lastModifyInfo.time;
    WS(weakSelf)
    [[HTTPCilent shareCilent] GET:[NSString stringWithFormat:@"order/getLogistics/%@", model.uuid] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if (kIsResponseSuccess(responseObject)) {
            weakSelf.labelExpress.text = responseObject[@"logistics"];
        }
        
    } 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
