RQVipViewController.m 25 KB

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