ClientdetailsViewController.m 4.53 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
{
73 74 75 76
    self.shoppingCar = [[self getStoryboardWithName] instantiateViewControllerWithIdentifier:@"ClientShoppingCarViewController"];
    self.shoppingCar.model = self.model;
    [self addChildViewController:self.shoppingCar];
    self.currentVC = self.shoppingCar;
曹云霄's avatar
曹云霄 committed
77
    self.shoppingCar.view.frame = CGRectMake(self.controllerBackgroundView.x, self.shoppingAndRecordBackview.bottom, self.controllerBackgroundView.width-25, self.controllerBackgroundView.mj_h-self.shoppingAndRecordBackview.mj_y-self.shoppingAndRecordBackview.mj_h);
78 79 80 81
    [self.controllerBackgroundView addSubview:self.shoppingCar.view];
    self.orderRecord = [[self getStoryboardWithName] instantiateViewControllerWithIdentifier:@"OrderRecordViewController"];
    [self addChildViewController:self.orderRecord];
    self.orderRecord.model = self.model;
曹云霄's avatar
曹云霄 committed
82
    self.orderRecord.view.frame = CGRectMake(self.controllerBackgroundView.x, self.shoppingAndRecordBackview.bottom, self.controllerBackgroundView.width-25, self.controllerBackgroundView.mj_h-self.shoppingAndRecordBackview.mj_y-self.shoppingAndRecordBackview.mj_h);
83
}
曹云霄's avatar
曹云霄 committed
84

85 86
#pragma mark - 切换子视图
- (void)switchChildView:(BaseViewController *)controller
勾芒's avatar
勾芒 committed
87
{
曹云霄's avatar
曹云霄 committed
88
    WS(weakSelf);
89 90 91 92
    [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
93 94 95 96
        }
    }];
}

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


#pragma mark -购物袋
- (IBAction)ShoppingbagButtonClick:(UIButton *)sender {
    
曹云霄's avatar
曹云霄 committed
111 112 113
    sender.backgroundColor = [UIColor whiteColor];
    sender.selected = YES;
    self.orderRecordButton.selected = NO;
114
    self.orderRecordButton.backgroundColor = kMainBlueColor;
115
    [self switchChildView:self.shoppingCar];
曹云霄's avatar
曹云霄 committed
116 117 118 119 120 121
}

#pragma mark -订单记录
- (IBAction)OrderrecordButtonClick:(UIButton *)sender {
    
    sender.backgroundColor = [UIColor whiteColor];
曹云霄's avatar
曹云霄 committed
122 123
    sender.selected = YES;
    self.shoppingBagButton.selected = NO;
124
    self.shoppingBagButton.backgroundColor = kMainBlueColor;
125
    [self switchChildView:self.orderRecord];
曹云霄's avatar
曹云霄 committed
126 127 128 129 130
}



@end