|
@@ -27,6 +27,7 @@
|
|
|
#import "UIViewController+TFPresent.h"
|
|
|
|
|
|
#define LZCategoryViewHeight 40.0f
|
|
|
+
|
|
|
@interface YMHomePageViewController ()<JXCategoryViewDelegate, JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,TYCyclePagerViewDataSource, TYCyclePagerViewDelegate>
|
|
|
{
|
|
|
dispatch_source_t _timer;
|
|
@@ -81,14 +82,23 @@
|
|
|
topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
|
|
|
[self.view insertSubview:topBgImgv atIndex:0];
|
|
|
|
|
|
- // 弹框,App 生命周期只弹出一次
|
|
|
- [self youpaifloadAdvert1];
|
|
|
+ NSLog(@"输出🍀\nYMHomePageViewController viewDidLoad");
|
|
|
}
|
|
|
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
[super viewDidAppear:animated];
|
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
|
|
+
|
|
|
+ NSLog(@"输出🍀\nYMHomePageViewController viewDidAppear");
|
|
|
+
|
|
|
+// [self getAdvertCompletion:^{
|
|
|
+//
|
|
|
+// NSLog(@"输出🍀\n%@",YMGlobalUtils.shared.advModels);
|
|
|
+// [self showAdvert];
|
|
|
+// }];
|
|
|
+
|
|
|
+// [self youpaifloadAdvert1];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -730,17 +740,23 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- NSMutableArray *arrm = [NSMutableArray array];
|
|
|
+
|
|
|
+
|
|
|
for (NSDictionary *advDict in listArr) {
|
|
|
YMAdvertModel *model = [YMAdvertModel yy_modelWithDictionary:advDict];
|
|
|
- [arrm addObject:model];
|
|
|
+ NSArray *advModelTags = YMGlobalUtils.shared.advModelTags;
|
|
|
+ if (![advModelTags containsObject:model.tag]) {
|
|
|
+ [YMGlobalUtils.shared.advModels addObject:model];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- for (YMAdvertModel *model in arrm) {
|
|
|
- if (model.window_type != 1) {
|
|
|
+ for (YMAdvertModel *model in YMGlobalUtils.shared.advModels) {
|
|
|
+ if (model.window_type != 1 && model.showedTag != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ model.showedTag = 1;
|
|
|
+
|
|
|
CGFloat delay = model.delayed_time;
|
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
@@ -786,49 +802,99 @@
|
|
|
}];
|
|
|
});
|
|
|
}
|
|
|
+ } failure:^(NSError *error) {}];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+//获取首冲弹框数据
|
|
|
+- (void)getAdvertCompletion: (void(^)(void))completion {
|
|
|
+ @weakify(self);
|
|
|
+ [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"6"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
|
|
|
+ @strongify(self);
|
|
|
+ NSDictionary* dict = (NSDictionary*)responseObject;
|
|
|
|
|
|
+ //NSLog(@"输出🍀\n%@",dict);
|
|
|
+ NSInteger code = [[dict objectForKey:@"code"] integerValue];
|
|
|
+ // 请求成功才会继续后面的逻辑
|
|
|
+ if (code != 0) { return; }
|
|
|
|
|
|
-// if (code==0) {//成功
|
|
|
-// YOUPAILCFirstRechargeModel *firstRechargeModel1 = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:dict[@"data"]];
|
|
|
-// for (int i = 0; i<firstRechargeModel1.youpaiplist.count; i++) {
|
|
|
-// YOUPAILCBannerModel* model = firstRechargeModel1.youpaiplist[i];
|
|
|
-//
|
|
|
-// if([NSStringFromClass([LCTools getCurrentVC].class) isEqual:@"YOUPAILZLiveAnchorVC"]) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// if([LCTools getCurrentVC].tabBarController == nil) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (model.youpaipwindow_type == 2) {
|
|
|
-// YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init];
|
|
|
-// window.isTouchDismiss = YES;
|
|
|
-// window.youpaipurl = model.youpaipwindow_link;
|
|
|
-// window.youpaipwidth = model.youpaipwidth;
|
|
|
-// window.youpaipheight = model.youpaipheight;
|
|
|
-// window.youpaipgravity = model.youpaipgravity;
|
|
|
-// [[LCTools getCurrentVC] TFPresentVC:window completion:^{}];
|
|
|
-//
|
|
|
-// }else{
|
|
|
-// YOUPAIZYFirstRechargeWindow *VC= [[YOUPAIZYFirstRechargeWindow alloc]init];
|
|
|
-// VC.youpaipdelegate = self;
|
|
|
-// VC.vWidth = KScreenWidth -30;
|
|
|
-// VC.vHeight = KScreenWidth-30;
|
|
|
-// VC.youpaipimageurl = model.youpaipimage;
|
|
|
-// VC.youpaiplink_type = model.youpaiplink_type;
|
|
|
-// VC.youpaiplink_url = model.youpaiplink_url;
|
|
|
-// VC.isTouchDismiss = YES;
|
|
|
-// [[LCTools getCurrentVC] TFPresentVC:VC completion:^{}];
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
+ NSDictionary *dataDict = [dict objectForKey:@"data"];
|
|
|
+ NSInteger is_open = [[dataDict objectForKey:@"is_open"] integerValue];
|
|
|
+ NSArray *listArr = [dataDict objectForKey:@"list"];
|
|
|
+
|
|
|
+ // 弹窗打开,才会进行数据解析
|
|
|
+ if (is_open != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (NSDictionary *advDict in listArr) {
|
|
|
+ YMAdvertModel *model = [YMAdvertModel yy_modelWithDictionary:advDict];
|
|
|
+ NSArray *advModelTags = YMGlobalUtils.shared.advModelTags;
|
|
|
+ if (![advModelTags containsObject:model.tag]) {
|
|
|
+ [YMGlobalUtils.shared.advModels addObject:model];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ completion();
|
|
|
} failure:^(NSError *error) {}];
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)showAdvert {
|
|
|
+ for (YMAdvertModel *model in YMGlobalUtils.shared.advModels) {
|
|
|
+ if (model.window_type != 1 && model.showedTag != 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ model.showedTag = 1;
|
|
|
+
|
|
|
+ CGFloat delay = model.delayed_time;
|
|
|
+
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ YOUPAIZYFirstRechargeWindow *VC = [[YOUPAIZYFirstRechargeWindow alloc]init];
|
|
|
+ //VC.youpaipdelegate = self;
|
|
|
+ VC.vWidth = KScreenWidth - adapt(80);
|
|
|
+ VC.vHeight = KScreenHeight * 0.6;
|
|
|
+ VC.youpaipimageurl = model.image;
|
|
|
+ VC.youpaiplink_type = model.link_type;
|
|
|
+ VC.youpaiplink_url = model.link_url;
|
|
|
+ VC.isTouchDismiss = YES;
|
|
|
+ VC.youpaipimgV.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
+
|
|
|
+ [[LCTools getCurrentVC] TFPresentVC:VC completion:^{}];
|
|
|
+
|
|
|
+ UIView *containerView = VC.baseView;
|
|
|
+
|
|
|
+ UILabel *titleLabel = [[UILabel alloc] init];
|
|
|
+ titleLabel.font = [UIFont systemFontOfSize:24 weight:(UIFontWeightBold)];
|
|
|
+ titleLabel.textColor = UIColor.blackColor;
|
|
|
+ titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
+ titleLabel.text = model.title;
|
|
|
+ [containerView addSubview:titleLabel];
|
|
|
+
|
|
|
+ UITextView *textView = [[UITextView alloc] init];
|
|
|
+ textView.text = model.content;
|
|
|
+ textView.font = [UIFont systemFontOfSize:15 weight:(UIFontWeightRegular)];
|
|
|
+ textView.textColor = [UIColor.blackColor colorWithAlphaComponent:0.5];
|
|
|
+ textView.backgroundColor = UIColor.clearColor;
|
|
|
+ textView.editable = NO;
|
|
|
+ [containerView addSubview:textView];
|
|
|
+
|
|
|
+ [titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(containerView).offset(adapt(20));
|
|
|
+ make.left.right.equalTo(containerView);
|
|
|
+ make.height.mas_equalTo(adapt(40));
|
|
|
+ }];
|
|
|
+ [textView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(titleLabel.mas_bottom).offset(adapt(20));
|
|
|
+ make.left.equalTo(containerView).offset(adapt(20));
|
|
|
+ make.right.equalTo(containerView).offset(adapt(-20));
|
|
|
+ make.bottom.equalTo(containerView).offset(adapt(-20));
|
|
|
+ }];
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
@end
|