123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- //
- // ProductViewController.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/26.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ProductViewController.h"
- #import "ZBProductListCell.h"
- #import "UIView+BABadgeView.h"
- @interface ProductViewController ()<LPPageVCDelegate,LPPageVCDataSource>
- {
- UIButton *messageBtn;
- }
- @property(nonatomic,strong)UIImageView *bgImageView;
- @property (nonatomic, strong) NSMutableArray *titleArr;
- @property (nonatomic, strong) NSMutableArray *vcArray;
- @property (nonatomic, strong) NSMutableArray *modelArray;
- @property (nonatomic, strong) NSMutableArray*classArray;
- @end
- @implementation ProductViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scrollDirectorNoti:) name:@"scrollDirectorNoti" object:nil];
- [self initNav];
-
- [self configSegmentDelegate];
- [self getDataClass];
-
-
- }
- #pragma mark---获取顶部分类
- -(void)getDataClass
- {
-
- if (![AccountTool isLogin]) {
- return;
- }
- [LoadingView showInView:self.view];
- [ZBHTTP post:[NSString stringWithFormat:@"%@api/goods/listTopBar",BASEURL] params:nil success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSLog(@"%@",json);
- NSArray *array =[NSArray yy_modelArrayWithClass:[ClassModel class] json:json[@"list"]];
- [self.classArray addObjectsFromArray:array];
-
- for (ClassModel *models in self.classArray) {
- [self.titleArr addObject:models.name];
- ZBProductListViewController *vc=[[ZBProductListViewController alloc]init];
- vc.model=models;
- [self.vcArray addObject:vc];
- }
- [self reloadData];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- - (void)configSegmentDelegate {
-
- self.normalTextColor = [UIColor whiteColor];
- self.higlightTextColor = [UIColor whiteColor];
- self.lineBackground = [UIColor whiteColor];
- self.segmentStyle = LPPageVCSegmentStyleLineHighlight;
-
- self.delegate = self;
- self.dataSource = self;
- }
- #pragma mark ======================= LPPageVC Delegate & DataSource =======================
- - (UIViewController *)pageVC:(LPPageVC *)pageVC viewControllerAtIndex:(NSInteger)index{
- return self.vcArray[index];
- }
- - (NSString *)pageVC:(LPPageVC *)pageVC titleAtIndex:(NSInteger)index{
- return self.titleArr[index];
- }
- - (NSInteger)numberOfContentForPageVC:(LPPageVC *)pageVC {
- return self.titleArr.count;
- }
- - (void)pageVC:(LPPageVC *)pageVC didClickEditMode:(LPPageVCEditMode)mode {
-
- }
- - (void)pageVC:(LPPageVC *)pageVC didChangeToIndex:(NSInteger)toIndex fromIndex:(NSInteger)fromIndex {
- NSInteger index = toIndex;
- if (toIndex<0 || toIndex >self.classArray.count-1) {
- index = 0;
- }
- ClassModel *models =self.classArray[index];
- [self.bgImageView sd_setImageWithURL:[NSURL URLWithString:models.backimg] placeholderImage:nil];
- }
- -(void)changeHeadInfo
- {
- ZBUserInfoViewController *setV =[[ZBUserInfoViewController alloc]init];
- [self.navigationController pushViewController:setV animated:YES];
- }
- #pragma mark -- 左边控制器页面push方法
- -(void)leftSliderClickWithRow:(NSNotification *)noti{
-
- NSIndexPath *indexPaht =[noti object];
- NSInteger row =indexPaht.row;
- if (row == 0 ) {//收藏夹
- ZBCollectionVC *collV =[[ZBCollectionVC alloc]init];
- [self.navigationController pushViewController:collV animated:YES];
- return;
- }else if (row == 1) {//客服小蜜
- ZBAdWebViewController *adWeb = [[ZBAdWebViewController alloc] init];
- adWeb.url =jiaochengUrl;
- [self.navigationController pushViewController:adWeb animated:YES];
- return;
- }
- //过审.没有快手
- if (![PublicFunction canOpenURL:kwaiUrl]) {
- ZBSetViewController *setv=[[ZBSetViewController alloc]init];
- [self.navigationController pushViewController:setv animated:YES];
-
- }else{
- if (row == 2){//招商合作
- ZBWebViewController *web = [[ZBWebViewController alloc] init];
-
- web.url = CooperationURl;
- [self.navigationController pushViewController:web animated:YES];
- }else if (row == 3) {//PId
- ZBPIdViewController *pidV =[[ZBPIdViewController alloc]init];
- [self.navigationController pushViewController:pidV animated:YES];
-
- }else if (row == 4){//设置
- ZBSetViewController *setv=[[ZBSetViewController alloc]init];
- [self.navigationController pushViewController:setv animated:YES];
- }
- }
-
-
-
- }
- #pragma mark -- 移除通知
- -(void)dealloc{
-
- [[NSNotificationCenter defaultCenter]removeObserver:self];
- }
- -(void)initNav
- {
-
- self.backView.hidden=NO;
- self.navBar.navTitleLabel.font=[UIFont systemFontOfSize:18];
- //接收通知
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(leftSliderClickWithRow:) name:@"product" object:nil];
-
- //接收通知
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeHeadInfo) name:@"producthead" object:nil];
-
- self.bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, KStatusBarHeight+NavBarHeight+95)];
- self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
- self.bgImageView.backgroundColor = [UIColor baseColor];
-
- [self.view addSubview:self.bgImageView];
- [self.view sendSubviewToBack:self.bgImageView];
- self.navBar.backgroundColor=[UIColor clearColor];
- self.backView.backgroundColor=[UIColor clearColor];
-
- UIButton *searchBtn =[[UIButton alloc]initWithFrame:CGRectMake(60, KStatusBarHeight+7, SCREEN_WIDTH-75, 31)];
- searchBtn.backgroundColor=[UIColor whiteColor];
- searchBtn.adjustsImageWhenHighlighted=NO;
- [searchBtn setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
- searchBtn.titleLabel.font=[UIFont systemFontOfSize:14];
- searchBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
- searchBtn.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 0);
- searchBtn.titleEdgeInsets=UIEdgeInsetsMake(0, 15, 0, 0);
- searchBtn.layer.cornerRadius=15.5;
- searchBtn.layer.masksToBounds=YES;
- [searchBtn setTitle:@"搜索你想要的商品" forState:UIControlStateNormal];
- [searchBtn setImage:[UIImage imageNamed:@"search_icon"] forState:UIControlStateNormal];
- [searchBtn addTarget:self action:@selector(searchClickBtn) forControlEvents:UIControlEventTouchUpInside];
- [self.navBar addSubview:searchBtn];
-
-
-
-
- }
- //- (void)scrollDirectorNoti:(NSNotification *)noti{
- //
- // NSDictionary *info = noti.userInfo;
- // //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
- // CGFloat director =[info[@"director"] floatValue];
- // if (director<0) {
- // self.backView.hidden=YES;
- // }else{
- // self.backView.hidden=NO;
- // }
- //
- // CGFloat offY = [info[@"offY"] floatValue];
- // CGFloat standard = NavBarHeight-KStatusBarHeight;//渐变的距离
- // self.navBar.alpha -= offY/standard;
- // if (self.navBar.alpha > 1) {
- // self.navBar.alpha = 1;
- // }
- // if (self.navBar.alpha < 0) {
- // self.navBar.alpha = 0;
- // }
- //
- // if ((self.navBar.y-offY) <= (-standard)) {
- // self.navBar.y = -standard;
- // return;
- // }
- // if (self.navBar.y-offY > 0) {
- // self.navBar.y = 0;
- // return;
- // }
- //
- // self.navBar.y -= offY;
- // [_segmentScrollView layoutIfNeeded];
- //
- //}
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navBar.hidden=NO;
- [PublicFunction saveAccountWithPush:@"product"];
- [PublicFunction saveAccountChangeInfoWithPush:@"producthead"];
-
- self.backView.hidden=NO;
- if ([AccountTool isLogin]) {
- AccountModel *infomodels =[AccountTool account];
- NSLog(@"%@",infomodels.img);
- [self.headImgV sd_setImageWithURL:[NSURL URLWithString:infomodels.img]];
-
- }
- [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleLightContent;
- self.tabBarController.tabBar.hidden=NO;
-
- }
- - (NSMutableArray *)titleArr {
- if (!_titleArr) {
- _titleArr = [NSMutableArray array];
-
- }
- return _titleArr;
- }
- - (NSMutableArray *)vcArray {
- if (!_vcArray) {
- _vcArray = [NSMutableArray array];
-
- }
- return _vcArray;
- }
- -(NSMutableArray *)classArray
- {
- if (!_classArray) {
- _classArray=[NSMutableArray array];
- }
- return _classArray;
- }
- -(NSMutableArray *)modelArray
- {
- if (!_modelArray) {
- _modelArray=[NSMutableArray array];
- }
- return _modelArray;
- }
- #pragma mark-----教程
- -(void)rightBtnClickBtn
- {
- ZBAdWebViewController *adWeb = [[ZBAdWebViewController alloc] init];
- adWeb.url =jiaochengUrl;
- [self.navigationController pushViewController:adWeb animated:YES];
- }
- #pragma mark---搜索
- -(void)searchClickBtn
- {
- ZBSearchViewController *searchViewController=[[ZBSearchViewController alloc]init];
- [self.navigationController pushViewController:searchViewController animated:NO];
- }
- @end
|