Ei kuvausta

HomeViewController.m 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. //
  2. // HomepageViewController.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 15/5/28.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "HomeViewController.h"
  9. #import "FKHomeViewModel.h"
  10. #import "FKNaviBarControl.h"
  11. #import "FKHomePersonInfoCell.h"
  12. #import "FKHomeFollowInfoCell.h"
  13. #import "FKHomeOrderHeaderCell.h"
  14. #import "FKHomeOrderEntranceCell.h"
  15. #import "FKHomeImageTextCell.h"
  16. #import "FLControllerHelper.h"
  17. #import "FirstLinkAppDelegate.h"
  18. #import "SessionListController.h"
  19. #import "SettingViewController.h"
  20. #import "AvatarViewController.h"
  21. #import "NicknameViewController.h"
  22. #import "FKPointController.h"
  23. #import "FKSignDoneView.h"
  24. #import "FKPriceWarnListController.h"
  25. #import "CollectViewController.h"
  26. #import "FKMyBookController.h"
  27. #import "FKOrderSegmentController.h"
  28. #import "FKMyVipController.h"
  29. #import "FKCouponController.h"
  30. #import "FKPushSettingController.h"
  31. #import "WebViewController.h"
  32. #import "UIImageView+FLAddition.h"
  33. #import "FKPersonOrderReform.h"
  34. #import "FKPersonOrderRequest.h"
  35. #import "UserDefaultManager.h"
  36. #import "FKHomeRequest.h"
  37. #import "FKHomeReform.h"
  38. #import "FKPointRequest.h"
  39. #import "FKPointReform.h"
  40. #import "FKWantBuyController.h"
  41. #import "FKWantBuyRequest.h"
  42. #import "FKWantBuyReform.h"
  43. #import "GuideView.h"
  44. const int FKOrderBadgeRequest = 1001;
  45. const int FKCouponCountRequest = 1002;
  46. const int FKSignDetailRequest = 1003;
  47. const int FKSignTodayRequest = 1004;
  48. const int FKHomeCountRequest = 1005;
  49. static NSString *WANT_BUY_IS_SHOW_FIRST_KEY = @"WANT_BUY_IS_SHOW_FIRST_KEY";
  50. static NSString *GUIDE_NOTIFICATION_IMAGENAME = @"guide_notification";
  51. static NSString *GUIDE_INTEGRAL_IMAGENAME = @"guide_integral";
  52. static NSString *GUIDE_WANGBUY_IMAGENAME = @"guide_want_buy";
  53. @interface HomeViewController ()
  54. <UINavigationControllerDelegate, UIScrollViewDelegate,FKHomeFollowCellDelegate,FLNetworkDelegate>
  55. @property (nonatomic, strong) FKHomeViewModel *viewModel;
  56. @property (nonatomic, strong) FKNaviBarControl *leftControl;
  57. @property (nonatomic, strong) FKNaviBarControl *rightControl;
  58. @property (nonatomic, strong) UILabel *tabbarBadgeView;
  59. @property (nonatomic, strong) FKHomePersonInfoCell *personCell;
  60. @property (nonatomic, assign) NSInteger wantBuyTotal;
  61. @end
  62. @implementation HomeViewController
  63. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  64. self = [super initWithCoder:aDecoder];
  65. if (self) {
  66. [self configTabbarBadgeView];
  67. [self configUnreadRefreshCallBackBeforeViewDidLoad];
  68. [[FKMessageManager sharedInstance] refreshMessageUnreadMessage];
  69. }
  70. return self;
  71. }
  72. - (void)loadView {
  73. [super loadView];
  74. self.navigationItem.title = @"我的";
  75. [self.view addSubview:self.tableView];
  76. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.edges.equalTo(self.view);
  78. }];
  79. }
  80. - (void)dealloc {
  81. [self.tabbarBadgeView removeFromSuperview];
  82. }
  83. - (void)viewDidLoad {
  84. [super viewDidLoad];
  85. [self.tabbarBadgeView removeFromSuperview];
  86. }
  87. - (void)viewWillAppear:(BOOL)animated {
  88. [super viewWillAppear:animated];
  89. [UIApplication sharedApplication].statusBarHidden = NO;
  90. [self.navigationController setNavigationBarHidden:NO animated:NO];
  91. [self configLeftNaviItem];
  92. [self configRightNaviItem];
  93. [self configMessageUnreadBadgeNumber];
  94. }
  95. - (void)viewDidAppear:(BOOL)animated {
  96. [super viewDidAppear:animated];
  97. if ([FKUserManager sharedManager].applicationMode == ApplicationModeVisitor) {
  98. self.viewModel.badgeItem = nil;
  99. self.tabbarBadgeView.hidden = YES;
  100. } else {
  101. [self requestBadgeInfo];
  102. [self requstCouponCountData];
  103. [self requestSignDetailData];
  104. [self requestHomeCountData];
  105. }
  106. [self configUnreadRefreshCallBackAfterViewDidLoad];
  107. [self.tableView reloadData];
  108. [self showGuideView];
  109. }
  110. #pragma mark - Request
  111. - (void)requestBadgeInfo {
  112. [FKPersonOrderRequest requestOrderBadge:FKOrderBadgeRequest deleagate:self];
  113. }
  114. -(void)requstCouponCountData {
  115. [FKHomeRequest requestItems:FKCouponCountRequest deleagate:self];
  116. }
  117. - (void)requestSignDetailData {
  118. [FKPointRequest reqPointDataWithIdentify:FKSignDetailRequest delegate:self];
  119. }
  120. - (void)requestHomeCountData {
  121. [FKHomeRequest requestCount:FKHomeCountRequest deleagate:self];
  122. }
  123. - (void)refreshControl:(FKRefreshControl *)refreshControl didEngageRefreshDirection:(RefreshDirection)direction {
  124. if (RefreshDirectionTop == direction) {
  125. [self requestBadgeInfo];
  126. [self requstCouponCountData];
  127. [self requestSignDetailData];
  128. [self requestHomeCountData];
  129. }
  130. }
  131. #pragma mark - response
  132. - (void)networkDidSuccessResponse:(NSDictionary *)response identify:(int)identify header:(MSGHeader *)header {
  133. [self.refreshControl finishRefreshingDirection:RefreshDirectionTop];
  134. [self.hudView hide:NO];
  135. if ([header.code intValue] == RESPONSE_MSG_NORMAL) {
  136. if (identify == FKOrderBadgeRequest) {
  137. self.viewModel.badgeItem = [FKPersonOrderReform parseOrderBadge:response];
  138. } else if (identify == FKCouponCountRequest) {
  139. self.viewModel.couponCount = [FKHomeReform parseCouponCount:response];
  140. self.viewModel.serverTime = (self.viewModel.couponCount > 0 ? [FKHomeReform parseServerTime:response] : nil);
  141. } else if (identify == FKSignDetailRequest) {
  142. self.viewModel.signModel = [FKPointReform parserDataModelWithDict:response];
  143. } else if (identify == FKSignTodayRequest) {
  144. self.viewModel.signModel.signToday = YES;
  145. [self.personCell setShowSignedBtn];
  146. FKPointSignItem *item = [FKPointReform parserSignInfoWithDict:response];
  147. [FKSignDoneView showInView:self.view.window
  148. withNextDay:item.nextDayScore
  149. score:item.score
  150. bgImage:nil
  151. completion:^(BOOL finished) {
  152. [self.personCell animationHideSignButtonCompletion:^(BOOL finished) {
  153. [self requestHomeCountData];
  154. }];
  155. }];
  156. return;
  157. } else if (identify == FKHomeCountRequest) {
  158. FKHomeCountModel *model = [FKHomeCountModel new];
  159. [model mts_setValuesForKeysWithDictionary:response[@"data"]];
  160. self.viewModel.countModel = model;
  161. }
  162. [self.tableView reloadData];
  163. }
  164. }
  165. - (void)networkDidReceiveError:(NSError *)error identify:(int)identify header:(MSGHeader *)header{
  166. [self.refreshControl finishRefreshingDirection:RefreshDirectionTop];
  167. [self.hudView hide:NO];
  168. [FLProgressHUDHelper showText:header.msg inView:self.view];
  169. }
  170. #pragma mark - TableView Delegate
  171. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  172. return [self.viewModel numberOfSectionsInTableView];
  173. }
  174. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  175. return [self.viewModel numberOfRowsInSection:section];
  176. }
  177. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  178. return 10;
  179. }
  180. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  181. return CGFLOAT_MIN;
  182. }
  183. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  184. return [self.viewModel heightForRowAtIndexPath:indexPath];
  185. }
  186. - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  187. kHomeCellType cellType = [self.viewModel cellTypeForIndexPath:indexPath];
  188. switch (cellType) {
  189. case kHomeCellTypePersonInfo: {
  190. FKHomePersonInfoCell *infoCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([FKHomePersonInfoCell class])];
  191. [self configPersonInfoCellWithAction:infoCell];
  192. self.personCell = infoCell;
  193. [infoCell fk_configWithViewModel:self.viewModel indexPath:indexPath];
  194. return infoCell;
  195. break;
  196. }
  197. case kHomeCellTypeFollow: {
  198. FKHomeFollowInfoCell *followCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([FKHomeFollowInfoCell class])];
  199. followCell.delegate = self;
  200. [followCell fk_configWithViewModel:self.viewModel indexPath:indexPath];
  201. return followCell;
  202. break;
  203. }
  204. case kHomeCellTypeOrder: {
  205. FKHomeOrderEntranceCell *orderCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([FKHomeOrderEntranceCell class])];
  206. orderCell.waitPayStr = self.viewModel.badgeItem.nonpaymentOrderBadge;
  207. WeakSelf(weakSelf);
  208. orderCell.enterOrderAction = ^(FKPersonOrderClassify type){
  209. [weakSelf pushOrderControllerWithType:type];
  210. };
  211. return orderCell;
  212. }
  213. case kHomeCellTypeVIP:
  214. case kHomeCellTypeCoupon:
  215. case kHomeCellTypeHelpBuy:
  216. case kHomeCellTypePush:
  217. case kHomeCellTypeConsult: {
  218. FKHomeImageTextCell *imageCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([FKHomeImageTextCell class])];
  219. [imageCell fk_configWithViewModel:self.viewModel indexPath:indexPath];
  220. return imageCell;
  221. break;
  222. }
  223. default:
  224. break;
  225. }
  226. return [[UITableViewCell alloc] init];
  227. }
  228. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  229. kHomeCellType cellType = [self.viewModel cellTypeForIndexPath:indexPath];
  230. switch (cellType) {
  231. case kHomeCellTypeVIP:
  232. case kHomeCellTypeCoupon:
  233. case kHomeCellTypeHelpBuy:
  234. case kHomeCellTypePush: {
  235. if (cellType == kHomeCellTypeVIP) {
  236. [self.viewModel shownVipRedpointGuide];
  237. [self.tableView reloadData];
  238. }
  239. if ([FKUserManager sharedManager].applicationMode == ApplicationModeVisitor) {
  240. [self showLoginActionMenu];
  241. } else {
  242. [self pushControllerWithCellType:cellType];
  243. }
  244. break;
  245. }
  246. case kHomeCellTypeConsult: {
  247. [self pushWebController];
  248. break;
  249. }
  250. default:
  251. break;
  252. }
  253. }
  254. #pragma mark - Push Controller
  255. - (void)pushControllerWithCellType:(kHomeCellType)cellType {
  256. UIViewController *controller;
  257. switch (cellType) {
  258. case kHomeCellTypeOrderHeader: {
  259. controller = [FKOrderSegmentController new];
  260. break;
  261. }
  262. case kHomeCellTypeVIP: {
  263. controller = [FKMyVipController new];
  264. break;
  265. }
  266. case kHomeCellTypeCoupon: {
  267. if ([self.viewModel needShowInvalidCouponMsg]){
  268. [self.viewModel saveLastShowInvalidCouponMsgTime];
  269. }
  270. controller = [FKCouponController new];
  271. break;
  272. }
  273. case kHomeCellTypeHelpBuy: {
  274. controller = [FKWantBuyController new];
  275. break;
  276. }
  277. case kHomeCellTypePush: {
  278. controller = [FKPushSettingController new];
  279. break;
  280. }
  281. default:
  282. break;
  283. }
  284. if (controller) {
  285. controller.hidesBottomBarWhenPushed = YES;
  286. [self.navigationController pushViewController:controller animated:YES];
  287. }
  288. }
  289. - (void)pushController:(UIViewController *)controller shouldLogin:(BOOL)shouldLogin {
  290. if (shouldLogin) {
  291. if (![FKUserManager isUserLogin]) {
  292. [self showLoginActionMenu];
  293. return;
  294. }
  295. }
  296. if (controller) {
  297. controller.hidesBottomBarWhenPushed = YES;
  298. [self.navigationController pushViewController:controller animated:YES];
  299. }
  300. }
  301. - (IBAction)pushMessageController {
  302. [self pushController:[[SessionListController alloc] init] shouldLogin:YES];
  303. }
  304. - (IBAction)pushSettingController:(id)sender {
  305. [self pushController:[[SettingViewController alloc] init] shouldLogin:YES];
  306. }
  307. - (IBAction)clickPersonNicknameAction:(id)sender {
  308. if (![FKUserManager isUserLogin]) {
  309. [FLControllerHelper presentLoginViewController];
  310. } else {
  311. NicknameViewController *controller = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:@"NicknameViewController"];
  312. controller.type = NicknameControllerTypeModify;
  313. [self pushController:controller shouldLogin:YES];
  314. }
  315. }
  316. - (IBAction)clickPersonAvatarAction:(id)sender {
  317. if (![FKUserManager isUserLogin]) {
  318. [FLControllerHelper presentLoginViewController];
  319. } else {
  320. AvatarViewController *controller = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:@"AvatarViewController"];
  321. controller.type = AvatarControllerTypeModify;
  322. [self pushController:controller shouldLogin:YES];
  323. }
  324. }
  325. - (IBAction)clickPersonPointAction:(id)sender {
  326. FKPointController *controller = [FKPointController new];
  327. [self pushController:controller shouldLogin:YES];
  328. }
  329. - (IBAction)clickPersonSignAction:(id)sender {
  330. if (![FKUserManager isUserLogin]) {
  331. [self showLoginActionMenu];
  332. } else if (self.viewModel.signModel.signToday == NO) {
  333. [FKPointRequest requestSignState:FKSignTodayRequest deleagate:self];
  334. }
  335. }
  336. #pragma mark - Push Controller - FKHomeFollowCellDelegate
  337. - (void)followClickCell:(id)cell index:(NSInteger)index {
  338. if (index == 0) {
  339. [self pushController:[FKPriceWarnListController new] shouldLogin:YES];
  340. } else if (index == 1) {
  341. [self pushController:[CollectViewController new]shouldLogin:YES];
  342. } else if (index == 2) {
  343. [self pushController:[FKMyBookController new]shouldLogin:YES];
  344. }
  345. }
  346. #pragma mark - Push Controller
  347. - (void)pushOrderControllerWithType:(FKPersonOrderClassify)type {
  348. FKOrderSegmentController *controller = [[FKOrderSegmentController alloc] init];
  349. controller.selectedType = type;
  350. [self pushController:controller shouldLogin:YES];
  351. }
  352. - (void)pushWebController {
  353. NSString *url = [NSString stringWithFormat:@"%@/support/index.html", [[FKServerUtil sharedInstance] webServer]];
  354. WebViewController *newViewController = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:@"WebViewController"];
  355. newViewController.url = url;
  356. newViewController.hidesBottomBarWhenPushed = YES;
  357. [self.navigationController pushViewController:newViewController animated:YES];
  358. }
  359. #pragma mark - Method
  360. - (void)showGuideView{
  361. if ([FKUserManager isUserLogin] && !IS_IPHONE_4) {
  362. CGPoint integralPoint = [self.personCell convertPoint:self.personCell.pointButton.frame.origin toView:nil];
  363. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:3];
  364. CGPoint wantBuyCellPoint = [self.tableView convertPoint:[self.tableView cellForRowAtIndexPath:indexPath].frame.origin toView:nil];
  365. BOOL res = [[[NSUserDefaults standardUserDefaults] objectForKey:WANT_BUY_IS_SHOW_FIRST_KEY] boolValue];
  366. if (!res) {
  367. GuideView *guideView = [[GuideView alloc] init];
  368. [guideView addMaskViewWithType:NEW_FEATURE_TYPE_ENUM_IMG image:@"guide_notification_img" andRect:CGRectMake(7, IS_IPHONE_X ? 50 : 26, 175, 61)];
  369. [guideView addMaskViewWithType:NEW_FEATURE_TYPE_ENUM_IMG image:@"guide_integral_img" andRect:CGRectMake(integralPoint.x, integralPoint.y, 200, 51)];
  370. [guideView addMaskView:@"guide_want_buy_img" withImageRect:CGRectMake(wantBuyCellPoint.x, wantBuyCellPoint.y-140, UISCREENWIDTH, 200) andBtnRect:CGRectMake(UISCREENWIDTH/2-50, wantBuyCellPoint.y-130, 120, 40)];
  371. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:WANT_BUY_IS_SHOW_FIRST_KEY];
  372. [[NSUserDefaults standardUserDefaults] synchronize];
  373. }
  374. }
  375. }
  376. - (void)configLeftNaviItem {
  377. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.leftControl];
  378. }
  379. - (void)configRightNaviItem {
  380. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.rightControl];
  381. }
  382. - (void)configTabbarBadgeView {
  383. FirstLinkAppDelegate *delegate = (FirstLinkAppDelegate *)[[UIApplication sharedApplication] delegate];
  384. UITabBarController *tabbarController = (UITabBarController*)delegate.window.rootViewController;
  385. if ([tabbarController isKindOfClass:[UITabBarController class]]) {
  386. // 只需要夹在一次角标提示
  387. if (!_tabbarBadgeView) {
  388. [tabbarController.tabBar addSubview:self.tabbarBadgeView];
  389. }
  390. BOOL hasShown = [[[NSUserDefaults standardUserDefaults] objectForKey:kVipRedpointGuideKey] boolValue];
  391. if (!hasShown) {
  392. self.tabbarBadgeView.hidden = NO;
  393. }
  394. }
  395. }
  396. - (void)configTabbarUnreadBadge {
  397. __weak FKMessageManager *messageManage = [FKMessageManager sharedInstance];
  398. NSInteger localBadge = [SessionListController localUnreadMessageCount];
  399. NSInteger remoteBadge = messageManage.remoteMessageBadge.totalBadge;
  400. NSInteger orderBadge = messageManage.orderBadge.nonpaymentOrderBadge.integerValue;
  401. NSInteger expiredCount = messageManage.expireCouponCount;
  402. self.tabbarBadgeView.hidden = ((localBadge + remoteBadge + orderBadge + expiredCount) > 0 ? NO : YES);
  403. BOOL hasShown = [[[NSUserDefaults standardUserDefaults] objectForKey:kVipRedpointGuideKey] boolValue];
  404. if (!hasShown) {
  405. self.tabbarBadgeView.hidden = NO;
  406. }
  407. }
  408. - (void)configUnreadRefreshCallBackBeforeViewDidLoad {
  409. WeakSelf(weakSelf);
  410. [FKMessageManager sharedInstance].unreadRefreshCallBackBeforeViewDidLoad = ^() {
  411. [weakSelf configTabbarUnreadBadge];
  412. };
  413. }
  414. - (void)configUnreadRefreshCallBackAfterViewDidLoad {
  415. WeakSelf(weakSelf);
  416. [FKMessageManager sharedInstance].unreadRefreshCallBackAfterViewDidLoad = ^() {
  417. [weakSelf configMessageUnreadBadgeNumber];
  418. [weakSelf configTabbarUnreadBadge];
  419. };
  420. }
  421. - (void)configMessageUnreadBadgeNumber {
  422. FKMessageManager *weakMessageManage = [FKMessageManager sharedInstance];
  423. NSInteger localBadge = [SessionListController localUnreadMessageCount];
  424. NSInteger totalBadge = (localBadge + weakMessageManage.remoteMessageBadge.totalBadge);
  425. self.leftControl.countLabel.text = [NSString stringWithFormat:@"%ld", (long)totalBadge];
  426. self.leftControl.countLabel.hidden = (totalBadge > 0 ? NO : YES);
  427. }
  428. - (void)configPersonInfoCellWithAction:(FKHomePersonInfoCell *)cell {
  429. [cell.nickLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickPersonNicknameAction:)]];
  430. [cell.headView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickPersonAvatarAction:)]];
  431. [cell.pointButton addTarget:self action:@selector(clickPersonPointAction:) forControlEvents:UIControlEventTouchUpInside];
  432. [cell.signButton addTarget:self action:@selector(clickPersonSignAction:) forControlEvents:UIControlEventTouchUpInside];
  433. }
  434. #pragma mark - Property
  435. - (FKHomeViewModel *)viewModel {
  436. if (!_viewModel) {
  437. _viewModel = [FKHomeViewModel new];
  438. }
  439. return _viewModel;
  440. }
  441. - (FKNaviBarControl *)leftControl {
  442. if (!_leftControl) {
  443. _leftControl = [[FKNaviBarControl alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  444. _leftControl.countLabel.hidden = YES;
  445. _leftControl.imageView.image = [UIImage imageNamed:@"homeLeftIcon"];
  446. [_leftControl addTarget:self action:@selector(pushMessageController) forControlEvents:UIControlEventTouchUpInside];
  447. [[_leftControl.widthAnchor constraintEqualToConstant:44] setActive:YES];
  448. [[_leftControl.heightAnchor constraintEqualToConstant:44] setActive:YES];
  449. [_leftControl remakeConstraints:NaviBarControlLayoutLeft];
  450. }
  451. return _leftControl;
  452. }
  453. - (FKNaviBarControl *)rightControl {
  454. if (!_rightControl) {
  455. _rightControl = [[FKNaviBarControl alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  456. _rightControl.imageView.image = [UIImage imageNamed:@"homeRightIcon"];
  457. [_rightControl addTarget:self action:@selector(pushSettingController:) forControlEvents:UIControlEventTouchUpInside];
  458. [[_rightControl.widthAnchor constraintEqualToConstant:44] setActive:YES];
  459. [[_rightControl.heightAnchor constraintEqualToConstant:44] setActive:YES];
  460. [_rightControl remakeConstraints:NaviBarControlLayoutRight];
  461. }
  462. return _rightControl;
  463. }
  464. - (UILabel*)tabbarBadgeView {
  465. if (!_tabbarBadgeView) {
  466. _tabbarBadgeView = [[UILabel alloc]init];
  467. _tabbarBadgeView.textAlignment = NSTextAlignmentCenter;
  468. _tabbarBadgeView.layer.cornerRadius = 4;
  469. _tabbarBadgeView.textColor = [UIColor whiteColor];
  470. _tabbarBadgeView.backgroundColor = UIColorFromRGB(0xff676b);
  471. _tabbarBadgeView.font = [UIFont systemFontOfSize:11];
  472. _tabbarBadgeView.clipsToBounds = YES;
  473. _tabbarBadgeView.hidden = YES;
  474. }
  475. _tabbarBadgeView.frame = CGRectMake(UISCREENWIDTH - (IS_IPHONE_6P ? 28 : 24), 6, 8, 8);
  476. return _tabbarBadgeView;
  477. }
  478. - (UITableView*)tableView {
  479. if (!_tableView) {
  480. _tableView = [[UITableView alloc] initWithFrame:CGRectZero
  481. style:UITableViewStyleGrouped];
  482. _tableView.backgroundColor = COMMON_TABLEVIEW_BACKGROUND_COLOR;
  483. _tableView.dataSource = self;
  484. _tableView.delegate = self;
  485. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  486. _tableView.sectionHeaderHeight = 0.0f;
  487. [self initRefreshControlWithTableView:_tableView];
  488. self.refreshControl.bottomEnabled = NO;
  489. if (@available(iOS 11.0, *)) {
  490. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  491. }
  492. [_tableView registerClass:[FKHomePersonInfoCell class] forCellReuseIdentifier:NSStringFromClass([FKHomePersonInfoCell class])];
  493. [_tableView registerClass:[FKHomeFollowInfoCell class] forCellReuseIdentifier:NSStringFromClass([FKHomeFollowInfoCell class])];
  494. [_tableView registerClass:[FKHomeOrderHeaderCell class] forCellReuseIdentifier:NSStringFromClass([FKHomeOrderHeaderCell class])];
  495. [_tableView registerClass:[FKHomeOrderEntranceCell class] forCellReuseIdentifier:NSStringFromClass([FKHomeOrderEntranceCell class])];
  496. [_tableView registerClass:[FKHomeImageTextCell class] forCellReuseIdentifier:NSStringFromClass([FKHomeImageTextCell class])];
  497. }
  498. return _tableView;
  499. }
  500. @end