Commit d1b707a1 cgx

优化首页轮播图逻辑

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