123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- //
- // HomePageVC.m
- // Blaufuchslive
- //
- // Created by 刘惠萍 on 2020/2/19.
- // Copyright © 2020 刘惠萍. All rights reserved.
- //
- #import "HomePageVC.h"
- #import "WKWebViewVC.h"
- #import "xingchuangke-Swift.h"
- @interface HomePageVC ()
- @property (strong, nonatomic) HomePageHeaderView *headerView;
- @property (strong, nonatomic) HomePageNavView *navView;
- @end
- @implementation HomePageVC
- - (HomePageNavView *)navView {
- if (!_navView) {
- _navView = [HomePageNavView new];
- _navView.frame = CGRectMake(0, 0, SCREEN_WIDTH, _navView.height);
- _navView.blockKF = ^{
- QYSource *source = [[QYSource alloc] init];
- source.title = @"客服";
- source.urlString = @"";
- QYSessionViewController *sessionViewController = [[QYSDK sharedSDK] sessionViewController];
- sessionViewController.sessionTitle = @"在线客服";
- sessionViewController.source = source;
- sessionViewController.hidesBottomBarWhenPushed = true;
- [GB_Nav pushViewController:sessionViewController animated:true];
- };
- }
- return _navView;
- }
- - (HomePageHeaderView *)headerView {
- if (!_headerView) {
- _headerView = [HomePageHeaderView new];
- self.headerView.frame = CGRectMake(W(0), 0, SCREEN_WIDTH, self.headerView.height);
- _headerView.blockModelBanner = ^(ModelBanner *model) {
- WKWebViewVC *vc=[WKWebViewVC new];
- vc.htmlString=UnPackStr(model.webUrl);
- vc.isH5=true;
- vc.isNav=true;
- vc.navStr=@"详情";
- [GB_Nav pushViewController:vc animated:true];
- };
- _headerView.blockKF = ^{
- QYSource *source = [[QYSource alloc] init];
- source.title = @"客服";
- source.urlString = @"";
- QYSessionViewController *sessionViewController = [[QYSDK sharedSDK] sessionViewController];
- sessionViewController.sessionTitle = @"在线客服";
- sessionViewController.source = source;
- sessionViewController.hidesBottomBarWhenPushed = true;
- [GB_Nav pushViewController:sessionViewController animated:true];
- };
- }
- return _headerView;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.view addSubview:self.navView];
- self.tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT -TABBAR_HEIGHT);
- self.navView.backgroundColor=[UIColor clearColor];
- self.tableView.tableHeaderView = self.headerView;
-
- [self requestShopLabelHomepage];
- [self.tableView registerClass:[DocumentLibraryCell class] forCellReuseIdentifier:@"DocumentLibraryCell"];
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = YES;
- [self requestList];
- }
- -(void)requestShopLabelHomepage{
- NSMutableArray *arr=[NSMutableArray new];
- [arr addObjectsFromArray:@[^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"商户录入";
- model.string=@"商户录入";
- model.blockClick = ^(ModelBaseData *m) {
- SelectPayBrandViewController *vc=[SelectPayBrandViewController new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"邀请好友";
- model.string=@"邀请好友";
- model.blockClick = ^(ModelBaseData *model) {
- InviteViewController *vc=[InviteViewController new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"我的代理";
- model.string=@"我的代理";
- model.blockClick = ^(ModelBaseData *m) {
- MyDelegateViewController *vc=[MyDelegateViewController new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"商户管理";
- model.string=@"商户管理";
- model.blockClick = ^(ModelBaseData *m) {
- BrandListViewController *vc=[BrandListViewController new];
- vc.strTitle = @"商户管理";
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"活动中心";
- model.string=@"活动中心";
- model.blockClick = ^(ModelBaseData *m) {
- ActiveListViewController *vc=[ActiveListViewController new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"机具管理";
- model.string=@"机具管理";
- model.blockClick = ^(ModelBaseData *m) {
- PosManangerViewController *vc=[PosManangerViewController new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"业绩管理";
- model.string=@"业绩管理";
- model.blockClick = ^(ModelBaseData *model) {
- BusinessMainViewController *vc=[BusinessMainViewController new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"交易管理";
- model.string=@"交易管理";
- model.blockClick = ^(ModelBaseData *m) {
- BrandListViewController *vc=[BrandListViewController new];
- vc.strTitle = @"交易管理";
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"我的资质";
- model.string=@"机具调拨";
- model.blockClick = ^(ModelBaseData *m) {
- PosTransferVC *vc=[PosTransferVC new];
- [GB_Nav pushViewController:vc animated:true];
- };
- return model;
- }(),^(){
- ModelBaseData * model = [ModelBaseData new];
- model.imageName = @"更多";
- model.string=@"更多";
- model.blockClick = ^(ModelBaseData *m) {
- [GlobalMethod showAlert:@"正在开发中..."];
- };
- return model;
- }()]];
- [self.headerView resetViewWithModel:arr];
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- if (self.tableView.contentOffset.y <= 0)
- {
- self.tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT -TABBAR_HEIGHT);
- self.navView.backgroundColor=[UIColor clearColor];
- }else{
- self.tableView.frame = CGRectMake(0, NAVIGATIONBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT -TABBAR_HEIGHT-NAVIGATIONBAR_HEIGHT);
- self.navView.backgroundColor = [UIColor colorWithHexString:@"#55C5EB"];
- }
- NSLog(@"%.f",self.tableView.contentOffset.y);
- }
- #pragma mark table view delegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.aryDatas.count;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- DocumentLibraryCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DocumentLibraryCell" forIndexPath:indexPath];
- [cell resetCellWithModel:self.aryDatas[indexPath.row]];
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return [DocumentLibraryCell fetchHeight:self.aryDatas[indexPath.row]];
- }
- - (void)requestList{
- [RequestApi requestGetInformationListWithPage:@"1" size:@"20" typeId:@"FFFFFF" delegate:self success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
- NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"][@"dataList"] toAryWithModelName:@"ModelDocumentLibrary"];
- if (self.isRemoveAll) {
- [self.aryDatas removeAllObjects];
- }
- self.pageNum ++;
- if (!isAry(ary)) {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }
- [self.aryDatas addObjectsFromArray:ary];
- [self.tableView reloadData];
- } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
-
- }];
-
- }
- @end
- @implementation HomePageHeaderView
- #pragma mark 懒加载
- - (UIImageView *)backImg{
- if (_backImg == nil) {
- _backImg = [UIImageView new];
- _backImg.image = [UIImage imageNamed:@"Home page-background"];
- _backImg.widthHeight = XY(SCREEN_WIDTH,W(200)+NAVIGATIONBAR_HEIGHT);
- }
- return _backImg;
- }
- - (AutoScView *)headerView{
- if (_headerView == nil) {
- _headerView = [AutoScView new];
- _headerView.frame = CGRectMake(W(0), 0, SCREEN_WIDTH-W(40),W(80));
- _headerView.backgroundColor = [UIColor whiteColor];
- _headerView.isShowProductImageStyle = true;
- [_headerView timerStart];
- _headerView.pageCurrentColor = [UIColor whiteColor];
- _headerView.pageDefaultColor = [UIColor colorWithHexString:@"#E0E0E0"];
- [GlobalMethod setRoundView:_headerView color:COLOR_BLUE numRound:5 width:0];
- _headerView.isShowNum = true;
- WEAKSELF
- _headerView.blockModel = ^(ModelBanner *model) {
- if (weakSelf.blockModelBanner) {
- weakSelf.blockModelBanner(model);
- }
- };
- }
- return _headerView;
- }
- - (UILabel *)labelTitleTS{
- if (_labelTitleTS == nil) {
- _labelTitleTS = [UILabel new];
- [GlobalMethod setLabel:_labelTitleTS widthLimit:0 numLines:0 fontNum:F(20) textColor:COLOR_LABEL text:@""];
- self.labelTitleTS.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
- }
- return _labelTitleTS;
- }
- - (UIImageView *)pView{
- if (_pView == nil) {
- _pView = [UIImageView new];
- [GlobalMethod setRoundView:_pView color:[UIColor clearColor] numRound:8 width:0];
- }
- return _pView;
- }
- - (UIImageView *)zView{
- if (_zView == nil) {
- _zView = [UIImageView new];
- [GlobalMethod setRoundView:_zView color:[UIColor clearColor] numRound:8 width:0];
- }
- return _zView;
- }
- - (UIImageView *)hotView{
- if (_hotView == nil) {
- _hotView = [UIImageView new];
- [GlobalMethod setRoundView:_hotView color:[UIColor clearColor] numRound:8 width:0];
- }
- return _hotView;
- }
- - (UILabel *)labelTitleWA{
- if (_labelTitleWA == nil) {
- _labelTitleWA = [UILabel new];
- [GlobalMethod setLabel:_labelTitleWA widthLimit:0 numLines:0 fontNum:F(20) textColor:COLOR_LABEL text:@""];
- self.labelTitleWA.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
- }
- return _labelTitleWA;
- }
- -(UIButton *)moreBtn{
- if (_moreBtn == nil) {
- _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _moreBtn.tag = 13;
- [_moreBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _moreBtn.titleLabel.font = [UIFont systemFontOfSize:F(13)];
- [_moreBtn setTitle:@"更多 >" forState:(UIControlStateNormal)];
- _moreBtn.widthHeight = XY(W(60),W(40));
- [_moreBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, - _moreBtn.imageView.image.size.width, 0, _moreBtn.imageView.image.size.width)];
- [_moreBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _moreBtn.titleLabel.bounds.size.width, 0, -_moreBtn.titleLabel.bounds.size.width)];
- [_moreBtn setTitleColor:[UIColor colorWithHexString:@"#898989"] forState:(UIControlStateNormal)];
- }
- return _moreBtn;
- }
- - (UIControl *)backImgControl{
- if (_backImgControl == nil) {
- _backImgControl = [UIControl new];
- _backImgControl.tag = 1;
- [_backImgControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _backImgControl.backgroundColor = [UIColor clearColor];
- }
- return _backImgControl;
- }
- - (UIControl *)pViewControl{
- if (_pViewControl == nil) {
- _pViewControl = [UIControl new];
- _pViewControl.tag = 2;
- [_pViewControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _pViewControl.backgroundColor = [UIColor clearColor];
- }
- return _pViewControl;
- }
- - (UIControl *)zViewControl{
- if (_zViewControl == nil) {
- _zViewControl = [UIControl new];
- _zViewControl.tag = 3;
- [_zViewControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _zViewControl.backgroundColor = [UIColor clearColor];
- }
- return _zViewControl;
- }
- - (UIControl *)hotViewControl{
- if (_hotViewControl == nil) {
- _hotViewControl = [UIControl new];
- _hotViewControl.tag = 4;
- [_hotViewControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _hotViewControl.backgroundColor = [UIColor clearColor];
- }
- return _hotViewControl;
- }
- - (NSMutableArray *)shopLabelList{
- if (!_shopLabelList) {
- _shopLabelList = [NSMutableArray new];
- }
- return _shopLabelList;
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- self.width = SCREEN_WIDTH;
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- [self addSubview:self.backImg];
- [self addSubview:self.headerView];
- [self addSubview:self.labelTitleTS];
- [self addSubview:self.pView];
- [self addSubview:self.zView];
- [self addSubview:self.hotView];
- [self addSubview:self.labelTitleWA];
- [self addSubview:self.moreBtn];
- [self addSubview:self.backImgControl];
- [self addSubview:self.pViewControl];
- [self addSubview:self.zViewControl];
- [self addSubview:self.hotViewControl];
-
- [self requestBannerList];
-
- //初始化页面
- [self resetViewWithModel:nil];
- }
- #pragma mark 刷新view
- - (void)resetViewWithModel:(NSMutableArray *)model{
- [self removeSubViewWithTag:TAG_LINE];
- //刷新view
- self.backImg.leftTop = XY(0,0);
- self.backImgControl.widthHeight = self.backImg.widthHeight;
- self.backImgControl.leftTop = self.backImg.leftTop;
- [RequestApi requestFindAdvertisingWheelWithPosition:@"4" delegate:nil success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
- NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"] toAryWithModelName:@"ModelBanner"];
- NSMutableArray *aryData=[NSMutableArray new];
- for (ModelBanner *model in ary) {
- [aryData addObject:model.imgPath];
- self.titleStr=model.webUrl;
- }
- [self.backImg sd_setImageWithURL:[NSURL URLWithString:aryData[0]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
-
- }];
- self.shopLabelList=model.mutableCopy;
- CGFloat x = W(10);//
- CGFloat y = self.backImg.bottom+W(20);//
- CGFloat height = self.backImg.bottom+W(20);//
- //刷新view
- for (int i = 0; i < model.count; i++) {
- ModelBaseData * modelReplay =model[i];
- HomePageBtnView * btnItem = [HomePageBtnView new];
- btnItem.model = modelReplay;
- btnItem.tag = TAG_LINE;
- btnItem.blockClick = ^(ModelBaseData *model) {
- if (modelReplay.blockClick) {
- modelReplay.blockClick(model);
- }
- };
- btnItem.width =(SCREEN_WIDTH-W(10)*2-W(10)*4)/5;
- [btnItem resetViewWithModel:modelReplay width:(SCREEN_WIDTH-W(10)*2-W(10)*4)/5];
- //根据计算文字的大小
- if (btnItem.width + x > SCREEN_WIDTH) {
- y += btnItem.height +W(40);
- x = W(10);
- }
- btnItem.leftTop = XY(x, y);
- [self addSubview:btnItem];
- if (i != model.count) {
- x = btnItem.right +W(10);
- }
- height = btnItem.bottom;
- }
- self.headerView.leftTop = XY(W(20),height+W(40));
- [self.labelTitleTS fitTitle:@"特色服务" variable:0];
- self.labelTitleTS.leftTop = XY(W(20),W(35)+self.headerView.bottom);
-
- [RequestApi requestFindAdvertisingWheelWithPosition:@"3" delegate:nil success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
- NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"] toAryWithModelName:@"ModelBanner"];
- NSMutableArray *aryData=[NSMutableArray new];
- for (ModelBanner *model in ary) {
- [aryData addObject:model.imgPath];
- }
- if (isAry(aryData)&&aryData.count==3) {
- [self.zView sd_setImageWithURL:[NSURL URLWithString:aryData[0]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- [self.pView sd_setImageWithURL:[NSURL URLWithString:aryData[2]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- [self.hotView sd_setImageWithURL:[NSURL URLWithString:aryData[1]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- self.pView.widthHeight = XY((SCREEN_WIDTH-W(48))/2, W(220));
- self.zView.widthHeight = XY(self.pView.width, (self.pView.height-W(5))/2);
- self.hotView.widthHeight = XY(self.pView.width, self.zView.height);
- self.pViewControl.widthHeight=self.pView.widthHeight;
- self.zViewControl.widthHeight=self.zView.widthHeight;
- self.hotViewControl.widthHeight=self.hotView.widthHeight;
- self.zView.leftTop = XY(W(20),self.labelTitleTS.bottom+W(22));
- self.zViewControl.leftTop=self.zView.leftTop;
- self.hotView.leftTop = XY(self.zView.left,self.zView.bottom+W(5));
- self.hotViewControl.leftTop=self.hotView.leftTop;
- self.pView.leftTop = XY(W(5)+self.zView.right,self.zView.top);
- self.pViewControl.leftTop=self.pView.leftTop;
- self.zView.hidden=false;
- self.hotView.hidden=false;
- self.pView.hidden=false;
- self.pViewControl.hidden=false;
- self.zViewControl.hidden=false;
- self.hotViewControl.hidden=false;
- [self.labelTitleWA fitTitle:@"文案库" variable:0];
- self.labelTitleWA.leftTop = XY(W(20),self.zView.bottom+W(35));
- self.moreBtn.rightCenterY = XY(SCREEN_WIDTH-W(20),self.labelTitleWA.centerY);
- self.height = self.labelTitleWA.bottom+W(10);
- }else if (isAry(aryData)&&aryData.count!=3) {
- [self.zView sd_setImageWithURL:[NSURL URLWithString:aryData[0]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- [self.hotView sd_setImageWithURL:[NSURL URLWithString:aryData[1]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- self.hotView.widthHeight = XY((SCREEN_WIDTH-W(48))/2, (W(220)-W(5))/2);
- self.zView.widthHeight = XY(self.hotView.width, self.hotView.height);
- self.hotViewControl.widthHeight=self.hotView.widthHeight;
- self.zViewControl.widthHeight=self.zView.widthHeight;
- self.zView.leftTop = XY(W(20),self.labelTitleTS.bottom+W(22));
- self.zViewControl.leftTop=self.zView.leftTop;
- self.hotView.leftTop = XY(W(5)+self.zView.right,self.zView.top);
- self.hotViewControl.leftTop=self.hotView.leftTop;
- self.zView.hidden=false;
- self.hotView.hidden=false;
- self.pView.hidden=true;
- self.pViewControl.hidden=true;
- self.zViewControl.hidden=false;
- self.hotViewControl.hidden=false;
- [self.labelTitleWA fitTitle:@"文案库" variable:0];
- self.labelTitleWA.leftTop = XY(W(20),self.zView.bottom+W(35));
- self.moreBtn.rightCenterY = XY(SCREEN_WIDTH-W(20),self.labelTitleWA.centerY);
- self.height = self.labelTitleWA.bottom+W(10);
- }
- } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
-
- }];
- self.height = self.labelTitleWA.bottom+W(10);
- }
- //REQUEST
- -(void)requestBannerList{
- [RequestApi requestFindAdvertisingWheelWithPosition:@"0" delegate:nil success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
- NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"] toAryWithModelName:@"ModelBanner"];
- NSMutableArray *aryData=[NSMutableArray new];
- for (ModelBanner *model in ary) {
- [aryData addObject:model.imgPath];
- }
- self.headerView.aryImageModel=ary.mutableCopy;
- [self.headerView resetWithImageAry:aryData];
-
- } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
-
- }];
- }
- #pragma mark 点击事件
- - (void)btnClick:(UIButton *)sender{
- switch (sender.tag) {
- case 13:
- {
- // ArticleManagerViewController *vc=[ArticleManagerViewController new];
- // [GB_Nav pushViewController:vc animated:true];
- [GB_Nav pushVCName:@"DocumentLibraryHomeVC" animated:true];
- }
- break;
- case 1:
- {
- WKWebViewVC *vc=[WKWebViewVC new];
- vc.htmlString=UnPackStr(self.titleStr);
- vc.isH5=true;
- vc.isNav=true;
- vc.navStr=@"详情";
- [GB_Nav pushViewController:vc animated:true];
- }
- break;
- case 3:
- {
- if (self.blockKF) {
- self.blockKF();
- }
- }
- break;
- case 2:
- {
- ApplyCardTabBarViewController *vc=[ApplyCardTabBarViewController new];
- vc.type = 0;
- [GB_Nav pushViewController:vc animated:true];
- }
- break;
- case 4:
- {
- StudyViewController *vc = [StudyViewController new];
- [GB_Nav pushViewController:vc animated:true];
- }
- break;
- default:
- break;
- }
- }
- @end
- @implementation HomePageNavView
- #pragma mark 懒加载
- -(UIButton *)addBtn{
- if (_addBtn == nil) {
- _addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _addBtn.tag = 2;
- [_addBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _addBtn.widthHeight = XY(W(30),W(40));
- [_addBtn setImage:[UIImage imageNamed:@"消息"] forState:(UIControlStateNormal)];
- }
- return _addBtn;
- }
- -(UIButton *)kfBtn{
- if (_kfBtn == nil) {
- _kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _kfBtn.tag = 1;
- [_kfBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- _kfBtn.widthHeight = XY(W(30),W(40));
- [_kfBtn setImage:[UIImage imageNamed:@"客服"] forState:(UIControlStateNormal)];
- }
- return _kfBtn;
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor clearColor];
- self.width = SCREEN_WIDTH;
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- [self addSubview:self.kfBtn];
- [self addSubview:self.addBtn];
- //初始化页面
- [self resetViewWithModel:nil];
- }
- #pragma mark 刷新view
- - (void)resetViewWithModel:(NSString *)model{
-
- self.addBtn.rightCenterY = XY(SCREEN_WIDTH-W(15),NAVIGATIONBAR_HEIGHT/2+W(13));
- self.kfBtn.rightCenterY = XY(self.addBtn.left-W(15),self.addBtn.centerY);
- self.height=NAVIGATIONBAR_HEIGHT;
- }
- #pragma mark 点击事件
- - (void)btnClick:(UIButton *)sender{
- switch (sender.tag) {
- case 1:
- {
- if (self.blockKF) {
- self.blockKF();
- }
- }
- break;
- case 2:
- {
- NewsListViewController *vc = [NewsListViewController new];
- [GB_Nav pushViewController:vc animated:true];
- }
- break;
- default:
- break;
- }
- }
- @end
- @implementation HomePageBtnView
- #pragma mark 懒加载
- - (UIImageView *)backImg{
- if (_backImg == nil) {
- _backImg = [UIImageView new];
- _backImg.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _backImg;
- }
- - (UILabel *)labelNum{
- if (_labelNum == nil) {
- _labelNum = [UILabel new];
- [GlobalMethod setLabel:_labelNum widthLimit:0 numLines:0 fontNum:F(13) textColor:COLOR_LABEL text:@""];
- self.labelNum.font = [UIFont fontWithName:@"Helvetica-Bold" size:F(13)];
- }
- return _labelNum;
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor clearColor];
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- [self addSubview:self.backImg];
- [self addSubview:self.labelNum];
- [self addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
- }
- #pragma mark 刷新view
- - (void)resetViewWithModel:(ModelBaseData *)model width:(CGFloat)widthLimit{
- [self.backImg removeSubViewWithTag:TAG_LINE];;//移除线
- //刷新view
- self.model=model;
- self.width=widthLimit;
- _backImg.widthHeight = XY(W(35),W(35));
- _backImg.image = [UIImage imageNamed:UnPackStr(model.imageName)];
- self.backImg.centerXTop = XY(widthLimit/2,W(0));
- [self.labelNum fitTitle:UnPackStr(model.string) variable:widthLimit];
- self.labelNum.centerXTop = XY(widthLimit/2,W(13)+self.backImg.bottom);
- self.height=self.labelNum.bottom+W(5);
- }
- #pragma mark 点击事件
- - (void)btnClick:(UIButton *)sender{
- if (self.blockClick) {
- self.blockClick(self.model);
- }
- }
- @end
- @implementation DocumentLibraryCell
- #pragma mark 懒加载
- - (UILabel *)labelTitle{
- if (_labelTitle == nil) {
- _labelTitle = [UILabel new];
- [GlobalMethod setLabel:_labelTitle widthLimit:0 numLines:2 fontNum:F(15) textColor:COLOR_LABEL text:@""];
- }
- return _labelTitle;
- }
- - (UIImageView *)iconImg{
- if (_iconImg == nil) {
- _iconImg = [UIImageView new];
- _iconImg.widthHeight = XY(W(79),W(135));
- [GlobalMethod setRoundView:_iconImg color:[UIColor clearColor] numRound:7 width:0];
- }
- return _iconImg;
- }
- - (UILabel *)labelTime{
- if (_labelTime == nil) {
- _labelTime = [UILabel new];
- [GlobalMethod setLabel:_labelTime widthLimit:0 numLines:0 fontNum:F(13) textColor:[UIColor colorWithHexString:@"#898989"] text:@""];
- }
- return _labelTime;
- }
- #pragma mark 初始化
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = [UIColor whiteColor];
- self.backgroundColor = [UIColor whiteColor];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- [self.contentView addSubview:self.labelTitle];
- [self.contentView addSubview:self.iconImg];
- [self.contentView addSubview:self.labelTime];
- }
- return self;
- }
- #pragma mark 刷新cell
- - (void)resetCellWithModel:(ModelDocumentLibrary *)model{
- [self.contentView removeSubViewWithTag:TAG_LINE];//移除线
- //刷新view
- self.model=model;
- [self.labelTitle fitTitle:[UnPackStr(model.title) stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"] variable:SCREEN_WIDTH-self.iconImg.width-W(60)];
- self.labelTitle.leftTop = XY(W(20),W(35));
- [GlobalMethod setAttributeLabel:self.labelTitle content:[UnPackStr(model.title) stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"] width:self.labelTitle.width lineSpace:10];
- [self.iconImg sd_setImageWithURL:[NSURL URLWithString:UnPackStr(model.imageone)] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
- self.iconImg.rightTop = XY(SCREEN_WIDTH-W(20),self.labelTitle.top);
- [self.labelTime fitTitle:UnPackStr(model.createtime) variable:0];
- self.labelTime.leftTop = XY(W(20),self.labelTitle.bottom+W(29));
- self.height = [self.contentView addLineFrame:CGRectMake(W(20), self.iconImg.bottom+W(10), SCREEN_WIDTH-W(40), 1)];
- }
- @end
|