// // CardBeenUseViewController.m // Lighting // // Created by 曹云霄 on 2016/10/19. // Copyright © 2016年 上海勾芒科技有限公司. All rights reserved. // #import "CardBeenUseViewController.h" #import "CardCollectionViewCell.h" #import "CardOrderInformationReusableView.h" #import "CardAmplificationViewController.h" @interface CardBeenUseViewController () @property (nonatomic,strong) RsJingDongECardRequest *requestModel; @property (nonatomic,strong) WYPopoverController *settingsPopoverController; /** * 数据源 */ @property (nonatomic,strong) NSMutableArray *datasArray; @end @implementation CardBeenUseViewController #pragma mark - lazy - (RsJingDongECardRequest *)requestModel { if (!_requestModel) { _requestModel = [[RsJingDongECardRequest alloc]init]; DataPage *page = [[DataPage alloc]init]; page.page = ZERO; page.rows = KROWS; page.order = @"desc"; _requestModel.guideIdEquals = [Shoppersmanager manager].shoppers.employee.fid; _requestModel.stateEquals = self.cardState; _requestModel.page = page; } return _requestModel; } - (NSMutableArray *)datasArray { if (!_datasArray) { _datasArray = [NSMutableArray array]; } return _datasArray; } - (void)viewDidLoad { [super viewDidLoad]; [self setupCollectionView]; } #pragma mark -获取数据 - (void)loadWebDataSource { WS(weakSelf); if (self.pullPageIndex == ONE) { [self.datasArray removeAllObjects]; } self.requestModel.page.page = self.pullPageIndex; [self getCardDatasActionCompleted:^(RsJingDongECardResponse *result) { if (weakSelf.pullPageIndex >= result.totalpages) { [weakSelf endRefresh:EndRefreshNotData]; }else { [weakSelf endRefresh:EndRefreshDefault]; } }]; } #pragma mark - 获取卡劵 - (void)getCardDatasActionCompleted:(void(^)(RsJingDongECardResponse *result))completed { WS(weakSelf); [HTTP networkRequestWithURL:SERVERREQUESTURL(CARDINFORMATION) withRequestType:ZERO withParameter:self.requestModel withReturnValueBlock:^(id returnValue) { if (RESULT(returnValue)) { RsJingDongECardResponse *cardInformation = [[RsJingDongECardResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil]; completed(cardInformation); [weakSelf.datasArray addObjectsFromArray:cardInformation.list]; [weakSelf.collectionView reloadData]; }else{ [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)]; } }withFailureBlock:^(NSError *error) { [weakSelf endRefresh:EndRefreshDefault]; [XBLoadingView showHUDViewWithText:error.localizedDescription]; }]; } #pragma mark - 使用京东卡劵 - (void)useJDECard:(NSString *)JDECardNumber { WS(weakSelf); [XBLoadingView showHUDViewWithDefault]; [HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(USEJDECARD),JDECardNumber] withRequestType:ZERO withParameter:nil withReturnValueBlock:^(id returnValue) { [XBLoadingView hideHUDViewWithDefault]; if (RESULT(returnValue)) { [weakSelf deleteUsedJDECard:JDECardNumber]; }else{ [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)]; } }withFailureBlock:^(NSError *error) { [XBLoadingView showHUDViewWithText:error.localizedDescription]; }]; } #pragma mark - 区分已经使用的E卡 - (void)deleteUsedJDECard:(NSString *)eCardNumber { //@property (nonatomic, strong) NSMutableArray *eCards; // 手动改为可变数组 for (int i=0; i