Commit cdbeba74 by 刘卓鑫

任务内容提交 定版百青藤

parent d711926b
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "9142D2B61F35C84E004F90CF" BlueprintIdentifier = "9142D2B61F35C84E004F90CF"
BuildableName = "ColorfulSchool.app" BuildableName = "&#x591a;&#x5f69;&#x6821;&#x56ed;.app"
BlueprintName = "ColorfulSchool" BlueprintName = "ColorfulSchool"
ReferencedContainer = "container:ColorfulSchool.xcodeproj"> ReferencedContainer = "container:ColorfulSchool.xcodeproj">
</BuildableReference> </BuildableReference>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "9142D2B61F35C84E004F90CF" BlueprintIdentifier = "9142D2B61F35C84E004F90CF"
BuildableName = "ColorfulSchool.app" BuildableName = "&#x591a;&#x5f69;&#x6821;&#x56ed;.app"
BlueprintName = "ColorfulSchool" BlueprintName = "ColorfulSchool"
ReferencedContainer = "container:ColorfulSchool.xcodeproj"> ReferencedContainer = "container:ColorfulSchool.xcodeproj">
</BuildableReference> </BuildableReference>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "9142D2B61F35C84E004F90CF" BlueprintIdentifier = "9142D2B61F35C84E004F90CF"
BuildableName = "ColorfulSchool.app" BuildableName = "&#x591a;&#x5f69;&#x6821;&#x56ed;.app"
BlueprintName = "ColorfulSchool" BlueprintName = "ColorfulSchool"
ReferencedContainer = "container:ColorfulSchool.xcodeproj"> ReferencedContainer = "container:ColorfulSchool.xcodeproj">
</BuildableReference> </BuildableReference>
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "9142D2B61F35C84E004F90CF" BlueprintIdentifier = "9142D2B61F35C84E004F90CF"
BuildableName = "ColorfulSchool.app" BuildableName = "&#x591a;&#x5f69;&#x6821;&#x56ed;.app"
BlueprintName = "ColorfulSchool" BlueprintName = "ColorfulSchool"
ReferencedContainer = "container:ColorfulSchool.xcodeproj"> ReferencedContainer = "container:ColorfulSchool.xcodeproj">
</BuildableReference> </BuildableReference>
......
...@@ -19,8 +19,13 @@ ...@@ -19,8 +19,13 @@
#import "YWPrintViewController.h" #import "YWPrintViewController.h"
#import "XMGFileTool.h" #import "XMGFileTool.h"
#import "FTUploader.h" #import "FTUploader.h"
#import "ZXBDTool.h"
#import "ZXNewOrderDetailViewController.h" #import "ZXNewOrderDetailViewController.h"
#import <AFNetworkReachabilityManager.h> #import <AFNetworkReachabilityManager.h>
#import "BaiduMobAdSDK/BaiduMobAdSplash.h"
#import "BaiduMobAdSDK/BaiduMobAdView.h"
#import "BaiduMobAdSDK/BaiduMobAdSetting.h"
#import "BDADHeader.h"
// 引入JPush功能所需头文件 // 引入JPush功能所需头文件
#import <JPUSHService.h> #import <JPUSHService.h>
// iOS10注册APNs所需头文件 // iOS10注册APNs所需头文件
...@@ -45,7 +50,7 @@ ...@@ -45,7 +50,7 @@
#import "ZXAdViewAdTool.h" #import "ZXAdViewAdTool.h"
#import "BUADTool.h" #import "BUADTool.h"
@interface AppDelegate ()<WXApiDelegate,UIAlertViewDelegate,UITabBarControllerDelegate,JPUSHRegisterDelegate, AVSpeechSynthesizerDelegate, BUSplashAdDelegate> @interface AppDelegate ()<WXApiDelegate,UIAlertViewDelegate,UITabBarControllerDelegate,JPUSHRegisterDelegate, AVSpeechSynthesizerDelegate, BUSplashAdDelegate, BaiduMobAdSplashDelegate>
{ {
BOOL _isPlaying;//是否正在播放 BOOL _isPlaying;//是否正在播放
} }
...@@ -54,7 +59,10 @@ ...@@ -54,7 +59,10 @@
@property (nonatomic,strong) UIAlertView *updateAlert; @property (nonatomic,strong) UIAlertView *updateAlert;
@property (nonatomic, strong) UpdateVersionModel *updateModel; @property (nonatomic, strong) UpdateVersionModel *updateModel;
@property (nonatomic) NSDictionary * notifyDic; @property (nonatomic) NSDictionary * notifyDic;
/** */
@property (nonatomic, strong) BaiduMobAdSplash *splash;
/** */
@property (nonatomic, strong) UIView *splashView;
@end @end
@implementation AppDelegate @implementation AppDelegate
...@@ -65,7 +73,7 @@ ...@@ -65,7 +73,7 @@
_isPlaying = NO; _isPlaying = NO;
//启动环境 //启动环境
[APIManager sharedAPIManager].lauchEnvironment = ZXColorfulSchoolEnvironmentTest; [APIManager sharedAPIManager].lauchEnvironment = ZXColorfulSchoolEnvironmentDevelop;
//极光推送 //极光推送
[self initPushWithOptions:launchOptions isProduct:YES]; [self initPushWithOptions:launchOptions isProduct:YES];
...@@ -75,9 +83,14 @@ ...@@ -75,9 +83,14 @@
//token登录 //token登录
[self tokenLogin]; [self tokenLogin];
//注册穿山甲
[BUADTool setupBUAdSDK];
//开屏广告 //开屏广告
[ZXAdTool startLauchAd]; @weakify(self);
[ZXAdTool startLauchAdIsBaiduAd:^{
@strongify(self);
[self createBaiduLauchAd];
}];
//版本检测 //版本检测
[self checkVersion]; [self checkVersion];
...@@ -94,6 +107,53 @@ ...@@ -94,6 +107,53 @@
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
return YES; return YES;
} }
#pragma mark - BaiduMobAdViewDelegate
- (NSString *)publisherId
{
return kBaiduAdAppId;
}
-(BOOL) enableLocation
{
//启用location会有一次alert提示
return YES;
}
-(void) willDisplayAd:(BaiduMobAdView*) adview
{
NSLog(@"delegate: will display ad");
}
-(void) failedDisplayAd:(BaiduMobFailReason) reason;
{
NSLog(@"delegate: failedDisplayAd %d", reason);
}
- (void)didAdImpressed {
NSLog(@"delegate: didAdImpressed");
}
- (void)didAdClicked {
NSLog(@"delegate: didAdClicked");
}
#pragma mark - 开屏广告
- (void) createBaiduLauchAd {
self.splash = [[BaiduMobAdSplash alloc] init];
self.splash.delegate = self;
self.splash.AdUnitTag = kBaiduAdLauchId;
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
self.splashView = [[UIView alloc] initWithFrame:window.frame];
[window addSubview:self.splashView];
[self.splash loadAndDisplayUsingContainerView:self.splashView];
}
#pragma mark - 穿山甲广告Delegate #pragma mark - 穿山甲广告Delegate
- (void)splashAdDidClose:(BUSplashAdView *)splashAd { - (void)splashAdDidClose:(BUSplashAdView *)splashAd {
[splashAd removeFromSuperview]; [splashAd removeFromSuperview];
......
// //
...@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
//单例化 //单例化
kSINGLETON_FOR_HEADER(ZXBDTool) kSINGLETON_FOR_HEADER(ZXBDTool)
- (void) createNativie20_3AdByView:(UIView *) view;
- (void) createNativieAdByView:(UIView *) view - (void) createNativieAdByView:(UIView *) view
topView:(UIView *) topView topView:(UIView *) topView
...@@ -28,6 +28,14 @@ kSINGLETON_FOR_HEADER(ZXBDTool) ...@@ -28,6 +28,14 @@ kSINGLETON_FOR_HEADER(ZXBDTool)
- (void) createBaiduLauchAdView; - (void) createBaiduLauchAdView;
- (void) createLauchAdWithDelegate:(id) delegate;
//创建激励视频广告
- (void) createRewardVideoAd;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
// //
...@@ -11,11 +11,18 @@ ...@@ -11,11 +11,18 @@
#import "BaiduMobAdSDK/BaiduMobAdSetting.h" #import "BaiduMobAdSDK/BaiduMobAdSetting.h"
#import "BaiduMobAdSDK/BaiduMobAdSplash.h" #import "BaiduMobAdSDK/BaiduMobAdSplash.h"
#import "BDADHeader.h" #import "BDADHeader.h"
#import "BaiduMobAdSDK/BaiduMobAdRewardVideo.h"
#import "BaiduMobAdSDK/BaiduMobAdSetting.h"
@interface ZXBDTool ()<BaiduMobAdViewDelegate, BaiduMobAdSplashDelegate> { @interface ZXBDTool ()<BaiduMobAdViewDelegate, BaiduMobAdSplashDelegate, BaiduMobAdRewardVideoDelegate> {
BaiduMobAdView *sharedAdView; BaiduMobAdView *sharedAdView;
} }
@property (nonatomic, strong) BaiduMobAdRewardVideo *reward;
/** */
@property (nonatomic, strong) BaiduMobAdSplash *splash;
/** */
@property (nonatomic, strong) UIView *splashView;
@property (nonatomic, strong) dispatch_source_t gcdTimer; @property (nonatomic, strong) dispatch_source_t gcdTimer;
@end @end
...@@ -82,6 +89,26 @@ kSINGLETON_FOR_CLASS(ZXBDTool) ...@@ -82,6 +89,26 @@ kSINGLETON_FOR_CLASS(ZXBDTool)
[self createCountingDowViewByAdView:sharedAdView]; [self createCountingDowViewByAdView:sharedAdView];
} }
} }
- (void) createNativie20_3AdByView:(UIView *) view {
[BaiduMobAdSetting setLpStyle:BaiduMobAdLpStyleDefault];
//使用嵌入广告的方法实例。
sharedAdView = [[BaiduMobAdView alloc] init];
sharedAdView.AdUnitTag = @"6592671";
sharedAdView.AdType = BaiduMobAdViewTypeBanner;
[view insertSubview:sharedAdView atIndex:0];
[sharedAdView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(view.mas_left).offset(5 * k6Scale);
make.right.equalTo(view.mas_right).offset(-5 * k6Scale);
make.height.mas_equalTo(kScreenWidth * 0.15);
make.bottom.equalTo(view.mas_bottom).offset(-kScreenWidth * 0.15);
}];
sharedAdView.delegate = self;
[sharedAdView start];
}
#pragma mark - ========== 创建删除view ========== #pragma mark - ========== 创建删除view ==========
- (void) createRemoveAdView:(BaiduMobAdView *) expressView{ - (void) createRemoveAdView:(BaiduMobAdView *) expressView{
UIImageView *closeBg = [[UIImageView alloc] init]; UIImageView *closeBg = [[UIImageView alloc] init];
...@@ -178,6 +205,21 @@ kSINGLETON_FOR_CLASS(ZXBDTool) ...@@ -178,6 +205,21 @@ kSINGLETON_FOR_CLASS(ZXBDTool)
sharedAdView = nil; sharedAdView = nil;
} }
- (void) createLauchAdWithDelegate:(id) delegate{
self.splash = [[BaiduMobAdSplash alloc] init];
self.splash.delegate = delegate;
self.splash.AdUnitTag = kBaiduAdLauchId;
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
self.splashView = [[UIView alloc] initWithFrame:window.frame];
[window addSubview:self.splashView];
[self.splash loadAndDisplayUsingContainerView:self.splashView];
}
#pragma mark - BaiduMobAdViewDelegate #pragma mark - BaiduMobAdViewDelegate
- (NSString *)publisherId - (NSString *)publisherId
{ {
...@@ -267,4 +309,54 @@ kSINGLETON_FOR_CLASS(ZXBDTool) ...@@ -267,4 +309,54 @@ kSINGLETON_FOR_CLASS(ZXBDTool)
} }
//创建激励视频广告
- (void) createRewardVideoAd {
self.reward = [[BaiduMobAdRewardVideo alloc] init];
self.reward.delegate = self;
self.reward.AdUnitTag = @"6697174";
self.reward.publisherId = kBaiduAdAppId;
[self.reward load];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.reward showFromViewController:[ZXTool getCurrentVC]];
});
}
- (void)rewardedVideoAdLoaded:(BaiduMobAdRewardVideo *)video {
[[[UIAlertView alloc]initWithTitle:@"激励视频缓存成功" message:nil delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil] show];
NSLog(@"激励视频缓存成功");
}
- (void)rewardedVideoAdLoadFailed:(BaiduMobAdRewardVideo *)video withError:(BaiduMobFailReason)reason {
[[[UIAlertView alloc]initWithTitle:@"激励视频缓存失败" message:nil delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil] show];
NSLog(@"激励视频缓存失败,failReason:%d",reason);
}
- (void)rewardedVideoAdShowFailed:(BaiduMobAdRewardVideo *)video withError:(BaiduMobFailReason)reason {
NSLog(@"激励视频展现失败,failReason:%d",reason);
//异常情况处理
[[[UIAlertView alloc]initWithTitle:@"激励视频展现失败" message:nil delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil] show];
}
- (void)rewardedVideoAdDidStarted:(BaiduMobAdRewardVideo *)video {
NSLog(@"激励视频开始播放");
}
- (void)rewardedVideoAdDidPlayFinish:(BaiduMobAdRewardVideo *)video {
NSLog(@"激励视频完成播放");
}
- (void)rewardedVideoAdDidClick:(BaiduMobAdRewardVideo *)video withPlayingProgress:(CGFloat)progress {
NSLog(@"激励视频LP被点击,progress:%f",progress);
}
- (void)rewardedVideoAdDidClose:(BaiduMobAdRewardVideo *)video withPlayingProgress:(CGFloat)progress {
NSLog(@"激励视频点击关闭,progress:%f",progress);
}
@end @end
// //
...@@ -12,10 +12,18 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,10 +12,18 @@ NS_ASSUME_NONNULL_BEGIN
@interface BUADTool : NSObject @interface BUADTool : NSObject
- (void)setupBUAdSDKAndLoadLauchAdByDelegate:(id) delegate; + (void)setupBUAdSDK;
- (void) loadLauchAdByDelegate:(id) delagte;
- (void) loadBannerAdWithController:(UIViewController *) viewController; - (void) loadBannerAdWithController:(UIViewController *) viewController superView:(UIView *) superView;
//创建激励视频
- (void) createRewardedVideoAdWithController:(UIViewController *) viewController;
////展示激励视频广告
//- (void) showRewardedVideoAd;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
// //
...@@ -9,22 +9,24 @@ ...@@ -9,22 +9,24 @@
#import "BUADTool.h" #import "BUADTool.h"
#import <BUAdSDK/BUAdSDK.h> #import <BUAdSDK/BUAdSDK.h>
@interface BUADTool() @interface BUADTool()<BUNativeExpressRewardedVideoAdDelegate, BUNativeExpressBannerViewDelegate>
/** */ /** */
@property (nonatomic, strong) BUNativeExpressBannerView *bannerView; @property (nonatomic, strong) BUNativeExpressBannerView *bannerView;
@property (nonatomic, strong) BUNativeExpressRewardedVideoAd *rewardedAd;
@end @end
@implementation BUADTool @implementation BUADTool
- (void)setupBUAdSDKAndLoadLauchAdByDelegate:(id) delegate {
+ (void)setupBUAdSDK {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[BUAdSDKManager setAppID:@"5033112"]; [BUAdSDKManager setAppID:@"5033112"];
[BUAdSDKManager setIsPaidApp:NO]; [BUAdSDKManager setIsPaidApp:NO];
// splash AD demo
[self loadLauchAdByDelegate:delegate];
}); });
}); });
} }
...@@ -57,20 +59,90 @@ ...@@ -57,20 +59,90 @@
NSLog(@"穿山甲开屏广告加载失败"); NSLog(@"穿山甲开屏广告加载失败");
} }
- (void) loadBannerAdWithController:(UIViewController *) viewController { - (void) loadBannerAdWithController:(UIViewController *) viewController superView:(UIView *) superView {
[BUAdSDKManager setAppID:@"5033112"];
[BUAdSDKManager setIsPaidApp:NO];
// splash AD demo // splash AD demo
BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90]; BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Banner600_90];
CGFloat bannerHeigh = kScreenWidth/600*90; CGFloat bannerHeigh = kScreenWidth/600*90;
if (self.bannerView == nil) { if (self.bannerView == nil) {
self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController imgSize:imgSize adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES]; self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:@"933112579" rootViewController:viewController imgSize:imgSize adSize:CGSizeMake(kScreenWidth, bannerHeigh) IsSupportDeepLink:YES];
self.bannerView.frame = CGRectMake(0, kScreenHeight - bannerHeigh, kScreenWidth, bannerHeigh); self.bannerView.frame = CGRectMake(0, kScreenWidth * 0.3 + 10 * k6Scale - bannerHeigh, kScreenWidth, bannerHeigh);
self.bannerView.delegate = (id)viewController; self.bannerView.delegate = self;
[viewController.view addSubview:self.bannerView]; [superView addSubview:self.bannerView];
} }
[self.bannerView loadAdData]; [self.bannerView loadAdData];
} }
- (void)createRewardedVideoAdWithController:(UIViewController *)viewController {
BURewardedVideoModel *model = [[BURewardedVideoModel alloc] init];
model.userId = @"123";
self.rewardedAd = [[BUNativeExpressRewardedVideoAd alloc] initWithSlotID:@"933112439" rewardedVideoModel:model];
self.rewardedAd.delegate = self;
[self.rewardedAd loadAdData];
//为保证播放流畅和展示流畅建议可在收到渲染成功和视频下载完成回调后再展示视频。
if (self.rewardedAd.isAdValid) {
[self.rewardedAd showAdFromRootViewController:viewController.navigationController];
}
}
#pragma mark - BUNativeExpressRewardedVideoAdDelegate
- (void)nativeExpressRewardedVideoAdDidLoad:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAd:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error {
}
- (void)nativeExpressRewardedVideoAdDidDownLoadVideo:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdViewRenderSuccess:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdViewRenderFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error {
}
- (void)nativeExpressRewardedVideoAdWillVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdDidVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdWillClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
[self.rewardedAd loadAdData];
}
- (void)nativeExpressRewardedVideoAdDidClick:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdDidClickSkip:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
- (void)nativeExpressRewardedVideoAdDidPlayFinish:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error {
}
- (void)nativeExpressRewardedVideoAdServerRewardDidSucceed:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd verify:(BOOL)verify {
}
- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
}
@end @end
// //
...@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZXAdTool : NSObject @interface ZXAdTool : NSObject
+ (void) startLauchAd; + (void) startLauchAdIsBaiduAd:(dispatch_block_t) baiduAd;
@end @end
......
// //
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
@implementation ZXAdTool @implementation ZXAdTool
+ (void) startLauchAd { + (void) startLauchAdIsBaiduAd:(dispatch_block_t) baiduAd {
//开屏广告 二次展示 //开屏广告 二次展示
if (CacheUserId == nil) { // if (CacheUserId == nil) {
return; // return;
} // }
// ZXLauchModel *lastAd = [ZXLauchModel findAll].lastObject; // ZXLauchModel *lastAd = [ZXLauchModel findAll].lastObject;
// if (lastAd && lastAd.whether) { // if (lastAd && lastAd.whether) {
// if (lastAd.platformSource == 1) { // if (lastAd.platformSource == 1) {
...@@ -58,8 +58,9 @@ ...@@ -58,8 +58,9 @@
// }]; // }];
//开屏广告 1次展示 //开屏广告 1次展示
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/tencent/advertisement/spread2?id=%@&sourceType=iOS", [kUserDefaults valueForKey:@"SX_MONEY"], CacheUserId] para:nil completed:^(CommonModel *common, NSString *error) { [ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/app/open/advert/round/info?id=%@&sourceType=0", [kUserDefaults valueForKey:@"SX_MONEY"], CacheUserId] para:nil completed:^(CommonModel *common, NSString *error) {
if (error == nil) { if (error == nil) {
ZXLauchModel *lauch = [ZXLauchModel mj_objectWithKeyValues:common.data]; ZXLauchModel *lauch = [ZXLauchModel mj_objectWithKeyValues:common.data];
[ZXLauchModel clearTable]; [ZXLauchModel clearTable];
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
if (lauch.whether == NO) { if (lauch.whether == NO) {
return ; return ;
} }
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (lauch.isButt) { if (lauch.isButt) {
...@@ -78,7 +80,10 @@ ...@@ -78,7 +80,10 @@
[[[ZXAdViewAdTool alloc] init] startLauchAd]; [[[ZXAdViewAdTool alloc] init] startLauchAd];
break; break;
case 5: //穿山甲 case 5: //穿山甲
[[BUADTool new] setupBUAdSDKAndLoadLauchAdByDelegate:UIApplication.sharedApplication.delegate]; [[[BUADTool alloc] init] loadLauchAdByDelegate:UIApplication.sharedApplication.delegate];
break;
case 6: //百度
baiduAd();
break; break;
default: default:
break; break;
......
//
// LMHWaterFallLayout.h
// WateFallLayoutTest
//
// Created by 刘梦桦 on 2017/5/18.
// Copyright © 2017年 lmh. All rights reserved.
//
#import <UIKit/UIKit.h>
@class LMHWaterFallLayout;
@protocol LMHWaterFallLayoutDeleaget<NSObject>
@required
/**
* 每个item的高度
*/
- (CGFloat)waterFallLayout:(LMHWaterFallLayout *)waterFallLayout heightForItemAtIndexPath:(NSUInteger)indexPath itemWidth:(CGFloat)itemWidth;
@optional
/**
* 有多少列
*/
- (NSUInteger)columnCountInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout;
/**
* 每列之间的间距
*/
- (CGFloat)columnMarginInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout;
/**
* 每行之间的间距
*/
- (CGFloat)rowMarginInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout;
/**
* 每个item的内边距
*/
- (UIEdgeInsets)edgeInsetdInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout;
@end
@interface LMHWaterFallLayout : UICollectionViewLayout
/** 代理 */
@property (nonatomic, weak) id<LMHWaterFallLayoutDeleaget> delegate;
@end
//
// LMHWaterFallLayout.m
// WateFallLayoutTest
//
// Created by 刘梦桦 on 2017/5/18.
// Copyright © 2017年 lmh. All rights reserved.
//
#import "LMHWaterFallLayout.h"
/** 默认的列数 */
static const CGFloat LMHDefaultColunmCount = 3;
/** 每一列之间的间距 */
static const CGFloat LMHDefaultColunmMargin = 10;
/** 每一行之间的间距 */
static const CGFloat LMHDefaultRowMargin = 10;
/** 内边距 */
static const UIEdgeInsets LMHDefaultEdgeInsets = {10,10,10,10};
@interface LMHWaterFallLayout()
/** 存放所有的布局属性 */
@property (nonatomic, strong) NSMutableArray * attrsArr;
/** 存放所有列的当前高度 */
@property (nonatomic, strong) NSMutableArray *columnHeights;
/** 内容的高度 */
@property (nonatomic, assign) CGFloat contentHeight;
- (NSUInteger)colunmCount;
- (CGFloat)columnMargin;
- (CGFloat)rowMargin;
- (UIEdgeInsets)edgeInsets;
@end
@implementation LMHWaterFallLayout
#pragma mark 懒加载
- (NSMutableArray *)attrsArr{
if (!_attrsArr) {
_attrsArr = [NSMutableArray array];
}
return _attrsArr;
}
- (NSMutableArray *)columnHeights{
if (!_columnHeights) {
_columnHeights = [NSMutableArray array];
}
return _columnHeights;
}
#pragma mark - 数据处理
/**
* 列数
*/
- (NSUInteger)colunmCount{
if ([self.delegate respondsToSelector:@selector(columnCountInWaterFallLayout:)]) {
return [self.delegate columnCountInWaterFallLayout:self];
}else{
return LMHDefaultColunmCount;
}
}
/**
* 列间距
*/
- (CGFloat)columnMargin{
if ([self.delegate respondsToSelector:@selector(columnMarginInWaterFallLayout:)]) {
return [self.delegate columnMarginInWaterFallLayout:self];
}else{
return LMHDefaultColunmMargin;
}
}
/**
* 行间距
*/
- (CGFloat)rowMargin{
if ([self.delegate respondsToSelector:@selector(rowMarginInWaterFallLayout:)]) {
return [self.delegate rowMarginInWaterFallLayout:self];
}else{
return LMHDefaultRowMargin;
}
}
/**
* item的内边距
*/
- (UIEdgeInsets)edgeInsets{
if ([self.delegate respondsToSelector:@selector(edgeInsetdInWaterFallLayout:)]) {
return [self.delegate edgeInsetdInWaterFallLayout:self];
}else{
return LMHDefaultEdgeInsets;
}
}
/**
* 初始化
*/
- (void)prepareLayout{
[super prepareLayout];
self.contentHeight = 0;
// 清楚之前计算的所有高度
[self.columnHeights removeAllObjects];
// 设置每一列默认的高度
for (NSInteger i = 0; i < LMHDefaultColunmCount ; i ++) {
[self.columnHeights addObject:@(LMHDefaultEdgeInsets.top)];
}
// 清楚之前所有的布局属性
[self.attrsArr removeAllObjects];
// 开始创建每一个cell对应的布局属性
NSInteger count = [self.collectionView numberOfItemsInSection:0];
for (int i = 0; i < count; i++) {
// 创建位置
NSIndexPath * indexPath = [NSIndexPath indexPathForItem:i inSection:0];
// 获取indexPath位置上cell对应的布局属性
UICollectionViewLayoutAttributes * attrs = [self layoutAttributesForItemAtIndexPath:indexPath];
[self.attrsArr addObject:attrs];
}
}
/**
* 返回indexPath位置cell对应的布局属性
*/
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath{
// 创建布局属性
UICollectionViewLayoutAttributes * attrs = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
//collectionView的宽度
CGFloat collectionViewW = self.collectionView.frame.size.width;
// 设置布局属性的frame
CGFloat cellW = (collectionViewW - self.edgeInsets.left - self.edgeInsets.right - (self.colunmCount - 1) * self.columnMargin) / self.colunmCount;
CGFloat cellH = [self.delegate waterFallLayout:self heightForItemAtIndexPath:indexPath.item itemWidth:cellW];
// 找出最短的那一列
NSInteger destColumn = 0;
CGFloat minColumnHeight = [self.columnHeights[0] doubleValue];
for (int i = 1; i < LMHDefaultColunmCount; i++) {
// 取得第i列的高度
CGFloat columnHeight = [self.columnHeights[i] doubleValue];
if (minColumnHeight > columnHeight) {
minColumnHeight = columnHeight;
destColumn = i;
}
}
CGFloat cellX = self.edgeInsets.left + destColumn * (cellW + self.columnMargin);
CGFloat cellY = minColumnHeight;
if (cellY != self.edgeInsets.top) {
cellY += self.rowMargin;
}
attrs.frame = CGRectMake(cellX, cellY, cellW, cellH);
// 更新最短那一列的高度
self.columnHeights[destColumn] = @(CGRectGetMaxY(attrs.frame));
// 记录内容的高度 - 即最长那一列的高度
CGFloat maxColumnHeight = [self.columnHeights[destColumn] doubleValue];
if (self.contentHeight < maxColumnHeight) {
self.contentHeight = maxColumnHeight;
}
return attrs;
}
/**
* 决定cell的高度
*/
- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect{
return self.attrsArr;
}
/**
* 内容的高度
*/
- (CGSize)collectionViewContentSize{
// CGFloat maxColumnHeight = [self.columnHeights[0] doubleValue];
// for (int i = 0; i < LMHDefaultColunmCount; i++) {
//
// // 取得第i列的高度
// CGFloat columnHeight = [self.columnHeights[i] doubleValue];
//
// if (maxColumnHeight < columnHeight) {
// maxColumnHeight = columnHeight;
// }
//
// }
return CGSizeMake(0, self.contentHeight + self.edgeInsets.bottom);
}
@end
//
// LZNCollectionViewFlowLayout.h
// ThirdTask-瀑布流
//
// Created by linzhennan on 16/3/21.
// Copyright © 2016年 Zhennan Lin. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LZNCollectionViewFlowLayout : UICollectionViewLayout
@property (nonatomic, assign) id<UICollectionViewDelegateFlowLayout> delegate;
@property (nonatomic, assign) NSUInteger cellCount; // cell 的个数
@property (nonatomic, strong) NSMutableArray *cellHeightArray;
@property (nonatomic, strong) NSMutableDictionary *cellAttributeDict; // cell 的位置信息
/**
* @author Paul Wang, 16-03-10 20:03:19
*
* @brief 构造方法,用于特殊高度的 headerView
*
* @param topHeight 顶高度
*
* @return
*/
- (instancetype)initWithTopHeight:(CGFloat)topHeight;
@end
//
// LZNCollectionViewFlowLayout.m
// ThirdTask-瀑布流
//
// Created by linzhennan on 16/3/21.
// Copyright © 2016年 Zhennan Lin. All rights reserved.
//
#import "LZNCollectionViewFlowLayout.h"
@interface LZNCollectionViewFlowLayout () {
CGFloat _topHeight;
}
@end
@implementation LZNCollectionViewFlowLayout
- (instancetype)initWithTopHeight:(CGFloat)topHeight {
self = [super init];
if (self) {
_topHeight = topHeight;
}
return self;
}
- (void)prepareLayout {
[super prepareLayout];
_cellHeightArray = [NSMutableArray array];
_cellAttributeDict = [NSMutableDictionary dictionary];
_delegate = (id<UICollectionViewDelegateFlowLayout>)self.collectionView.delegate;
// 获取cell的个数
_cellCount = [self.collectionView numberOfItemsInSection:0];
if (_cellCount == 0) {
return;
}
float top = _topHeight;
for (NSInteger i = 0; i < 2; i++) {
[_cellHeightArray addObject:@(top)];
}
// 调用layoutForItemAtIndexPath方法,为每个cell布局,
for (NSInteger i = 0; i < _cellCount; i ++) {
[self layoutItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
}
}
- (void)layoutItemAtIndexPath:(NSIndexPath *)indexPath {
// 通过协议获得cell的间隙
UIEdgeInsets edgeInsets = [self.delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:indexPath.row];
// 通过协议获得cell的大小
CGSize itemSize = [self.delegate collectionView:self.collectionView layout:self sizeForItemAtIndexPath:indexPath];
NSInteger column = 0;
float shortHeight = [[_cellHeightArray objectAtIndex:column] floatValue];
//找出高度最小的列,将cell加到最小列中
for (int i = 0; i < _cellHeightArray.count; i++) {
float height = [[_cellHeightArray objectAtIndex:i] floatValue];
if (height < shortHeight) {
shortHeight = height;
column = i;
}
}
float top = [[_cellHeightArray objectAtIndex:column] floatValue];
//确定cell的frame
CGRect frame = CGRectMake(edgeInsets.left + column * (edgeInsets.left + itemSize.width), top + edgeInsets.top, itemSize.width, itemSize.height);
//更新列高
[_cellHeightArray replaceObjectAtIndex:column withObject:[NSNumber numberWithFloat:top + edgeInsets.top + itemSize.height]];
//每个cell的frame对应一个indexPath,放入字典中
[_cellAttributeDict setObject:NSStringFromCGRect(frame) forKey:indexPath];
}
//返回cell的布局信息,如果忽略传入的rect一次性将所有的cell布局信息返回,图片过多时性能会很差
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSMutableArray *muArr = [NSMutableArray array];
for (NSIndexPath *indexPath in _cellAttributeDict) {
CGRect cellRect = CGRectFromString(_cellAttributeDict[indexPath]);
if (CGRectIntersectsRect(cellRect, rect)) {
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
[muArr addObject:attributes];
}
}
return muArr;
}
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
attributes.frame = CGRectFromString(_cellAttributeDict[indexPath]);
return attributes;
}
//最后还要实现这个方法,返回collectionView内容的大小
//只需要遍历前面创建的存放列高的数组得到列最高的一个作为高度返回就可以了
- (CGSize)collectionViewContentSize {
CGSize size = self.collectionView.frame.size;
float maxHeight = 0;
// 查找最高的列的高度
for (int i = 0; i < _cellHeightArray.count; i++) {
float colHeight = [[_cellHeightArray objectAtIndex:i] floatValue];
if (colHeight > maxHeight) {
maxHeight = colHeight;
}
}
size.height = maxHeight;
return size;
}
@end
...@@ -9,15 +9,14 @@ ...@@ -9,15 +9,14 @@
#import "ZXAliMaMaViewController.h" #import "ZXAliMaMaViewController.h"
#import "ZXAdViewService.h" #import "ZXAdViewService.h"
#import "ZXAlimamaModel.h" #import "ZXAlimamaModel.h"
#import "LMHWaterFallLayout.h"
#import "ZXAlimamaCollectionViewCell.h" #import "ZXAlimamaCollectionViewCell.h"
#import "ZXBannerJumpViewController.h" #import "ZXBannerJumpViewController.h"
#import "enlargeClickRegionBtn.h" #import "enlargeClickRegionBtn.h"
#import "ZXAliMaRecomondModel.h" #import "ZXAliMaRecomondModel.h"
#import "ZXAliMaRecomondModel.h" #import "LZNCollectionViewFlowLayout.h"
static NSString * const LMHShopId = @"shop"; static NSString * const LMHShopId = @"shop";
@interface ZXAliMaMaViewController ()<UICollectionViewDataSource, LMHWaterFallLayoutDeleaget, UICollectionViewDelegate> @interface ZXAliMaMaViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
/** 所有的商品数据 */ /** 所有的商品数据 */
@property (nonatomic, strong) NSMutableArray * shops; @property (nonatomic, strong) NSMutableArray * shops;
...@@ -119,11 +118,12 @@ static NSString * const LMHShopId = @"shop"; ...@@ -119,11 +118,12 @@ static NSString * const LMHShopId = @"shop";
- (void)setupLayoutAndCollectionView{ - (void)setupLayoutAndCollectionView{
// 创建布局 // 创建布局
LMHWaterFallLayout * waterFallLayout = [[LMHWaterFallLayout alloc]init]; // LMHWaterFallLayout * waterFallLayout = [[LMHWaterFallLayout alloc]init];
waterFallLayout.delegate = self; // waterFallLayout.delegate = self;
LZNCollectionViewFlowLayout *flow = [[LZNCollectionViewFlowLayout alloc] init];
flow.delegate = self;
// 创建collectionView // 创建collectionView
UICollectionView * collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTopHeight - kTabBarHeight - 30 * k6Scale) collectionViewLayout:waterFallLayout]; UICollectionView * collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTopHeight - kTabBarHeight - 30 * k6Scale) collectionViewLayout:flow];
collectionView.backgroundColor = [UIColor whiteColor]; collectionView.backgroundColor = [UIColor whiteColor];
collectionView.dataSource = self; collectionView.dataSource = self;
...@@ -253,49 +253,38 @@ static NSString * const LMHShopId = @"shop"; ...@@ -253,49 +253,38 @@ static NSString * const LMHShopId = @"shop";
} }
#pragma mark - UICollectionViewDelegateFlowLayout
#pragma mark - <LMHWaterFallLayoutDeleaget> - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- (CGFloat)waterFallLayout:(LMHWaterFallLayout *)waterFallLayout heightForItemAtIndexPath:(NSUInteger)indexPath itemWidth:(CGFloat)itemWidth{ return CGSizeMake((kScreenWidth - 30 * k6Scale) / 2.0f, 245 * k6Scale);
return 245 * k6Scale;
} }
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- (CGFloat)rowMarginInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout{ return UIEdgeInsetsMake(10 * k6Scale, 10 * k6Scale, 10 * k6Scale, 10 * k6Scale);
return 10;
} }
- (NSUInteger)columnCountInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout{
return 2;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if ([self.titleStr isEqualToString:@"推荐"]) { if ([self.titleStr isEqualToString:@"推荐"]) {
ZXAliMaRecomondModel *recom = self.shops[indexPath.item]; ZXAliMaRecomondModel *recom = self.shops[indexPath.item];
NSString *url = [NSString stringWithFormat:@"%@/alimama/tbk/dg/material/optional?pageNo=1&q=%@&deviceType=IMEI&deviceValue=02399123192391293123&cat=hot", [kUserDefaults objectForKey:@"HomePage"], recom.title]; NSString *url = [NSString stringWithFormat:@"%@/alimama/tbk/dg/material/optional/forItemId?pageNo=1&q=%@&deviceType=IMEI&deviceValue=02399123192391293123&cat=hot&itemId=%@&hasCoupon=0", [kUserDefaults objectForKey:@"HomePage"], recom.title, recom.num_iid];
[[ZXAdViewService sharedManager] GET:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { [[ZXAdViewService sharedManager] GET:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
id res = responseObject[@"data"][@"tbk_dg_material_optional_response"][@"result_list"][@"map_data"]; id res = responseObject[@"data"];
if (res) { if (res) {
NSArray *list = [ZXAlimamaModel mj_objectArrayWithKeyValuesArray:res]; if (res[@"couponShareUrl"]) {
for (ZXAlimamaModel *item in list) { NSString *url = [@"taobao:" stringByAppendingString:res[@"couponShareUrl"]];
if ([item.item_id integerValue] == [recom.num_iid integerValue]) {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *url = [@"taobao:" stringByAppendingString:item.coupon_share_url];
NSURL *URL = [NSURL URLWithString:url]; NSURL *URL = [NSURL URLWithString:url];
if ([[UIApplication sharedApplication] canOpenURL:URL]) { if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL]; [[UIApplication sharedApplication] openURL:URL];
}
} else { } else {
ZXBannerJumpViewController *jumpVc = [[ZXBannerJumpViewController alloc] init]; if (res[@"url"]) {
jumpVc.jumpUrl = [@"https:" stringByAppendingString:item.coupon_share_url]; NSString *url = [@"taobao:" stringByAppendingString:res[@"url"]];
jumpVc.hidesBottomBarWhenPushed = YES; NSURL *URL = [NSURL URLWithString:url];
[self.navigationController pushViewController:jumpVc animated:YES]; if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL];
} }
}); } else {
[ZXTool showText:@"活动已下架,请关注后续活动!"];
} }
} }
} else { } else {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "ZXSearchViewController.h" #import "ZXSearchViewController.h"
#import "ZXAdViewService.h" #import "ZXAdViewService.h"
#import "ZXAlimamaModel.h" #import "ZXAlimamaModel.h"
#import "LMHWaterFallLayout.h" #import "LZNCollectionViewFlowLayout.h"
#import "ZXAlimamaCollectionViewCell.h" #import "ZXAlimamaCollectionViewCell.h"
#import "ZXBannerJumpViewController.h" #import "ZXBannerJumpViewController.h"
#import "enlargeClickRegionBtn.h" #import "enlargeClickRegionBtn.h"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#import "ZXFliterView.h" #import "ZXFliterView.h"
@interface ZXSearchViewController ()<UICollectionViewDataSource, LMHWaterFallLayoutDeleaget, UICollectionViewDelegate, ZXFliterDelegate> @interface ZXSearchViewController ()<UICollectionViewDataSource, UICollectionViewDelegate, ZXFliterDelegate>
/** 所有的商品数据 */ /** 所有的商品数据 */
@property (nonatomic, strong) NSMutableArray * shops; @property (nonatomic, strong) NSMutableArray * shops;
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
- (void)setupLayoutAndCollectionView{ - (void)setupLayoutAndCollectionView{
// 创建布局 // 创建布局
LMHWaterFallLayout * waterFallLayout = [[LMHWaterFallLayout alloc]init]; LZNCollectionViewFlowLayout * waterFallLayout = [[LZNCollectionViewFlowLayout alloc]init];
waterFallLayout.delegate = self; waterFallLayout.delegate = self;
// 创建collectionView // 创建collectionView
...@@ -256,23 +256,7 @@ ...@@ -256,23 +256,7 @@
#pragma mark - <LMHWaterFallLayoutDeleaget>
- (CGFloat)waterFallLayout:(LMHWaterFallLayout *)waterFallLayout heightForItemAtIndexPath:(NSUInteger)indexPath itemWidth:(CGFloat)itemWidth{
return 238 * k6Scale;
}
- (CGFloat)rowMarginInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout{
return 10;
}
- (NSUInteger)columnCountInWaterFallLayout:(LMHWaterFallLayout *)waterFallLayout{
return 2;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
ZXAlimamaModel *model = self.shops[indexPath.item]; ZXAlimamaModel *model = self.shops[indexPath.item];
NSString *url = [@"taobao:" stringByAppendingString:model.coupon_share_url]; NSString *url = [@"taobao:" stringByAppendingString:model.coupon_share_url];
...@@ -286,7 +270,13 @@ ...@@ -286,7 +270,13 @@
[self.navigationController pushViewController:jumpVc animated:YES]; [self.navigationController pushViewController:jumpVc animated:YES];
} }
} }
#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake((kScreenWidth - 30 * k6Scale) / 2.0f, 245 * k6Scale);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(10 * k6Scale, 10 * k6Scale, 10 * k6Scale, 10 * k6Scale);
}
#pragma mark - filterdelegate #pragma mark - filterdelegate
- (void)filterByPrices:(NSInteger)status { - (void)filterByPrices:(NSInteger)status {
NSString *searchStr = @""; NSString *searchStr = @"";
......
// //
...@@ -62,13 +62,14 @@ kSINGLETON_FOR_CLASS(APIManager) ...@@ -62,13 +62,14 @@ kSINGLETON_FOR_CLASS(APIManager)
// [userDefaults setObject:@"http://192.168.100.112:8888" forKey:@"DCWash"]; // [userDefaults setObject:@"http://192.168.100.112:8888" forKey:@"DCWash"];
[userDefaults setObject:@"8197" forKey:@"DCWashSocketPort"]; [userDefaults setObject:@"8197" forKey:@"DCWashSocketPort"];
[userDefaults setObject:@"2081ad8ddc23576.natapp.cc" forKey:@"DCWashSocketUrl"]; [userDefaults setObject:@"2081ad8ddc23576.natapp.cc" forKey:@"DCWashSocketUrl"];
[userDefaults setObject:@"http://dev-task-appserv.168cad.top" forKey:@"Task"];
[userDefaults setObject:@"http://ex-dev-dcxy-static.168cad.top" forKey:@"TaskH5"];
[userDefaults synchronize]; [userDefaults synchronize];
break; break;
} }
case ZXColorfulSchoolEnvironmentTest: { case ZXColorfulSchoolEnvironmentTest: {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"http://internal-test-dcxyapi.168cad.top/dcintsrv/mt/entrance.do" forKey:@"schoolIp"]; [userDefaults setObject:@"http://internal-test-dcxyapi.168cad.top/dcintsrv/mt/entrance.do" forKey:@"schoolIp"];
[userDefaults setObject:@"internal-test-dcgz-bg-static.168cad.top" forKey:@"RootUrl"]; [userDefaults setObject:@"internal-test-dcgz-bg-static.168cad.top" forKey:@"RootUrl"];
[userDefaults setObject:@"http://internal-test-dcxyapi.168cad.top/dcintsrv/pay/createAliOrder.do"forKey:@"Ali"]; [userDefaults setObject:@"http://internal-test-dcxyapi.168cad.top/dcintsrv/pay/createAliOrder.do"forKey:@"Ali"];
...@@ -99,7 +100,8 @@ kSINGLETON_FOR_CLASS(APIManager) ...@@ -99,7 +100,8 @@ kSINGLETON_FOR_CLASS(APIManager)
[userDefaults setObject:@"http://ex-test-other-device-app.168cad.top" forKey:@"DCWash"]; [userDefaults setObject:@"http://ex-test-other-device-app.168cad.top" forKey:@"DCWash"];
[userDefaults setObject:@"8197" forKey:@"DCWashSocketPort"]; [userDefaults setObject:@"8197" forKey:@"DCWashSocketPort"];
[userDefaults setObject:@"12081ad8ddc23576.natapp.cc" forKey:@"DCWashSocketUrl"]; [userDefaults setObject:@"12081ad8ddc23576.natapp.cc" forKey:@"DCWashSocketUrl"];
[userDefaults setObject:@"http://test-task-appserv.168cad.top" forKey:@"Task"];
[userDefaults setObject:@"http://ex-test-dcxy-static.168cad.top" forKey:@"TaskH5"];
[userDefaults synchronize]; [userDefaults synchronize];
break; break;
} }
...@@ -145,6 +147,8 @@ kSINGLETON_FOR_CLASS(APIManager) ...@@ -145,6 +147,8 @@ kSINGLETON_FOR_CLASS(APIManager)
[userDefaults setObject:@"8005" forKey:@"DCWashSocketPort"]; [userDefaults setObject:@"8005" forKey:@"DCWashSocketPort"];
[userDefaults setObject:@"other-tcp-mobile.dcrym.com" forKey:@"DCWashSocketUrl"]; [userDefaults setObject:@"other-tcp-mobile.dcrym.com" forKey:@"DCWashSocketUrl"];
[userDefaults setObject:@"http://product-task-appserv.168cad.top" forKey:@"Task"];
[userDefaults setObject:@"http://ex-dev-dcxy-static.168cad.top" forKey:@"TaskH5"];
[userDefaults synchronize]; [userDefaults synchronize];
break; break;
} }
......
// //
...@@ -22,4 +22,10 @@ ...@@ -22,4 +22,10 @@
@property (nonatomic, strong) NSArray *switchs; @property (nonatomic, strong) NSArray *switchs;
@property(nonatomic, weak) id<didSelectItemActionDelegate> delegate; @property(nonatomic, weak) id<didSelectItemActionDelegate> delegate;
/** 当前选中的title */
@property (nonatomic, copy) NSString *buttonTitle;
@end @end
// //
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#import "JXLayoutButton.h" #import "JXLayoutButton.h"
@interface CustomerTabbar() @interface CustomerTabbar()
/** */
@property (nonatomic, strong) JXLayoutButton *currentButton;
@property (nonatomic, assign) int currentIndex; @property (nonatomic, assign) int currentIndex;
@property (nonatomic, strong) UIView *maskView; @property (nonatomic, strong) UIView *maskView;
@end @end
...@@ -53,6 +54,10 @@ ...@@ -53,6 +54,10 @@
[titleArray addObject:@"短视频"]; [titleArray addObject:@"短视频"];
[imagesArray addObject:@"nav_video_nor"]; [imagesArray addObject:@"nav_video_nor"];
[selectImagesArray addObject:@"nav_video_sel"]; [selectImagesArray addObject:@"nav_video_sel"];
} else if ([dic[@"type"] isEqualToString:@"14"]) {
[titleArray addObject:@"任务"];
[imagesArray addObject:@"nav_video_nor"];
[selectImagesArray addObject:@"nav_video_sel"];
} }
} }
if (isHasSc) { if (isHasSc) {
...@@ -72,9 +77,16 @@ ...@@ -72,9 +77,16 @@
btn.frame = CGRectMake(W * i, 0, W, 49); btn.frame = CGRectMake(W * i, 0, W, 49);
@weakify(self); @weakify(self);
[[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(JXLayoutButton *x) { [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(JXLayoutButton *x) {
currentBtn.enabled = YES;
if ([title isEqualToString:@"商城"]) {
if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) {
[self.delegate selectPageIndex:4 fromIndex:self.currentIndex];
}
self.currentIndex = 4;
} else {
self.currentButton.enabled = YES;
x.enabled = NO; x.enabled = NO;
currentBtn = x; self.currentButton = x;
@strongify(self); @strongify(self);
if ([title isEqualToString:@"多彩"]) { if ([title isEqualToString:@"多彩"]) {
if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) { if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) {
...@@ -96,20 +108,22 @@ ...@@ -96,20 +108,22 @@
[self.delegate selectPageIndex:3 fromIndex:self.currentIndex]; [self.delegate selectPageIndex:3 fromIndex:self.currentIndex];
} }
self.currentIndex = 3; self.currentIndex = 3;
} else if ([title isEqualToString:@"商城"]) {
if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) {
[self.delegate selectPageIndex:4 fromIndex:self.currentIndex];
}
self.currentIndex = 4;
} else if ([title isEqualToString:@"我的"]) { } else if ([title isEqualToString:@"我的"]) {
if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) { if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) {
[self.delegate selectPageIndex:5 fromIndex:self.currentIndex]; [self.delegate selectPageIndex:5 fromIndex:self.currentIndex];
} }
self.currentIndex = 5; self.currentIndex = 5;
} else if ([title isEqualToString:@"任务"]) {
if ([self.delegate respondsToSelector:@selector(selectPageIndex:fromIndex:)]) {
[self.delegate selectPageIndex:6 fromIndex:self.currentIndex];
} }
self.currentIndex = 6;
}
}
}]; }];
if (i==0) { if (i==0) {
currentBtn = btn; self.currentButton = btn;
btn.enabled = NO; btn.enabled = NO;
self.currentIndex = 0; self.currentIndex = 0;
} }
...@@ -132,6 +146,24 @@ ...@@ -132,6 +146,24 @@
return button; return button;
} }
- (void)setButtonTitle:(NSString *)buttonTitle {
_buttonTitle = buttonTitle;
if (![buttonTitle isEqualToString:@"商城"]) {
for (int i = 0; i < self.subviews.count; i++) {
JXLayoutButton *button = self.subviews[i];
button.enabled = YES;
if ([button.titleLabel.text isEqualToString:buttonTitle]) {
self.currentIndex = 2;
button.enabled = NO;
self.currentButton = button;
}
}
}
}
@end @end
// //
...@@ -526,27 +526,18 @@ ...@@ -526,27 +526,18 @@
return; return;
} }
NSString *url = [NSString stringWithFormat:@"%@/alimama/tbk/dg/material/optional?pageNo=1&q=%@&deviceType=IMEI&deviceValue=02399123192391293123&cat=hot", [kUserDefaults objectForKey:@"HomePage"], dic[@"title"]]; NSString *url = [NSString stringWithFormat:@"%@/alimama/tbk/dg/material/optional/forItemId?pageNo=1&q=%@&deviceType=IMEI&deviceValue=02399123192391293123&cat=hot&itemId=%@&hasCoupon=0", [kUserDefaults objectForKey:@"HomePage"], dic[@"title"], item_id];
[[ZXAdViewService sharedManager] GET:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { [[ZXAdViewService sharedManager] GET:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
id res = responseObject[@"data"][@"tbk_dg_material_optional_response"][@"result_list"][@"map_data"]; id res = responseObject[@"data"];
if (res) { if (res) {
NSArray *list = [ZXAlimamaModel mj_objectArrayWithKeyValuesArray:res]; if (res[@"couponShareUrl"]) {
__block ZXAlimamaModel *m; [self jumpTaobaoWithItem:res[@"couponShareUrl"]];
for (ZXAlimamaModel *item in list) {
if ([item.item_id integerValue] == [item_id integerValue]) {
m = item;
}
}
if (m) {
[self jumpTaobaoWithItem:m];
} else { } else {
if (list.count) { if (res[@"url"]) {
[self jumpTaobaoWithItem:list[0]]; [self jumpTaobaoWithItem:res[@"url"]];
} else { } else {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:@"活动已下架,请关注后续活动!"]; [ZXTool showText:@"活动已下架,请关注后续活动!"];
});
} }
} }
} else { } else {
...@@ -576,15 +567,15 @@ ...@@ -576,15 +567,15 @@
} }
} }
- (void) jumpTaobaoWithItem:(ZXAlimamaModel *) item { - (void) jumpTaobaoWithItem:(NSString *) couponShareUrl {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSString *url = [@"taobao:" stringByAppendingString:item.coupon_share_url]; NSString *url = [@"taobao:" stringByAppendingString:couponShareUrl];
NSURL *URL = [NSURL URLWithString:url]; NSURL *URL = [NSURL URLWithString:url];
if ([[UIApplication sharedApplication] canOpenURL:URL]) { if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL]; [[UIApplication sharedApplication] openURL:URL];
} else { } else {
ZXBannerJumpViewController *jumpVc = [[ZXBannerJumpViewController alloc] init]; ZXBannerJumpViewController *jumpVc = [[ZXBannerJumpViewController alloc] init];
jumpVc.jumpUrl = [@"https:" stringByAppendingString:item.coupon_share_url]; jumpVc.jumpUrl = [@"https:" stringByAppendingString:couponShareUrl];
jumpVc.hidesBottomBarWhenPushed = YES; jumpVc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:jumpVc animated:YES]; [self.navigationController pushViewController:jumpVc animated:YES];
} }
......
// //
...@@ -34,10 +34,11 @@ ...@@ -34,10 +34,11 @@
#import "AimiWalletViewController.h" #import "AimiWalletViewController.h"
#import "enlargeClickRegionBtn.h" #import "enlargeClickRegionBtn.h"
#import "CropImageController.h" #import "CropImageController.h"
#import "ZXBDTool.h"
#import "WWWWEbViewController.h" #import "WWWWEbViewController.h"
#import "ZXAdViewService.h" #import "ZXAdViewService.h"
#import "ZXBannerJumpViewController.h" #import "ZXBannerJumpViewController.h"
#import "ZXTaskViewController.h"
@interface ZXHomePageViewController ()<UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate, CropImageDelegate> @interface ZXHomePageViewController ()<UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate, CropImageDelegate>
/** tableview */ /** tableview */
@property (nonatomic, strong) UITableView *myTableView; @property (nonatomic, strong) UITableView *myTableView;
...@@ -95,13 +96,13 @@ ...@@ -95,13 +96,13 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUserNameAction:) name:@"changeUserNameNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUserNameAction:) name:@"changeUserNameNotification" object:nil];
//测试按钮 // //测试按钮
// UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, kScreenHeight - 150, 80, 80)]; // UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, kScreenHeight - 150, 80, 80)];
// [self.view addSubview:btn]; // [self.view addSubview:btn];
// btn.backgroundColor = [UIColor orangeColor]; // btn.backgroundColor = [UIColor orangeColor];
// [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) { // [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
// WWWWEbViewController *vc = [[WWWWEbViewController alloc] init]; // ZXTaskViewController *vc = [[NSClassFromString(@"ZXTaskViewController") alloc] init];
// vc.jumpUrl = @"https://cpu.baidu.com/1032/ed6b6847?scid=43624";
// [self.navigationController pushViewController:vc animated:YES]; // [self.navigationController pushViewController:vc animated:YES];
// }]; // }];
...@@ -165,8 +166,62 @@ ...@@ -165,8 +166,62 @@
[ExpecptionModel clearTable]; [ExpecptionModel clearTable];
} }
} }
}
//查看任务相关内容
@weakify(self);
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodPOST url:[NSString stringWithFormat:@"%@/dcxy/api/tasks/homePage", [kUserDefaults objectForKey:@"Task"]] para:nil completed:^(CommonModel *common, NSString *error) {
@strongify(self);
if ([common.data boolValue]) {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
[self showTaskDialog];
});
}
}];
}
#pragma mark - 显示领券弹窗
- (void) showTaskDialog {
UIView *taskBgView = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds];
[kAppWindow addSubview:taskBgView];
taskBgView.backgroundColor = kRGBColor(0, 0, 0, 0.4);
UIImage *image = [UIImage imageNamed:@"task_home"];
UIImageView *imageV = [[UIImageView alloc] init];
imageV.image = image;
imageV.userInteractionEnabled = YES;
[taskBgView addSubview:imageV];
[imageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(taskBgView.mas_centerX);
make.top.equalTo(taskBgView.mas_top).offset(kTopHeight + 70 * k6Scale);
make.width.mas_equalTo(355 * k6Scale);
make.height.mas_equalTo(355 * k6Scale * image.size.height / image.size.width);
}];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
[imageV addGestureRecognizer:tap];
@weakify(self);
[[tap rac_gestureSignal] subscribeNext:^(id x) {
@strongify(self);
ZXTaskViewController *taskVc = [[ZXTaskViewController alloc] init];
taskVc.jumpUrl = [NSString stringWithFormat:@"%@/taskApp/coupon.html?token=%@", [kUserDefaults objectForKey:@"TaskH5"], CacheToken];
taskVc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:taskVc animated:YES];
}];
enlargeClickRegionBtn *closeButton = [[enlargeClickRegionBtn alloc] init];
[taskBgView addSubview:closeButton];
[closeButton setBackgroundImage:[UIImage imageNamed:@"task_close"] forState:UIControlStateNormal];
[closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(31 * k6Scale);
make.centerX.equalTo(taskBgView);
make.top.equalTo(imageV.mas_bottom);
}];
[[closeButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
taskBgView.hidden = YES;
[taskBgView removeFromSuperview];
}];
}
- (UITableView *)myTableView { - (UITableView *)myTableView {
if (_myTableView== nil) { if (_myTableView== nil) {
CGFloat bottomH = 0; CGFloat bottomH = 0;
...@@ -174,7 +229,7 @@ ...@@ -174,7 +229,7 @@
bottomH = 34; bottomH = 34;
} }
_myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kTopHeight + 13 * k6Scale, kScreenWidth, kScreenHeight - bottomH - 49 - kTopHeight - 13 * k6Scale) style:UITableViewStyleGrouped]; _myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kTopHeight + 13 * k6Scale, kScreenWidth, kScreenHeight - bottomH - 49 - kTopHeight - 13 * k6Scale) style:UITableViewStyleGrouped];
// _myTableView.contentInset = UIEdgeInsetsMake(6 * k6Scale, 0, 0, 0); // _myTableView.contentInset = UIEdgeInsetsMake(6 * k6Scale, 0, 0, 0);
_myTableView.delegate = self; _myTableView.delegate = self;
_myTableView.dataSource = self; _myTableView.dataSource = self;
_myTableView.showsHorizontalScrollIndicator = NO; _myTableView.showsHorizontalScrollIndicator = NO;
...@@ -255,10 +310,10 @@ ...@@ -255,10 +310,10 @@
NSArray *arr = self.service.dataSource[section]; NSArray *arr = self.service.dataSource[section];
return arr.count?1:0; return arr.count?1:0;
} }
// ZXHomeChildInfo *child = sec.blockData.firstObject; // ZXHomeChildInfo *child = sec.blockData.firstObject;
// if (child && [child.blockType isEqualToString:@"3"]) { // if (child && [child.blockType isEqualToString:@"3"]) {
// return 1; // return 1;
// } // }
return sec.blockData.count; return sec.blockData.count;
} }
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
......
// //
...@@ -13,15 +13,14 @@ ...@@ -13,15 +13,14 @@
#import "SDCycleScrollView.h" #import "SDCycleScrollView.h"
#import "ZXAdViewAdTool.h" #import "ZXAdViewAdTool.h"
#import "BUADTool.h" #import "BUADTool.h"
#import <BUAdSDK/BUAdSDK.h> #import "ZXBDTool.h"
@interface ZXSelfHelpViewController ()<BUNativeExpressBannerViewDelegate> { @interface ZXSelfHelpViewController () {
enlargeClickRegionBtn *showCode; enlargeClickRegionBtn *showCode;
} }
/** banner广澳 */
@property (nonatomic, strong) BUNativeExpressBannerView *bannerView;
@property (nonatomic, strong) dispatch_source_t gcdTimer; @property (nonatomic, strong) dispatch_source_t gcdTimer;
/** /**
...@@ -82,8 +81,30 @@ ...@@ -82,8 +81,30 @@
[self createBannerView]; [self createBannerView];
[self createCodeView]; [self createCodeView];
if ([[kUserDefaults objectForKey:kAPP_SELP_ADVIEW_SHOW] isEqualToString:@"yes"]) { if ([[kUserDefaults objectForKey:kAPP_SELP_ADVIEW_SHOW] isEqualToString:@"yes"]) {
[[[BUADTool alloc] init] loadBannerAdWithController:self]; UIView *adSuperView = [[UIView alloc] init];
[self.view addSubview:adSuperView];
adSuperView.backgroundColor = UIColor.whiteColor;
[adSuperView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(self.view);
make.height.mas_equalTo(kScreenWidth * 0.3 + 10 * k6Scale);
}];
enlargeClickRegionBtn *closeButton = [[enlargeClickRegionBtn alloc] init];
[closeButton setBackgroundImage:[UIImage imageNamed:@"task_close"] forState:UIControlStateNormal];
[adSuperView addSubview:closeButton];
[closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.top.equalTo(adSuperView);
make.width.height.mas_equalTo(20 * k6Scale);
}];
[adSuperView bringSubviewToFront:closeButton];
[[closeButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
adSuperView.hidden = YES;
[adSuperView removeFromSuperview];
}];
[[ZXBDTool new] createNativie20_3AdByView:adSuperView];
[[[BUADTool alloc] init] loadBannerAdWithController:self superView:adSuperView];
} }
...@@ -381,42 +402,5 @@ ...@@ -381,42 +402,5 @@
#pragma BUNativeExpressBannerViewDelegate
- (void)nativeExpressBannerAdViewDidLoad:(BUNativeExpressBannerView *)bannerAdView {
NSLog(@"%s",__func__);
}
- (void)nativeExpressBannerAdView:(BUNativeExpressBannerView *)bannerAdView didLoadFailWithError:(NSError *)error {
NSLog(@"%s",__func__);
}
- (void)nativeExpressBannerAdViewRenderSuccess:(BUNativeExpressBannerView *)bannerAdView {
NSLog(@"%s",__func__);
}
- (void)nativeExpressBannerAdViewRenderFail:(BUNativeExpressBannerView *)bannerAdView error:(NSError *)error {
NSLog(@"%s",__func__);
}
- (void)nativeExpressBannerAdViewWillBecomVisible:(BUNativeExpressBannerView *)bannerAdView {
NSLog(@"%s",__func__);
}
- (void)nativeExpressBannerAdViewDidClick:(BUNativeExpressBannerView *)bannerAdView {
NSLog(@"%s",__func__);
}
- (void)nativeExpressBannerAdView:(BUNativeExpressBannerView *)bannerAdView dislikeWithReason:(NSArray<BUDislikeWords *> *)filterwords {
NSLog(@"%s",__func__);
[UIView animateWithDuration:0.25 animations:^{
bannerAdView.alpha = 0;
} completion:^(BOOL finished) {
[bannerAdView removeFromSuperview];
if (self.bannerView == bannerAdView) {
self.bannerView = nil;
}
}];
}
@end @end
// //
...@@ -78,9 +78,7 @@ ...@@ -78,9 +78,7 @@
}]; }];
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[[back rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) { [[back rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
[self.bluetoothManager cutBluetoothAndSocketConnect];
self.bluetoothManager.delegate = nil;
self.bluetoothManager = nil;
[weakSelf.navigationController popViewControllerAnimated:YES]; [weakSelf.navigationController popViewControllerAnimated:YES];
}]; }];
...@@ -246,5 +244,14 @@ ...@@ -246,5 +244,14 @@
- (void) connectBluetoothFaliure { - (void) connectBluetoothFaliure {
self.okPayButton.enabled = YES; self.okPayButton.enabled = YES;
} }
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.bluetoothManager cutBluetoothAndSocketConnect];
self.bluetoothManager.delegate = nil;
self.bluetoothManager = nil;
}
- (void)dealloc {
NSLog(@"%s", __func__);
}
@end @end
//
//
// ZXTaskManager.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/11/26.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXTaskManager : NSObject
kSINGLETON_FOR_HEADER(ZXTaskManager)
/** task */
@property (nonatomic, copy) NSString *taskCode;
/** 任务状态 0失败 1已完成(未上报) 2已上报*/
@property (nonatomic, assign) NSInteger status;
@end
NS_ASSUME_NONNULL_END
//
//
// ZXTaskManager.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/11/26.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXTaskManager.h"
@implementation ZXTaskManager
kSINGLETON_FOR_CLASS(ZXTaskManager)
@end
//
//
// ZXTaskViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/11/22.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXTaskViewController : UIViewController
/** jumpUrl */
@property (nonatomic, copy) NSString *jumpUrl;
/** 是否是任务首页 */
@property (nonatomic, assign) NSInteger isTaskHomePage;
/** 状态栏颜色 */
@property (nonatomic, copy) NSString *colorHex;
/** 跳转淘宝惠购 */
@property (nonatomic, copy) dispatch_block_t jumpTaobaoHJ;
@end
NS_ASSUME_NONNULL_END
// //
...@@ -174,4 +174,6 @@ typedef void(^checkIsOldCustomer)(BOOL isOld); ...@@ -174,4 +174,6 @@ typedef void(^checkIsOldCustomer)(BOOL isOld);
+(void) alimamaTest; +(void) alimamaTest;
//ip
+ (NSString*)getCurentLocalIP;
@end @end
// //
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import <CoreTelephony/CTTelephonyNetworkInfo.h> #import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h> #import <CoreTelephony/CTCarrier.h>
#import <ifaddrs.h>
#import <arpa/inet.h>
#import "ZXFirstPageService.h" #import "ZXFirstPageService.h"
#import "ZXSections.h" #import "ZXSections.h"
#import "ZXBookMarkModel.h" #import "ZXBookMarkModel.h"
...@@ -1763,5 +1765,55 @@ void ProviderReleaseData (void *info, const void *data, size_t size){ ...@@ -1763,5 +1765,55 @@ void ProviderReleaseData (void *info, const void *data, size_t size){
}]; }];
} }
} }
#pragma mark - 获取ip地址
+ (NSString*)getCurentLocalIP{
    NSString*address =nil;
    struct ifaddrs*interfaces =NULL;
    struct ifaddrs*temp_addr =NULL;
    int success =0;
    // retrieve the current interfaces - returns 0 on success
    success =getifaddrs(&interfaces);
    if(success ==0) {
        // Loop through linked list of interfaces
        temp_addr = interfaces;
        while(temp_addr !=NULL) {
            NSLog(@"%d",temp_addr->ifa_addr->sa_family);
            if(temp_addr->ifa_addr->sa_family==AF_INET|| temp_addr->ifa_addr->sa_family==AF_INET6|| temp_addr->ifa_addr->sa_family==AF_LINK) {
                if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
                    // Get NSString from C String
                    address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
                }
            }
            temp_addr = temp_addr->ifa_next;
        }
    }
    // Free memory
    freeifaddrs(interfaces);
    return address;
}
@end @end
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>app需要你开启定位权限</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>zh_CN</string> <string>zh_CN</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>多彩校园</string> <string>$(PRODUCT_NAME)</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
......
// //
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#import "ZXRSNewsManagerController.h" #import "ZXRSNewsManagerController.h"
#import "ZXMallViewController.h" #import "ZXMallViewController.h"
#import "ZXBQTViewController.h" #import "ZXBQTViewController.h"
#import "ZXTaskViewController.h"
@interface MyTabViewController ()<didSelectItemActionDelegate> @interface MyTabViewController ()<didSelectItemActionDelegate>
{ {
...@@ -31,13 +31,16 @@ ...@@ -31,13 +31,16 @@
XMGNavigationViewController *nav4; XMGNavigationViewController *nav4;
XMGNavigationViewController *nav5; XMGNavigationViewController *nav5;
XMGNavigationViewController *nav6; XMGNavigationViewController *nav6;
XMGNavigationViewController *nav7;
ZXMallViewController *webVC; ZXMallViewController *webVC;
//设置默认tabBar选项; //设置默认tabBar选项;
CustomerTabbar *cusTabbar;
} }
/** 开关集合 */ /** 开关集合 */
@property (nonatomic, strong) NSMutableArray *switchs; @property (nonatomic, strong) NSMutableArray *switchs;
/** */
@property (nonatomic, strong) CustomerTabbar *cusTabbar;
@end @end
@implementation MyTabViewController @implementation MyTabViewController
...@@ -91,7 +94,7 @@ ...@@ -91,7 +94,7 @@
//type 1资讯 2商城 3支付配置 4免密开关 5小程序(app不需要) 10阿里妈妈 11百青藤 //type 1资讯 2商城 3支付配置 4免密开关 5小程序(app不需要) 10阿里妈妈 11百青藤
[self.switchs removeAllObjects]; [self.switchs removeAllObjects];
for (NSDictionary *dic in arr) { for (NSDictionary *dic in arr) {
if ([dic[@"type"] isEqualToString:@"1"] || [dic[@"type"] isEqualToString:@"2"] || [dic[@"type"] isEqualToString:@"10"] || [dic[@"type"] isEqualToString:@"11"]) { if ([dic[@"type"] isEqualToString:@"1"] || [dic[@"type"] isEqualToString:@"2"] || [dic[@"type"] isEqualToString:@"10"] || [dic[@"type"] isEqualToString:@"11"] || [dic[@"type"] isEqualToString:@"14"]) {
if ([dic[@"isEnabled"] integerValue] == 1) { if ([dic[@"isEnabled"] integerValue] == 1) {
[self.switchs addObject:dic]; [self.switchs addObject:dic];
} }
...@@ -105,6 +108,8 @@ ...@@ -105,6 +108,8 @@
if ([dic[@"type"] isEqualToString:@"12"] && [dic[@"isEnabled"] integerValue] == 1) { if ([dic[@"type"] isEqualToString:@"12"] && [dic[@"isEnabled"] integerValue] == 1) {
[kUserDefaults setValue:@"yes" forKey:kAPP_SELP_ADVIEW_SHOW];//默认是no [kUserDefaults setValue:@"yes" forKey:kAPP_SELP_ADVIEW_SHOW];//默认是no
} }
} }
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self setupAllTitleButton]; [self setupAllTitleButton];
...@@ -134,6 +139,7 @@ ...@@ -134,6 +139,7 @@
@strongify(self); @strongify(self);
//MARK:跳转商城 //MARK:跳转商城
[self selectPageIndex:5 fromIndex:0]; [self selectPageIndex:5 fromIndex:0];
}; };
nav =[[XMGNavigationViewController alloc]initWithRootViewController:homeView]; nav =[[XMGNavigationViewController alloc]initWithRootViewController:homeView];
...@@ -146,6 +152,7 @@ ...@@ -146,6 +152,7 @@
nav6 = [[XMGNavigationViewController alloc] initWithRootViewController:bqtVc]; nav6 = [[XMGNavigationViewController alloc] initWithRootViewController:bqtVc];
nav6.navigationController.navigationBar.hidden = YES; nav6.navigationController.navigationBar.hidden = YES;
//资讯 //资讯
ZXRSNewsManagerController *rsManagerVc = [[ZXRSNewsManagerController alloc] init]; ZXRSNewsManagerController *rsManagerVc = [[ZXRSNewsManagerController alloc] init];
rsManagerVc.isFromTabbar = YES; rsManagerVc.isFromTabbar = YES;
...@@ -161,14 +168,27 @@ ...@@ -161,14 +168,27 @@
ZXHomePageMeViewController * mineView = [[ZXHomePageMeViewController alloc]init]; ZXHomePageMeViewController * mineView = [[ZXHomePageMeViewController alloc]init];
nav3 =[[XMGNavigationViewController alloc]initWithRootViewController:mineView]; nav3 =[[XMGNavigationViewController alloc]initWithRootViewController:mineView];
ZXTaskViewController *taskVc = [[ZXTaskViewController alloc] init];
taskVc.isTaskHomePage = YES;
nav7 = [[XMGNavigationViewController alloc] initWithRootViewController:taskVc];
taskVc.jumpTaobaoHJ = ^{
@strongify(self);
//MARK:跳转淘宝惠购
self.selectedIndex = 2;
self.cusTabbar.buttonTitle = @"淘宝惠购";
};
nav7.navigationController.navigationBar.hidden = YES;
[self addChildViewController:nav]; [self addChildViewController:nav];
[self addChildViewController:nav4]; [self addChildViewController:nav4];
[self addChildViewController:nav5]; [self addChildViewController:nav5];
[self addChildViewController:nav6]; [self addChildViewController:nav6];
[self addChildViewController:nav1]; [self addChildViewController:nav1];
[self addChildViewController:nav3]; [self addChildViewController:nav3];
[self addChildViewController:nav7];
nav.interactivePopGestureRecognizer.enabled = NO; nav.interactivePopGestureRecognizer.enabled = NO;
nav1.interactivePopGestureRecognizer.enabled = NO; nav1.interactivePopGestureRecognizer.enabled = NO;
nav3.interactivePopGestureRecognizer.enabled = NO; nav3.interactivePopGestureRecognizer.enabled = NO;
...@@ -178,15 +198,15 @@ ...@@ -178,15 +198,15 @@
// 设置tabBar上所有按钮内容 // 设置tabBar上所有按钮内容
- (void)setupAllTitleButton - (void)setupAllTitleButton
{ {
if (cusTabbar == nil) { if (self.cusTabbar == nil) {
cusTabbar = [[CustomerTabbar alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 49)]; self.cusTabbar = [[CustomerTabbar alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 49)];
cusTabbar.delegate = self; self.cusTabbar.delegate = self;
[self.tabBar addSubview:cusTabbar]; [self.tabBar addSubview:self.cusTabbar];
} }
cusTabbar.switchs = self.switchs; self.cusTabbar.switchs = self.switchs;
} }
- (void)viewWillLayoutSubviews { - (void)viewWillLayoutSubviews {
[self.tabBar bringSubviewToFront:cusTabbar]; [self.tabBar bringSubviewToFront:self.cusTabbar];
} }
-(void)playSound{ -(void)playSound{
NSString *path = [[NSBundle mainBundle] pathForResource:@"like" ofType:@"caf"]; NSString *path = [[NSBundle mainBundle] pathForResource:@"like" ofType:@"caf"];
...@@ -229,6 +249,11 @@ ...@@ -229,6 +249,11 @@
if(![nav6.topViewController isKindOfClass:[ZXMallViewController class]]) { if(![nav6.topViewController isKindOfClass:[ZXMallViewController class]]) {
[nav6 pushViewController:webVC animated:YES]; [nav6 pushViewController:webVC animated:YES];
} }
} else if (fromIndex == 6) {
if(![nav7.topViewController isKindOfClass:[ZXMallViewController class]]) {
[nav7 pushViewController:webVC animated:YES];
}
} else { } else {
...@@ -241,7 +266,6 @@ ...@@ -241,7 +266,6 @@
} else { } else {
self.selectedIndex=toIndex; self.selectedIndex=toIndex;
} }
} }
@end @end
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "任务完成_抽奖券.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "任务完成_抽奖券@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "任务完成_抽奖券@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "首次登录_关闭.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "首次登录_关闭@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "首次登录_关闭@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "首次登录_获得奖券.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "首次登录_获得奖券@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "首次登录_获得奖券@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment