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

#import "ProductLibraryViewController.h"
#import "ProductCollectionViewCell.h"
#import "ProductDetailsViewController.h"
#import "ScreeningView.h"
#import "screeningFirstView.h"
#import "screeningSecondView.h"
#import "ExperienceCentreViewController.h"


18
@interface ProductLibraryViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UIGestureRecognizerDelegate,ScreeningButtonClickdelegate,TableviewSelectedIndexdelegate,SelectedCollectionItemDelegate,CAAnimationDelegate>
曹云霄's avatar
曹云霄 committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129

/**
 *  筛选背景框View
 */
@property (nonatomic,strong) ScreeningView *screenView;

/**
 *  分类View
 */
@property (nonatomic,strong) screeningFirstView *screenFirstView;

/**
 *  筛选View
 */
@property (nonatomic,strong) screeningSecondView *screenSecondView;

/**
 *  筛选数据源
 */
@property (nonatomic,strong) NSMutableArray *screeningDatas;

/**
 *  当前筛选按钮选中状态
 */
@property (nonatomic,assign) NSInteger selectedIndex;

/**
 *  商品数据源对象
 */
@property (nonatomic,strong) NSMutableArray *datasArray;

/**
 *  复选返回时临时保存数据
 */
@property (nonatomic,strong) GoodsResponse *temporaryArray;

/**
 *  搜索结果个数
 */
@property (nonatomic,assign) int resultCount;


@end

@implementation ProductLibraryViewController

/**
 *  初始化筛选数据源
 */
- (NSMutableArray *)screeningDatas
{
    if (_screeningDatas == nil) {
        
        _screeningDatas = [NSMutableArray array];
    }
    return _screeningDatas;
}


/**
 *  初始化商品数据源数组
 */
- (NSMutableArray *)datasArray
{
    if (_datasArray == nil) {
        
        _datasArray = [NSMutableArray array];
    }
    return _datasArray;
}


/**
 *  初始化复选模型
 */
- (GoodsCondition *)condtionModel
{
    if (!_condtionModel) {
        _condtionModel = [[GoodsCondition alloc]init];
        DataPage *page = [[DataPage alloc]init];
        page.page = ONE;
        page.rows = KROWS;
        _condtionModel.page = page;
    }
    return _condtionModel;
}

#pragma mark -渲染完成
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.navigationController.fd_fullscreenPopGestureRecognizer.enabled = NO;
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}

#pragma mark -视图即将消失
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.fd_fullscreenPopGestureRecognizer.enabled = YES;
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self uiConfigAction];
130
    [self getFiltrateData];
曹云霄's avatar
曹云霄 committed
131 132
}

133 134 135 136 137 138 139 140 141 142 143 144 145
#pragma mark -布局
- (void)uiConfigAction
{
    self.selectedIndex = 9999;//无任何意义
    self.productCollectionLayout.itemSize = CGSizeMake((ScreenWidth-100)/3, (ScreenWidth-100)/3);
    self.productCollectionLayout.sectionInset = UIEdgeInsetsMake(20, 30, 20, 30);
    self.productCollectionLayout.minimumLineSpacing = 20;
    self.productCollectionLayout.minimumInteritemSpacing = 20;
    [self createScreeningButton];
}

