HomePageVC.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. //
  2. // HomePageVC.m
  3. // Blaufuchslive
  4. //
  5. // Created by 刘惠萍 on 2020/2/19.
  6. // Copyright © 2020 刘惠萍. All rights reserved.
  7. //
  8. #import "HomePageVC.h"
  9. #import "WKWebViewVC.h"
  10. #import "xingchuangke-Swift.h"
  11. @interface HomePageVC ()
  12. @property (strong, nonatomic) HomePageHeaderView *headerView;
  13. @property (strong, nonatomic) HomePageNavView *navView;
  14. @end
  15. @implementation HomePageVC
  16. - (HomePageNavView *)navView {
  17. if (!_navView) {
  18. _navView = [HomePageNavView new];
  19. _navView.frame = CGRectMake(0, 0, SCREEN_WIDTH, _navView.height);
  20. _navView.blockKF = ^{
  21. QYSource *source = [[QYSource alloc] init];
  22. source.title = @"客服";
  23. source.urlString = @"";
  24. QYSessionViewController *sessionViewController = [[QYSDK sharedSDK] sessionViewController];
  25. sessionViewController.sessionTitle = @"在线客服";
  26. sessionViewController.source = source;
  27. sessionViewController.hidesBottomBarWhenPushed = true;
  28. [GB_Nav pushViewController:sessionViewController animated:true];
  29. };
  30. }
  31. return _navView;
  32. }
  33. - (HomePageHeaderView *)headerView {
  34. if (!_headerView) {
  35. _headerView = [HomePageHeaderView new];
  36. self.headerView.frame = CGRectMake(W(0), 0, SCREEN_WIDTH, self.headerView.height);
  37. _headerView.blockModelBanner = ^(ModelBanner *model) {
  38. WKWebViewVC *vc=[WKWebViewVC new];
  39. vc.htmlString=UnPackStr(model.webUrl);
  40. vc.isH5=true;
  41. vc.isNav=true;
  42. vc.navStr=@"详情";
  43. [GB_Nav pushViewController:vc animated:true];
  44. };
  45. _headerView.blockKF = ^{
  46. QYSource *source = [[QYSource alloc] init];
  47. source.title = @"客服";
  48. source.urlString = @"";
  49. QYSessionViewController *sessionViewController = [[QYSDK sharedSDK] sessionViewController];
  50. sessionViewController.sessionTitle = @"在线客服";
  51. sessionViewController.source = source;
  52. sessionViewController.hidesBottomBarWhenPushed = true;
  53. [GB_Nav pushViewController:sessionViewController animated:true];
  54. };
  55. }
  56. return _headerView;
  57. }
  58. - (void)viewDidLoad {
  59. [super viewDidLoad];
  60. [self.view addSubview:self.navView];
  61. self.tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT -TABBAR_HEIGHT);
  62. self.navView.backgroundColor=[UIColor clearColor];
  63. self.tableView.tableHeaderView = self.headerView;
  64. [self requestShopLabelHomepage];
  65. [self.tableView registerClass:[DocumentLibraryCell class] forCellReuseIdentifier:@"DocumentLibraryCell"];
  66. }
  67. - (void)viewWillAppear:(BOOL)animated{
  68. [super viewWillAppear:animated];
  69. self.navigationController.navigationBarHidden = YES;
  70. [self requestList];
  71. }
  72. -(void)requestShopLabelHomepage{
  73. NSMutableArray *arr=[NSMutableArray new];
  74. [arr addObjectsFromArray:@[^(){
  75. ModelBaseData * model = [ModelBaseData new];
  76. model.imageName = @"商户录入";
  77. model.string=@"商户录入";
  78. model.blockClick = ^(ModelBaseData *m) {
  79. SelectPayBrandViewController *vc=[SelectPayBrandViewController new];
  80. [GB_Nav pushViewController:vc animated:true];
  81. };
  82. return model;
  83. }(),^(){
  84. ModelBaseData * model = [ModelBaseData new];
  85. model.imageName = @"邀请好友";
  86. model.string=@"邀请好友";
  87. model.blockClick = ^(ModelBaseData *model) {
  88. InviteViewController *vc=[InviteViewController new];
  89. [GB_Nav pushViewController:vc animated:true];
  90. };
  91. return model;
  92. }(),^(){
  93. ModelBaseData * model = [ModelBaseData new];
  94. model.imageName = @"我的代理";
  95. model.string=@"我的代理";
  96. model.blockClick = ^(ModelBaseData *m) {
  97. MyDelegateViewController *vc=[MyDelegateViewController new];
  98. [GB_Nav pushViewController:vc animated:true];
  99. };
  100. return model;
  101. }(),^(){
  102. ModelBaseData * model = [ModelBaseData new];
  103. model.imageName = @"商户管理";
  104. model.string=@"商户管理";
  105. model.blockClick = ^(ModelBaseData *m) {
  106. BrandListViewController *vc=[BrandListViewController new];
  107. vc.strTitle = @"商户管理";
  108. [GB_Nav pushViewController:vc animated:true];
  109. };
  110. return model;
  111. }(),^(){
  112. ModelBaseData * model = [ModelBaseData new];
  113. model.imageName = @"活动中心";
  114. model.string=@"活动中心";
  115. model.blockClick = ^(ModelBaseData *m) {
  116. ActiveListViewController *vc=[ActiveListViewController new];
  117. [GB_Nav pushViewController:vc animated:true];
  118. };
  119. return model;
  120. }(),^(){
  121. ModelBaseData * model = [ModelBaseData new];
  122. model.imageName = @"机具管理";
  123. model.string=@"机具管理";
  124. model.blockClick = ^(ModelBaseData *m) {
  125. PosManangerViewController *vc=[PosManangerViewController new];
  126. [GB_Nav pushViewController:vc animated:true];
  127. };
  128. return model;
  129. }(),^(){
  130. ModelBaseData * model = [ModelBaseData new];
  131. model.imageName = @"业绩管理";
  132. model.string=@"业绩管理";
  133. model.blockClick = ^(ModelBaseData *model) {
  134. BusinessMainViewController *vc=[BusinessMainViewController new];
  135. [GB_Nav pushViewController:vc animated:true];
  136. };
  137. return model;
  138. }(),^(){
  139. ModelBaseData * model = [ModelBaseData new];
  140. model.imageName = @"交易管理";
  141. model.string=@"交易管理";
  142. model.blockClick = ^(ModelBaseData *m) {
  143. BrandListViewController *vc=[BrandListViewController new];
  144. vc.strTitle = @"交易管理";
  145. [GB_Nav pushViewController:vc animated:true];
  146. };
  147. return model;
  148. }(),^(){
  149. ModelBaseData * model = [ModelBaseData new];
  150. model.imageName = @"我的资质";
  151. model.string=@"机具调拨";
  152. model.blockClick = ^(ModelBaseData *m) {
  153. PosTransferVC *vc=[PosTransferVC new];
  154. [GB_Nav pushViewController:vc animated:true];
  155. };
  156. return model;
  157. }(),^(){
  158. ModelBaseData * model = [ModelBaseData new];
  159. model.imageName = @"更多";
  160. model.string=@"更多";
  161. model.blockClick = ^(ModelBaseData *m) {
  162. [GlobalMethod showAlert:@"正在开发中..."];
  163. };
  164. return model;
  165. }()]];
  166. [self.headerView resetViewWithModel:arr];
  167. }
  168. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  169. {
  170. if (self.tableView.contentOffset.y <= 0)
  171. {
  172. self.tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT -TABBAR_HEIGHT);
  173. self.navView.backgroundColor=[UIColor clearColor];
  174. }else{
  175. self.tableView.frame = CGRectMake(0, NAVIGATIONBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT -TABBAR_HEIGHT-NAVIGATIONBAR_HEIGHT);
  176. self.navView.backgroundColor = [UIColor colorWithHexString:@"#55C5EB"];
  177. }
  178. NSLog(@"%.f",self.tableView.contentOffset.y);
  179. }
  180. #pragma mark table view delegate
  181. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  182. return self.aryDatas.count;
  183. }
  184. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  185. DocumentLibraryCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DocumentLibraryCell" forIndexPath:indexPath];
  186. [cell resetCellWithModel:self.aryDatas[indexPath.row]];
  187. return cell;
  188. }
  189. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  190. return [DocumentLibraryCell fetchHeight:self.aryDatas[indexPath.row]];
  191. }
  192. - (void)requestList{
  193. [RequestApi requestGetInformationListWithPage:@"1" size:@"20" typeId:@"FFFFFF" delegate:self success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
  194. NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"][@"dataList"] toAryWithModelName:@"ModelDocumentLibrary"];
  195. if (self.isRemoveAll) {
  196. [self.aryDatas removeAllObjects];
  197. }
  198. self.pageNum ++;
  199. if (!isAry(ary)) {
  200. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  201. }
  202. [self.aryDatas addObjectsFromArray:ary];
  203. [self.tableView reloadData];
  204. } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
  205. }];
  206. }
  207. @end
  208. @implementation HomePageHeaderView
  209. #pragma mark 懒加载
  210. - (UIImageView *)backImg{
  211. if (_backImg == nil) {
  212. _backImg = [UIImageView new];
  213. _backImg.image = [UIImage imageNamed:@"Home page-background"];
  214. _backImg.widthHeight = XY(SCREEN_WIDTH,W(200)+NAVIGATIONBAR_HEIGHT);
  215. }
  216. return _backImg;
  217. }
  218. - (AutoScView *)headerView{
  219. if (_headerView == nil) {
  220. _headerView = [AutoScView new];
  221. _headerView.frame = CGRectMake(W(0), 0, SCREEN_WIDTH-W(40),W(80));
  222. _headerView.backgroundColor = [UIColor whiteColor];
  223. _headerView.isShowProductImageStyle = true;
  224. [_headerView timerStart];
  225. _headerView.pageCurrentColor = [UIColor whiteColor];
  226. _headerView.pageDefaultColor = [UIColor colorWithHexString:@"#E0E0E0"];
  227. [GlobalMethod setRoundView:_headerView color:COLOR_BLUE numRound:5 width:0];
  228. _headerView.isShowNum = true;
  229. WEAKSELF
  230. _headerView.blockModel = ^(ModelBanner *model) {
  231. if (weakSelf.blockModelBanner) {
  232. weakSelf.blockModelBanner(model);
  233. }
  234. };
  235. }
  236. return _headerView;
  237. }
  238. - (UILabel *)labelTitleTS{
  239. if (_labelTitleTS == nil) {
  240. _labelTitleTS = [UILabel new];
  241. [GlobalMethod setLabel:_labelTitleTS widthLimit:0 numLines:0 fontNum:F(20) textColor:COLOR_LABEL text:@""];
  242. self.labelTitleTS.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
  243. }
  244. return _labelTitleTS;
  245. }
  246. - (UIImageView *)pView{
  247. if (_pView == nil) {
  248. _pView = [UIImageView new];
  249. [GlobalMethod setRoundView:_pView color:[UIColor clearColor] numRound:8 width:0];
  250. }
  251. return _pView;
  252. }
  253. - (UIImageView *)zView{
  254. if (_zView == nil) {
  255. _zView = [UIImageView new];
  256. [GlobalMethod setRoundView:_zView color:[UIColor clearColor] numRound:8 width:0];
  257. }
  258. return _zView;
  259. }
  260. - (UIImageView *)hotView{
  261. if (_hotView == nil) {
  262. _hotView = [UIImageView new];
  263. [GlobalMethod setRoundView:_hotView color:[UIColor clearColor] numRound:8 width:0];
  264. }
  265. return _hotView;
  266. }
  267. - (UILabel *)labelTitleWA{
  268. if (_labelTitleWA == nil) {
  269. _labelTitleWA = [UILabel new];
  270. [GlobalMethod setLabel:_labelTitleWA widthLimit:0 numLines:0 fontNum:F(20) textColor:COLOR_LABEL text:@""];
  271. self.labelTitleWA.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
  272. }
  273. return _labelTitleWA;
  274. }
  275. -(UIButton *)moreBtn{
  276. if (_moreBtn == nil) {
  277. _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  278. _moreBtn.tag = 13;
  279. [_moreBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  280. _moreBtn.titleLabel.font = [UIFont systemFontOfSize:F(13)];
  281. [_moreBtn setTitle:@"更多 >" forState:(UIControlStateNormal)];
  282. _moreBtn.widthHeight = XY(W(60),W(40));
  283. [_moreBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, - _moreBtn.imageView.image.size.width, 0, _moreBtn.imageView.image.size.width)];
  284. [_moreBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _moreBtn.titleLabel.bounds.size.width, 0, -_moreBtn.titleLabel.bounds.size.width)];
  285. [_moreBtn setTitleColor:[UIColor colorWithHexString:@"#898989"] forState:(UIControlStateNormal)];
  286. }
  287. return _moreBtn;
  288. }
  289. - (UIControl *)backImgControl{
  290. if (_backImgControl == nil) {
  291. _backImgControl = [UIControl new];
  292. _backImgControl.tag = 1;
  293. [_backImgControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  294. _backImgControl.backgroundColor = [UIColor clearColor];
  295. }
  296. return _backImgControl;
  297. }
  298. - (UIControl *)pViewControl{
  299. if (_pViewControl == nil) {
  300. _pViewControl = [UIControl new];
  301. _pViewControl.tag = 2;
  302. [_pViewControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  303. _pViewControl.backgroundColor = [UIColor clearColor];
  304. }
  305. return _pViewControl;
  306. }
  307. - (UIControl *)zViewControl{
  308. if (_zViewControl == nil) {
  309. _zViewControl = [UIControl new];
  310. _zViewControl.tag = 3;
  311. [_zViewControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  312. _zViewControl.backgroundColor = [UIColor clearColor];
  313. }
  314. return _zViewControl;
  315. }
  316. - (UIControl *)hotViewControl{
  317. if (_hotViewControl == nil) {
  318. _hotViewControl = [UIControl new];
  319. _hotViewControl.tag = 4;
  320. [_hotViewControl addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  321. _hotViewControl.backgroundColor = [UIColor clearColor];
  322. }
  323. return _hotViewControl;
  324. }
  325. - (NSMutableArray *)shopLabelList{
  326. if (!_shopLabelList) {
  327. _shopLabelList = [NSMutableArray new];
  328. }
  329. return _shopLabelList;
  330. }
  331. #pragma mark 初始化
  332. - (instancetype)initWithFrame:(CGRect)frame{
  333. self = [super initWithFrame:frame];
  334. if (self) {
  335. self.backgroundColor = [UIColor whiteColor];
  336. self.width = SCREEN_WIDTH;
  337. [self addSubView];
  338. }
  339. return self;
  340. }
  341. //添加subview
  342. - (void)addSubView{
  343. [self addSubview:self.backImg];
  344. [self addSubview:self.headerView];
  345. [self addSubview:self.labelTitleTS];
  346. [self addSubview:self.pView];
  347. [self addSubview:self.zView];
  348. [self addSubview:self.hotView];
  349. [self addSubview:self.labelTitleWA];
  350. [self addSubview:self.moreBtn];
  351. [self addSubview:self.backImgControl];
  352. [self addSubview:self.pViewControl];
  353. [self addSubview:self.zViewControl];
  354. [self addSubview:self.hotViewControl];
  355. [self requestBannerList];
  356. //初始化页面
  357. [self resetViewWithModel:nil];
  358. }
  359. #pragma mark 刷新view
  360. - (void)resetViewWithModel:(NSMutableArray *)model{
  361. [self removeSubViewWithTag:TAG_LINE];
  362. //刷新view
  363. self.backImg.leftTop = XY(0,0);
  364. self.backImgControl.widthHeight = self.backImg.widthHeight;
  365. self.backImgControl.leftTop = self.backImg.leftTop;
  366. [RequestApi requestFindAdvertisingWheelWithPosition:@"4" delegate:nil success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
  367. NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"] toAryWithModelName:@"ModelBanner"];
  368. NSMutableArray *aryData=[NSMutableArray new];
  369. for (ModelBanner *model in ary) {
  370. [aryData addObject:model.imgPath];
  371. self.titleStr=model.webUrl;
  372. }
  373. [self.backImg sd_setImageWithURL:[NSURL URLWithString:aryData[0]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  374. } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
  375. }];
  376. self.shopLabelList=model.mutableCopy;
  377. CGFloat x = W(10);//
  378. CGFloat y = self.backImg.bottom+W(20);//
  379. CGFloat height = self.backImg.bottom+W(20);//
  380. //刷新view
  381. for (int i = 0; i < model.count; i++) {
  382. ModelBaseData * modelReplay =model[i];
  383. HomePageBtnView * btnItem = [HomePageBtnView new];
  384. btnItem.model = modelReplay;
  385. btnItem.tag = TAG_LINE;
  386. btnItem.blockClick = ^(ModelBaseData *model) {
  387. if (modelReplay.blockClick) {
  388. modelReplay.blockClick(model);
  389. }
  390. };
  391. btnItem.width =(SCREEN_WIDTH-W(10)*2-W(10)*4)/5;
  392. [btnItem resetViewWithModel:modelReplay width:(SCREEN_WIDTH-W(10)*2-W(10)*4)/5];
  393. //根据计算文字的大小
  394. if (btnItem.width + x > SCREEN_WIDTH) {
  395. y += btnItem.height +W(40);
  396. x = W(10);
  397. }
  398. btnItem.leftTop = XY(x, y);
  399. [self addSubview:btnItem];
  400. if (i != model.count) {
  401. x = btnItem.right +W(10);
  402. }
  403. height = btnItem.bottom;
  404. }
  405. self.headerView.leftTop = XY(W(20),height+W(40));
  406. [self.labelTitleTS fitTitle:@"特色服务" variable:0];
  407. self.labelTitleTS.leftTop = XY(W(20),W(35)+self.headerView.bottom);
  408. [RequestApi requestFindAdvertisingWheelWithPosition:@"3" delegate:nil success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
  409. NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"] toAryWithModelName:@"ModelBanner"];
  410. NSMutableArray *aryData=[NSMutableArray new];
  411. for (ModelBanner *model in ary) {
  412. [aryData addObject:model.imgPath];
  413. }
  414. if (isAry(aryData)&&aryData.count==3) {
  415. [self.zView sd_setImageWithURL:[NSURL URLWithString:aryData[0]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  416. [self.pView sd_setImageWithURL:[NSURL URLWithString:aryData[2]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  417. [self.hotView sd_setImageWithURL:[NSURL URLWithString:aryData[1]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  418. self.pView.widthHeight = XY((SCREEN_WIDTH-W(48))/2, W(220));
  419. self.zView.widthHeight = XY(self.pView.width, (self.pView.height-W(5))/2);
  420. self.hotView.widthHeight = XY(self.pView.width, self.zView.height);
  421. self.pViewControl.widthHeight=self.pView.widthHeight;
  422. self.zViewControl.widthHeight=self.zView.widthHeight;
  423. self.hotViewControl.widthHeight=self.hotView.widthHeight;
  424. self.zView.leftTop = XY(W(20),self.labelTitleTS.bottom+W(22));
  425. self.zViewControl.leftTop=self.zView.leftTop;
  426. self.hotView.leftTop = XY(self.zView.left,self.zView.bottom+W(5));
  427. self.hotViewControl.leftTop=self.hotView.leftTop;
  428. self.pView.leftTop = XY(W(5)+self.zView.right,self.zView.top);
  429. self.pViewControl.leftTop=self.pView.leftTop;
  430. self.zView.hidden=false;
  431. self.hotView.hidden=false;
  432. self.pView.hidden=false;
  433. self.pViewControl.hidden=false;
  434. self.zViewControl.hidden=false;
  435. self.hotViewControl.hidden=false;
  436. [self.labelTitleWA fitTitle:@"文案库" variable:0];
  437. self.labelTitleWA.leftTop = XY(W(20),self.zView.bottom+W(35));
  438. self.moreBtn.rightCenterY = XY(SCREEN_WIDTH-W(20),self.labelTitleWA.centerY);
  439. self.height = self.labelTitleWA.bottom+W(10);
  440. }else if (isAry(aryData)&&aryData.count!=3) {
  441. [self.zView sd_setImageWithURL:[NSURL URLWithString:aryData[0]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  442. [self.hotView sd_setImageWithURL:[NSURL URLWithString:aryData[1]] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  443. self.hotView.widthHeight = XY((SCREEN_WIDTH-W(48))/2, (W(220)-W(5))/2);
  444. self.zView.widthHeight = XY(self.hotView.width, self.hotView.height);
  445. self.hotViewControl.widthHeight=self.hotView.widthHeight;
  446. self.zViewControl.widthHeight=self.zView.widthHeight;
  447. self.zView.leftTop = XY(W(20),self.labelTitleTS.bottom+W(22));
  448. self.zViewControl.leftTop=self.zView.leftTop;
  449. self.hotView.leftTop = XY(W(5)+self.zView.right,self.zView.top);
  450. self.hotViewControl.leftTop=self.hotView.leftTop;
  451. self.zView.hidden=false;
  452. self.hotView.hidden=false;
  453. self.pView.hidden=true;
  454. self.pViewControl.hidden=true;
  455. self.zViewControl.hidden=false;
  456. self.hotViewControl.hidden=false;
  457. [self.labelTitleWA fitTitle:@"文案库" variable:0];
  458. self.labelTitleWA.leftTop = XY(W(20),self.zView.bottom+W(35));
  459. self.moreBtn.rightCenterY = XY(SCREEN_WIDTH-W(20),self.labelTitleWA.centerY);
  460. self.height = self.labelTitleWA.bottom+W(10);
  461. }
  462. } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
  463. }];
  464. self.height = self.labelTitleWA.bottom+W(10);
  465. }
  466. //REQUEST
  467. -(void)requestBannerList{
  468. [RequestApi requestFindAdvertisingWheelWithPosition:@"0" delegate:nil success:^(NSDictionary * _Nonnull response, id _Nonnull mark) {
  469. NSArray * ary = [GlobalMethod exchangeDic:response[@"dataInfo"] toAryWithModelName:@"ModelBanner"];
  470. NSMutableArray *aryData=[NSMutableArray new];
  471. for (ModelBanner *model in ary) {
  472. [aryData addObject:model.imgPath];
  473. }
  474. self.headerView.aryImageModel=ary.mutableCopy;
  475. [self.headerView resetWithImageAry:aryData];
  476. } failure:^(NSString * _Nonnull errorStr, id _Nonnull mark) {
  477. }];
  478. }
  479. #pragma mark 点击事件
  480. - (void)btnClick:(UIButton *)sender{
  481. switch (sender.tag) {
  482. case 13:
  483. {
  484. // ArticleManagerViewController *vc=[ArticleManagerViewController new];
  485. // [GB_Nav pushViewController:vc animated:true];
  486. [GB_Nav pushVCName:@"DocumentLibraryHomeVC" animated:true];
  487. }
  488. break;
  489. case 1:
  490. {
  491. WKWebViewVC *vc=[WKWebViewVC new];
  492. vc.htmlString=UnPackStr(self.titleStr);
  493. vc.isH5=true;
  494. vc.isNav=true;
  495. vc.navStr=@"详情";
  496. [GB_Nav pushViewController:vc animated:true];
  497. }
  498. break;
  499. case 3:
  500. {
  501. if (self.blockKF) {
  502. self.blockKF();
  503. }
  504. }
  505. break;
  506. case 2:
  507. {
  508. ApplyCardTabBarViewController *vc=[ApplyCardTabBarViewController new];
  509. vc.type = 0;
  510. [GB_Nav pushViewController:vc animated:true];
  511. }
  512. break;
  513. case 4:
  514. {
  515. StudyViewController *vc = [StudyViewController new];
  516. [GB_Nav pushViewController:vc animated:true];
  517. }
  518. break;
  519. default:
  520. break;
  521. }
  522. }
  523. @end
  524. @implementation HomePageNavView
  525. #pragma mark 懒加载
  526. -(UIButton *)addBtn{
  527. if (_addBtn == nil) {
  528. _addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  529. _addBtn.tag = 2;
  530. [_addBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  531. _addBtn.widthHeight = XY(W(30),W(40));
  532. [_addBtn setImage:[UIImage imageNamed:@"消息"] forState:(UIControlStateNormal)];
  533. }
  534. return _addBtn;
  535. }
  536. -(UIButton *)kfBtn{
  537. if (_kfBtn == nil) {
  538. _kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  539. _kfBtn.tag = 1;
  540. [_kfBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  541. _kfBtn.widthHeight = XY(W(30),W(40));
  542. [_kfBtn setImage:[UIImage imageNamed:@"客服"] forState:(UIControlStateNormal)];
  543. }
  544. return _kfBtn;
  545. }
  546. #pragma mark 初始化
  547. - (instancetype)initWithFrame:(CGRect)frame{
  548. self = [super initWithFrame:frame];
  549. if (self) {
  550. self.backgroundColor = [UIColor clearColor];
  551. self.width = SCREEN_WIDTH;
  552. [self addSubView];
  553. }
  554. return self;
  555. }
  556. //添加subview
  557. - (void)addSubView{
  558. [self addSubview:self.kfBtn];
  559. [self addSubview:self.addBtn];
  560. //初始化页面
  561. [self resetViewWithModel:nil];
  562. }
  563. #pragma mark 刷新view
  564. - (void)resetViewWithModel:(NSString *)model{
  565. self.addBtn.rightCenterY = XY(SCREEN_WIDTH-W(15),NAVIGATIONBAR_HEIGHT/2+W(13));
  566. self.kfBtn.rightCenterY = XY(self.addBtn.left-W(15),self.addBtn.centerY);
  567. self.height=NAVIGATIONBAR_HEIGHT;
  568. }
  569. #pragma mark 点击事件
  570. - (void)btnClick:(UIButton *)sender{
  571. switch (sender.tag) {
  572. case 1:
  573. {
  574. if (self.blockKF) {
  575. self.blockKF();
  576. }
  577. }
  578. break;
  579. case 2:
  580. {
  581. NewsListViewController *vc = [NewsListViewController new];
  582. [GB_Nav pushViewController:vc animated:true];
  583. }
  584. break;
  585. default:
  586. break;
  587. }
  588. }
  589. @end
  590. @implementation HomePageBtnView
  591. #pragma mark 懒加载
  592. - (UIImageView *)backImg{
  593. if (_backImg == nil) {
  594. _backImg = [UIImageView new];
  595. _backImg.contentMode = UIViewContentModeScaleAspectFit;
  596. }
  597. return _backImg;
  598. }
  599. - (UILabel *)labelNum{
  600. if (_labelNum == nil) {
  601. _labelNum = [UILabel new];
  602. [GlobalMethod setLabel:_labelNum widthLimit:0 numLines:0 fontNum:F(13) textColor:COLOR_LABEL text:@""];
  603. self.labelNum.font = [UIFont fontWithName:@"Helvetica-Bold" size:F(13)];
  604. }
  605. return _labelNum;
  606. }
  607. #pragma mark 初始化
  608. - (instancetype)initWithFrame:(CGRect)frame{
  609. self = [super initWithFrame:frame];
  610. if (self) {
  611. self.backgroundColor = [UIColor clearColor];
  612. [self addSubView];
  613. }
  614. return self;
  615. }
  616. //添加subview
  617. - (void)addSubView{
  618. [self addSubview:self.backImg];
  619. [self addSubview:self.labelNum];
  620. [self addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
  621. }
  622. #pragma mark 刷新view
  623. - (void)resetViewWithModel:(ModelBaseData *)model width:(CGFloat)widthLimit{
  624. [self.backImg removeSubViewWithTag:TAG_LINE];;//移除线
  625. //刷新view
  626. self.model=model;
  627. self.width=widthLimit;
  628. _backImg.widthHeight = XY(W(35),W(35));
  629. _backImg.image = [UIImage imageNamed:UnPackStr(model.imageName)];
  630. self.backImg.centerXTop = XY(widthLimit/2,W(0));
  631. [self.labelNum fitTitle:UnPackStr(model.string) variable:widthLimit];
  632. self.labelNum.centerXTop = XY(widthLimit/2,W(13)+self.backImg.bottom);
  633. self.height=self.labelNum.bottom+W(5);
  634. }
  635. #pragma mark 点击事件
  636. - (void)btnClick:(UIButton *)sender{
  637. if (self.blockClick) {
  638. self.blockClick(self.model);
  639. }
  640. }
  641. @end
  642. @implementation DocumentLibraryCell
  643. #pragma mark 懒加载
  644. - (UILabel *)labelTitle{
  645. if (_labelTitle == nil) {
  646. _labelTitle = [UILabel new];
  647. [GlobalMethod setLabel:_labelTitle widthLimit:0 numLines:2 fontNum:F(15) textColor:COLOR_LABEL text:@""];
  648. }
  649. return _labelTitle;
  650. }
  651. - (UIImageView *)iconImg{
  652. if (_iconImg == nil) {
  653. _iconImg = [UIImageView new];
  654. _iconImg.widthHeight = XY(W(79),W(135));
  655. [GlobalMethod setRoundView:_iconImg color:[UIColor clearColor] numRound:7 width:0];
  656. }
  657. return _iconImg;
  658. }
  659. - (UILabel *)labelTime{
  660. if (_labelTime == nil) {
  661. _labelTime = [UILabel new];
  662. [GlobalMethod setLabel:_labelTime widthLimit:0 numLines:0 fontNum:F(13) textColor:[UIColor colorWithHexString:@"#898989"] text:@""];
  663. }
  664. return _labelTime;
  665. }
  666. #pragma mark 初始化
  667. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  668. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  669. if (self) {
  670. self.contentView.backgroundColor = [UIColor whiteColor];
  671. self.backgroundColor = [UIColor whiteColor];
  672. self.selectionStyle = UITableViewCellSelectionStyleNone;
  673. [self.contentView addSubview:self.labelTitle];
  674. [self.contentView addSubview:self.iconImg];
  675. [self.contentView addSubview:self.labelTime];
  676. }
  677. return self;
  678. }
  679. #pragma mark 刷新cell
  680. - (void)resetCellWithModel:(ModelDocumentLibrary *)model{
  681. [self.contentView removeSubViewWithTag:TAG_LINE];//移除线
  682. //刷新view
  683. self.model=model;
  684. [self.labelTitle fitTitle:[UnPackStr(model.title) stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"] variable:SCREEN_WIDTH-self.iconImg.width-W(60)];
  685. self.labelTitle.leftTop = XY(W(20),W(35));
  686. [GlobalMethod setAttributeLabel:self.labelTitle content:[UnPackStr(model.title) stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"] width:self.labelTitle.width lineSpace:10];
  687. [self.iconImg sd_setImageWithURL:[NSURL URLWithString:UnPackStr(model.imageone)] placeholderImage:[UIImage imageNamed:IMAGE_HEAD_DEFAULT]];
  688. self.iconImg.rightTop = XY(SCREEN_WIDTH-W(20),self.labelTitle.top);
  689. [self.labelTime fitTitle:UnPackStr(model.createtime) variable:0];
  690. self.labelTime.leftTop = XY(W(20),self.labelTitle.bottom+W(29));
  691. self.height = [self.contentView addLineFrame:CGRectMake(W(20), self.iconImg.bottom+W(10), SCREEN_WIDTH-W(40), 1)];
  692. }
  693. @end