添加首充管理功能,新增 FirstRechargeManager 和相关模型以支持首充监控;在多个模块中集成首充监控逻辑,确保在登录和页面加载时正确启动和停止监控;移除不再使用的首充相关代码,优化代码结构和可读性。

This commit is contained in:
edwinQQQ
2025-06-26 11:08:21 +08:00
parent 6f59274ca0
commit 86094da26f
51 changed files with 602 additions and 1813 deletions

View File

@@ -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{