RQVipViewController.m 25 KB

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