添加首充管理功能,新增 FirstRechargeManager 和相关模型以支持首充监控;在多个模块中集成首充监控逻辑,确保在登录和页面加载时正确启动和停止监控;移除不再使用的首充相关代码,优化代码结构和可读性。
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
#import <JXCategoryView/JXCategoryView.h>
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
#import "SDWebImageManager.h"
|
||||
#import "FirstRechargeModel.h"
|
||||
#import "FirstRechargeManager.h"
|
||||
///Tool
|
||||
#import "Api+Home.h"
|
||||
#import "YUMIMacroUitls.h"
|
||||
@@ -329,7 +331,8 @@ JXCategoryViewDelegate,
|
||||
XPHomeContainerProtocol,
|
||||
XPNewHomeNavViewDelegate,
|
||||
XPNewHomeHeadViewDelegate,
|
||||
XPHomeRecommendOtherRoomViewDelegate>
|
||||
XPHomeRecommendOtherRoomViewDelegate,
|
||||
FirstRechargeManagerDelegate>
|
||||
|
||||
///头视图
|
||||
@property(nonatomic,strong) XPNewHomeHeadView *headView;
|
||||
@@ -357,6 +360,11 @@ XPHomeRecommendOtherRoomViewDelegate>
|
||||
|
||||
@property (nonatomic, assign) bool hasLoadAPIs;
|
||||
|
||||
// 首充弹窗引用
|
||||
@property (nonatomic, strong) XPWebViewController *firstChargeWebVC;
|
||||
// 首充弹窗背景视图
|
||||
@property (nonatomic, strong) UIView *firstChargeBackgroundView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPNewHomeViewController
|
||||
@@ -369,7 +377,8 @@ XPHomeRecommendOtherRoomViewDelegate>
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
[FirstRechargeManager sharedManager].delegate = nil;
|
||||
}
|
||||
|
||||
- (BOOL)isHiddenNavBar {
|
||||
@@ -390,6 +399,12 @@ XPHomeRecommendOtherRoomViewDelegate>
|
||||
[self initSubViewConstraints];
|
||||
|
||||
[self requestCheckIp];
|
||||
|
||||
// 注册首充管理器监听
|
||||
[FirstRechargeManager sharedManager].delegate = self;
|
||||
[[FirstRechargeManager sharedManager] startMonitoring];
|
||||
|
||||
// [self.presenter getUserFirstChargeStatus];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,6 +421,9 @@ XPHomeRecommendOtherRoomViewDelegate>
|
||||
}
|
||||
|
||||
- (void)tokenInvalid {
|
||||
// 停止首充监控
|
||||
[[FirstRechargeManager sharedManager] stopMonitoring];
|
||||
|
||||
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
||||
[[AccountInfoStorage instance] saveTicket:nil];
|
||||
if ([NIMSDK sharedSDK].loginManager.isLogined) {
|
||||
@@ -769,6 +787,85 @@ XPHomeRecommendOtherRoomViewDelegate>
|
||||
self.type = index;
|
||||
}
|
||||
|
||||
- (void)getFirstChargeSuccess:(FirstRechargeModel *)model {
|
||||
if (model.chargeStatus == NO) {
|
||||
// TODO: 弹出窗口 web view
|
||||
XPWebViewController *web = [[XPWebViewController alloc] initWithRoomUID:@""];
|
||||
[self addChildViewController:web];
|
||||
[self.view addSubview:web.view];
|
||||
web.view.frame = CGRectMake(0, 0, KScreenWidth/2, KScreenHeight/2);
|
||||
web.view.center = self.view.center;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - FirstRechargeManagerDelegate
|
||||
|
||||
- (void)firstRechargeManager:(FirstRechargeManager *)manager didCheckFirstRecharge:(FirstRechargeModel *)model shouldShow:(BOOL)shouldShow {
|
||||
if (shouldShow && model.chargeStatus == NO) {
|
||||
// 展示首充弹窗
|
||||
[self showFirstRechargePopup:model];
|
||||
|
||||
// 标记今天已展示过(在展示后标记)
|
||||
[[FirstRechargeManager sharedManager] markTodayShown];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showFirstRechargePopup:(FirstRechargeModel *)model {
|
||||
if (model.chargeStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果已经有弹窗在显示,先移除它
|
||||
[self removeFirstChargePopup];
|
||||
|
||||
// 创建背景视图
|
||||
self.firstChargeBackgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
|
||||
self.firstChargeBackgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
||||
|
||||
// 添加点击手势
|
||||
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleBackgroundTap:)];
|
||||
[self.firstChargeBackgroundView addGestureRecognizer:tapGesture];
|
||||
|
||||
// 添加背景视图
|
||||
[self.view addSubview:self.firstChargeBackgroundView];
|
||||
|
||||
// 创建并配置 web 视图
|
||||
self.firstChargeWebVC = [[XPWebViewController alloc] initWithRoomUID:@""];
|
||||
self.firstChargeWebVC.isPush = NO;
|
||||
self.firstChargeWebVC.url = @"https://jandan.net/pic";
|
||||
[self addChildViewController:self.firstChargeWebVC];
|
||||
[self.firstChargeBackgroundView addSubview:self.firstChargeWebVC.view];
|
||||
self.firstChargeWebVC.view.frame = CGRectMake(0, 0, KScreenWidth/2, KScreenHeight/2);
|
||||
self.firstChargeWebVC.view.center = self.firstChargeBackgroundView.center;
|
||||
|
||||
// 3秒后自动移除
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self removeFirstChargePopup];
|
||||
});
|
||||
}
|
||||
|
||||
// 处理背景点击事件
|
||||
- (void)handleBackgroundTap:(UITapGestureRecognizer *)gesture {
|
||||
CGPoint location = [gesture locationInView:self.firstChargeBackgroundView];
|
||||
if (!CGRectContainsPoint(self.firstChargeWebVC.view.frame, location)) {
|
||||
[self removeFirstChargePopup];
|
||||
}
|
||||
}
|
||||
|
||||
// 修改移除弹窗的方法
|
||||
- (void)removeFirstChargePopup {
|
||||
if (self.firstChargeWebVC) {
|
||||
[self.firstChargeWebVC.view removeFromSuperview];
|
||||
[self.firstChargeWebVC removeFromParentViewController];
|
||||
self.firstChargeWebVC = nil;
|
||||
}
|
||||
|
||||
if (self.firstChargeBackgroundView) {
|
||||
[self.firstChargeBackgroundView removeFromSuperview];
|
||||
self.firstChargeBackgroundView = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - XPNewHomeHeadViewDelegate
|
||||
///
|
||||
-(void)checkIpRegionSuccess:(NSInteger)seconds{
|
||||
|
Reference in New Issue
Block a user