#pragma mark -上、下拉加载数据 (获取商品)
- (void)loadWebDataSource
曹云霄's avatar
曹云霄 committed
146 147
{
    WS(weakSelf);
148 149 150 151 152 153 154
    //扫描二维码结果
    if (![[self class] isBlankString:self.barcode]) {
        [self barCodeSearchRequest];
    }else
    {
        if (![[self class] isBlankString:self.selectedCode]) {
            switch (weakSelf.selectedIndex) {
曹云霄's avatar
曹云霄 committed
155
                case 0://类型
156
                {
曹云霄's avatar
曹云霄 committed
157
                    weakSelf.condtionModel.categoryEquals = weakSelf.selectedCode;
158 159
                }
                    break;
曹云霄's avatar
曹云霄 committed
160
                case 1://风格
161
                {
曹云霄's avatar
曹云霄 committed
162
                    weakSelf.condtionModel.styleEquals = weakSelf.selectedCode;
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
                }
                    break;
                case 2://空间
                {
                    weakSelf.condtionModel.spaceEquals = weakSelf.selectedCode;
                }
                    break;
                case 3://材质
                {
                    weakSelf.condtionModel.materialEqueals = weakSelf.selectedCode;
                }
                    break;
                case 4://价格
                {
                    //价格字符串切割
                    NSArray *spacrArray = [weakSelf.selectedCode componentsSeparatedByString:@"到"];
                    weakSelf.condtionModel.startprice = (NSDecimalNumber *)[NSDecimalNumber numberWithInteger:[[spacrArray objectAtIndex_opple:0] integerValue]];
                    weakSelf.condtionModel.endprice = (NSDecimalNumber *)[NSDecimalNumber numberWithInteger:[[spacrArray objectAtIndex_opple:1] integerValue]];
                }
                    break;
                default:
                    weakSelf.condtionModel.nameLike = weakSelf.selectedCode;
                    break;
            }
曹云霄's avatar
曹云霄 committed
187
        }
188 189
        if (self.pullPageIndex == ONE) {
            [self.datasArray removeAllObjects];
曹云霄's avatar
曹云霄 committed
190
        }
191 192 193 194 195 196 197 198 199
        self.condtionModel.page.page = self.pullPageIndex;
        [self getGoodsListdatas:self.condtionModel completed:^(GoodsResponse *result) {
            if (weakSelf.pullPageIndex >= result.totalpages) {
                [weakSelf endRefresh:EndRefreshNotData];
            }else {
                [weakSelf endRefresh:EndRefreshDefault];
            }
        }];
    }
曹云霄's avatar
曹云霄 committed
200 201
}

202

