RQVipViewController.m 25 KB

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