| | |
| | | #import "discoverGoodsDetailViewController.h" |
| | | |
| | | @interface CollectionController ()<UITableViewDataSource,UITableViewDelegate>{ |
| | | HMSegmentedControl *segmentedControl; |
| | | // HMSegmentedControl *segmentedControl; |
| | | |
| | | UITableView * mytableview; |
| | | |
| | |
| | | |
| | | [self initScene]; |
| | | } |
| | | - (void)viewWillAppear:(BOOL)animated{ |
| | | // if (_videoData.count == 0) { |
| | | // videoPage = 1; |
| | | // } |
| | | [self getVideoDataResuse:1]; |
| | | |
| | | } |
| | | |
| | | -(void)initScene{ |
| | | //设置背景色 |
| | |
| | | [self createNavgationBar]; |
| | | |
| | | //创建选项 |
| | | [self createSegmentedControl]; |
| | | // [self createSegmentedControl]; |
| | | |
| | | //创建列表 |
| | | [self createTableView]; |
| | |
| | | self.navigationItem.rightBarButtonItem = deleteBarItem; |
| | | } |
| | | |
| | | /** |
| | | 创建选项栏 |
| | | */ |
| | | -(void)createSegmentedControl{ |
| | | segmentedControl = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"影视收藏", @"商品收藏"]]; |
| | | [segmentedControl setFrame:CGRectMake(0, 64, KScreenW, 48)]; |
| | | segmentedControl.selectionIndicatorHeight = 4.0f; |
| | | segmentedControl.backgroundColor = KGlobalLightGreyColor_255; |
| | | segmentedControl.titleTextAttributes = @{NSForegroundColorAttributeName : kGlobalDeepGreyColor}; |
| | | segmentedControl.selectionIndicatorColor = kGlobalYellowColor; |
| | | segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe; |
| | | segmentedControl.selectedSegmentIndex = 0; |
| | | segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown; |
| | | segmentedControl.shouldAnimateUserSelection = YES; |
| | | segmentedControl.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15]}; |
| | | [segmentedControl addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged]; |
| | | |
| | | //选项下面的横线 |
| | | UILabel *Line = [[UILabel alloc]initWithFrame:CGRectMake(0, 48, KScreenW, 1)]; |
| | | Line.backgroundColor = kGlobaLineColor; |
| | | [segmentedControl addSubview:Line]; |
| | | |
| | | //选项中间的分割线 |
| | | UILabel *Line1 = [[UILabel alloc]initWithFrame:CGRectMake(KScreenW / 2 - 0.5 , 10 ,1, 28)]; |
| | | Line1.backgroundColor = kGlobaLineColor; |
| | | [segmentedControl addSubview:Line1]; |
| | | |
| | | [self.view addSubview:segmentedControl]; |
| | | } |
| | | ///** |
| | | // 创建选项栏 |
| | | // */ |
| | | //-(void)createSegmentedControl{ |
| | | // segmentedControl = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"影视收藏", @"商品收藏"]]; |
| | | // NSInteger height = 64; |
| | | // if (KIsiPhoneX) { |
| | | // height = 84; |
| | | // } |
| | | // [segmentedControl setFrame:CGRectMake(0, height, KScreenW, 48)]; |
| | | // segmentedControl.selectionIndicatorHeight = 4.0f; |
| | | // segmentedControl.backgroundColor = KGlobalLightGreyColor_255; |
| | | // segmentedControl.titleTextAttributes = @{NSForegroundColorAttributeName : kGlobalDeepGreyColor}; |
| | | // segmentedControl.selectionIndicatorColor = kGlobalYellowColor; |
| | | // segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe; |
| | | // segmentedControl.selectedSegmentIndex = 0; |
| | | // segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown; |
| | | // segmentedControl.shouldAnimateUserSelection = YES; |
| | | // segmentedControl.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15]}; |
| | | // [segmentedControl addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged]; |
| | | // |
| | | // //选项下面的横线 |
| | | // UILabel *Line = [[UILabel alloc]initWithFrame:CGRectMake(0, 48, KScreenW, 1)]; |
| | | // Line.backgroundColor = kGlobaLineColor; |
| | | // [segmentedControl addSubview:Line]; |
| | | // |
| | | // //选项中间的分割线 |
| | | // UILabel *Line1 = [[UILabel alloc]initWithFrame:CGRectMake(KScreenW / 2 - 0.5 , 10 ,1, 28)]; |
| | | // Line1.backgroundColor = kGlobaLineColor; |
| | | // [segmentedControl addSubview:Line1]; |
| | | // |
| | | //// [self.view addSubview:segmentedControl]; |
| | | //} |
| | | |
| | | /** |
| | | 创建列表 |
| | | */ |
| | | -(void)createTableView{ |
| | | mytableview = [[UITableView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(segmentedControl.frame) , KScreenW, KScreenH - 117) style:UITableViewStylePlain]; |
| | | NSInteger height = 117 - 48; |
| | | if (KIsiPhoneX) { |
| | | height = 137 - 48 ; |
| | | } |
| | | mytableview = [[UITableView alloc]initWithFrame:CGRectMake(0,0 , KScreenW, KScreenH ) style:UITableViewStylePlain]; |
| | | mytableview.delegate = self; |
| | | mytableview.dataSource = self; |
| | | mytableview.backgroundColor = kGlobalBackgroundColor; |
| | |
| | | */ |
| | | -(void)CreateOperatingView{ |
| | | //盛放全选按钮和删除按钮的视图 |
| | | allSelAndDelView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenH-40, KScreenW, 40)]; |
| | | CGFloat height = 40; |
| | | if (KIsiPhoneX) { |
| | | height = 60; |
| | | } |
| | | allSelAndDelView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenH-height, KScreenW, 40)]; |
| | | allSelAndDelView.backgroundColor = [UIColor whiteColor]; |
| | | //默认隐藏,只有用户点击编辑按钮时,才会出现 |
| | | allSelAndDelView.hidden = YES; |
| | |
| | | 下拉刷新方法 |
| | | */ |
| | | - (void)loadNewData{ |
| | | if (WhetherChooseGoodsCollection) { |
| | | //收藏的商品 |
| | | goodsPage = 1; |
| | | [self getGoodsDataResuse:goodsPage]; |
| | | }else{ |
| | | //收藏的视频 |
| | | videoPage = 1; |
| | | [self getVideoDataResuse:videoPage]; |
| | | } |
| | | videoPage = 1; |
| | | [self getVideoDataResuse:videoPage]; |
| | | } |
| | | |
| | | /** |
| | | 上拉加载更多视图 |
| | | */ |
| | | - (void)loadMoreData{ |
| | | if (WhetherChooseGoodsCollection) { |
| | | //收藏的商品 |
| | | [self getGoodsDataResuse:goodsPage]; |
| | | }else{ |
| | | //收藏的视频 |
| | | [self getVideoDataResuse:videoPage]; |
| | | } |
| | | |
| | | //收藏的视频 |
| | | [self getVideoDataResuse:videoPage]; |
| | | } |
| | | |
| | | /** |
| | |
| | | }else{ |
| | | [prompt setHidden:NO]; |
| | | } |
| | | |
| | | [mytableview.mj_footer endRefreshing]; |
| | | if (_videoData.count < 20) { |
| | | [mytableview.mj_footer endRefreshingWithNoMoreData]; |
| | | } |
| | | if (_videoData.count < 3) { |
| | | mytableview.mj_footer.hidden = YES; |
| | | } |
| | | }else{ |
| | | [mytableview.mj_footer endRefreshing]; |
| | | NSLog(@"%@",error); |
| | | if ([error compare:@"似乎已断开与互联网的连接。"] == 0) { |
| | | [self autoDisappearAlertTime:1 msg:@"网络不可用,请检查网络"]; |
| | | } |
| | | } |
| | | [SVProgressHUD dismiss]; |
| | | }]; |
| | | [mytableview.mj_header endRefreshing]; |
| | | [mytableview.mj_footer endRefreshing]; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | 商品收藏列表 |
| | | |
| | | @param pageNumber 页数 |
| | | */ |
| | | -(void)getGoodsDataResuse:(NSInteger)pageNumber{ |
| | | [SVProgressHUD showWithStatus:@"疯狂加载中"]; |
| | | [[YTHNetInterface startInterface] getCollectListWithUid:[YTHsharedManger startManger].Uid WithSystem:@"1" withPage:[NSString stringWithFormat:@"%ld",(long)pageNumber] withBlock:^(BOOL isSuccessful, id result, NSString *error) { |
| | | if (isSuccessful) { |
| | | NSDictionary *dic =(NSDictionary *)result; |
| | | if (!_goodsData) { |
| | | _goodsData = [[NSMutableArray alloc] initWithCapacity:0]; |
| | | } |
| | | if (pageNumber == 1) { |
| | | [_goodsData removeAllObjects]; |
| | | } |
| | | |
| | | NSArray *arr = [[dic objectForKey:@"Data"] objectForKey:@"data"]; |
| | | for (int i =0; i<arr.count; i++) { |
| | | [_goodsData addObject:[arr objectAtIndex:i]]; |
| | | } |
| | | if ([arr count]>0){ |
| | | ++goodsPage; |
| | | } |
| | | //取消编辑状态 |
| | | mytableview.editing = NO; |
| | | [self editNO]; |
| | | |
| | | [mytableview reloadData]; |
| | | if(_goodsData.count>0){ |
| | | [prompt setHidden:YES]; |
| | | }else{ |
| | | [prompt setHidden:NO]; |
| | | } |
| | | }else{ |
| | | NSLog(@"%@",error); |
| | | } |
| | | [SVProgressHUD dismiss]; |
| | | }]; |
| | | [mytableview.mj_header endRefreshing]; |
| | | [mytableview.mj_footer endRefreshing]; |
| | | } |
| | | |
| | | /** |
| | | 取消编辑状态 |
| | |
| | | mytableview.editing = NO; |
| | | [self editNO]; |
| | | goodsPage = 1; |
| | | [self getGoodsDataResuse:goodsPage]; |
| | | // [self getGoodsDataResuse:goodsPage]; |
| | | }else{ |
| | | [SVProgressHUD showErrorWithStatus:@"取消收藏失败!"]; |
| | | } |
| | |
| | | } |
| | | |
| | | -(void)deletebutton:(id)sender{ |
| | | [deleteBut setTitle:[NSString stringWithFormat:@"删除"] forState:UIControlStateNormal]; |
| | | |
| | | if (mytableview.editing) { |
| | | [mytableview setEditing:NO]; |
| | | [deleBtn setSelected:NO]; |