曹云霄's avatar
曹云霄 committed
203
#pragma mark -获取产品筛选数据
204
- (void)getFiltrateData
曹云霄's avatar
曹云霄 committed
205
{
206
  WS(weakSelf);
曹云霄's avatar
曹云霄 committed
207 208
  [HTTP networkWithDictionaryRequestWithURL:SERVERREQUESTURL(PRODUCTSCREENING)  withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
      if (RESULT(returnValue)) {
209
          [weakSelf.screeningDatas removeAllObjects];
曹云霄's avatar
曹云霄 committed
210 211
          GoodsFilter *goodsStyle = [[GoodsFilter alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
          [weakSelf.screeningDatas addObject:goodsStyle.categories];
212
          [weakSelf.screeningDatas addObject:goodsStyle.styles];
曹云霄's avatar
曹云霄 committed
213 214 215
          [weakSelf.screeningDatas addObject:goodsStyle.space];
          [weakSelf.screeningDatas addObject:goodsStyle.material];
          [weakSelf.screeningDatas addObject:goodsStyle.price];
216
    }else {
曹云霄's avatar
曹云霄 committed
217 218 219 220 221 222 223 224 225 226
          [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
      }
      
  }withFailureBlock:^(NSError *error) {
      [XBLoadingView showHUDViewWithText:error.localizedDescription];
  }];
}


#pragma mark -获取商品列表数据
227
- (void)getGoodsListdatas:(GoodsCondition *)conditon completed:(void(^)(GoodsResponse *result))completed
曹云霄's avatar
曹云霄 committed
228 229 230 231
{
    WS(weakSelf);
    [HTTP networkRequestWithURL:SERVERREQUESTURL(PRODUCTLIST)  withRequestType:ZERO withParameter:conditon withReturnValueBlock:^(id returnValue) {
        if (RESULT(returnValue)) {
232 233 234 235 236 237
            GoodsResponse *result = [[GoodsResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
            completed(result);
            for (TOGoodsEntity *model in result.goodsEntity) {
                [weakSelf.datasArray addObject:model];
            }
            [weakSelf.collectionView reloadData];
曹云霄's avatar
曹云霄 committed
238
        }else {
曹云霄's avatar
曹云霄 committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
           [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
        }
    }withFailureBlock:^(NSError *error) {
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}

#pragma mark 填条形码搜索
- (void)barCodeSearchRequest
{
    WS(weakSelf);
    [XBLoadingView showHUDViewWithDefault];
    NSString *urlString = [NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(BARCODESEARCH),self.barcode];
    [HTTP networkWithDictionaryRequestWithURL:[self returnUrlString:urlString]  withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
        [XBLoadingView hideHUDViewWithDefault];
        if (RESULT(returnValue)) {
            if ([RESPONSE(returnValue) isKindOfClass:[NSNull class]]) {
                [XBLoadingView showHUDViewWithText:@"暂无商品信息"];
                return;
            }
            TOGoodsEntity *goods = [[TOGoodsEntity alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
            [weakSelf.datasArray removeAllObjects];
            [weakSelf.datasArray addObject:goods];
262
            [weakSelf.collectionView reloadData];
曹云霄's avatar
曹云霄 committed
263
        }else {
曹云霄's avatar
曹云霄 committed
264 265
            [XBLoadingView showHUDViewWithText:@"查询失败"];
        }
266
    }withFailureBlock:^(NSError *error) {
曹云霄's avatar
曹云霄 committed
267
        [XBLoadingView hideHUDViewWithDefault];
268 269
        [weakSelf endRefresh:EndRefreshDefault];
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
曹云霄's avatar
曹云霄 committed
270 271 272 273 274
    }];
}


#pragma mark -筛选按钮
275
- (void)createScreeningButton
曹云霄's avatar
曹云霄 committed
276
{
277 278
    UIButton *screeningButton = [UIButton buttonWithType:UIButtonTypeSystem];
    screeningButton.frame = CGRectMake(ScreenWidth-100, ScreenHeight*6/10, 50, 50);
曹云霄's avatar
曹云霄 committed
279 280 281 282 283 284 285 286 287 288
    //阴影层
    CALayer *layer = [CALayer layer];
    layer.frame = CGRectMake(ScreenWidth-97.5, ScreenHeight*6/10+2.5, 45, 45);//保证layer的size比筛选按钮高宽都短5像素
    layer.backgroundColor = [UIColor blackColor].CGColor;
    layer.shadowOffset = CGSizeMake(0, 8);
    layer.shadowOpacity = 0.7;
    layer.cornerRadius = 25;
    [self.view.layer addSublayer:layer];
    
    //筛选按钮
289 290 291 292 293 294 295 296 297
    screeningButton.layer.masksToBounds = YES;
    screeningButton.layer.cornerRadius = 25;
    [screeningButton setTitle:@"筛选" forState:UIControlStateNormal];
    screeningButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [screeningButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [screeningButton setTitleColor:kMainBlueColor forState:UIControlStateSelected];
    [screeningButton addTarget:self action:@selector(screeningButtonClick) forControlEvents:UIControlEventTouchUpInside];
    screeningButton.backgroundColor = kMainBlueColor;
    [self.view addSubview:screeningButton];
曹云霄's avatar
曹云霄 committed
298 299 300 301 302 303
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ProductCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"productcell" forIndexPath:indexPath];
曹云霄's avatar
曹云霄 committed
304
    TOGoodsEntity *model = [self.datasArray objectAtIndex_opple:indexPath.item];
曹云霄's avatar
曹云霄 committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
    cell.model = model;
    cell.cellindex = indexPath.row;
    //加入购物车
    WS(weakSelf);
    __weak typeof(ProductCollectionViewCell *) weakCell = cell;
    [cell setReturnCellCgpoint:^void(CGPoint centerPoint,NSInteger cellindex ,CGSize size) {
        //判断是否有当前客户
        if (![Shoppersmanager manager].currentCustomer) {
            [XBLoadingView showHUDViewWithText:@"必须设置当前客户"];
            return;
        }
        //库存为0时不能加入购物车
        if (model.number == 0) {
            [XBLoadingView showHUDViewWithText:@"此商品库存不足"];
            return;
        }
曹云霄's avatar
曹云霄 committed
321
        TOGoodsEntity *model = [weakSelf.datasArray objectAtIndex_opple:cellindex];
曹云霄's avatar
曹云霄 committed
322 323 324
        [XBLoadingView showHUDViewWithDefault];
        [weakSelf addGoodsShoppingbags:model complate:^{
            [XBLoadingView hideHUDViewWithDefault];
325 326 327 328
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            imageView.image = weakCell.productImageView.image;
            imageView.center = centerPoint;
            [weakSelf.view.window.layer addSublayer:imageView.layer];
曹云霄's avatar
曹云霄 committed
329 330 331
            [imageView startAnimationWithEndPoint:SHARED_APPDELEGATE.shoppingCarPoint withControlPoint:CGPointMake(200, 200) animateWithDuration:ONE completed:^{
                [weakSelf queryShoppingCarNumber];
            }];
曹云霄's avatar
曹云霄 committed
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
        }];
    }];
    return cell;
}

#pragma mark -动画完成后移除
- (void)removeFromLayer:(CALayer *)layerAnimation{
    
    [layerAnimation removeFromSuperlayer];
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.datasArray.count;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
351
    ProductDetailsViewController *productDetails = [ProductDetailsViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_MAIN];
曹云霄's avatar
曹云霄 committed
352
    productDetails.goodsID = [[self.datasArray objectAtIndex_opple:indexPath.item] fid];
353
    [self pushViewController:productDetails animated:YES];
曹云霄's avatar
曹云霄 committed
354 355 356 357
}


#pragma mark -筛选
358
- (void)screeningButtonClick
曹云霄's avatar
曹云霄 committed
359 360 361 362 363 364
{
    self.screenView = [[[NSBundle mainBundle] loadNibNamed:@"ScreeningView" owner:self options:nil]firstObject];
    self.screenView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    self.screenView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.screenView.delegate = self;
    //点击手势
365
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissScreenView)];
曹云霄's avatar
曹云霄 committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
    tap.delegate = self;
    tap.cancelsTouchesInView = NO;
    [self.screenView addGestureRecognizer:tap];
    self.screenView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [self.view.window addSubview:self.screenView];
    self.screenView.alpha = 0;
    //监听Segmented菜单
    [self.screenView.sortingSegmented addTarget:self action:@selector(sortingSegmentedClick:) forControlEvents:UIControlEventValueChanged];
    self.selectedIndex = 0;
    [self CreateClassificationView];
    [UIView animateWithDuration:0.2 animations:^{
        self.screenView.alpha = 1;
    }];
}


#pragma mark -分类、筛选view切换
- (void)sortingSegmentedClick:(UISegmentedControl *)sender {
    
    switch (sender.selectedSegmentIndex) {
        case 0://分类
        {
            [self.screenSecondView removeFromSuperview];
            [self CreateClassificationView];
        }
            break;
        case 1://筛选
        {
            [self.screenFirstView removeFromSuperview];
            [self CreateScreenSubView];
        }
            break;
            
        default:
            break;
    }
}

#pragma mark -创建分类View
- (void)CreateClassificationView
{
    //分类View
    self.screenFirstView = [[[NSBundle mainBundle] loadNibNamed:@"screeningFirstView" owner:self options:nil] firstObject];
    self.screenFirstView.frame = CGRectMake(0, 50, 470, 310);
    self.screenFirstView.delegate = self;
411
    [self screeningButtonClick:self.selectedIndex];
曹云霄's avatar
曹云霄 committed
412 413 414 415 416 417 418 419 420 421
    [self.screenView.backgroundView addSubview:self.screenFirstView];
}


#pragma mark -创建筛选选项View
- (void)CreateScreenSubView
{
    self.screenSecondView = [[[NSBundle mainBundle] loadNibNamed:@"screeningSecondView" owner:self options:nil] firstObject];
    self.screenSecondView.frame = CGRectMake(0, 50, 470, 310);
    self.screenSecondView.delegate = self;
422
    [self screeningButtonClick:self.selectedIndex];
曹云霄's avatar
曹云霄 committed
423 424 425 426 427
    self.screenSecondView.totalNumber = self.datasArray.count;
    [self.screenView.backgroundView addSubview:self.screenSecondView];
}


428 429
#pragma mark -screeningButtonClickdelegate代理
- (void)screeningButtonClick:(NSInteger)buttontag
曹云霄's avatar
曹云霄 committed
430 431 432 433 434
{
    self.selectedIndex = buttontag;
    //分类
    if (self.screenView.sortingSegmented.selectedSegmentIndex == 0) {
        self.screenFirstView.selectedIndex = buttontag;
曹云霄's avatar
曹云霄 committed
435
        self.screenFirstView.datasArray = [self.screeningDatas objectAtIndex_opple:buttontag];
曹云霄's avatar
曹云霄 committed
436 437 438 439 440
    }
    //筛选
    else if (self.screenView.sortingSegmented.selectedSegmentIndex == 1)
    {
        self.screenSecondView.selectedIndex = buttontag;
曹云霄's avatar
曹云霄 committed
441
        self.screenSecondView.datasArray = [self.screeningDatas objectAtIndex_opple:buttontag];
曹云霄's avatar
曹云霄 committed
442 443 444 445 446 447 448 449
    }
}

#pragma mark -选中条件
- (void)selectedItem:(NSString *)typecode withTitle:(NSString *)title
{
    [self emptyModel];

450
    [self dismissScreenView];
曹云霄's avatar
曹云霄 committed
451 452 453 454 455 456
    if (self.selectedIndex == 4) {
        self.selectedCode = title;
    }else
    {
      self.selectedCode = typecode;
    }
457
    [self.collectionView.mj_header beginRefreshing];
曹云霄's avatar
曹云霄 committed
458 459 460 461 462 463 464
}


#pragma mark -筛选子模块的
- (void)tableSelectedindex:(NSInteger)index
{
    
465
    [self screeningButtonClick:index];
曹云霄's avatar
曹云霄 committed
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
    self.screenView.indexselected = index;
    
}


#pragma mark -筛选复选模块选中的uicollection cell
- (void)collectionSelectedindexWithStyleCode:(NSString *)styleCode
                              withCategories:(NSString *)categoriesCode
                                   withSpace:(NSString *)spaceCode
                                withMaterial:(NSString *)materialCode
                                   withPrice:(NSString *)priceTitle
{
    
    GoodsCondition *condition = [[GoodsCondition alloc]init];
    DataPage *page = [[DataPage alloc]init];
    page.rows = 10;
    page.page = 1;
    condition.page = page;
    if (![[self class] isBlankString:styleCode]) {
       condition.styleEquals = styleCode;
    }
    if (![[self class] isBlankString:categoriesCode]) {
       condition.categoryEquals = categoriesCode;
    }
    if (![[self class] isBlankString:spaceCode]) {
        condition.spaceEquals = spaceCode;
    }
    if (![[self class] isBlankString:materialCode]) {
        condition.materialEqueals = materialCode;
    }
    if (![priceTitle isEqualToString:@"全部"]) {
        //价格字符串切割
        NSArray *spacrArray = [priceTitle componentsSeparatedByString:@"到"];
曹云霄's avatar
曹云霄 committed
499 500
        condition.startprice = (NSDecimalNumber *)[NSDecimalNumber numberWithInteger:[[spacrArray objectAtIndex_opple:0] integerValue]];
        condition.endprice = (NSDecimalNumber *)[NSDecimalNumber numberWithInteger:[[spacrArray objectAtIndex_opple:1] integerValue]];
曹云霄's avatar
曹云霄 committed
501 502 503 504 505 506 507 508 509
    }
    self.condtionModel.styleEquals = condition.styleEquals;
    self.condtionModel.categoryEquals = condition.categoryEquals;
    self.condtionModel.spaceEquals = condition.spaceEquals;
    self.condtionModel.materialEqueals = condition.materialEqueals;
    self.condtionModel.startprice = condition.startprice;
    self.condtionModel.endprice = condition.endprice;
    self.selectedCode = nil;//清空单选
    WS(weakSelf);
510 511
    [self getGoodsListdatas:condition completed:^(GoodsResponse *result) {
        weakSelf.screenSecondView.totalNumber = result.total;
曹云霄's avatar
曹云霄 committed
512
        //临时保存
513
        weakSelf.temporaryArray = result;
曹云霄's avatar
曹云霄 committed
514 515 516 517 518
    }];
}


#pragma mark -显示筛选后的结果
519
- (void)showScreeningResponse
曹云霄's avatar
曹云霄 committed
520 521 522
{
    if (self.temporaryArray.goodsEntity.count == 0) {
        [XBLoadingView showHUDViewWithText:@"暂无数据"];
曹云霄's avatar
曹云霄 committed
523
    }else {
曹云霄's avatar
曹云霄 committed
524
        self.datasArray = [NSMutableArray arrayWithArray:self.temporaryArray.goodsEntity];
525 526
        [self.collectionView reloadData];
        [self dismissScreenView];
曹云霄's avatar
曹云霄 committed
527 528 529 530 531
    }
}


#pragma mark -移除筛选框
532
- (void)dismissScreenView
曹云霄's avatar
曹云霄 committed
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
{
    [UIView animateWithDuration:0.2 animations:^{
        self.screenView.alpha = 0;
    }completion:^(BOOL finished) {
        [self.screenView removeFromSuperview];
    }];
}


#pragma mark -UIGestureRecognizerDelegate代理方法
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    //取消子视图的的时间穿透,否则子视图的点击无效,会被传递到父视图响应
    if (CGRectContainsPoint(self.screenView.backgroundView.frame, [touch locationInView:self.screenView])) {
        return NO;
    }
    return YES;
}


#pragma mark -添加至购物车
- (void)addGoodsShoppingbags:(TOGoodsEntity *)model complate:(void(^)())response
{
    SaveShoppingCartRequest *shopCar = [[SaveShoppingCartRequest alloc]init];
557
    shopCar.consumerId = [Customermanager manager].model.consumer.fid;
曹云霄's avatar
曹云霄 committed
558 559
    shopCar.goodsId = model.fid;
    shopCar.count = @"1";
560
    shopCar.attachmentUrl = @"";
曹云霄's avatar
曹云霄 committed
561 562 563
    [HTTP networkRequestWithURL:SERVERREQUESTURL(ADDSHOPPINGBAG)  withRequestType:ZERO withParameter:shopCar withReturnValueBlock:^(id returnValue) {
        if (RESULT(returnValue)) {
            response();
曹云霄's avatar
曹云霄 committed
564
        }else {
曹云霄's avatar
曹云霄 committed
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
        }
    }withFailureBlock:^(id error) {
        [XBLoadingView hideHUDViewWithDefault];
        [XBLoadingView showHUDViewWithText:@"加入购物车失败"];
    }];
}

#pragma mark -清空模型
- (void)emptyModel
{
    self.condtionModel.nameLike = nil;
    self.condtionModel.styleEquals = nil;
    self.condtionModel.spaceEquals = nil;
    self.condtionModel.categoryEquals = nil;
    self.condtionModel.startprice = nil;
    self.condtionModel.endprice = nil;
    self.condtionModel.materialEqueals = nil;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    [[SDImageCache sharedImageCache] clearDisk];
    NSLog(@"结算到内存警告");
    // Dispose of any resources that can be recreated.
}

@end