Commit d1b707a1 cgx

优化首页轮播图逻辑

1 个父辈 7f49ef22
...@@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *info_url; @property (nonatomic, copy) NSString *info_url;
// banner图描述 // banner图描述
@property (nonatomic, copy) NSString *banner_desc; @property (nonatomic, copy) NSString *banner_desc;
// 登录标识
@property (nonatomic, assign) int login_flag;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -85,37 +85,42 @@ ...@@ -85,37 +85,42 @@
#pragma mark - CWCarouselDelegate #pragma mark - CWCarouselDelegate
- (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index { - (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index {
// 判断是否登录成功
if ([LoginUtils getUserLoginData]) {
BannerModel *model = self.bannerDatas[index]; BannerModel *model = self.bannerDatas[index];
if (model.login_flag == 0) { // 用户无需登录直接跳转
[self jumpToBannerPageWithModel:model];
} else {
if ([LoginUtils getUserLoginData]) {
[self jumpToBannerPageWithModel:model];
} else {
// 跳转到登录页面
[LoginUtils jumpToLoginControllerWithTarget:self.ds_viewController];
}
}
}
- (void)jumpToBannerPageWithModel:(BannerModel *)model {
[DataStatisticsUtil event:Banner_Click attributes:@{@"name":model.banner_name, @"url":model.banner_url}]; [DataStatisticsUtil event:Banner_Click attributes:@{@"name":model.banner_name, @"url":model.banner_url}];
switch (model.banner_id) { BOOL isNative = [model.info_url containsString:@"native"];
case 13: { // 进入失眠拯救计划页面 // 跳转到原生页面
[self.ds_viewController.navigationController pushViewController:[[DsWebController alloc] initWithLink:model.info_url isShowNavi:NO] animated:YES]; if (isNative) {
} int type = [[[model.info_url componentsSeparatedByString:@"type="] lastObject] intValue];
break; if (type == 1) { // 切换到AI睡眠教练标签
case 11: { // 切换到AI睡眠教练标签
self.ds_viewController.tabBarController.selectedIndex = 1; self.ds_viewController.tabBarController.selectedIndex = 1;
} } else if (type == 2) { // 首页
break; self.ds_viewController.tabBarController.selectedIndex = 0;
case 10: { // 进入哄睡页面 } else if (type == 3) { // 哄睡页面
UnityGameController *gameVC = [UnityGameController new]; UnityGameController *gameVC = [UnityGameController new];
gameVC.gameType = GameTypeCoax; gameVC.gameType = GameTypeCoax;
[self.ds_viewController.navigationController pushViewController:gameVC animated:YES]; [self.ds_viewController.navigationController pushViewController:gameVC animated:YES];
} } else if (type == 4) { // 小球游戏
break; UnityGameController *gameVC = [UnityGameController new];
case 8: { // 进入睡眠评测页面 gameVC.gameType = GameTypeBall;
[self.ds_viewController.navigationController pushViewController:[[DsWebController alloc] initWithLink:model.info_url isShowNavi:NO] animated:YES]; [self.ds_viewController.navigationController pushViewController:gameVC animated:YES];
}
break;
default:
break;
} }
} else { } else {
// 跳转到登录页面 // 跳转到H5页面
[LoginUtils jumpToLoginControllerWithTarget:self.ds_viewController]; [self.ds_viewController.navigationController pushViewController:[[DsWebController alloc] initWithLink:model.info_url isShowNavi:NO] animated:YES];
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!