12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // RQPlaceBuyItemViewModel.m
- // JiaPei
- //
- // Created by 张嵘 on 2023/4/19.
- //
- #import "RQPlaceBuyItemViewModel.h"
- @interface RQPlaceBuyItemViewModel ()
- @property (nonatomic, readwrite, strong) RQPlaceListModel *placeListModel;
- @property (nonatomic, readwrite, assign) BOOL isBuy;
- @property (nonatomic, readwrite, assign) BOOL chooseAgree;
- @end
- @implementation RQPlaceBuyItemViewModel
- - (instancetype)initWithPlaceListModel:(RQPlaceListModel *)placeListModel {
- if (self = [super init]) {
- @weakify(self)
- self.placeListModel = placeListModel;
- CGFloat width = RQ_SCREEN_WIDTH - 32.f;
- self.rowHeight = (width * (56.f / 345.f)) + 16 + 20 + 16;
- RAC(self, isBuy) = [[RACObserve(placeListModel, isCheckVip) deliverOnMainThread] takeUntil:self.rac_willDeallocSignal];
- [[[[RACObserve(RQ_COMMON_MANAGER, vipListArr) deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] skip:1] subscribeNext:^(id _Nullable x) {
- BOOL isBuy = [RQ_COMMON_MANAGER.vipListArr containsObject:placeListModel.name];
- placeListModel.isCheckVip = isBuy;
- }];
- self.operation = ^{
- @strongify(self)
-
- if (self.isAgree) {
- if (self.isBuy) {
-
- } else {
- [self.wpviewModel wwvPLJS:placeListModel.id goodType:2];
- }
- } else {
- [[RACScheduler mainThreadScheduler] schedule:^{
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请阅读用户协议!才能购买考场会员哦!" confirmTitle:@"立即阅读" cancelTitle:@"取消" confirmAction:^{
- @strongify(self)
- self.chooseAgree = YES;
- NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://ys.zzxcx.net/jsjp-sf.html"]];
- RQWebViewModel *viewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey : request,RQViewModelWebViewTypeKey:@(RQWebViewType_VIP)}];
- RQWebViewViewController *viewController = [[RQWebViewViewController alloc] initWithViewModel:viewModel];
- RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:viewController];
- [RQControllerHelper.currentViewController presentViewController:nav animated:YES completion:nil];
- } cancelAction:nil];
- }];
- }
-
-
-
- };
- }
- return self;
- }
- - (NSString *)itemClassName {
- return @"RQPlaceBuyCell";
- }
- @end
|