NYLIVipCoachViewController.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. //
  2. // NYLIVipCoachViewController.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2025/1/23.
  6. // Copyright © 2025 JCZ. All rights reserved.
  7. //
  8. #import "NYLIVipCoachViewController.h"
  9. #import "NYLIVipCoachContentView.h"
  10. @interface NYLIVipCoachViewController ()
  11. /// viewModel
  12. @property (nonatomic, readonly, strong) NYLIVipCoachViewModel *viewModel;
  13. @property (nonatomic, readwrite, strong) RQVipBuyView *vipBuyView;
  14. @property (nonatomic, readwrite, strong) NYLiVipBuyNewView *vipBuyNewView;
  15. @property (nonatomic, readwrite, strong) RQTypeModel *chooseTypeModel;
  16. @property (nonatomic, readwrite, strong) IAPManager *iapManager;
  17. @property (nonatomic, strong) NYWPViewModel *wpviewModel;
  18. @property (nonatomic, readwrite, strong) UIButton *back_btn;
  19. @end
  20. @implementation NYLIVipCoachViewController
  21. @dynamic viewModel;
  22. #pragma mark - SystemMethod
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. /// 初始化
  26. [self rq_setup];
  27. [self.wpviewModel.wView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) {
  28. NSLog(@"navigator.userAgent.result is ++++ %@", result);
  29. }];
  30. [self.wpviewModel wkvPL:NYPiapph];
  31. }
  32. - (void)viewWillAppear:(BOOL)animated {
  33. [super viewWillAppear:animated];
  34. /// 清除缓存
  35. NSSet *websiteDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
  36. NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
  37. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{
  38. }];
  39. [self.navigationController.navigationBar setHidden:YES];
  40. }
  41. - (void)viewWillDisappear:(BOOL)animated{
  42. [super viewWillDisappear:animated];
  43. [self.navigationController.navigationBar setHidden:NO];
  44. }
  45. - (void)dealloc {
  46. self.wpviewModel = nil;
  47. RQ_VIP_Module.chooseTypeModel = nil;
  48. [[NSNotificationCenter defaultCenter] removeObserver:self];
  49. }
  50. - (void)viewDidLayoutSubviews {
  51. [super viewDidLayoutSubviews];
  52. CGFloat customHeight = (self.viewModel.vipPageType == RQVIPPageType_Alert)? self.view.rq_height : RQ_SCREEN_HEIGHT;
  53. self.collectionView.size = CGSizeMake(RQ_SCREEN_WIDTH, self.view.rq_height - RQ_FIT_HORIZONTAL(110.f) - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
  54. // self.vipBuyView.frame = CGRectMake(0, customHeight - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_FIT_HORIZONTAL(93.f), RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(93.f) + RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
  55. self.vipBuyNewView.frame = CGRectMake(0, customHeight - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_FIT_HORIZONTAL(110.f), RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(110.f) + RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
  56. }
  57. #pragma mark - PrivateMethods
  58. /// 初始化
  59. - (void)rq_setup {
  60. /// set up ...
  61. @weakify(self)
  62. self.back_btn = [UIButton buttonWithType:UIButtonTypeCustom];
  63. self.back_btn.frame = CGRectMake(5, 44, 50, 50);
  64. [self.back_btn addTarget:self action:@selector(backActiondo:) forControlEvents:UIControlEventTouchUpInside];
  65. [self.back_btn setImage:[UIImage imageNamed:@"li_back_white"] forState:UIControlStateNormal];
  66. self.collectionView.bounces = NO;
  67. self.flowLayout.sectionHeadersPinToVisibleBounds = (self.viewModel.vipPageType == RQVIPPageType_Alert);
  68. self.collectionView.backgroundColor = RQ_MAIN_TEXT_COLOR_WHITE;
  69. [self.view addSubview:self.vipBuyNewView];
  70. [self.view addSubview:self.back_btn];
  71. [[[RACObserve(self.viewModel, dataSource) distinctUntilChanged] deliverOnMainThread] subscribeNext:^(id _Nullable x) {
  72. @strongify(self)
  73. if (self.viewModel.dataSource.count > 0) {
  74. NYLIVipHeaderImageViewGroupModel *vipHeaderImageViewGroupViewModel = self.viewModel.dataSource.firstObject;
  75. if (vipHeaderImageViewGroupViewModel.itemViewModels.count > 0) {
  76. NSArray *currentArr = [vipHeaderImageViewGroupViewModel.itemViewModels.rac_sequence filter:^BOOL(RQVipSinglePriceItemViewModel *vipSinglePriceItemViewModel) {
  77. return ![vipSinglePriceItemViewModel.typeModel.dictLabel containsString:@"理论实操计时"];
  78. }].array;
  79. RQVipSinglePriceItemViewModel *vipSinglePriceItemViewModel;
  80. if (currentArr.count > 0) {
  81. vipSinglePriceItemViewModel = currentArr.firstObject;
  82. } else {
  83. vipSinglePriceItemViewModel = vipHeaderImageViewGroupViewModel.itemViewModels.firstObject;
  84. }
  85. if (RQObjectIsNil(RQ_VIP_Module.chooseTypeModel)) {
  86. RQ_VIP_Module.chooseTypeModel = vipSinglePriceItemViewModel.typeModel;
  87. } else {
  88. }
  89. }
  90. }
  91. }];
  92. [self initPayNoti];
  93. [self.vipBuyView.buyBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  94. @strongify(self)
  95. if (!self.vipBuyView.userAgreeBtn.selected) {
  96. [[RACScheduler mainThreadScheduler] schedule:^{
  97. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请阅读用户协议!才能开通会员哦!" confirmTitle:@"立即阅读" cancelTitle:@"取消" confirmAction:^{
  98. @strongify(self)
  99. self.vipBuyView.userAgreeBtn.selected = YES;
  100. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://ys.zzxcx.net/jsjp-sf.html"]];
  101. RQWebViewModel *viewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey : request,RQViewModelWebViewTypeKey:@(RQWebViewType_VIP)}];
  102. RQWebViewViewController *viewController = [[RQWebViewViewController alloc] initWithViewModel:viewModel];
  103. RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:viewController];
  104. [RQControllerHelper.currentViewController presentViewController:nav animated:YES completion:nil];
  105. } cancelAction:nil];
  106. }];
  107. return;
  108. }
  109. if (RQObjectIsNil(RQ_VIP_Module.chooseTypeModel)) {
  110. [MBProgressHUD rq_showTips:@"暂无可用VIP套餐"];
  111. } else {
  112. [self.wpviewModel wwvPLJS:RQ_VIP_Module.chooseTypeModel.dictCode];
  113. }
  114. }];
  115. [self.vipBuyNewView.buyBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  116. @strongify(self)
  117. if (!self.vipBuyNewView.userAgreeBtn.selected) {
  118. [[RACScheduler mainThreadScheduler] schedule:^{
  119. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请阅读用户协议!才能开通会员哦!" confirmTitle:@"立即阅读" cancelTitle:@"取消" confirmAction:^{
  120. @strongify(self)
  121. self.vipBuyNewView.userAgreeBtn.selected = YES;
  122. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://ys.zzxcx.net/jsjp-sf.html"]];
  123. RQWebViewModel *viewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey : request,RQViewModelWebViewTypeKey:@(RQWebViewType_VIP)}];
  124. RQWebViewViewController *viewController = [[RQWebViewViewController alloc] initWithViewModel:viewModel];
  125. RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:viewController];
  126. [RQControllerHelper.currentViewController presentViewController:nav animated:YES completion:nil];
  127. } cancelAction:nil];
  128. }];
  129. return;
  130. }
  131. if (RQObjectIsNil(RQ_VIP_Module.chooseTypeModel)) {
  132. [MBProgressHUD rq_showTips:@"暂无可用VIP套餐"];
  133. } else {
  134. [self.wpviewModel wwvPLJS:RQ_VIP_Module.chooseTypeModel.dictCode];
  135. }
  136. }];
  137. }
  138. //返回
  139. - (void)backActiondo:(UIButton *)btn{
  140. [self.navigationController popViewControllerAnimated:YES];
  141. }
  142. - (void)initPayNoti {
  143. [[NSNotificationCenter defaultCenter] addObserver:self
  144. selector:@selector(ailyPayOrWechatSuccessAction)
  145. name:RQUserNotificationOrWechatSuccess
  146. object:nil];
  147. [[NSNotificationCenter defaultCenter] addObserver:self
  148. selector:@selector(ailyPayOrWechatFailAction)
  149. name:RQUserNotificationOrWechatFail
  150. object:nil];
  151. }
  152. - (void)ailyPayOrWechatSuccessAction {
  153. @weakify(self)
  154. RQVideoVipModel *historyVideoVipModel = RQ_VIP_Module.videoVipModel;
  155. [MBProgressHUD rq_showProgressHUD:@"更新VIP信息..."];
  156. NSLog(@"处理支付成功结果");
  157. [[[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
  158. [subscriber sendNext:@"延时3.f秒"];
  159. return nil;
  160. }] delay:3.f] subscribeNext:^(id x) {
  161. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  162. @strongify(self)
  163. [MBProgressHUD rq_hideHUD];
  164. if ([RQ_VIP_Module.chooseTypeModel.dictLabel containsString:@"科一"]) {
  165. if (RQStringIsNotEmpty(historyVideoVipModel.subject1)) {
  166. /// 续费
  167. if ([historyVideoVipModel.subject1 isEqualToString:RQ_VIP_Module.videoVipModel.subject1]) {
  168. /// 续费未查询到结果
  169. [self checkVipFail];
  170. } else {
  171. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已续费成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  172. @strongify(self)
  173. // if (self.payViewController) {
  174. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  175. // }
  176. }];
  177. }
  178. } else {
  179. /// 购买
  180. if (RQStringIsEmpty(RQ_VIP_Module.videoVipModel.subject1)) {
  181. /// 购买未查询到结果
  182. [self checkVipFail];
  183. } else {
  184. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已购买成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  185. @strongify(self)
  186. // if (self.payViewController) {
  187. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  188. // }
  189. }];
  190. }
  191. }
  192. } else if ([RQ_VIP_Module.chooseTypeModel.dictLabel containsString:@"科二"]) {
  193. if (RQStringIsNotEmpty(historyVideoVipModel.subject2)) {
  194. /// 续费
  195. if ([historyVideoVipModel.subject2 isEqualToString:RQ_VIP_Module.videoVipModel.subject2]) {
  196. /// 续费未查询到结果
  197. [self checkVipFail];
  198. } else {
  199. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已续费成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  200. @strongify(self)
  201. // if (self.payViewController) {
  202. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  203. // }
  204. }];
  205. }
  206. } else {
  207. /// 购买
  208. if (RQStringIsEmpty(RQ_VIP_Module.videoVipModel.subject2)) {
  209. /// 购买未查询到结果
  210. [self checkVipFail];
  211. } else {
  212. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已购买成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  213. @strongify(self)
  214. // if (self.payViewController) {
  215. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  216. // }
  217. }];
  218. }
  219. }
  220. } else if ([RQ_VIP_Module.chooseTypeModel.dictLabel containsString:@"科三"]) {
  221. if (RQStringIsNotEmpty(historyVideoVipModel.subject3)) {
  222. /// 续费
  223. if ([historyVideoVipModel.subject3 isEqualToString:RQ_VIP_Module.videoVipModel.subject3]) {
  224. /// 续费未查询到结果
  225. [self checkVipFail];
  226. } else {
  227. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已续费成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  228. @strongify(self)
  229. // if (self.payViewController) {
  230. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  231. // }
  232. }];
  233. }
  234. } else {
  235. /// 购买
  236. if (RQStringIsEmpty(RQ_VIP_Module.videoVipModel.subject3)) {
  237. /// 购买未查询到结果
  238. [self checkVipFail];
  239. } else {
  240. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已购买成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  241. @strongify(self)
  242. // if (self.payViewController) {
  243. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  244. // }
  245. }];
  246. }
  247. }
  248. } else if ([RQ_VIP_Module.chooseTypeModel.dictLabel containsString:@"科四"]) {
  249. if (RQStringIsNotEmpty(historyVideoVipModel.subject4)) {
  250. /// 续费
  251. if ([historyVideoVipModel.subject4 isEqualToString:RQ_VIP_Module.videoVipModel.subject4]) {
  252. /// 续费未查询到结果
  253. [self checkVipFail];
  254. } else {
  255. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已续费成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  256. @strongify(self)
  257. // if (self.payViewController) {
  258. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  259. // }
  260. }];
  261. }
  262. } else {
  263. /// 购买
  264. if (RQStringIsEmpty(RQ_VIP_Module.videoVipModel.subject4)) {
  265. /// 购买未查询到结果
  266. [self checkVipFail];
  267. } else {
  268. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已购买成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  269. @strongify(self)
  270. // if (self.payViewController) {
  271. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  272. // }
  273. }];
  274. }
  275. }
  276. } else if ([RQ_VIP_Module.chooseTypeModel.dictLabel containsString:@"理论实操计时"]) {
  277. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  278. @strongify(self)
  279. if (isSuccess) {
  280. if (activationModel.isShare && activationModel.isActive == 1) {
  281. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已购买成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  282. @strongify(self)
  283. // if (self.payViewController) {
  284. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  285. // }
  286. }];
  287. } else {
  288. [self checkVipFail];
  289. }
  290. } else {
  291. [self checkVipFail];
  292. }
  293. }];
  294. } else {
  295. if ([historyVideoVipModel.subject1 isEqualToString:RQ_VIP_Module.videoVipModel.subject1] && [historyVideoVipModel.subject2 isEqualToString:RQ_VIP_Module.videoVipModel.subject2] &&
  296. [historyVideoVipModel.subject3 isEqualToString:RQ_VIP_Module.videoVipModel.subject3] && [historyVideoVipModel.subject4 isEqualToString:RQ_VIP_Module.videoVipModel.subject4]) {
  297. /// 续费未查询到结果
  298. [self checkVipFail];
  299. } else {
  300. [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message:@"您已购买成功!" confirmTitle:@"确定" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  301. @strongify(self)
  302. // if (self.payViewController) {
  303. // [self.payViewController dismissViewControllerAnimated:YES completion:nil];
  304. // }
  305. }];
  306. }
  307. }
  308. }];
  309. }];
  310. }
  311. - (void)checkVipFail {
  312. @weakify(self)
  313. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"更新VIP信息失败" confirmTitle:@"继续更新" cancelTitle:@"取消" confirmAction:^{
  314. @strongify(self)
  315. [self ailyPayOrWechatSuccessAction];
  316. } cancelAction:nil];
  317. }
  318. // 支付失败
  319. - (void)ailyPayOrWechatFailAction {
  320. NSLog(@"处理支付失败结果");
  321. }
  322. #pragma mark - OverrideMethods
  323. /// 配置collectionView的区域
  324. - (UIEdgeInsets)contentInset {
  325. return UIEdgeInsetsMake(0, 0, 0, 0);
  326. }
  327. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  328. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  329. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  330. return [NSClassFromString(itemViewModel.itemClassName) cellWithCollectionView:collectionView forIndexPath:indexPath];
  331. }
  332. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  333. [cell bindViewModel:object];
  334. }
  335. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  336. switch (section) {
  337. case 0: {
  338. return UIEdgeInsetsMake(0, 16, 0, 16);
  339. }
  340. case 1: {
  341. return UIEdgeInsetsMake(0, 16, 0, 16);
  342. }
  343. case 2: {
  344. return UIEdgeInsetsMake(0, 16, 0, 16);
  345. }
  346. case 3: {
  347. return UIEdgeInsetsMake(0, 16, 0, 16);
  348. }
  349. case 4: {
  350. return UIEdgeInsetsMake(0, 16, 0, 16);
  351. }
  352. case 5: {
  353. return UIEdgeInsetsMake(0, 16, 0, 16);
  354. }
  355. case 6: {
  356. return UIEdgeInsetsMake(0, 16, 0, 16);
  357. }
  358. default: {
  359. return UIEdgeInsetsZero;
  360. }
  361. }
  362. }
  363. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  364. switch (section) {
  365. case 0:
  366. case 1:
  367. return 16;
  368. default:
  369. return 8;
  370. }
  371. }
  372. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  373. switch (section) {
  374. case 1:
  375. return 0;
  376. default:
  377. return 8;
  378. }
  379. }
  380. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  381. @weakify(self)
  382. // 如果是头视图
  383. if (kind == UICollectionElementKindSectionHeader) {
  384. if (indexPath.section == 0) {
  385. if (self.viewModel.vipPageType == RQVIPPageType_Alert) {
  386. RQVipAlertHeaderCollectionReusableView *headerView = [RQVipAlertHeaderCollectionReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  387. [headerView.closeBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  388. @strongify(self)
  389. [self dismissViewControllerAnimated:YES completion:nil];
  390. }];
  391. return headerView;
  392. } else {
  393. NYLIVipHeaderImageViewNewReusableView *vipHeaderImageViewReusableView = [NYLIVipHeaderImageViewNewReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  394. // RQVipHeaderImageViewNewGroupViewModel *vipHeaderImageViewGroupViewModel = self.viewModel.dataSource[indexPath.section];
  395. // [vipHeaderImageViewReusableView bindViewModel:vipHeaderImageViewGroupViewModel];
  396. return vipHeaderImageViewReusableView;
  397. }
  398. } else {
  399. RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  400. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  401. [headerView bindViewModel:groupViewModel];
  402. headerView.headerContentLabel.hidden = YES;
  403. headerView.footerContentLabel.hidden = YES;
  404. if (indexPath.section == 1 && self.viewModel.vipPageType == RQVIPPageType_Alert) {
  405. headerView.backgroundColor = UIColor.clearColor;
  406. }
  407. headerView.backgroundColor = UIColor.clearColor;
  408. return headerView;
  409. }
  410. } else {
  411. RQCommonReusableView *footerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  412. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  413. [footerView bindViewModel:groupViewModel];
  414. footerView.headerContentLabel.hidden = YES;
  415. footerView.footerContentLabel.hidden = YES;
  416. footerView.backgroundColor = UIColor.clearColor;
  417. return footerView;
  418. }
  419. }
  420. - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  421. switch (indexPath.section) {
  422. case 0:
  423. case 1:{
  424. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  425. if ([groupViewModel.itemViewModels[indexPath.row] isKindOfClass:[RQVipTrainPriceItemViewModel class]]) {
  426. return (!RQObjectIsNil(RQ_VIP_Module.activationModel) && RQ_VIP_Module.activationModel.isShare && !(RQ_VIP_Module.activationModel.isActive == 1));
  427. } else {
  428. return YES;
  429. }
  430. }
  431. default:
  432. return NO;
  433. }
  434. }
  435. #pragma mark - HWPanModalPresentable3
  436. - (NYWPViewModel *)wpviewModel{
  437. if(!_wpviewModel){
  438. _wpviewModel = [[NYWPViewModel alloc] init];
  439. }
  440. return _wpviewModel;
  441. }
  442. - (UIScrollView *)panScrollable {
  443. return self.collectionView;
  444. }
  445. - (PanModalHeight)longFormHeight {
  446. return PanModalHeightMake(PanModalHeightTypeContent, RQ_SCREEN_HEIGHT * (459.f / 812.f));
  447. }
  448. - (CGFloat)cornerRadius {
  449. return 0.0;
  450. }
  451. - (BOOL)allowsTapBackgroundToDismiss {
  452. return NO;
  453. }
  454. - (BOOL)showDragIndicator {
  455. return NO;
  456. }
  457. #pragma mark - LazyLoad
  458. - (RQVipBuyView *)vipBuyView {
  459. if (!_vipBuyView) {
  460. _vipBuyView = [RQVipBuyView vipBuyView];
  461. RAC(_vipBuyView, typeModel) = [[RACObserve(RQ_VIP_Module, chooseTypeModel) distinctUntilChanged] takeUntil:self.rac_willDeallocSignal];
  462. }
  463. return _vipBuyView;
  464. }
  465. - (NYLiVipBuyNewView *)vipBuyNewView {
  466. if (!_vipBuyNewView) {
  467. _vipBuyNewView = [NYLiVipBuyNewView vipBuyNewView];
  468. RAC(_vipBuyNewView, typeModel) = [[RACObserve(RQ_VIP_Module, chooseTypeModel) distinctUntilChanged] takeUntil:self.rac_willDeallocSignal];
  469. }
  470. return _vipBuyNewView;
  471. }
  472. @end