ClientdetailsViewController.m 4.49 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9
//
//  ClientdetailsViewController.m
//  Lighting
//
//  Created by 曹云霄 on 16/5/3.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "ClientdetailsViewController.h"
10 11
#import "ClientShoppingCarViewController.h"
#import "OrderRecordViewController.h"
12

13
@interface ClientdetailsViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
曹云霄's avatar
曹云霄 committed
14 15

/**
16
 *  当前控制器
曹云霄's avatar
曹云霄 committed
17
 */
18
@property (nonatomic,strong) BaseViewController *currentVC;
曹云霄's avatar
曹云霄 committed
19

勾芒's avatar
勾芒 committed
20
/**
21
 *  购物袋
勾芒's avatar
勾芒 committed
22
 */
23
@property (nonatomic,strong) ClientShoppingCarViewController *shoppingCar;
勾芒's avatar
勾芒 committed
24 25

/**
26
 *  订单记录
勾芒's avatar
勾芒 committed
27
 */
28
@property (nonatomic,strong) OrderRecordViewController *orderRecord;
勾芒's avatar
勾芒 committed
29

曹云霄's avatar
曹云霄 committed
30 31 32 33
@end

@implementation ClientdetailsViewController

勾芒's avatar
勾芒 committed
34

曹云霄's avatar
曹云霄 committed
35 36 37 38
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self uiConfigAction];
39
    [self addChildViewController];
曹云霄's avatar
曹云霄 committed
40 41 42 43 44 45 46
}


#pragma mark -UI
- (void)uiConfigAction
{
    //圆角
曹云霄's avatar
曹云霄 committed
47 48 49 50 51 52
    self.shoppingAndRecordBackview.layer.masksToBounds = YES;
    self.shoppingAndRecordBackview.layer.cornerRadius = kCornerRadius;
    self.shoppingBagButton.layer.masksToBounds = YES;
    self.shoppingBagButton.layer.cornerRadius = kCornerRadius;
    self.orderRecordButton.layer.masksToBounds = YES;
    self.orderRecordButton.layer.cornerRadius = kCornerRadius;
勾芒's avatar
勾芒 committed
53 54
    self.setupButton.layer.masksToBounds = YES;
    self.setupButton.layer.cornerRadius = kCornerRadius;
曹云霄's avatar
曹云霄 committed
55 56 57 58 59
    
    //默认选中购物袋
    self.shoppingBagButton.selected = YES;
    self.shoppingBagButton.backgroundColor = [UIColor whiteColor];
    
勾芒's avatar
勾芒 committed
60 61 62 63
    //赋值
    [self.customerHeader sd_setImageWithURL:[NSURL URLWithString:self.model.picture] placeholderImage:ReplaceImage];
    self.customerName.text = self.model.name;
    self.customerPhoneNumber.text = self.model.mobile;
勾芒's avatar
勾芒 committed
64
    self.companyName.text = self.model.company;
勾芒's avatar
勾芒 committed
65
    self.customerLocation.text = self.model.address;
勾芒's avatar
勾芒 committed
66 67
    self.setupButton.selected = self.model.selectedState;
    [self.setupButton setTitle:self.model.selectedState?@"退出当前客户":@"设为当前客户" forState:UIControlStateNormal];
曹云霄's avatar
曹云霄 committed
68 69
}

70 71
#pragma mark - 添加子视图
- (void)addChildViewController
勾芒's avatar
勾芒 committed
72
{
曹云霄's avatar
曹云霄 committed
73
    self.shoppingCar = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"ClientShoppingCarViewController"];
74 75 76 77 78
    self.shoppingCar.model = self.model;
    [self addChildViewController:self.shoppingCar];
    self.currentVC = self.shoppingCar;
    [self.controllerBackgroundView addSubview:self.shoppingCar.view];
    
曹云霄's avatar
曹云霄 committed
79
    self.orderRecord = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"OrderRecordViewController"];
80 81
    [self addChildViewController:self.orderRecord];
    self.orderRecord.model = self.model;
82 83 84 85 86 87 88
}

#pragma mark - 设置frame
- (void)viewDidLayoutSubviews
{
    self.currentVC.view.frame = CGRectMake(0, self.shoppingAndRecordBackview.bottom, self.controllerBackgroundView.width, self.controllerBackgroundView.height-self.shoppingAndRecordBackview.bottom);
    self.orderRecord.view.frame = CGRectMake(0, self.shoppingAndRecordBackview.bottom, self.controllerBackgroundView.width, self.controllerBackgroundView.height-self.shoppingAndRecordBackview.bottom);
89
}
曹云霄's avatar
曹云霄 committed
90

91 92
#pragma mark - 切换子视图
- (void)switchChildView:(BaseViewController *)controller
勾芒's avatar
勾芒 committed
93
{
曹云霄's avatar
曹云霄 committed
94
    WS(weakSelf);
95 96 97 98
    [self transitionFromViewController:self.currentVC toViewController:controller duration:0.5 options:UIViewAnimationOptionTransitionNone animations:nil completion:^(BOOL finished) {
        if (finished) {
            [weakSelf.controllerBackgroundView addSubview:controller.view];
            weakSelf.currentVC = controller;
勾芒's avatar
勾芒 committed
99 100 101 102
        }
    }];
}

曹云霄's avatar
曹云霄 committed
103 104
#pragma mark -设为当前的客户
- (IBAction)SetupcurrentUserButtonClick:(UIButton *)sender {
勾芒's avatar
勾芒 committed
105
   
勾芒's avatar
勾芒 committed
106
    if (self.CurrentUserBlock) {
勾芒's avatar
勾芒 committed
107
        self.CurrentUserBlock(_cellindex,sender.currentTitle);
勾芒's avatar
勾芒 committed
108
    }
勾芒's avatar
勾芒 committed
109 110
     [sender setTitle:sender.selected?@"设为当前客户":@"退出当前客户" forState:UIControlStateNormal];
     sender.selected = !sender.selected;
曹云霄's avatar
曹云霄 committed
111 112 113 114 115 116
}


#pragma mark -购物袋
- (IBAction)ShoppingbagButtonClick:(UIButton *)sender {
    
曹云霄's avatar
曹云霄 committed
117 118 119
    sender.backgroundColor = [UIColor whiteColor];
    sender.selected = YES;
    self.orderRecordButton.selected = NO;
120
    self.orderRecordButton.backgroundColor = kMainBlueColor;
121
    [self switchChildView:self.shoppingCar];
曹云霄's avatar
曹云霄 committed
122 123 124 125 126 127
}

#pragma mark -订单记录
- (IBAction)OrderrecordButtonClick:(UIButton *)sender {
    
    sender.backgroundColor = [UIColor whiteColor];
曹云霄's avatar
曹云霄 committed
128 129
    sender.selected = YES;
    self.shoppingBagButton.selected = NO;
130
    self.shoppingBagButton.backgroundColor = kMainBlueColor;
131
    [self switchChildView:self.orderRecord];
曹云霄's avatar
曹云霄 committed
132 133 134 135 136
}



@end