| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 |
- //
- // SalesOrderOptionCombinationPromotionDetailHomeVC.m
- // IBOSS
- //
- // Created by 关宏厚 on 2020/9/14.
- // Copyright © 2020 elongtian. All rights reserved.
- //
- #import "SalesOrderOptionCombinationPromotionDetailHomeVC.h"
- @interface SalesOrderOptionCombinationPromotionDetailHomeVC ()<UIScrollViewDelegate>
- {
- SalesOrderOptionCombinationPromotionDetailVC *promotionDetailVC;
- SalesOrderOptionCombinationDetailVC *combinationDetailVC;
- // 滑动线
- UILabel *_sliderLabel;
- // 滚动条
- UIScrollView *_mainScrollView;
- // 基本信息按钮
- UIButton *_promotionDetailBtn;
- // 业绩信息按钮
- UIButton *_combinationDetailBtn;
-
- // 保存
- UIButton *_btnSave;
- }
- @end
- // 5个导航菜单
- static int navcount = 2;
- @implementation SalesOrderOptionCombinationPromotionDetailHomeVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- _orderGoodsDetailList=[[NSMutableArray alloc]init];
- _combinationGoodsDetailList=[[NSMutableArray alloc]init];
- [self initUI];
- [self setMainSrollView];
- //设置默认
- [self sliderWithTag:self.currentIndex+1];
-
- }
- /**
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- self.view.backgroundColor = [UIColor whiteColor];
- _mainScrollView.frame = CGRectMake(0, 40, Screen_Width,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50);
- for (NSInteger i = 0; i < _mainScrollView.subviews.count; i++) {
- _mainScrollView.subviews[i].frame = CGRectMake(Screen_Width * i, 0, Screen_Width,CGRectGetHeight(_mainScrollView.frame));
- }
- [self.promotionDetailVC viewSafeAreaInsetsDidChange];
- [self.combinationDetailVC viewSafeAreaInsetsDidChange];
-
- UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
- CGFloat h =40;
- _btnSave.frame=CGRectMake(0, self.view.safeAreaLayoutGuide.layoutFrame.size.height- h - 5 , Screen_Width,h) ;
- [super viewSafeAreaInsetsDidChange];
- }
- -(void)initUI
- {
- UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 40)];
- [self.view setBackgroundColor:[UIColor whiteColor]];
- _promotionDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_promotionDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_promotionDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _promotionDetailBtn.frame = CGRectMake(2, 0, Screen_Width/navcount, navView.frame.size.height);
- _promotionDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_promotionDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_promotionDetailBtn setTitle:@"促销明细" forState:UIControlStateNormal];
- _promotionDetailBtn.tag = 1;
- _promotionDetailBtn.selected = YES;
- [navView addSubview:_promotionDetailBtn];
-
- // 组合明细
- _combinationDetailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _combinationDetailBtn.frame = CGRectMake(_promotionDetailBtn.frame.origin.x+_promotionDetailBtn.frame.size.width, _promotionDetailBtn.frame.origin.y, Screen_Width/navcount, navView.frame.size.height);
- [_combinationDetailBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
- [_combinationDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
-
- _combinationDetailBtn.titleLabel.font = [UIFont systemFontOfSize:TitleFontOfSize];
- [_combinationDetailBtn addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventTouchUpInside];
- [_combinationDetailBtn setTitle:@"组合明细" forState:UIControlStateNormal];
- _combinationDetailBtn.tag = 2;
- [navView addSubview:_combinationDetailBtn];
-
- // 选中后的红线
- _sliderLabel = [[UILabel alloc]initWithFrame:CGRectMake(_promotionDetailBtn.frame.origin.x, 40-2, Screen_Width/navcount, 2)];
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(((Screen_Width/navcount)-75)/2, 0, 75, 2)];
- line.backgroundColor = [UIColor redColor];
- [_sliderLabel addSubview:line];
- [navView addSubview:_sliderLabel];
- [self.view addSubview:navView];
-
- self.navigationItem.title =@"自选组合促销明细";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0,45,22);
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
- [self loadGoodsDetail];
- }
- -(void)loadGoodsDetail
- {
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetPromotionDetailData" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_code forKeyedSubscript:@"Code"];
- [dict setObject:_brandId forKeyedSubscript:@"BrandID"];
- [dict setObject:_kindCode forKeyedSubscript:@"KindCode"];
- [dict setObject:_warehouseId forKeyedSubscript:@"WarehouseID"];
-
- [dict setObject:_varietyId forKeyedSubscript:@"VarietyID"];
-
- [dict setObject:_seriesId forKeyedSubscript:@"SeriesID"];
-
- [dict setObject:_specification forKeyedSubscript:@"Specification"];
-
- [dict setObject:_onlyCode forKeyedSubscript:@"OnlyCode"];
-
- [dict setObject:_colorNumber forKeyedSubscript:@"ColorNumber"];
-
- [dict setObject:_gradeIds forKeyedSubscript:@"GradeIDs"];
-
- [dict setObject:_promotionTypeId forKeyedSubscript:@"PromotionsType"];
- [dict setObject:_promotionDetailName forKeyedSubscript:@"PromotionDetailName"];
-
- [dict setObject:_promotionName forKeyedSubscript:@"PromotionName"];
-
- [dict setObject:_organizationCode forKeyedSubscript:@"OrganizationCode"];
-
- [dict setObject:_promotionOrderModel.detailId forKeyedSubscript:@"DetailID"];
-
- _downManager = [[ASIDownManager alloc] init];
- [self startLoading];
- _downManager.delegate = self;
- _downManager.onRequestSuccess = @selector(onPromotionOrderDetailLoadFinish:);
- _downManager.onRequestFail = @selector(onPromotionOrderDetailLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- -(void)onPromotionOrderDetailLoadFinish:(ASIDownManager *)sender {
- NSDictionary *dic = [sender.mWebStr JSONValue];
-
- [self stopLoading];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- int iNewCount = 0;
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0)
- {
- NSDictionary *resultDic=[dic objectForKey:@"Result"];
- NSArray *promotionArray= [resultDic objectForKey:@"Table"];
- NSArray *combinationArray= [resultDic objectForKey:@"Table1"];
-
- if(promotionArray!=nil&&promotionArray.count>0)
- {
- for(int i=0;i<promotionArray.count;i++)
- {
- NSDictionary *dic=[promotionArray objectAtIndex:i];
- InventoryListModel *model = [InventoryListModel new];
- int promotionGoodsIdValue= [[dic objectForKey:@"PromotionGoodsID"]intValue];
-
- model.promotionGoodsId=[NSString stringWithFormat:@"%d",promotionGoodsIdValue];
- int promotionDetailIdValue=[[dic objectForKey:@"PromotionDetailID"]intValue];
- model.promotionDetailId=[NSString stringWithFormat:@"%d",promotionDetailIdValue];;
- model.codeId=[[dic objectForKey:@"CodeID"]intValue];
-
- model.code=[dic objectForKey:@"Code"];
-
- model.onlyCode=[dic objectForKey:@"OnlyCode"];
- model.specification=[dic objectForKey:@"Specification"];
- model.brandId=[dic objectForKey:@"BrandID"];
- model.brandName=[dic objectForKey:@"BrandName"];
- model.gradeId=[[dic objectForKey:@"GradeID"]intValue];
- model.gradeName=[dic objectForKey:@"GradeName"];
- model.kindId=[dic objectForKey:@"KindID"];
- model.kindName=[dic objectForKey:@"KindName"];
- model.seriesId=[dic objectForKey:@"SeriesID"];
- model.seriesName=[dic objectForKey:@"SeriesName"];
- model.varietyId=[dic objectForKey:@"VarietyID"];
- model.varietyName=[dic objectForKey:@"VarietyName"];
- model.unitId=[dic objectForKey:@"UnitID"];
- model.unitName=[dic objectForKey:@"UnitName"];
- model.warehouseId=[dic objectForKey:@"WarehouseID"];
- model.wareHouseName=[dic objectForKey:@"WarehouseName"];
- model.positionNumber=[dic objectForKey:@"PositionNumber"];
- double salesPriceValue= [[dic objectForKey:@"SalsePrice"]doubleValue];
- model.salesPrice=[NSString stringWithFormat:@"%lf",salesPriceValue];
- model.giftFlag=[[dic objectForKey:@"GiftGoodsFlag"]boolValue];
- int goodsNumberValue= [[dic objectForKey:@"GoodsNumber"]intValue];
- model.goodsQuantity=[NSString stringWithFormat:@"%d",goodsNumberValue];
- model.usePositionId=@"0";
- model.colorNumber=[dic objectForKey:@"ColorNumber"];
- model.acreage=[[dic objectForKey:@"Acreage"]doubleValue];
- double weightValue= [[dic objectForKey:@"Weight"]doubleValue];
- model.weight=[NSString stringWithFormat:@"%lf",weightValue];
-
- double volumeValue= [[dic objectForKey:@"Volume"]doubleValue];
-
- model.volume=[NSString stringWithFormat:@"%lf",volumeValue];
-
- model.decimalPlaces=[dic objectForKey:@"DecimalPlaces"];
- model.promotionTypeDetailId=[dic objectForKey:@"PromotionTypeDetailID"];
- model.circulateType=[[dic objectForKey:@"CirculateType"]integerValue];
-
- int packageValue= [[dic objectForKey:@"Package"]intValue];
- model.package=[NSString stringWithFormat:@"%d",packageValue];
-
- model.goodsName=[dic objectForKey:@"GoodsName"];
- model.goodsCateName=[dic objectForKey:@"GoodsCateName"];
- double markedPriceValue= [[dic objectForKey:@"MarkedPrice"]doubleValue];
- model.markedPrice=[NSString stringWithFormat:@"%lf",markedPriceValue];
- int inventoryQuantityValue= [[dic objectForKey:@"InventoryQuantity"]intValue];
- model.inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
-
- int salesQuantityValue= [[dic objectForKey:@"salesQuantity"]intValue];
- model.salesQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
- model.canSaleQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
- int promotionTypeIdValue= [[dic objectForKey:@"PromotionsTypeID"]intValue];
- model.promotionTypeDetailId=[NSString stringWithFormat:@"%d",promotionTypeIdValue];
- model.acreageFlag=[[dic objectForKey:@"AcreageFlag"]boolValue];
- model.inventoryId=[dic objectForKey:@"InventoryID"];
-
- int goodsNumberHideValue= [[dic objectForKey:@"GoodsNumberHide"]intValue];
- model.goodsQuantityHide=[NSString stringWithFormat:@"%d",goodsNumberHideValue];
-
- int minimumPurchaseQuantityValue= [[dic objectForKey:@"MinimPurchaseQuantity"]intValue];
- model.minimumPurchaseQuantity=[NSString stringWithFormat:@"%d",minimumPurchaseQuantityValue];
-
- model.combinationId=[dic objectForKey:@"CombinationID"];
- model.combinationQuantity=@"0";
- OrderQuantity *orderQuantity=[OrderQuantity new];
- [orderQuantity setSalesOrderDetailBoxAndPiece:[model.salesQuantity intValue] inventoryModel:model];
- if(i==0)
- {
- [model setIsChecked:YES];
- }
- else
- {
- [model setIsChecked:NO];
- }
- [_orderGoodsDetailList addObject:model];
- }
-
-
- }
-
- if(combinationArray!=nil&&combinationArray.count>0)
- {
- for(int i=0;i<combinationArray.count;i++)
- {
- NSDictionary *dic=[combinationArray objectAtIndex:i];
- InventoryListModel *model=[InventoryListModel new];
- int promotionGoodsIdValue= [[dic objectForKey:@"PromotionGoodsID"]intValue];
- model.promotionGoodsId=[NSString stringWithFormat:@"%d",promotionGoodsIdValue];
-
- int promotionDetailIdValue=[ [dic objectForKey:@"PromotionDetailID"]intValue]; model.promotionDetailId=[NSString stringWithFormat:@"%d",promotionDetailIdValue];
- model.codeId=[[dic objectForKey:@"CodeID"]intValue];
-
- model.code=[dic objectForKey:@"Code"];
- model.usePositionId=@"0";
- model.onlyCode=[dic objectForKey:@"OnlyCode"];
- model.specification=[dic objectForKey:@"Specification"];
- model.brandId=[dic objectForKey:@"BrandID"];
- model.brandName=[dic objectForKey:@"BrandName"];
- model.gradeId=[[dic objectForKey:@"GradeID"]intValue];
- model.gradeName=[dic objectForKey:@"GradeName"];
- model.kindId=[dic objectForKey:@"KindID"];
- model.kindName=[dic objectForKey:@"KindName"];
- model.seriesId=[dic objectForKey:@"SeriesID"];
- model.seriesName=[dic objectForKey:@"SeriesName"];
- model.varietyId=[dic objectForKey:@"VarietyID"];
- model.varietyName=[dic objectForKey:@"VarietyName"];
- model.unitId=[dic objectForKey:@"UnitID"];
- model.unitName=[dic objectForKey:@"UnitName"];
- model.warehouseId=[dic objectForKey:@"WarehouseID"];
- model.wareHouseName=[dic objectForKey:@"WarehouseName"];
- model.positionNumber=[dic objectForKey:@"PositionNumber"];
- double salesPriceValue= [[dic objectForKey:@"SalsePrice"]doubleValue];
- model.salesPrice=[NSString stringWithFormat:@"%lf",salesPriceValue];
- model.giftFlag=[[dic objectForKey:@"GiftGoodsFlag"]boolValue];
- int goodsNumberValue= [[dic objectForKey:@"GoodsNumber"]intValue];
- model.goodsQuantity=[NSString stringWithFormat:@"%d",goodsNumberValue];
- model.colorNumber=[dic objectForKey:@"ColorNumber"];
- model.acreage=[[dic objectForKey:@"Acreage"]doubleValue];
- double weightValue= [[dic objectForKey:@"Weight"]doubleValue];
- model.weight=[NSString stringWithFormat:@"%lf",weightValue];
-
- double volumeValue= [[dic objectForKey:@"Volume"]doubleValue];
-
- model.volume=[NSString stringWithFormat:@"%lf",volumeValue];
-
- model.decimalPlaces=[dic objectForKey:@"DecimalPlaces"];
-
- model.circulateType=[[dic objectForKey:@"CirculateType"]integerValue];
-
- int packageValue= [[dic objectForKey:@"Package"]intValue];
- model.package=[NSString stringWithFormat:@"%d",packageValue];
-
- model.goodsName=[dic objectForKey:@"GoodsName"];
- model.goodsCateName=[dic objectForKey:@"GoodsCateName"];
- double markedPriceValue= [[dic objectForKey:@"MarkedPrice"]doubleValue];
- model.markedPrice=[NSString stringWithFormat:@"%lf",markedPriceValue];
- int inventoryQuantityValue= [[dic objectForKey:@"InventoryQuantity"]intValue];
- model.inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
-
- int salesQuantityValue= [[dic objectForKey:@"salesQuantity"]intValue];
- model.salesQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
- model.canSaleQuantity=[NSString stringWithFormat:@"%d",salesQuantityValue];
- model.promotionTypeId=[dic objectForKey:@"PromotionsTypeID"];
- model.acreageFlag=[[dic objectForKey:@"AcreageFlag"]boolValue];
- model.inventoryId=[dic objectForKey:@"InventoryID"];
-
- int goodsNumberHideValue= [[dic objectForKey:@"GoodsNumberHide"]intValue];
- model.goodsQuantityHide=[NSString stringWithFormat:@"%d",goodsNumberHideValue];
-
- int minimumPurchaseQuantityValue= [[dic objectForKey:@"MinimPurchaseQuantity"]intValue];
- model.minimumPurchaseQuantity=[NSString stringWithFormat:@"%d",minimumPurchaseQuantityValue];
-
- model.combinationId=[dic objectForKey:@"CombinationID"];
- model.combinationQuantity=@"0";
- [_combinationGoodsDetailList addObject:model];
- }
- }
-
- if(_orderGoodsDetailList!=nil&&_orderGoodsDetailList.count>0)
- {
- InventoryListModel *orderGoodsModel=[_orderGoodsDetailList objectAtIndex:0];
- NSString *combinationId=orderGoodsModel.combinationId;
- _combinationGoodsDetailFilterList=[[NSMutableArray alloc]init];
- for(int i=0;i<_combinationGoodsDetailList.count;i++)
- {
- InventoryListModel *combinationModel=[_combinationGoodsDetailList objectAtIndex:i];
- if([combinationId intValue]==[combinationModel.combinationId intValue])
- {
- [_combinationGoodsDetailFilterList addObject:combinationModel];
- }
- }
-
- if(_combinationGoodsDetailFilterList!=nil&&_combinationGoodsDetailFilterList.count>0)
- {
- InventoryListModel *combinationModel= [_combinationGoodsDetailFilterList objectAtIndex:0];
- [combinationModel setIsCheckedStatus:YES];
-
- [self.combinationDetailVC loadData:_combinationGoodsDetailFilterList promotionGoodsList:_orderGoodsDetailList];
- }
-
- [self.promotionDetailVC loadData:_orderGoodsDetailList combinationGoodsList:_combinationGoodsDetailList ];
-
- }
- }
- }
- }
- -(void)onPromotionOrderDetailLoadFail:(ASIDownManager *)sender {
- [self stopLoading];
- [self showAlertViewText:@"加载失败"];
- }
- -(void)refreshData:(NSMutableArray *)goodsList
- {
- [ self.combinationDetailVC loadData:goodsList promotionGoodsList:_orderGoodsDetailList];
- }
- -(void)refreshPromotionGoodsData:(NSMutableArray*)goodsList
- {
- [self.promotionDetailVC loadData:goodsList combinationGoodsList:_combinationGoodsDetailList];
- }
- -(void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 初始化srollView
- */
- - (void)setMainSrollView{
- UIImage *pic = [UIImage imageNamed:@"bt_datasave"];
- CGFloat h =50;
- // 滚动view
- _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40, Screen_Width, Screen_Height- h - 10 - rectStatusHeight-rectNavHeight - 40)];
- _mainScrollView.delegate = self;
- _mainScrollView.backgroundColor = [UIColor whiteColor];
- _mainScrollView.pagingEnabled = YES;
- _mainScrollView.showsHorizontalScrollIndicator = NO;
- _mainScrollView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:_mainScrollView];
-
- NSArray *views = @[self.promotionDetailVC.view,self.combinationDetailVC.view];
- for (NSInteger i = 0; i< views.count; i++) {
- //把三个vc的view依次贴到mainScrollView上面
- UIView *pageView = [[UIView alloc]initWithFrame:CGRectMake(Screen_Width * i, 0, _mainScrollView.frame.size.width, _mainScrollView.frame.size.height)];
- [pageView addSubview:views[i]];
- [_mainScrollView addSubview:pageView];
- }
- _mainScrollView.contentSize = CGSizeMake(Screen_Width*(views.count), 0);
- //滚动到_currentIndex对应的tab
- [_mainScrollView setContentOffset:CGPointMake((_mainScrollView.frame.size.width)*_currentIndex, 0) animated:YES];
-
- //保存按钮
- _btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
- _btnSave.frame=CGRectMake(0, Screen_Height- h- rectStatusHeight-rectNavHeight, Screen_Width,h) ;
- [_btnSave setBackgroundImage:pic forState:UIControlStateNormal];
- [_btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_btnSave];
- }
- /**
- 基本信息vc
-
- @return <#return value description#>
- */
- - (SalesOrderOptionCombinationPromotionDetailVC *)promotionDetailVC{
- if (promotionDetailVC == nil) {
- promotionDetailVC = [[SalesOrderOptionCombinationPromotionDetailVC alloc] init];
-
- promotionDetailVC.goodsDelegate = self;
- }
- return promotionDetailVC;
- }
- /**
- 业绩信息vc
-
- @return <#return value description#>
- */
- - (SalesOrderOptionCombinationDetailVC *)combinationDetailVC{
- if (combinationDetailVC == nil) {
- combinationDetailVC = [[SalesOrderOptionCombinationDetailVC alloc] init];
-
- combinationDetailVC.goodsDelegate=self;
- }
- return combinationDetailVC;
- }
- /**
- 滑动tag
-
- @param tag <#tag description#>
- */
- - (void)sliderWithTag:(NSInteger)tag{
- self.currentIndex = tag;
- _promotionDetailBtn.selected = NO;
- _combinationDetailBtn.selected = NO;
- UIButton *sender = [self buttonWithTag:tag];
- sender.selected = YES;
- //动画
- _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
- }
- /**
- 返回相应的button
-
- @param tag <#tag description#>
- @return <#return value description#>
- */
- - (UIButton *)buttonWithTag:(NSInteger )tag{
- if (tag == 1) {
- return _promotionDetailBtn;
- }else if (tag == 2){
- return _combinationDetailBtn;
- }
- else{
- return nil;
- }
- }
- /**
- 按钮点击事件
-
- @param sender <#sender description#>
- */
- - (void)sliderAction:(UIButton *)sender{
- if (self.currentIndex == sender.tag) {
- return;
- }
- // 切换controller
- [self.view endEditing:YES];
- [self sliderAnimationWithTag:sender.tag];
- [UIView animateWithDuration:0.3 animations:^{
- _mainScrollView.contentOffset = CGPointMake(Screen_Width*(sender.tag-1), 0);
- } completion:^(BOOL finished) {
-
- }];
- }
- /**
- 滑动tag
-
- @param tag <#tag description#>
- */
- - (void)sliderAnimationWithTag:(NSInteger)tag{
- self.currentIndex = tag;
- _promotionDetailBtn.selected = NO;
- _combinationDetailBtn.selected = NO;
- UIButton *sender = [self buttonWithTag:tag];
- sender.selected = YES;
- //动画
- [UIView animateWithDuration:0.3 animations:^{
- _sliderLabel.frame = CGRectMake(sender.frame.origin.x, _sliderLabel.frame.origin.y, _sliderLabel.frame.size.width, _sliderLabel.frame.size.height);
-
- } completion:^(BOOL finished) {
- }];
- }
- /**
- 滑动label位置
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- //实时计算当前位置,实现和titleView上的按钮的联动
- CGFloat contentOffSetX = scrollView.contentOffset.x;
- CGFloat X = contentOffSetX/ navcount;
- CGRect frame = _sliderLabel.frame;
- frame.origin.x = X;
- _sliderLabel.frame = frame;
- if(X > _sliderLabel.frame.size.width/2){
- UIView *line = _sliderLabel.subviews[0];
- line.frame = CGRectMake(((Screen_Width/navcount)-40)/2, 0, 40, 2);
- }else{
- UIView *line = _sliderLabel.subviews[0];
- line.frame = CGRectMake(((Screen_Width/navcount)-70)/2, 0, 70, 2);
- }
- }
- /**
- 滑动完成
-
- @param scrollView <#scrollView description#>
- */
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
- CGFloat contentOffSetX = scrollView.contentOffset.x;
- int index_ = contentOffSetX/Screen_Width;
- [self sliderWithTag:index_+1];
- }
- -(void)dataSave
- {
- NSMutableArray *goodsDetailList=promotionDetailVC.promotionGoodsDetailList;
- bool isChecked=NO;
- if(goodsDetailList==nil||goodsDetailList.count==0)
- {
- [self showAlertViewText:@"不允许进行该操作,原因:没有任何数据"];
- return;
- }
- for(int i=0;i<goodsDetailList.count;i++)
- {
- InventoryListModel *goodsModel=[goodsDetailList objectAtIndex:i];
- if(goodsModel.isCheckedStatus)
- {
- isChecked=YES;
- break;
- }
- }
-
- if(!isChecked)
- {
- [self showAlertViewText:@"不允许进行该操作,原因:没有任何数据"];
- return;
- }
-
- NSMutableDictionary *goodsDetailDic=[[NSMutableDictionary alloc]init];
- if(goodsDetailList!=nil&&goodsDetailList.count>0)
- {
- NSMutableString *sb=[[NSMutableString alloc]init];
- for(int i=0;i<goodsDetailList.count;i++)
- {
- InventoryListModel *goodsModel=[goodsDetailList objectAtIndex:i];
- NSString *promotionGoodsId=goodsModel.promotionGoodsId;
- [sb appendString:promotionGoodsId];
- [sb appendString:@","];
- }
- NSString *opCombinationPromotionFlag=[sb copy];
- opCombinationPromotionFlag=[NSString stringWithFormat:@"%@%@%@",_promotionOrderModel.detailId,@"-",opCombinationPromotionFlag];
- opCombinationPromotionFlag =[opCombinationPromotionFlag substringToIndex:opCombinationPromotionFlag.length-1];
- [goodsDetailDic setObject:opCombinationPromotionFlag forKey:_promotionOrderModel.detailId];
- }
-
- if([self.orderDelegate respondsToSelector:@selector(updatePromotionGoodsData: goodsDetailList:giftAmount: goodsDetailDic:)])
- {
- [self.orderDelegate updatePromotionGoodsData:_promotionOrderModel goodsDetailList:goodsDetailList giftAmount:0 goodsDetailDic:goodsDetailDic];
- [self.navigationController popViewControllerAnimated:YES];
- }
-
- }
- @end
|