update
This commit is contained in:
@@ -19,18 +19,17 @@
|
||||
|
||||
#import "ConfigData.h"
|
||||
#import "ConfigDataModel.h"
|
||||
#import "LinkConfig.h"
|
||||
|
||||
@interface MainOldViewController () <WKUIDelegate,WKNavigationDelegate,DSWebMenuDelegate>
|
||||
|
||||
@property (strong, nonatomic) WKWebView *webView;
|
||||
@property (nonatomic,strong) WKUserContentController *wkUController;
|
||||
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicatorView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet DSWebDragView *webDragView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *dragHeightConstarint;
|
||||
@property (weak, nonatomic) IBOutlet DSWebMenuCollectionView *webMenuCollectionView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton *goIntoBtn;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MainOldViewController
|
||||
@@ -46,8 +45,8 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.mainUserId = PPN88UserID;
|
||||
|
||||
self.mainUserId = Candy916UserID;
|
||||
|
||||
WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
|
||||
wkWebConfig.preferences.javaScriptCanOpenWindowsAutomatically = YES;
|
||||
|
||||
@@ -63,8 +62,31 @@
|
||||
|
||||
NSMutableArray *menuArray = @[].mutableCopy;
|
||||
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
// 回到菜单按钮
|
||||
NSInteger height = 60;
|
||||
[menuArray addObject:[NSNumber numberWithInteger:DSWebMenuHomeType]];
|
||||
// 回到主页
|
||||
height = height + 60;
|
||||
LinkConfig *config = [[LinkConfig alloc] init];
|
||||
config.isGoBack = YES;
|
||||
config.icon = @"";
|
||||
config.name = @"HOME";
|
||||
config.linkUrl = appDelegate.mainURLString;
|
||||
[menuArray addObject:config];
|
||||
// 菜单
|
||||
if (!ISNULLSTR(appDelegate.data.linkConfig)) {
|
||||
NSError *jsonError;
|
||||
id linkConfigResponse = [NSJSONSerialization JSONObjectWithData:[appDelegate.data.linkConfig dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&jsonError];
|
||||
if (jsonError==nil && [linkConfigResponse isKindOfClass:[NSArray class]]) {
|
||||
NSArray *linkConfigArray = linkConfigResponse;
|
||||
height = height + linkConfigArray.count*60;
|
||||
for (NSDictionary *dic in linkConfigArray) {
|
||||
LinkConfig *linkModel = [LinkConfig modelWithDictionary:dic];
|
||||
[menuArray addObject:linkModel];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 客服平台
|
||||
if (!ISNULLSTR(appDelegate.data.fbUrl)) {
|
||||
height = height + 60;
|
||||
[menuArray addObject:[NSNumber numberWithInteger:DSWebMenuFacebookType]];
|
||||
@@ -77,9 +99,15 @@
|
||||
height = height + 60;
|
||||
[menuArray addObject:[NSNumber numberWithInteger:DSWebMenuWhatsAppType]];
|
||||
}
|
||||
// 刷新按钮
|
||||
height = height + 60;
|
||||
[menuArray addObject:[NSNumber numberWithInteger:DSWebMenuRefreshType]];
|
||||
self.webMenuCollectionView.shareArray = menuArray;
|
||||
self.webMenuCollectionView.webMenuDelegate = self;
|
||||
|
||||
if (height > self.view.frame.size.height) {
|
||||
height = self.view.frame.size.height;
|
||||
}
|
||||
self.dragHeightConstarint.constant = height;
|
||||
self.webDragView.freeRect = CGRectMake(0, 128, self.view.frame.size.width, self.view.frame.size.height-128);
|
||||
self.webDragView.isKeepBounds = YES;
|
||||
@@ -127,7 +155,7 @@
|
||||
}else{
|
||||
[self intoMainWebView];
|
||||
|
||||
[self setupAddContactData];
|
||||
// [self setupAddContactData];
|
||||
|
||||
// 判断是否第一次安装
|
||||
NSUserDefaults *userfault = [NSUserDefaults standardUserDefaults];
|
||||
@@ -137,32 +165,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[self.view bringSubviewToFront:self.webDragView];
|
||||
[self.view bringSubviewToFront:self.webMenuCollectionView];
|
||||
}
|
||||
|
||||
-(void)webMenuCollectionViewWithMenuType:(DSWebMenuType)webMenuType
|
||||
-(void)webMenuCollectionViewWithMenuType:(id)webMenuType
|
||||
{
|
||||
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
if (webMenuType == DSWebMenuHomeType) {
|
||||
if (self.isPresent == YES) {
|
||||
[self dismissViewControllerAnimated:YES completion:^{}];
|
||||
if ([webMenuType isKindOfClass:[LinkConfig class]]) {
|
||||
LinkConfig *link = webMenuType;
|
||||
if (link.isGoBack == YES) {
|
||||
if (self.isPresent == YES) {
|
||||
[self dismissViewControllerAnimated:YES completion:^{}];
|
||||
}else{
|
||||
self.mainURLString = link.linkUrl;
|
||||
self.isPresent = NO;
|
||||
[self intoMainWebView];
|
||||
}
|
||||
}else{
|
||||
self.mainURLString = link.linkUrl;
|
||||
self.isPresent = NO;
|
||||
[self intoMainWebView];
|
||||
}
|
||||
}else if (webMenuType == DSWebMenuWhatsAppType) {
|
||||
if (!ISNULLSTR(appDelegate.data.wsUrl)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://wa.me/message/%@",appDelegate.data.wsUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
|
||||
}
|
||||
}else if (webMenuType == DSWebMenuTelegramType) {
|
||||
if (!ISNULLSTR(appDelegate.data.tgUrl)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://t.me/%@",appDelegate.data.tgUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
|
||||
}
|
||||
}else if (webMenuType == DSWebMenuFacebookType) {
|
||||
if (!ISNULLSTR(appDelegate.data.fbUrl)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"fb://profile/%@",appDelegate.data.fbUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
|
||||
}else if ([webMenuType isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber *number = webMenuType;
|
||||
DSWebMenuType menuType = number.integerValue;
|
||||
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
if (menuType == DSWebMenuHomeType) {
|
||||
|
||||
}else if (menuType == DSWebMenuRefreshType) {
|
||||
self.isPresent = NO;
|
||||
[self intoMainWebView];
|
||||
}else if (menuType == DSWebMenuWhatsAppType) {
|
||||
if (!ISNULLSTR(appDelegate.data.wsUrl)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",appDelegate.data.wsUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
|
||||
}
|
||||
}else if (menuType == DSWebMenuTelegramType) {
|
||||
if (!ISNULLSTR(appDelegate.data.tgUrl)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",appDelegate.data.tgUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
|
||||
}
|
||||
}else if (menuType == DSWebMenuFacebookType) {
|
||||
if (!ISNULLSTR(appDelegate.data.fbUrl)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",appDelegate.data.fbUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
|
||||
}
|
||||
}
|
||||
}
|
||||
self.webDragView.hidden = NO;
|
||||
@@ -191,7 +235,9 @@
|
||||
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
|
||||
{
|
||||
if (navigationAction.request.URL) {
|
||||
MainOldViewController *view = [[MainOldViewController alloc] init];
|
||||
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
||||
MainOldViewController *view = [sb instantiateViewControllerWithIdentifier:@"MainOldViewController"];
|
||||
// MainOldViewController *view = [[MainOldViewController alloc] init];
|
||||
view.gameURLString = navigationAction.request.URL.absoluteString;
|
||||
view.isPresent = YES;
|
||||
view.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
|
||||
Reference in New Issue
Block a user