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

#import "ClientdetailsViewController.h"
#import "ClientDetailsTableViewCell.h"
11 12
#import "OrderTableViewCell.h"
#import "OrderdetailsViewController.h"
勾芒's avatar
勾芒 committed
13 14
#import "ShopcarModel.h"

15

曹云霄's avatar
曹云霄 committed
16 17 18 19 20 21 22
@interface ClientdetailsViewController ()<UITableViewDelegate,UITableViewDataSource>

/**
 *  客户详情
 */
@property (weak, nonatomic) IBOutlet UITableView *ClientdetailsTableview;

勾芒's avatar
勾芒 committed
23 24 25 26 27 28 29 30 31 32
/**
 *  购物车数据源
 */
@property (nonatomic,strong) NSMutableArray *shopResponseArray;

/**
 *  订单记录数据
 */
@property (nonatomic,strong) NSMutableArray *orderRecordArray;

曹云霄's avatar
曹云霄 committed
33 34 35 36 37 38


@end

@implementation ClientdetailsViewController

勾芒's avatar
勾芒 committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

/**
 *  购物袋数据源
 */
- (NSMutableArray *)shopResponseArray
{
    if (_shopResponseArray == nil) {
        
        _shopResponseArray = [NSMutableArray array];
    }
    return _shopResponseArray;
}


/**
 *  订单记录数据源
 */
- (NSMutableArray *)orderRecordArray
{
    if (_orderRecordArray == nil) {
        
        _orderRecordArray = [NSMutableArray array];
    }
    return _orderRecordArray;
}



曹云霄's avatar
曹云霄 committed
67 68 69 70 71 72 73 74 75 76 77
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self uiConfigAction];
}


#pragma mark -UI
- (void)uiConfigAction
{
勾芒's avatar
勾芒 committed
78
    
曹云霄's avatar
曹云霄 committed
79 80 81 82
    self.ClientdetailsTableview.delegate = self;
    self.ClientdetailsTableview.dataSource = self;
    
    //圆角
曹云霄's avatar
曹云霄 committed
83 84 85 86 87 88
    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
89 90
    self.setupButton.layer.masksToBounds = YES;
    self.setupButton.layer.cornerRadius = kCornerRadius;
曹云霄's avatar
曹云霄 committed
91 92 93 94 95
    
    //默认选中购物袋
    self.shoppingBagButton.selected = YES;
    self.shoppingBagButton.backgroundColor = [UIColor whiteColor];
    
勾芒's avatar
勾芒 committed
96 97 98 99 100 101
    //赋值
    [self.customerHeader sd_setImageWithURL:[NSURL URLWithString:self.model.picture] placeholderImage:ReplaceImage];
    self.customerName.text = self.model.name;
    self.customerPhoneNumber.text = self.model.mobile;
    self.companyName.text = self.model.name;
    self.customerLocation.text = self.model.address;
曹云霄's avatar
曹云霄 committed
102 103
}

勾芒's avatar
勾芒 committed
104 105


曹云霄's avatar
曹云霄 committed
106 107
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
108 109 110 111
    if (self.shoppingBagButton.selected) {
        
        ClientDetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ClientDetails" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
勾芒's avatar
勾芒 committed
112
        cell.model = [self.orderRecordArray objectAtIndex_opple:indexPath.row];
113 114 115 116 117 118 119 120 121
        return cell;
        
    }else if (self.orderRecordButton.selected)
    {
        OrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ordercell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return  cell;
    }
    return  nil;
曹云霄's avatar
曹云霄 committed
122 123
}

勾芒's avatar
勾芒 committed
124

曹云霄's avatar
曹云霄 committed
125 126
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
勾芒's avatar
勾芒 committed
127 128 129 130 131 132 133 134 135
    if (self.shoppingBagButton.selected) {
        
        return self.shopResponseArray.count;
    }
    if (self.orderRecordButton.selected) {
        
        return self.orderRecordArray.count;
    }
    return 0;
曹云霄's avatar
曹云霄 committed
136 137
}

勾芒's avatar
勾芒 committed
138

曹云霄's avatar
曹云霄 committed
139 140
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
141 142 143 144 145 146 147 148 149
    if (self.shoppingBagButton.selected) {
        
        return 100;
    }
    else if (self.orderRecordButton.selected)
    {
        return 200;
    }
    return 0;
曹云霄's avatar
曹云霄 committed
150 151
}

勾芒's avatar
勾芒 committed
152 153


154 155 156 157 158
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"StoryboardwithCYX" bundle:nil];
    OrderdetailsViewController *orderdetails = [storyboard instantiateViewControllerWithIdentifier:@"orderdetails"];
    [self.navigationController pushViewController:orderdetails animated:YES];
勾芒's avatar
勾芒 committed
159 160 161 162 163 164 165
}



#pragma mark -获取购物车商品
- (void)getShoppingCardata
{
166
    
勾芒's avatar
勾芒 committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
    ShopCartFilter *shopcarNumber = [[ShopCartFilter alloc]init];
    shopcarNumber.consumerId = [Customermanager manager].customerID;
    DataPage *Newpage = [[DataPage alloc]init];
    Newpage.page = 0;
    shopcarNumber.dp = Newpage;
    [self CreateMBProgressHUDLoding];
    [[NetworkRequestClassManager Manager] NetworkRequestWithURL:[NSString stringWithFormat:@"%@%@",ServerAddress,@"/shopcart/query"] WithRequestType:0 WithParameter:shopcarNumber WithReturnValueBlock:^(id returnValue) {
        
        [self RemoveMBProgressHUDLoding];
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            
            ShopCartResponse *shopcar = [[ShopCartResponse alloc]initWithDictionary:returnValue[@"data"] error:nil];
            //自定义属性
            for (TOShopcartEntity *objc in shopcar.shopcart) {
                
                ShopcarModel *model = [[ShopcarModel alloc]init];
                model.goods = objc.goods;
                model.fid = objc.fid;
                model.createName = objc.createName;
                model.createBy = objc.createBy;
                model.createDate = objc.createDate;
                model.updateName = objc.updateName;
                model.updateBy = objc.updateBy;
                model.updateDate = objc.updateDate;
                model.goodsId = objc.goodsId;
                model.goodsNum = objc.goodsNum;
                model.consumerId = objc.consumerId;
                
                [self.shopResponseArray addObject:model];
            }
            
            [self.ClientdetailsTableview reloadData];
            
        }else
        {
            [self ErrorMBProgressView:returnValue[@"message"]];
        }
        
    } WithErrorCodeBlock:^(id errorCodeValue) {
        
    } WithFailureBlock:^(id error) {
        
        [self RemoveMBProgressHUDLoding];
    }];
211
}
曹云霄's avatar
曹云霄 committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark -设为当前的客户
- (IBAction)SetupcurrentUserButtonClick:(UIButton *)sender {
    
    
}


#pragma mark -购物袋
- (IBAction)ShoppingbagButtonClick:(UIButton *)sender {
    
    
曹云霄's avatar
曹云霄 committed
232 233 234
    sender.backgroundColor = [UIColor whiteColor];
    sender.selected = YES;
    self.orderRecordButton.selected = NO;
235
    self.orderRecordButton.backgroundColor = kMainBlueColor;
勾芒's avatar
勾芒 committed
236
    
237
    [self.ClientdetailsTableview reloadData];
曹云霄's avatar
曹云霄 committed
238 239 240 241 242
}

#pragma mark -订单记录
- (IBAction)OrderrecordButtonClick:(UIButton *)sender {
    
曹云霄's avatar
曹云霄 committed
243
    
曹云霄's avatar
曹云霄 committed
244
    sender.backgroundColor = [UIColor whiteColor];
曹云霄's avatar
曹云霄 committed
245 246
    sender.selected = YES;
    self.shoppingBagButton.selected = NO;
247 248
    self.shoppingBagButton.backgroundColor = kMainBlueColor;
    [self.ClientdetailsTableview reloadData];
曹云霄's avatar
曹云霄 committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end