更新 YUMIHtmlUrl.h 和 YUMIHtmlUrl.m,新增首充相关的 URL 类型和路径;在 FeedBackViewController.h 和 FeedBackViewController.m 中,调整属性类型为强引用以增强内存管理;重构 FeedBackViewController 的视图设置逻辑,添加子视图的初始化方法以提高代码可读性;移除不再使用的 FeedBackViewController.xib 文件,优化项目结构;在 XPGiftBarView.h 和 XPGiftBarView.m 中,移除首充按钮相关代码,替换为新的首充视图逻辑;更新 XPWebViewController.h 和 XPWebViewController.m,调整 webview 属性为可写以支持动态更新;在 FirstRechargeManager.m 中,优化首充状态检查逻辑,确保在调试模式下始终显示首充信息。
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#import <JXCategoryView/JXCategoryView.h>
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
#import "SDWebImageManager.h"
|
||||
#import "FirstRechargeModel.h"
|
||||
#import "FirstRechargeManager.h"
|
||||
///Tool
|
||||
#import "Api+Home.h"
|
||||
@@ -402,9 +401,9 @@ FirstRechargeManagerDelegate>
|
||||
|
||||
// 注册首充管理器监听
|
||||
[FirstRechargeManager sharedManager].delegate = self;
|
||||
[[FirstRechargeManager sharedManager] startMonitoring];
|
||||
|
||||
// [self.presenter getUserFirstChargeStatus];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[[FirstRechargeManager sharedManager] startMonitoring];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,36 +817,86 @@ FirstRechargeManagerDelegate>
|
||||
// 如果已经有弹窗在显示,先移除它
|
||||
[self removeFirstChargePopup];
|
||||
|
||||
// 创建背景视图
|
||||
self.firstChargeBackgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
|
||||
// 获取 keyWindow 以确保盖在 tabbar 上
|
||||
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
||||
if (!keyWindow) {
|
||||
keyWindow = [UIApplication sharedApplication].windows.firstObject;
|
||||
}
|
||||
|
||||
// 创建背景视图,使用 keyWindow 的 bounds
|
||||
self.firstChargeBackgroundView = [[UIView alloc] initWithFrame:keyWindow.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];
|
||||
// 添加到 keyWindow 上,确保盖在 tabbar 上
|
||||
[keyWindow 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.firstChargeWebVC.url = URLWithType(kFirstChargeHomeIndex);
|
||||
|
||||
// 获取当前的根视图控制器来添加子控制器
|
||||
UIViewController *rootViewController = keyWindow.rootViewController;
|
||||
if ([rootViewController isKindOfClass:[UINavigationController class]]) {
|
||||
rootViewController = [(UINavigationController *)rootViewController topViewController];
|
||||
} else if ([rootViewController isKindOfClass:[UITabBarController class]]) {
|
||||
UITabBarController *tabBarController = (UITabBarController *)rootViewController;
|
||||
rootViewController = tabBarController.selectedViewController;
|
||||
if ([rootViewController isKindOfClass:[UINavigationController class]]) {
|
||||
rootViewController = [(UINavigationController *)rootViewController topViewController];
|
||||
}
|
||||
}
|
||||
|
||||
[rootViewController addChildViewController:self.firstChargeWebVC];
|
||||
[self.firstChargeBackgroundView addSubview:self.firstChargeWebVC.view];
|
||||
self.firstChargeWebVC.view.frame = CGRectMake(0, 0, KScreenWidth/2, KScreenHeight/2);
|
||||
[self.firstChargeWebVC didMoveToParentViewController:rootViewController];
|
||||
|
||||
self.firstChargeWebVC.view.backgroundColor = [UIColor clearColor];
|
||||
self.firstChargeWebVC.webview.backgroundColor = [UIColor clearColor];
|
||||
self.firstChargeWebVC.webview.opaque = NO;
|
||||
self.firstChargeWebVC.webview.scrollView.backgroundColor = [UIColor clearColor];
|
||||
self.firstChargeWebVC.view.frame = CGRectMake(0, 0, KScreenWidth - 40, KScreenHeight*2/3);
|
||||
self.firstChargeWebVC.view.center = self.firstChargeBackgroundView.center;
|
||||
|
||||
// 添加关闭按钮
|
||||
// UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
// [closeButton setTitle:@"✕" forState:UIControlStateNormal];
|
||||
// [closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
// closeButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
|
||||
// [closeButton addTarget:self action:@selector(removeFirstChargePopup) forControlEvents:UIControlEventTouchUpInside];
|
||||
// closeButton.frame = CGRectMake(0, 0, 30, 30);
|
||||
// closeButton.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
||||
// closeButton.layer.cornerRadius = 15;
|
||||
// [self.firstChargeBackgroundView addSubview:closeButton];
|
||||
//
|
||||
// // 设置关闭按钮位置(webView 右上角)
|
||||
// CGRect webViewFrame = self.firstChargeWebVC.view.frame;
|
||||
// closeButton.center = CGPointMake(CGRectGetMaxX(webViewFrame) - 15, CGRectGetMinY(webViewFrame) + 15);
|
||||
|
||||
// 3秒后自动移除
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self removeFirstChargePopup];
|
||||
});
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.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)) {
|
||||
|
||||
// 检查是否点击在 webView 区域外
|
||||
if (self.firstChargeWebVC && self.firstChargeWebVC.view) {
|
||||
CGRect webViewFrame = self.firstChargeWebVC.view.frame;
|
||||
if (!CGRectContainsPoint(webViewFrame, location)) {
|
||||
// 点击在 webView 外部,移除弹窗
|
||||
[self removeFirstChargePopup];
|
||||
}
|
||||
} else {
|
||||
// 如果 webView 不存在,直接移除弹窗
|
||||
[self removeFirstChargePopup];
|
||||
}
|
||||
}
|
||||
@@ -855,6 +904,7 @@ FirstRechargeManagerDelegate>
|
||||
// 修改移除弹窗的方法
|
||||
- (void)removeFirstChargePopup {
|
||||
if (self.firstChargeWebVC) {
|
||||
[self.firstChargeWebVC willMoveToParentViewController:nil];
|
||||
[self.firstChargeWebVC.view removeFromSuperview];
|
||||
[self.firstChargeWebVC removeFromParentViewController];
|
||||
self.firstChargeWebVC = nil;
|
||||
|
Reference in New Issue
Block a user