192 lines
6.9 KiB
Objective-C
192 lines
6.9 KiB
Objective-C
//
|
|
// IfishADTimerViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 2017/4/19.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "IfishADTimerViewController.h"
|
|
#import "NSObject+LBLaunchImage.h"
|
|
#import "IfishLoadingWebViewController.h"
|
|
#import "IfishMianTabViewController.h"
|
|
#import "IfishAlibcWebViewController.h"
|
|
#import <AlibcTradeSDK/AlibcTradeSDK.h>
|
|
@interface IfishADTimerViewController ()
|
|
@property(nonatomic)UIActivityIndicatorView*indicatorView;
|
|
@property(nonatomic,strong) NSString *adUrl;
|
|
@property(nonatomic,strong) NSString *imgUrl;
|
|
@property(nonatomic,strong) UIImageView *backImg;
|
|
|
|
@end
|
|
|
|
@implementation IfishADTimerViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
self.backImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ifish_loading_hold"]];
|
|
self.backImg.frame = CGRectMake(0,0,kScreenSize.width,kScreenSize.height);
|
|
self.backImg.contentMode = UIViewContentModeScaleAspectFill;
|
|
[self.view addSubview:self.backImg];
|
|
|
|
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
|
_indicatorView.center=CGPointMake(kScreenSize.width/2, kScreenSize.height/2);
|
|
//[self.view addSubview:_indicatorView];
|
|
|
|
self.bakbutton.hidden = YES;
|
|
[self loadADdata];
|
|
}
|
|
|
|
-(void)loadADdata
|
|
{
|
|
__weak typeof (self)weakSelf = self;
|
|
[AFHttpTool getIfishBannerData:IfishAdTypeLoadAD success:^(id response) {
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
NSString *result=reDic[@"result"];
|
|
if ([result isEqualToString:@"100"]) {
|
|
NSArray *data= reDic[@"data"];
|
|
for (NSDictionary *dic in data) {
|
|
IfishBannerData *bannerdata = [[IfishBannerData alloc] initWithDict:dic];
|
|
weakSelf.imgUrl = bannerdata.adImage;
|
|
weakSelf.adUrl = bannerdata.adLink;
|
|
|
|
}
|
|
|
|
[weakSelf startLounchImg];
|
|
|
|
}else{
|
|
|
|
//[weakSelf.view makeToast:@"广告位获取失败"];
|
|
}
|
|
|
|
[_indicatorView stopAnimating];
|
|
} failure:^(NSError *err) {
|
|
[_indicatorView stopAnimating];
|
|
DisconnectNetController *connectVC =[[DisconnectNetController alloc] init];
|
|
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:connectVC];
|
|
[nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
|
[UIApplication sharedApplication].delegate.window.rootViewController=nav;
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)startLounchImg{
|
|
|
|
__weak typeof(self) weakSelf = self;
|
|
[NSObject makeLBLaunchImageAdView:^(LBLaunchImageAdView *imgAdView) {
|
|
//[weakSelf.view addSubview:imgAdView];
|
|
//防止透明导航遮挡 跳过按钮
|
|
[[UIApplication sharedApplication].delegate.window addSubview:imgAdView];
|
|
|
|
//设置广告的类型
|
|
imgAdView.getLBlaunchImageAdViewType(LogoAdType);
|
|
//设置本地启动图片
|
|
//imgAdView.localAdImgName = @"Ifishlaunch_adView.jpg";
|
|
imgAdView.imgUrl = weakSelf.imgUrl;
|
|
//自定义跳过按钮
|
|
|
|
imgAdView.skipBtn.backgroundColor = [UIColor blackColor];
|
|
//各种点击事件的回调
|
|
imgAdView.clickBlock = ^(clickType type){
|
|
switch (type) {
|
|
case clickAdType:{
|
|
NSLog(@"点击广告回调");
|
|
|
|
if (![weakSelf.adUrl isKindOfClass:[NSNull class]] && weakSelf.adUrl &&![weakSelf.adUrl isEqualToString:@""]){
|
|
|
|
//字条串是否包含有某字符串
|
|
if ([self.adUrl rangeOfString:@"taobao"].location == NSNotFound) {
|
|
IfishLoadingWebViewController *pushVC = [[IfishLoadingWebViewController alloc] init];
|
|
pushVC.pushlink = weakSelf.adUrl;
|
|
|
|
[weakSelf.navigationController pushViewController:pushVC animated:YES];
|
|
|
|
}else {
|
|
|
|
[weakSelf tapTtemListAt:weakSelf.adUrl];
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
break;
|
|
case skipAdType:
|
|
{
|
|
NSLog(@"点击跳过回调");
|
|
[weakSelf setAppTabRoot];
|
|
}
|
|
|
|
break;
|
|
case overtimeAdType:
|
|
|
|
{
|
|
|
|
NSLog(@"倒计时完成后的回调");
|
|
[weakSelf setAppTabRoot];
|
|
}
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
#pragma mark - 商品列表点击事件
|
|
// 宝贝详情页面
|
|
-(void)tapTtemListAt:(NSString *)goodslink
|
|
{
|
|
//535991514644
|
|
//id<AlibcTradePage> page = [AlibcTradePageFactory itemDetailPage: @"535991514644"];
|
|
//根据链接打开页面
|
|
id<AlibcTradePage> page = [AlibcTradePageFactory page:goodslink];
|
|
AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
|
|
showParam.openType = AlibcOpenTypeH5;
|
|
|
|
//自定义web
|
|
IfishAlibcWebViewController* myView = [[IfishAlibcWebViewController alloc] init];
|
|
NSInteger ret = [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController webView:myView.webView page:page showParams:showParam taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
|
|
|
|
} tradeProcessFailedCallback:^(NSError * _Nullable error) {
|
|
|
|
}]; //返回1,说明h5打开,否则不应该展示页面
|
|
if (ret == 1) {
|
|
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
[self.navigationController pushViewController:myView animated:YES];
|
|
//[self presentViewController:myView animated:YES completion:^{
|
|
|
|
//}];
|
|
}
|
|
}
|
|
|
|
//设置根视图
|
|
-(void)setAppTabRoot{
|
|
|
|
IfishMianTabViewController *mianVC=[[IfishMianTabViewController alloc] init];
|
|
[UIApplication sharedApplication].delegate.window.rootViewController=mianVC;
|
|
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
@end
|