Commit f34a4a85 by 刘卓鑫

提交蓝牙洗衣 蓝牙洗浴

parent be11be68
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
</Bucket>
<?xml version="1.0" encoding="UTF-8"?>
<VariablesViewState
version = "1.0">
<ContextStates>
<ContextState
contextName = "__64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke.49:AFHTTPRequestOperation.m">
<PersistentStrings>
<PersistentString
value = "">
</PersistentString>
</PersistentStrings>
</ContextState>
</ContextStates>
</VariablesViewState>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildLocationStyle</key>
<string>UseAppPreferences</string>
<key>CustomBuildLocationType</key>
<string>RelativeToDerivedData</string>
<key>DerivedDataLocationStyle</key>
<string>Default</string>
<key>EnabledFullIndexStoreVisibility</key>
<false/>
<key>IssueFilterStyle</key>
<string>ShowActiveSchemeOnly</string>
<key>LiveSourceIssuesEnabled</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/NewFirstPage(&#x65b0;&#x7248;&#x9996;&#x9875;)/ViewModel/ZXFirstPageService.m"
timestampString = "574228712.707621"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "50"
endingLineNumber = "50"
landmarkName = "-loadFirstPageDataCompleted:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildLocationStyle</key>
<string>UseAppPreferences</string>
<key>CustomBuildLocationType</key>
<string>RelativeToDerivedData</string>
<key>DerivedDataLocationStyle</key>
<string>Default</string>
<key>EnabledFullIndexStoreVisibility</key>
<false/>
<key>IssueFilterStyle</key>
<string>ShowActiveSchemeOnly</string>
<key>LiveSourceIssuesEnabled</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "28C6FFDE-C05F-4E54-9523-AA903B6B7436"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "FD18D5E8-2EB4-4B99-991D-178382D38CC6"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "1"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "5ABFA4A1-90B2-4BB2-A520-8212CD4CCAF9"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/MineView(&#x4e2a;&#x4eba;&#x4e2d;&#x5fc3;)/UserSetting/ChangePasswordAndPhone/Controller/ZXChangeMsgViewController.m"
timestampString = "590570949.174037"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "289"
endingLineNumber = "289"
landmarkName = "-changeAction"
landmarkType = "7">
<Locations>
<Location
uuid = "5ABFA4A1-90B2-4BB2-A520-8212CD4CCAF9 - 4364e748c2fb8405"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "__41-[ZXChangeMsgViewController changeAction]_block_invoke.275"
moduleName = "ColorfulSchool"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liuzhuoxin/codeStore/colorfulSchoolReconsitution/ColorfulSchool/ColorfulSchool/Classes/MineView(%E4%B8%AA%E4%BA%BA%E4%B8%AD%E5%BF%83)/UserSetting/ChangePasswordAndPhone/Controller/ZXChangeMsgViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "289"
endingLineNumber = "289"
offsetFromSymbolStart = "92">
</Location>
<Location
uuid = "5ABFA4A1-90B2-4BB2-A520-8212CD4CCAF9 - 63e148375c775850"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "__41-[ZXChangeMsgViewController changeAction]_block_invoke_2.277"
moduleName = "ColorfulSchool"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/liuzhuoxin/codeStore/colorfulSchoolReconsitution/ColorfulSchool/ColorfulSchool/Classes/MineView(%E4%B8%AA%E4%BA%BA%E4%B8%AD%E5%BF%83)/UserSetting/ChangePasswordAndPhone/Controller/ZXChangeMsgViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "289"
endingLineNumber = "289"
offsetFromSymbolStart = "32">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "4FA2480E-8256-4C34-A3EE-8FEA833B0958"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/HomePage(&#x9996;&#x9875;)/Operation(&#x81ea;&#x52a9;&#x670d;&#x52a1;)/1.0Version(1.0&#x8d2d;&#x5238;)/QRCode/HMScanner.m"
timestampString = "590417142.6473891"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "274"
endingLineNumber = "274"
landmarkName = "-setupSession"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6291A0D1-A28C-48A7-B7F8-7B681EBCCB94"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/Vendor(&#x4e09;&#x65b9;)/SGQRCode/SGQRCodeObtain.m"
timestampString = "590570949.174207"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "591"
endingLineNumber = "591"
landmarkName = "-openFlashlight"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CA50FE84-5017-4579-A947-A592339DFEBE"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/HomePage(&#x9996;&#x9875;)/Operation(&#x81ea;&#x52a9;&#x670d;&#x52a1;)/1.0Version(1.0&#x8d2d;&#x5238;)/SearchEquipment/Controller/SearchEquipmenController.m"
timestampString = "590570949.174304"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "226"
endingLineNumber = "226"
landmarkName = "-backBtnClick:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
</Bucket>
......@@ -76,8 +76,8 @@
[self tokenLogin];
//开屏广告
// [ZXAdTool startLauchAd];
[[[ZXAdViewAdTool alloc] init] startLauchAd];
[ZXAdTool startLauchAd];
//版本检测
[self checkVersion];
......
//
//
......@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void) startLauchAd;
- (void) loadNativeAdBySuperView:(UIView *) superView;
@end
NS_ASSUME_NONNULL_END
//
//
......@@ -14,6 +14,7 @@
#include <net/if_dl.h>
#import "ZXFullScreenAdView.h"
#import "ZXAdViewService.h"
#import "sys/utsname.h"
@interface ZXAdViewAdTool ()
......@@ -21,21 +22,100 @@
@implementation ZXAdViewAdTool
- (void) startLauchAd {
NSString *url = [[NSString stringWithFormat:@"http://open.adview.cn/agent/openRequest.do?ver=2.7.0&n=1&appid=SDK20191516030954opvyhmi3khwalbw&pt=4&posId=POSIDn5ahrkelm20e&pack=com.pxkjformal.parallelcampus&w=640&h=960&tab=0&ip=%@&os=1&bdr=%@&tp=%@&brd=Apple&ua=%@&sw=%f&sh=%f&deny=%f&sn=%@&mac=%@&didsha1=%@&dpidsha1=%@&macsha1=%@&didmd5=%@&dpidmd5=%@&macmd5=%@&nt=%@&nop=%@&country=ISO-3166-1 Alpha-3&language=alpha-2/ISO 639- 1&tm=0&time=%@&token=%@&html5=2", [BYHelp getIPAddress], [[UIDevice currentDevice] systemVersion], [ZXTool getCurrentDevice], [ZXTool returnUserAgent], kScreenWidth, kScreenHeight, [UIScreen mainScreen].scale, [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString], [self macAddress], [self iemi],[self sha1:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], [self sha1:[self macAddress]], [ZXTool md5:[self iemi]], [ZXTool md5:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], [ZXTool md5:[self macAddress]], [ZXTool returnNetworkStatus]==1?@"WIFI":@"4G", [ZXTool currentYYS], [ZXTool getCurrentTimeStamp], [ZXTool md5:[NSString stringWithFormat:@"SDK20191516030954opvyhmi3khwalbw%@", [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]]]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// NSDictionary *dic = @{@"ver":@"4.0.1",@"n":@"1", @"appid":@"SDK20191516030954opvyhmi3khwalbw",@"pt":@"4", @"posId":@"POSIDn5ahrkelm20e", @"pack":@"com.pxkjformal.parallelcampus", @"w":@(kScreenWidth), @"h":@(kScreenHeight), @"tab":@"0", @"ip":[BYHelp getIPAddress], @"bdr":[[UIDevice currentDevice] systemVersion], @"tp":@"", @"brd":@"Apple", @"ua":[ZXTool getCurrentDevice], @"sw":@(kScreenWidth), @"sh":@(kScreenHeight), @"deny":@([UIScreen mainScreen].scale), @"sn":@"867FD2E0-F1FB-4D05-B3AE-383951FEE6EA", @"mac":[self macAddress], @"didsha1":[self iemi], @"dpidsha1":[self sha1:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], @"macsha1":[self sha1:[self macAddress]], @"didmd5":[ZXTool md5:[self iemi]], @"dpidmd5":[ZXTool md5:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], @"macmd5":[ZXTool md5:[self macAddress]], @"nt":([ZXTool returnNetworkStatus]==1?@"WIFI":@"4G"), @"nop":[ZXTool currentYYS], @"country":@"ISO-3166-1 Alpha-3", @"language":@"alpha-2/ISO639- 1", @"tm":@"0", @"time":[ZXTool getCurrentTimeStamp], @"token":[ZXTool md5:[NSString stringWithFormat:@"SDK20191516030954opvyhmi3khwalbw%@", [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]]]};
[[ZXAdViewService sharedManager] POST:url parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
- (NSString *)iphoneType {
struct utsname systemInfo;
uname(&systemInfo);
NSString*platform = [NSString stringWithCString:
systemInfo.machine encoding:NSASCIIStringEncoding];
return platform;
}
- (void) startLauchAd {
NSString *url = [NSString stringWithFormat:@"http://open.adview.cn/agent/openRequest.do?ver=2.7.0&n=1&appid=SDK20191516030954opvyhmi3khwalbw&pt=4&posId=POSIDn5ahrkelm20e&pack=com.pxkjformal.parallelcampus&w=640&h=960&tab=0&ip=%@&os=1&bdr=%@&tp=%@&brd=Apple&ua=%@&sw=%f&sh=%f&deny=%f&sn=%@&mac=%@&didsha1=%@&dpidsha1=%@&macsha1=%@&didmd5=%@&dpidmd5=%@&macmd5=%@&nt=%@&nop=%@&country=CHN&language=zh&tm=0&time=%@&token=%@&html5=2", [BYHelp getIPAddress], [[UIDevice currentDevice] systemVersion], [self iphoneType], [ZXTool returnUserAgent], kScreenWidth, kScreenHeight, [UIScreen mainScreen].scale, [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString], [self macAddress], [self iemi],[self sha1:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], [self sha1:[self macAddress]], [ZXTool md5:[self iemi]], [ZXTool md5:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], [ZXTool md5:[self macAddress]], [self netWorkStatus], [self returnYYS], [ZXTool getCurrentTimeStamp], [ZXTool md5:[NSString stringWithFormat:@"SDK20191516030954opvyhmi3khwalbw%@", [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]]]];
NSString *percentUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[ZXAdViewService sharedManager] POST:percentUrl parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
dispatch_async(dispatch_get_main_queue(), ^{
if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
[self createLauchAd:responseObject];
}
});
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
}
- (NSString *) netWorkStatus {
NSString *net = [kUserDefaults valueForKey:@"kNetworkingStatus"];
if (net == nil || [net isEqualToString:@""]) {
return @"";
} else if ([net isEqualToString:@"无网络"]) {
return @"";
} else if ([net isEqualToString:@"4G"]) {
return @"4G";
} else if ([net isEqualToString:@"WIFI"]) {
return @"WIFI";
}
return @"";
}
- (NSString *) returnYYS {
NSString *yys = [ZXTool currentYYS];
NSString *netInfo = @"";
if ([yys isEqualToString:@"中国移动"]) {
netInfo = @"46000";
} else if ([yys isEqualToString:@"中国联通"]) {
netInfo = @"46001";
} else if ([yys isEqualToString:@"中国电信"]) {
netInfo = @"46003";
}
return netInfo;
}
- (void) loadNativeAdBySuperView:(UIView *)superView {
NSString *url = [[NSString stringWithFormat:@"http://open.adview.cn/agent/openRequest.do?ver=2.7.0&n=1&appid=SDK20191516030954opvyhmi3khwalbw&pt=6&posId=POSIDvxuf9txxi563&pack=com.pxkjformal.parallelcampus&w=640&h=960&tab=0&ip=%@&os=1&bdr=%@&tp=%@&brd=Apple&ua=%@&sw=%f&sh=%f&deny=%f&sn=%@&mac=%@&didsha1=%@&dpidsha1=%@&macsha1=%@&didmd5=%@&dpidmd5=%@&macmd5=%@&nt=%@&nop=%@&country=CHN&language=zh&tm=0&time=%@&token=%@&html5=2", [BYHelp getIPAddress], [[UIDevice currentDevice] systemVersion], [self iphoneType], [ZXTool returnUserAgent], kScreenWidth, kScreenHeight, [UIScreen mainScreen].scale, [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString], [self macAddress], [self iemi],[self sha1:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], [self sha1:[self macAddress]], [ZXTool md5:[self iemi]], [ZXTool md5:[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]], [ZXTool md5:[self macAddress]], [self netWorkStatus], [self returnYYS], [ZXTool getCurrentTimeStamp], [ZXTool md5:[NSString stringWithFormat:@"SDK20191516030954opvyhmi3khwalbw%@", [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]]]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[ZXAdViewService sharedManager] POST:url parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
dispatch_async(dispatch_get_main_queue(), ^{
if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
NSDictionary *ad = [responseObject[@"ad"] lastObject];
NSDictionary *imageDic = [ad[@"native"][@"images"] lastObject];
if (ad == nil || imageDic == nil) {
return ;
}
CGFloat imageW = [imageDic[@"w"] floatValue];
CGFloat imageH = [imageDic[@"h"] floatValue];
NSString *imageUrl = imageDic[@"url"];
UIImageView *adView = [[UIImageView alloc] init];
[adView sd_setImageWithURL:[NSURL URLWithString:imageUrl]];
[superView addSubview:adView];
[adView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(superView);
make.height.mas_equalTo(kScreenWidth * imageH / imageW);
}];
adView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
[adView addGestureRecognizer:tap];
[[tap rac_gestureSignal] subscribeNext:^(id x) {
//内部点击
[ZXAdViewService nativeAdClickByAdModel:ad image:imageUrl];
//上报相关
[ZXAdViewService clickAd:ad[@"ec"]];
//点击逻辑
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ad[@"dl"]]];
}];
//内部曝光
[ZXAdViewService nativeAdExposeByAdModel:ad image:imageUrl];
//广告曝光
[ZXAdViewService exposeAd:ad[@"es"]];
}
});
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
}
#pragma mark - 创建adView 开屏广告
- (void) createLauchAd:(NSDictionary *) lauch {
NSDictionary *ad = [lauch[@"ad"] lastObject];
......@@ -65,7 +145,8 @@
- (NSString *) iemi {
return [NSString stringWithFormat:@"8%dae6249275%d439f2f80acf%dd78546%de5095a34%d", arc4random()/10, arc4random()/10, arc4random()/10, arc4random()/10, arc4random()/10];
NSString *idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
return [self sha1:idfa];
}
- (NSString*) sha1:(NSString *) str
{
......@@ -119,7 +200,7 @@
return NULL;
}
if(sysctl(mib,6,NULL, &len,NULL,0) <0) {
printf("Error: sysctl, take 1\n");
......
//
//
......@@ -17,9 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
* model 广告模型
*/
+ (void) nativeAdClickByAdModel:(NSDictionary *) model;
+ (void) nativeAdClickByAdModel:(NSDictionary *) model image:(NSString *) image;
+ (void) nativeAdExposeByAdModel:(NSDictionary *) model;
+ (void) nativeAdExposeByAdModel:(NSDictionary *) model image:(NSString *) image;
// 曝光
+ (void) exposeAd:(NSDictionary *) dic;
+ (void) clickAd:(NSArray *) arr;
......
//
//
......@@ -33,6 +33,29 @@
}];
});
}
/*
* model 广告模型
*/
+ (void) nativeAdClickByAdModel:(NSDictionary *) model image:(NSString *) image {
if (model == nil) {
return;
}
dispatch_async(dispatch_get_global_queue(0, 0), ^{
if ([[kUserDefaults valueForKey:@"isNeedExposure"] isEqualToString:@"1"]) {
return;
}
NSString *pid = model[@"posId"];
NSString *uid = [kUserDefaults valueForKey:@"userId"]?[kUserDefaults valueForKey:@"userId"]:@"";
NSDictionary *dic = @{@"adsenseName":@"adView",@"advertType":@"点击",@"advertTitle":@"adView", @"advertImg":image, @"customerId":uid, @"advertId":pid,@"platformCode":@"DCXY_iOS"};
//内部曝光
NSString *url = [NSString stringWithFormat:@"%@/app/adsenseCollectData/adsenseCollectData4Add",[kUserDefaults valueForKey:@"Ad"]];
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodPOST url:url para:dic completed:^(CommonModel *common, NSString *error) {
}];
});
}
+ (void) nativeAdExposeByAdModel:(NSDictionary *) model {
if (model == nil) {
return;
......@@ -53,7 +76,25 @@
}];
});
}
+ (void) nativeAdExposeByAdModel:(NSDictionary *) model image:(NSString *) image {
if (model == nil) {
return;
}
dispatch_async(dispatch_get_global_queue(0, 0), ^{
if ([[kUserDefaults valueForKey:@"isNeedExposure"] isEqualToString:@"1"]) {
return;
}
NSString *pid = model[@"posId"];
NSString *uid = [kUserDefaults valueForKey:@"userId"]?[kUserDefaults valueForKey:@"userId"]:@"";
NSDictionary *dic = @{@"adsenseName":@"adView",@"advertType":@"曝光",@"advertTitle":@"adView", @"advertImg":image, @"customerId":uid, @"advertId":pid,@"platformCode":@"DCXY_iOS"};
//内部曝光
NSString *url = [NSString stringWithFormat:@"%@/app/adsenseCollectData/adsenseCollectData4Add",[kUserDefaults valueForKey:@"Ad"]];
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodPOST url:url para:dic completed:^(CommonModel *common, NSString *error) {
}];
});
}
//AD曝光
+ (void) exposeAd:(NSDictionary *) dic {
if (dic == nil) {
......@@ -87,6 +128,7 @@
// 设置请求头
[manager.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[manager.requestSerializer setValue:CacheToken forHTTPHeaderField:@"token"];
manager.responseSerializer.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml",@"text/html", @"application/json",@"text/plain", @"application/x-gzip", @"text/json",nil];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes=[[NSSet alloc] initWithObjects:@"application/xml", @"text/xml",@"text/html", @"application/json",@"text/plain", @"text/json", nil];
......
//
//
......@@ -73,12 +73,12 @@
case 1: //腾讯
[[ZXTXAdTool sharedZXTXAdTool] createLauchAdByPlacmentId:kTXAdLauchPLACEMENTID];
break;
case 2: //百度
[[ZXBDTool sharedZXBDTool] createBaiduLauchAdView];
break;
case 5: //addView
case 2: //adView
[[[ZXAdViewAdTool alloc] init] startLauchAd];
break;
case 5: //
break;
default:
break;
}
......
//
//
......@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
/** 是否对接 */
@property (nonatomic, assign) NSInteger isButt;
/** "平台来源 1腾讯 2百度 3瑞狮 4友盟 5adView" */
/** "平台来源 1腾讯 2adView 3瑞狮 4友盟 5" */
@property (nonatomic, assign) NSInteger platformSource;
/** 广告标题 */
......
//
// 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
//
// ZXAliMaMaManagerViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/23.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXAliMaMaManagerViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// ZXAliMaMaManagerViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/23.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXAliMaMaManagerViewController.h"
#import "enlargeClickRegionBtn.h"
#import "HMSegmentedControl.h"
#import "UIView+Frame.h"
#import "ZXAliMaMaSerarchResultViewController.h"
#import "PYSearchViewController.h"
#import "ZXAliMaMaViewController.h"
@interface ZXAliMaMaManagerViewController ()<UIScrollViewDelegate> {
HMSegmentedControl *_segmentedControl;
}
@property (nonatomic, strong) NSArray *titleArr;
@property (nonatomic, strong) UIScrollView *scrollView;
/** */
@property (nonatomic, strong) UITextField *searchField;
@end
@implementation ZXAliMaMaManagerViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self createNabar];
[self addChildVc];
[self createUI];
}
#pragma mark - ========== 创建导航栏 ==========
- (void) createNabar {
self.view.backgroundColor = [UIColor whiteColor];
UIView *naBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kTopHeight)];
[self.view addSubview:naBar];
naBar.backgroundColor = kTopicColor;
UIView *searchBgView = [[UIView alloc] init];
searchBgView.backgroundColor = [UIColor whiteColor];
[naBar addSubview:searchBgView];
kViewRadius(searchBgView, 8 * k6Scale);
[searchBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(naBar.mas_left).offset(10 * k6Scale);
make.right.equalTo(naBar.mas_right).offset(-10 * k6Scale);
make.height.mas_equalTo(28 * k6Scale);
make.top.equalTo(naBar.mas_top).offset(kStatusBarHeight + 8 * k6Scale);
}];
UILabel *label = [[UILabel alloc] init];
[naBar addSubview:label];
label.backgroundColor = [UIColor clearColor];
label.textColor = RGB(170, 170, 170);
label.text = @"请输入要搜索的商品";
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(naBar.mas_left).offset(20 * k6Scale);
make.right.equalTo(naBar.mas_right).offset(-50 * k6Scale);
make.height.mas_equalTo(28 * k6Scale);
make.centerY.equalTo(searchBgView);
}];
label.font = kFontSize(13 * k6Scale);
UITapGestureRecognizer *search = [[UITapGestureRecognizer alloc] init];
[searchBgView addGestureRecognizer:search];
@weakify(self);
[[search rac_gestureSignal] subscribeNext:^(id x) {
@strongify(self);
// 1. Create an Array of popular search
// NSArray *list = [ZXBookracketModel findByCriteria:[NSString stringWithFormat:@"where userId = '%@'", [kUserDefaults valueForKey:@"userId"]]];
// NSMutableArray *lis = [[NSMutableArray alloc] init];
// for (ZXBookracketModel *m in list) {
// [lis addObject:m.title];
// }
// NSArray *hotSeaches = lis;
// 2. Create a search view controller
@weakify(self);
PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:@[] searchBarPlaceholder:@"请输入要搜索的商品" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) {
@strongify(self);
ZXAliMaMaSerarchResultViewController *searchResultVc = [[ZXAliMaMaSerarchResultViewController alloc] init];
searchResultVc.searchStr = searchText;
[self.navigationController pushViewController:searchResultVc animated:YES];
}];
searchViewController.searchHistoryStyle = PYSearchHistoryStyleNormalTag;
// searchViewController.hotSearchStyle = 4;
searchViewController.searchViewControllerShowMode = PYSearchViewControllerShowModePush;
searchViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:searchViewController animated:YES];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSArray *)titleArr {
if (_titleArr == nil) {
_titleArr = @[@"全部", @"男装", @"女装", @"美妆", @"配饰", @"男鞋", @"女鞋", @"手机", @"零食", @"水果", @"文具", @"礼品鲜花", @"户外运动"];
}
return _titleArr;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[UIApplication sharedApplication].statusBarStyle = 1;
self.navigationController.navigationBar.hidden = YES;
self.tabBarController.tabBar.hidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
#pragma mark - ========== uI ==========
- (void) createUI {
//侧滑
_segmentedControl = [[HMSegmentedControl alloc] init];
[self.view addSubview:_segmentedControl];
[_segmentedControl mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.top.equalTo(self.view.mas_top).offset(kTopHeight);
make.height.mas_equalTo(30 * k6Scale);
}];
[_segmentedControl layoutSubviews];
/*! 设置标题 */
_segmentedControl.sectionTitles = self.titleArr;
/*! 自适应宽度,随着屏幕滑动自动滚动 */
_segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
/*! 默认选中第0个view */
_segmentedControl.selectedSegmentIndex = 0;
/*! 标题背景颜色 */
_segmentedControl.backgroundColor = [UIColor clearColor];
/*! 标题默认字体颜色 */
_segmentedControl.titleTextAttributes = @{NSForegroundColorAttributeName : kRGBColor(180, 180, 180, 1), NSFontAttributeName:kFontSize(12 * k6Scale)};
/*! 标题选中字体颜色 */
_segmentedControl.selectedTitleTextAttributes = @{NSForegroundColorAttributeName : [UIColor redColor], NSFontAttributeName:kFontSize(14 * k6Scale)};
/*! 标题选中的下划线的颜色 */
_segmentedControl.selectionIndicatorColor = [UIColor redColor];
/*! 标题选中的下划线的高度 */
_segmentedControl.selectionIndicatorHeight = 2.0f;
/*! 标题选中的样式:本样式为宽度修改过的统一宽度 */
_segmentedControl.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleFixed;
/*! 标题选中的样式:本样式为box */
_segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe;
/*! 标题选中的下划线的方向:本样式为向下 */
_segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
/*! 标题的中间的隔线:默认为:NO */
_segmentedControl.verticalDividerEnabled = NO;
/*! 标题的中间的隔线颜色 */
_segmentedControl.verticalDividerColor = kRGBColor(227, 228, 229, 1);
_segmentedControl.verticalDividerWidth = 0.5f;
// /*! 标题点击事件 */
@weakify(self);
[_segmentedControl setIndexChangeBlock:^(NSInteger index) {
@strongify(self);
[self.scrollView setContentOffset:CGPointMake(kScreenWidth * index, 0) animated:YES];
}];
self.scrollView = [[UIScrollView alloc] init];
[self.view addSubview:self.scrollView];
self.scrollView.backgroundColor = [UIColor whiteColor];
self.scrollView.pagingEnabled = YES;
self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.contentSize = CGSizeMake(kScreenWidth * self.titleArr.count, 0);
self.scrollView.delegate = self;
[self.view addSubview:self.scrollView];
//第一次进来显示第一个视图控制器
[self scrollViewDidEndScrollingAnimation:self.scrollView];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_segmentedControl.mas_bottom);
make.left.equalTo(self.view.mas_left);
make.right.equalTo(self.view.mas_right);
make.bottom.equalTo(self.view.mas_bottom);
}];
}
#pragma mark - ***** UIScrollViewDelegate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
[self scrollViewDidEndScrollingAnimation:scrollView];
CGFloat pageWidth = scrollView.frame.size.width;
NSInteger page = scrollView.contentOffset.x / pageWidth;
[_segmentedControl setSelectedSegmentIndex:page];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
NSInteger idx = (NSUInteger)(scrollView.contentOffset.x / scrollView.frame.size.width);
if (idx < 0) {
idx = 0;
}
// 拿出子控制器
UIViewController *vc = self.childViewControllers[idx];
vc.view.xmg_x = scrollView.contentOffset.x;
vc.view.xmg_width = scrollView.xmg_width;
[scrollView addSubview:vc.view];
}
/**
* 添加子视图控制器
*/
-(void)addChildVc {
for (NSString *title in self.titleArr) {
ZXAliMaMaViewController *aliVc = [[ZXAliMaMaViewController alloc] init];
aliVc.titleStr = title;
[self addChildViewController:aliVc];
}
}
@end
//
// ZXAliMaMaSerarchResultViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/23.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXAliMaMaSerarchResultViewController : UIViewController
/** */
@property (nonatomic, copy) NSString *searchStr;
@end
NS_ASSUME_NONNULL_END
//
// ZXAliMaMaViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/8.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXAliMaMaViewController : UIViewController
/** */
@property (nonatomic, copy) NSString *titleStr;
@end
NS_ASSUME_NONNULL_END
//
// ZXAliMaMaViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/8.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXAliMaMaViewController.h"
#import "ZXAdViewService.h"
#import "ZXAlimamaModel.h"
#import "LMHWaterFallLayout.h"
#import "ZXAlimamaCollectionViewCell.h"
#import "ZXBannerJumpViewController.h"
#import "enlargeClickRegionBtn.h"
static NSString * const LMHShopId = @"shop";
@interface ZXAliMaMaViewController ()<UICollectionViewDataSource, LMHWaterFallLayoutDeleaget, UICollectionViewDelegate>
/** 所有的商品数据 */
@property (nonatomic, strong) NSMutableArray * shops;
/** */
@property (nonatomic, weak) UICollectionView * collectionView;
/** 列数 */
@property (nonatomic, assign) NSUInteger columnCount;
/** */
@property (nonatomic, strong) UITextField *searchField;
/** */
@property (nonatomic, assign) NSInteger currentPage;
@end
@implementation ZXAliMaMaViewController
#pragma mark - 懒加载
- (NSMutableArray *)shops{
if (!_shops) {
_shops = [NSMutableArray array];
}
return _shops;
}
- (void)viewDidLoad {
[super viewDidLoad];
// [self initialize];
[self setupLayoutAndCollectionView];
[self setupRefresh];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[UIApplication sharedApplication].statusBarStyle = 1;
self.navigationController.navigationBar.hidden = YES;
self.tabBarController.tabBar.hidden = NO;
}
/**
* 初始化
*/
- (void)initialize{
self.view.backgroundColor = [UIColor whiteColor];
UIView *naBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kTopHeight)];
[self.view addSubview:naBar];
naBar.backgroundColor = kTopicColor;
UIView *searchBgView = [[UIView alloc] init];
searchBgView.backgroundColor = [UIColor whiteColor];
[naBar addSubview:searchBgView];
kViewRadius(searchBgView, 8 * k6Scale);
[searchBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(naBar.mas_left).offset(20 * k6Scale);
make.right.equalTo(naBar.mas_right).offset(-50 * k6Scale);
make.height.mas_equalTo(28 * k6Scale);
make.top.equalTo(naBar.mas_top).offset(kStatusBarHeight + 8 * k6Scale);
}];
self.searchField = [[UITextField alloc] init];
[naBar addSubview:self.searchField];
self.searchField.backgroundColor = [UIColor clearColor];
kViewRadius(self.searchField, 8 * k6Scale);
self.searchField.placeholder = @"请输入要搜索的商品";
[self.searchField mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(naBar.mas_left).offset(25 * k6Scale);
make.right.equalTo(naBar.mas_right).offset(-50 * k6Scale);
make.height.mas_equalTo(28 * k6Scale);
make.centerY.equalTo(searchBgView);
}];
self.searchField.font = kFontSize(13 * k6Scale);
self.searchField.clearButtonMode = UITextFieldViewModeWhileEditing;
enlargeClickRegionBtn *searchButton = [[enlargeClickRegionBtn alloc] init];
[searchButton setBackgroundImage:[UIImage imageNamed:@"searchsss"] forState:UIControlStateNormal];
[naBar addSubview:searchButton];
[searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(25 * k6Scale);
make.centerY.equalTo(self.searchField);
make.left.equalTo(self.searchField.mas_right).offset(12.5 * k6Scale);
}];
[searchButton addTarget:self action:@selector(searchAction:) forControlEvents:UIControlEventTouchDown];
}
#pragma mark - 搜索
- (void) searchAction:(UIButton *) sender {
[[UIApplication sharedApplication].keyWindow endEditing:YES];
[self loadNewShops];
}
/**
* 创建布局和collectionView
*/
- (void)setupLayoutAndCollectionView{
// 创建布局
LMHWaterFallLayout * waterFallLayout = [[LMHWaterFallLayout alloc]init];
waterFallLayout.delegate = self;
// 创建collectionView
UICollectionView * collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTopHeight - kTabBarHeight - 30 * k6Scale) collectionViewLayout:waterFallLayout];
collectionView.backgroundColor = [UIColor whiteColor];
collectionView.dataSource = self;
collectionView.delegate = self;
[self.view addSubview:collectionView];
// 注册
[collectionView registerClass:[ZXAlimamaCollectionViewCell class] forCellWithReuseIdentifier:LMHShopId];
self.collectionView = collectionView;
}
/**
* 刷新控件
*/
- (void)setupRefresh{
self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewShops)];
// self.collectionView.mj_header.backgroundColor = [UIColor yellowColor];
[self.collectionView.mj_header beginRefreshing];
self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreShops)];
// self.collectionView.mj_footer.backgroundColor = [UIColor yellowColor];
self.collectionView.mj_footer.hidden = YES;
}
/**
* 加载新的商品
*/
- (void)loadNewShops{
self.currentPage = 1;
[self loadData];
}
- (void) loadData {
NSString *url = [NSString stringWithFormat:@"%@/alimama/tbk/dg/material/optional?pageNo=%ld&pageNo=20&q=%@&deviceType=IMEI&deviceValue=02399123192391293123&cat=hot", [kUserDefaults objectForKey:@"HomePage"], (long)self.currentPage,[self.titleStr isEqualToString:@"全部"]?@"":self.titleStr];
[[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"];
if (res) {
NSArray *list = [ZXAlimamaModel mj_objectArrayWithKeyValuesArray:res];
if (self.currentPage == 1) {
[self.shops removeAllObjects];
}
[self.shops addObjectsFromArray:list];
dispatch_async(dispatch_get_main_queue(), ^{
[self.collectionView.mj_header endRefreshing];
[self.collectionView.mj_footer endRefreshing];
[self.collectionView reloadData];
});
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@", error);
}];
}
/**
* 加载更多商品
*/
- (void)loadMoreShops{
self.currentPage ++;
[self loadData];
}
#pragma mark UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
self.collectionView.mj_footer.hidden = self.shops.count == 0;
return self.shops.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
ZXAlimamaCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:LMHShopId forIndexPath:indexPath];
cell.model = self.shops[indexPath.item];
return cell;
}
#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 {
ZXAlimamaModel *model = self.shops[indexPath.item];
NSString *url = [@"taobao:" stringByAppendingString:model.coupon_share_url];
NSURL *URL = [NSURL URLWithString:url];
if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL];
} else {
ZXBannerJumpViewController *jumpVc = [[ZXBannerJumpViewController alloc] init];
jumpVc.jumpUrl = [@"https:" stringByAppendingString:model.coupon_share_url];
jumpVc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:jumpVc animated:YES];
}
}
@end
//
// ZXAlimamaCollectionViewCell.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/8.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ZXAlimamaModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface ZXAlimamaCollectionViewCell : UICollectionViewCell
/** */
@property (nonatomic, strong) ZXAlimamaModel *model;
@end
NS_ASSUME_NONNULL_END
//
// ZXAlimamaCollectionViewCell.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/8.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXAlimamaCollectionViewCell.h"
@interface ZXAlimamaCollectionViewCell()
/** */
@property (nonatomic, strong) UIImageView *iconImageView;
/** */
@property (nonatomic, strong) UILabel *titleLabel;
/** 优惠后的价格 */
@property (nonatomic, strong) UILabel *priceLabel;
/** 优惠前的价格 */
@property (nonatomic, strong) UILabel *priceOnceLabel;
/** */
@property (nonatomic, strong) UILabel *payNumLabel;
/** 券的 */
@property (nonatomic, strong) UILabel *quanLabel;
@end
@implementation ZXAlimamaCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = kRGB(250, 250, 250);
self.contentView.backgroundColor = [UIColor whiteColor];
self.iconImageView = [[UIImageView alloc] init];
[self.contentView addSubview:self.iconImageView];
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.equalTo(self.contentView);
make.height.mas_equalTo(155 * k6Scale);
}];
kViewRadius(self, 5 * k6Scale);
self.layer.borderColor = RGB(233, 233, 233).CGColor;
self.layer.borderWidth = 1;
self.titleLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.titleLabel];
self.titleLabel.font = kFontSize(13 * k6Scale);
self.titleLabel.textColor = RGB(78, 78, 78);
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(10 * k6Scale);
make.right.equalTo(self.contentView.mas_right).offset(-10 * k6Scale);
make.top.equalTo(self.iconImageView.mas_bottom).offset(5 * k6Scale);
}];
self.priceLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.priceLabel];
self.priceLabel.font = kFontSize(14 * k6Scale);
self.priceLabel.textColor = RGB(255, 77, 32);
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(10 * k6Scale);
make.top.equalTo(self.titleLabel.mas_bottom).offset(5 * k6Scale);
}];
self.priceOnceLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.priceOnceLabel];
self.priceOnceLabel.font = kFontSize(12 * k6Scale);
self.priceOnceLabel.textColor = RGB(133, 133, 133);
[self.priceOnceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.priceLabel.mas_right).offset(10 * k6Scale);
make.centerY.equalTo(self.priceLabel);
}];
UIImageView *quamBgView = [[UIImageView alloc] init];
[self.contentView addSubview:quamBgView];
[quamBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(10 * k6Scale);
make.top.equalTo(self.priceLabel.mas_bottom).offset(5 * k6Scale);
}];
quamBgView.image = [UIImage imageNamed:@"label"];
self.quanLabel = [[UILabel alloc] init];
[quamBgView addSubview:self.quanLabel];
self.quanLabel.font = kFontSize(12 * k6Scale);
self.quanLabel.textColor = UIColor.whiteColor;
[self.quanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(quamBgView).insets(UIEdgeInsetsMake(1 * k6Scale, 5 * k6Scale, 1 * k6Scale, 5 * k6Scale));
}];
kViewRadius(quamBgView, 5 * k6Scale);
self.payNumLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.payNumLabel];
self.payNumLabel.font = kFontSize(12 * k6Scale);
self.payNumLabel.textColor = RGB(133, 133, 133);
[self.payNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-10 * k6Scale);
make.centerY.equalTo(self.quanLabel.mas_centerY);
}];
}
return self;
}
- (void)setModel:(ZXAlimamaModel *)model {
_model = model;
[self.iconImageView sd_setImageWithURL:[NSURL URLWithString:_model.pict_url]];
self.titleLabel.text = _model.title;
self.priceLabel.text = [NSString stringWithFormat:@"¥%.1f", ([_model.zk_final_price floatValue] - [_model.coupon_amount floatValue])];
//添加中划线
NSDictionary *centerAttribtDic = @{NSStrikethroughStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle],NSForegroundColorAttributeName:RGB(133, 133, 133)};
NSMutableAttributedString * centerAttr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@", _model.zk_final_price] attributes:centerAttribtDic];
self.priceOnceLabel.attributedText = centerAttr;
self.quanLabel.text = [NSString stringWithFormat:@"¥%@券", _model.coupon_amount?_model.coupon_amount:@"0"];
self.payNumLabel.text = [NSString stringWithFormat:@"月销%@", _model.volume];
}
@end
//
// ZXAlimamaModel.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/8.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXAlimamaModel : NSObject
@property (nonatomic, strong) NSString *nick;
@property (nonatomic, strong) NSNumber *user_type;
@property (nonatomic, strong) NSString *coupon_amount;
@property (nonatomic, strong) NSString *tk_total_commi;
@property (nonatomic, strong) NSString *commission_type;
@property (nonatomic, strong) NSNumber *shop_dsr;
@property (nonatomic, strong) NSString *zk_final_price;
@property (nonatomic, strong) NSString *tk_total_sales;
@property (nonatomic, strong) NSString *shop_title;
@property (nonatomic, strong) NSString *url;
@property (nonatomic, strong) NSNumber *item_id;
@property (nonatomic, strong) NSString *provcity;
@property (nonatomic, strong) NSString *real_post_fee;
@property (nonatomic, strong) NSString *reserve_price;
@property (nonatomic, strong) NSString *commission_rate;
@property (nonatomic, strong) NSString *coupon_start_time;
@property (nonatomic, strong) NSNumber *volume;
@property (nonatomic, strong) NSString *info_dxjh;
@property (nonatomic, strong) NSString *category_name;
@property (nonatomic, strong) NSNumber *level_one_category_id;
@property (nonatomic, strong) NSNumber *coupon_total_count;
@property (nonatomic, strong) NSString *coupon_info;
@property (nonatomic, strong) NSString *include_dxjh;
@property (nonatomic, strong) NSString *item_description;
@property (nonatomic, strong) NSString *item_url;
@property (nonatomic, strong) NSNumber *coupon_remain_count;
@property (nonatomic, strong) NSString *coupon_share_url;
@property (nonatomic, strong) NSString *include_mkt;
@property (nonatomic, strong) NSString *short_title;
@property (nonatomic, strong) NSString *x_id;
@property (nonatomic, strong) NSString *coupon_id;
@property (nonatomic, strong) NSNumber *seller_id;
@property (nonatomic, strong) NSString *pict_url;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *coupon_end_time;
@property (nonatomic, strong) NSNumber *category_id;
@property (nonatomic, strong) NSNumber *num_iid;
@property (nonatomic, strong) NSString *level_one_category_name;
@property (nonatomic, strong) NSString *white_image;
@property (nonatomic, strong) NSString *coupon_start_fee;
@property (nonatomic, strong) NSDictionary *small_images;
@end
NS_ASSUME_NONNULL_END
//
// ZXAlimamaModel.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/8.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXAlimamaModel.h"
@implementation ZXAlimamaModel
@end
//
// ZXFliterView.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/23.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol ZXFliterDelegate <NSObject>
//选择了价格 isUp是否升序
- (void) filterByPrices:(NSInteger) status;
//选择了销量 isSelect
- (void) filterBySales:(NSInteger) status;
//选择了 isBaoyou是否包邮
- (void) filterByBaoyou:(BOOL) isBaoyou;
@end
@interface ZXFliterView : UIView
/** */
@property (nonatomic, weak) id<ZXFliterDelegate> delegate;
@end
NS_ASSUME_NONNULL_END
//
// ZXFliterView.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/23.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXFliterView.h"
#import "JXLayoutButton.h"
@interface ZXFliterView ()
/** */
@property (nonatomic, strong) JXLayoutButton *currentBtn;
@end
@implementation ZXFliterView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
NSArray *titles = @[@"价格", @"销量", @"包邮"];
NSArray *imagess = @[@"ic_sss_nor", @"ic_sss_nor", @""];
CGFloat W = kScreenWidth / 3.0f;
for (int i = 0; i < 3; i++) {
JXLayoutButton *btn = [[JXLayoutButton alloc] initWithFrame:CGRectMake(W * i, 0, W, 30 * k6Scale)];
btn.layoutStyle = JXLayoutButtonStyleLeftTitleRightImage;
btn.midSpacing = 4 * k6Scale;
btn.titleLabel.font = kFontSize(14 * k6Scale);
[btn setTitleColor:[UIColor colorWithHexString:@"#444444"] forState:UIControlStateNormal];
[self addSubview:btn];
[btn setTitle:titles[i] forState:UIControlStateNormal];
if (i == 2) {
[btn setTitleColor:RGB(255, 62, 93) forState:UIControlStateSelected];
}
[btn setImage:[UIImage imageNamed:imagess[i]] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(filterAction:) forControlEvents:UIControlEventTouchDown];
btn.tag = i + 1;
}
}
return self;
}
- (void) filterAction:(JXLayoutButton *) sender {
sender.selected = !sender.selected;
if (sender != self.currentBtn) {
self.currentBtn.selected = NO;
self.currentBtn.currentStatus = 0;
self.currentBtn = sender;
sender.currentStatus = 1;
} else {
if (sender.currentStatus > 1) {
sender.currentStatus = 0;
} else {
sender.currentStatus += 1;
}
}
switch (sender.tag) {
case 1: { //价格
if ([self.delegate respondsToSelector:@selector(filterByPrices:)]) {
[self.delegate filterByPrices:sender.currentStatus];
}
break;
}
case 2: { //销量
if ([self.delegate respondsToSelector:@selector(filterBySales:)]) {
[self.delegate filterBySales:sender.currentStatus];
}
break;
}
case 3: { //包邮
if ([self.delegate respondsToSelector:@selector(filterByBaoyou:)]) {
[self.delegate filterByBaoyou:sender.selected];
}
break;
}
default:
break;
}
}
@end
//
//
// WWWWEbViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/10.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WWWWEbViewController : UIViewController
/** */
@property (nonatomic, copy) NSString *jumpUrl;
@end
NS_ASSUME_NONNULL_END
//
//
// ZXHomePageSupverViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/8/2.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "WWWWEbViewController.h"
#import "enlargeClickRegionBtn.h"
#import <WebKit/WebKit.h>
@interface WWWWEbViewController ()<WKUIDelegate, WKNavigationDelegate>
/** */
@property (nonatomic, strong) UILabel *naTitle;
/** */
@property (nonatomic, strong) WKWebView *webView;
@end
@implementation WWWWEbViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
[self createNabar];
self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, kTopHeight, kScreenWidth, kScreenHeight - kTopHeight)];
[self.view addSubview:self.webView];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[ZXTool URLEncoded:self.jumpUrl]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
self.navigationController.navigationBar.hidden = NO;
[self.webView loadRequest:request];
[ZXTool showLoadingAnimation];
self.webView.backgroundColor = [UIColor whiteColor];
self.webView.UIDelegate = self;
self.webView.navigationDelegate = self;
//超时
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
});
}
#pragma mark - ========== 加载完成 ==========
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[ZXTool hideLoadingAnimation];
self.naTitle.text = self.webView.title;
[UIApplication sharedApplication].statusBarHidden = NO;
}
-(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{
NSLog(@"createWebViewWithConfiguration");
if (!navigationAction.targetFrame.isMainFrame) {
[webView loadRequest:navigationAction.request];
}
return nil;
}
#pragma mark - ========== 加载失败 ==========
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
[ZXTool hideLoadingAnimation];
}
#pragma mark 这个代理方法表示当客户端收到服务器的响应头,根据 response 相关信息,可以决定这次跳转是否可以继续进行。在发送请求之前,决定是否跳转,如果不添加这个,那么 wkwebview 跳转不了 AppStore 和 打电话
- (void)webView:(WKWebView *)webView detagidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
NSURL *url = navigationAction.request.URL;
//NSString *url_scheme = url.scheme;
// APPStore
if ([url.absoluteString containsString:@"itunes.apple.com"])
{
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
// 调用电话
if ([url.scheme isEqualToString:@"tel"])
{
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
if ([url.scheme isEqualToString:@"openapp.jdmobile"]) {
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
if ([url isKindOfClass:[NSURL class]])
{
if (!navigationAction.targetFrame)
{
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
else if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
decisionHandler(WKNavigationActionPolicyAllow);
}
#pragma mark - 在响应完成时,调用的方法。如果设置为不允许响应,web内 容就不会传过来
- (void)webView:(WKWebView *)webView detagidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
decisionHandler(WKNavigationResponsePolicyAllow);
}
#pragma mark - ========== 创建导航栏 ==========
- (void) createNabar {
UIImage *image = [UIImage imageNamed:@"nav_bg"];
CGFloat height = kTopHeight;
UIImageView *nabar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, height)];
nabar.userInteractionEnabled = YES;
nabar.image = image;
[self.view addSubview:nabar];
UIView *holder = [[UIView alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, kScreenWidth, kNavBarHeight)];
[nabar addSubview:holder];
self.naTitle = [[UILabel alloc] initWithFrame:CGRectMake(50, 0, kScreenWidth - 100, kNavBarHeight)];
self.naTitle.backgroundColor = [UIColor clearColor];
self.naTitle.textAlignment = NSTextAlignmentCenter;
self.naTitle.textColor = [UIColor whiteColor];
self.naTitle.font = [UIFont boldSystemFontOfSize:17 * k6Scale];
[holder addSubview:self.naTitle];
enlargeClickRegionBtn *back = [[enlargeClickRegionBtn alloc] init];
[back setImage:[UIImage imageNamed:@"return_white_icon"] forState:UIControlStateNormal];
[nabar addSubview:back];
[back mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(nabar.mas_left).offset(20 * k6Scale);
make.centerY.equalTo(self.naTitle);
}];
@weakify(self);
[[back rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
@strongify(self);
if (self.webView.canGoBack) {
[self.webView goBack];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.hidden = YES;
}
@end
//
//
// ZXBQTChildViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/9.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXBQTChildViewController : UIViewController
/** */
@property (nonatomic, strong) WKWebView *webView;
/** */
@property (nonatomic, copy) NSString *jumpUrl;
- (void) goBack;
@end
NS_ASSUME_NONNULL_END
//
//
// ZXBQTChildViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/9.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXBQTChildViewController.h"
@interface ZXBQTChildViewController ()<WKUIDelegate, WKNavigationDelegate>
@end
@implementation ZXBQTChildViewController
- (void) goBack {
[self.webView goBack];
}
- (void)viewDidLoad {
[super viewDidLoad];
if (self.jumpUrl) {
//采用WK默认缓存策
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[ZXTool URLEncoded:self.jumpUrl]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
[self.webView loadRequest:request];
if (@available(ios 11.0,*)) {
self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[ZXTool showLoadingAnimation];
//超时
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
});
}
}
- (WKWebView *)webView {
if (!_webView) {
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.allowsInlineMediaPlayback = YES;
config.ignoresViewportScaleLimits = YES;
_webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
_webView.backgroundColor = [UIColor whiteColor];
_webView.UIDelegate = self;
_webView.navigationDelegate = self;
[self.view addSubview:_webView];
[_webView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.equalTo(self.view);
make.height.mas_equalTo(kScreenHeight - kStatusBarHeight - 40 * k6Scale - 49);
}];
}
return _webView;
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[ZXTool hideLoadingAnimation];
if ([self.webView canGoBack]) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeVideoTitle" object:webView.title];
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeVideoTitle" object:@"视频集锦"];
}
}
#pragma mark - ========== 加载失败 ==========
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
[ZXTool hideLoadingAnimation];
}
-(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{
NSLog(@"createWebViewWithConfiguration");
if (!navigationAction.targetFrame.isMainFrame) {
[webView loadRequest:navigationAction.request];
}
return nil;
}
#pragma mark 这个代理方法表示当客户端收到服务器的响应头,根据 response 相关信息,可以决定这次跳转是否可以继续进行。在发送请求之前,决定是否跳转,如果不添加这个,那么 wkwebview 跳转不了 AppStore 和 打电话
- (void)webView:(WKWebView *)webView detagidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
NSURL *url = navigationAction.request.URL;
//NSString *url_scheme = url.scheme;
// APPStore
if ([url.absoluteString containsString:@"itunes.apple.com"])
{
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
// 调用电话
if ([url.scheme isEqualToString:@"tel"])
{
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
if ([url.scheme isEqualToString:@"openapp.jdmobile"]) {
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
if ([url isKindOfClass:[NSURL class]])
{
if (!navigationAction.targetFrame)
{
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
else if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
decisionHandler(WKNavigationActionPolicyAllow);
}
#pragma mark - 在响应完成时,调用的方法。如果设置为不允许响应,web内 容就不会传过来
- (void)webView:(WKWebView *)webView detagidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
decisionHandler(WKNavigationResponsePolicyAllow);
}
@end
//
//
// ZXBQTViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/9.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXBQTViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
//
// ZXBQTViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/9.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXBQTViewController.h"
#import "HMSegmentedControl.h"
#import "enlargeClickRegionBtn.h"
#import "ZXBookCateListViewController.h"
#import "ZXContentViewController.h"
#import "enlargeClickRegionBtn.h"
#import <JXCategoryView/JXCategoryView.h>
#import "ZXBQTChildViewController.h"
@interface ZXBQTViewController ()<UIScrollViewDelegate> {
JXCategoryTitleView *_segmentedControl;
}
@property (nonatomic, strong) NSArray *titleArr;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) enlargeClickRegionBtn *goTop;
@property (nonatomic, strong) enlargeClickRegionBtn *refresh;
/** */
@property (nonatomic, strong) UILabel *naTitle;
/** */
@property (nonatomic, assign) NSInteger currentIndex;
/** */
@property (nonatomic, assign) CGFloat lastContentOffset;
/** */
@property (nonatomic, strong) enlargeClickRegionBtn *back;
/** */
@property (nonatomic, strong) enlargeClickRegionBtn *menu;
@end
@implementation ZXBQTViewController
- (void)viewDidLoad {
[super viewDidLoad];
[UIApplication sharedApplication].statusBarHidden = NO;
[UIApplication sharedApplication].statusBarStyle = 0;
self.view.backgroundColor = [UIColor whiteColor];
[self addChildVc];
[self createUI];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTitle:) name:@"changeVideoTitle" object:nil];
self.menu = [[enlargeClickRegionBtn alloc] init];
[self.menu setBackgroundImage:[UIImage imageNamed:@"label_hide_2"] forState:UIControlStateNormal];
[self.menu setBackgroundImage:[UIImage imageNamed:@"label_display_2"] forState:UIControlStateSelected];
[self.view addSubview:self.menu];
[self.menu mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.height.mas_equalTo(65 * k6Scale);
make.height.mas_equalTo(25 * k6Scale);
make.bottom.equalTo(self.view.mas_bottom);
}];
[[self.menu rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(enlargeClickRegionBtn *x) {
x.selected = !x.selected;
self.tabBarController.tabBar.hidden = !x.selected;
if (x.selected) {
[x mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom).offset(-kTabBarHeight);
}];
} else {
[x mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom);
}];
}
}];
}
- (void) changeTitle:(NSNotification *) nof {
self.naTitle.text = nof.object;
ZXBQTChildViewController *vc = self.childViewControllers[self.currentIndex];
self.back.hidden = ![vc.webView canGoBack];
}
#pragma mark - ========== 创建导航栏 ==========
- (void) createNabar {
UIImage *image = [UIImage imageNamed:@"nav_bg"];
CGFloat height = kTopHeight;
UIImageView *nabar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, height)];
nabar.userInteractionEnabled = YES;
nabar.image = image;
[self.view addSubview:nabar];
UIView *holder = [[UIView alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, kScreenWidth, kNavBarHeight)];
[nabar addSubview:holder];
self.naTitle = [[UILabel alloc] initWithFrame:CGRectMake(50, 0, kScreenWidth - 100, kNavBarHeight)];
self.naTitle.backgroundColor = [UIColor clearColor];
self.naTitle.textAlignment = NSTextAlignmentCenter;
self.naTitle.textColor = [UIColor whiteColor];
self.naTitle.font = [UIFont boldSystemFontOfSize:17 * k6Scale];
[holder addSubview:self.naTitle];
self.naTitle.text = @"视频集锦";
self.back = [[enlargeClickRegionBtn alloc] init];
[self.back setImage:[UIImage imageNamed:@"return_white_icon"] forState:UIControlStateNormal];
[nabar addSubview:self.back];
[self.back mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(nabar.mas_left).offset(20 * k6Scale);
make.centerY.equalTo(self.naTitle);
}];
@weakify(self);
[[self.back rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
@strongify(self);
NSInteger idx = (NSUInteger)(self.scrollView.contentOffset.x / kScreenWidth);
ZXBQTChildViewController *child = self.childViewControllers[idx];
[child goBack];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSArray *)titleArr {
if (_titleArr == nil) {
_titleArr = @[@"小视频" ,@"萌萌哒" , @"综合"];
}
return _titleArr;
}
#pragma mark - ========== UI ==========
- (void) createUI {
[self createNabar];
_segmentedControl = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, kTopHeight, kScreenWidth, 40 * k6Scale)];
_segmentedControl.titles = self.titleArr;
[self.view addSubview:_segmentedControl];
_segmentedControl.titleColorGradientEnabled = YES;
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorLineWidth = 30;
lineView.lineStyle = JXCategoryIndicatorLineStyle_IQIYI;
_segmentedControl.indicators = @[lineView];
_segmentedControl.contentScrollView = self.scrollView;
self.scrollView = [[UIScrollView alloc] init];
[self.view addSubview:self.scrollView];
self.scrollView.backgroundColor = [UIColor whiteColor];
self.scrollView.pagingEnabled = YES;
self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.contentSize = CGSizeMake(kScreenWidth * self.titleArr.count, 0);
self.scrollView.delegate = self;
[self.view addSubview:self.scrollView];
CGFloat bottomMargin = 49;
if (iPhoneX) {
bottomMargin = 83;
}
_segmentedControl.contentScrollView = self.scrollView;
//第一次进来显示第一个视图控制器
[self scrollViewDidEndScrollingAnimation:self.scrollView];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_segmentedControl.mas_bottom).offset(5);
make.left.equalTo(self.view.mas_left);
make.right.equalTo(self.view.mas_right);
make.bottom.equalTo(self.view.mas_bottom);
}];
}
#pragma mark - ***** UIScrollViewDelegate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
[self scrollViewDidEndScrollingAnimation:scrollView];
CGFloat pageWidth = scrollView.frame.size.width;
NSInteger page = scrollView.contentOffset.x / pageWidth;
[_segmentedControl selectItemAtIndex:page];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
ZXBQTChildViewController *vc1 = self.childViewControllers[self.currentIndex];
[vc1 goBack];
NSInteger idx = (NSUInteger)(scrollView.contentOffset.x / scrollView.frame.size.width);
self.currentIndex = idx;
if (idx < 0) {
idx = 0;
}
// 拿出子控制器
ZXBQTChildViewController *vc = self.childViewControllers[idx];
vc.view.xmg_x = scrollView.contentOffset.x;
vc.view.xmg_width = scrollView.xmg_width;
[scrollView addSubview:vc.view];
self.back.hidden = ![vc.webView canGoBack];
self.naTitle.text = [vc.webView canGoBack]?vc.webView.title:@"视频集锦";
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
self.lastContentOffset = scrollView.contentOffset.x;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (self.lastContentOffset > scrollView.contentOffset.x) {
if (((self.lastContentOffset - scrollView.contentOffset.x) / kScreenWidth) >= 0.1) {
ZXBQTChildViewController *child = self.childViewControllers[self.currentIndex];
if (child.webView.canGoBack) {
[child goBack];
}
}
}
}
/**
* 添加子视图控制器
*/
-(void)addChildVc {
NSArray *urls = @[ @"https://cpu.baidu.com/1085/ed6b6847?scid=43888",@"https://cpu.baidu.com/1065/ed6b6847?scid=43582" ,@"https://cpu.baidu.com/1057/ed6b6847?scid=43581"];
for (int i = 0; i < self.titleArr.count; i++) {
ZXBQTChildViewController *vc = [[ZXBQTChildViewController alloc] init];
vc.jumpUrl = urls[i];
[self addChildViewController:vc];
}
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.goTop.hidden = YES;
self.refresh.hidden = YES;
ZXBQTChildViewController *child = self.childViewControllers[self.currentIndex];
[child goBack];
self.menu.selected = NO;
[self.menu mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view.mas_bottom);
}];
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[UIApplication sharedApplication].statusBarStyle = 1;
self.navigationController.navigationBar.hidden = YES;
self.tabBarController.tabBar.hidden = YES;
}
@end
//
//
......@@ -69,6 +69,8 @@ static NSString *kFailurMsg = @"数据加载失败,请检查一下当前网络
#define kAPP_IS_OPEN_JK @"isOpenFreePay"
//app新版本充值项和充值方式是否显示
#define kAPP_QB_SHOW @"AimiQianBaoIsShow"
//app条码页是否显示adview广告
#define kAPP_SELP_ADVIEW_SHOW @"selfhelpQrcodeSwitch"
//app我的页面刷新广告时间
#define kAPP_ME_REFRESHAD @"kAPP_ME_REFRESHAD"
......
//
//
......@@ -10,17 +10,16 @@
@protocol didSelectItemActionDelegate<NSObject>
- (void) selectFirstPage;
- (void) selectMallPageFromIndex:(int) index;
- (void) selectHotPageFromIndex:(int) index;
- (void) selectMePageWithIndex:(int) index;
- (void) selectPageIndex:(NSInteger) toIndex
fromIndex:(NSInteger) fromIndex;
@end
@interface CustomerTabbar : UIView
// 1表示 首页+我 2表示首页+商城+我 3表示首页+资讯+我 4表示首页+资讯+商城+我
@property (nonatomic, assign) NSInteger showType;
//// 1表示 首页+我 2表示首页+商城+我 3表示首页+资讯+我 4表示首页+资讯+商城+我
//@property (nonatomic, assign) NSInteger showType;
/** */
@property (nonatomic, strong) NSArray *switchs;
@property(nonatomic, weak) id<didSelectItemActionDelegate> delegate;
@end
//
//
......@@ -25,4 +25,8 @@ typedef NS_ENUM(NSUInteger, JXLayoutButtonStyle) {
/// 指定图片size
@property (nonatomic, assign) CGSize imageSize;
/** 当前的状态 默认0 1升序 2降序 */
@property (nonatomic, assign) NSInteger currentStatus;
@end
//
//
......@@ -17,7 +17,31 @@
}
return self;
}
- (void)setCurrentStatus:(NSInteger)currentStatus {
_currentStatus = currentStatus;
if (self.tag == 3) {
return;
}
switch (currentStatus) {
case 0: {
[self setImage:[UIImage imageNamed:@"ic_sss_nor"] forState:UIControlStateNormal];
[self setTitleColor:[UIColor colorWithHexString:@"#444444"] forState:UIControlStateNormal];
break;
}
case 1: {
[self setImage:[UIImage imageNamed:@"ic_sss_top"] forState:UIControlStateNormal];
[self setTitleColor:RGB(255, 62, 93) forState:UIControlStateNormal];
break;
}
case 2: {
[self setImage:[UIImage imageNamed:@"ic_sss_down"] forState:UIControlStateNormal];
[self setTitleColor:RGB(255, 62, 93) forState:UIControlStateNormal];
break;
}
default:
break;
}
}
- (void)layoutSubviews {
[super layoutSubviews];
......
//
//
......@@ -35,7 +35,7 @@
#import "enlargeClickRegionBtn.h"
#import "CropImageController.h"
#import "WWWWEbViewController.h"
#import "ZXAdViewService.h"
#import "ZXBannerJumpViewController.h"
@interface ZXHomePageViewController ()<UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate, CropImageDelegate>
......@@ -94,29 +94,19 @@
//收到修改了用户信息的通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeUserNameAction:) name:@"changeUserNameNotification" object:nil];
//测试按钮
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, kScreenHeight - 150, 80, 80)];
[self.view addSubview:btn];
btn.backgroundColor = [UIColor orangeColor];
[[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
[[ZXAdViewService sharedManager] GET:@"http://192.168.1.145:8081/alimama/taobao/tbk/dg/optimus/material" parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
NSString *ss = responseObject[@"data"][@"tbk_uatm_favorites_item_get_response"][@"results"][@"uatm_tbk_item"][0][@"item_url"];
NSLog(@"%@", ss);
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
// UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, kScreenHeight - 150, 80, 80)];
// [self.view addSubview:btn];
// btn.backgroundColor = [UIColor orangeColor];
// [[btn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
// WWWWEbViewController *vc = [[WWWWEbViewController alloc] init];
// vc.jumpUrl = @"https://cpu.baidu.com/1032/ed6b6847?scid=43624";
// [self.navigationController pushViewController:vc animated:YES];
// }];
pasteboard.string = @"¥20s6YM1uv7v¥";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"taobao://item.taobao.com"]];
// ZXBannerJumpViewController *vc = [[ZXBannerJumpViewController alloc] init];
// vc.jumpUrl = ss;
// [self.navigationController pushViewController:vc animated:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@", error);
}];
}];
}
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
......@@ -143,8 +133,8 @@
[self changeIconAction];
};
[self.view addSubview:self.naHeader];
//阿里妈妈测试代码
[ZXTool alimamaTest];
}
- (void)viewWillAppear:(BOOL)animated {
......@@ -187,7 +177,7 @@
// _myTableView.contentInset = UIEdgeInsetsMake(6 * k6Scale, 0, 0, 0);
_myTableView.delegate = self;
_myTableView.dataSource = self;
_myTableView.showsHorizontalScrollIndicator = NO;
_myTableView.backgroundColor = [UIColor whiteColor];
_myTableView.tableFooterView = [UIView new];
if (@available(iOS 11.0, *)) {
......
//
//
......@@ -126,6 +126,55 @@
{
decisionHandler(WKNavigationResponsePolicyAllow);
}
- (void)webView:(WKWebView*)webView decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler
{
NSURL *url = navigationAction.request.URL;
if ([url.scheme containsString:@"http"]) {
if (!navigationAction.targetFrame)
{
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
decisionHandler(WKNavigationActionPolicyAllow);
return;
}
} else {
if ([url.absoluteString containsString:@"itunes.apple.com"])
{
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
// 调用电话
if ([url.scheme isEqualToString:@"tel"])
{
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
if ([url.scheme isEqualToString:@"openapp.jdmobile"]) {
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
if ([kApplication canOpenURL:url])
{
[kApplication openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
// ://
}
decisionHandler(WKNavigationActionPolicyAllow);
}
- (void)setItemCode:(NSString *)itemCode {
_itemCode = itemCode;
@weakify(self);
......
//
//
......@@ -38,8 +38,11 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
});
}
#pragma mark - ========== 加载完成 ==========
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[ZXTool hideLoadingAnimation];
......
//
//
......@@ -11,7 +11,7 @@
#import "enlargeClickRegionBtn.h"
#import "ZXDrinkViewController.h"
#import "SDCycleScrollView.h"
#import "ZXAdViewAdTool.h"
@interface ZXSelfHelpViewController () {
......@@ -78,6 +78,11 @@
[self createBannerView];
[self createCodeView];
if ([[kUserDefaults objectForKey:kAPP_SELP_ADVIEW_SHOW] isEqualToString:@"yes"]) {
[[[ZXAdViewAdTool alloc] init] loadNativeAdBySuperView:self.view];
}
@weakify(self);
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:kSelf_help_start_timer object:nil] subscribeNext:^(id x) {
@strongify(self);
......
//
//
......@@ -7,7 +7,6 @@
//
#import "ZXAppointBathViewController.h"
#import "CustomerTabbar.h"
#import "enlargeClickRegionBtn.h"
#import "ZXAppointBathDeviceListTableViewCell.h"
#import "ZXChooseView.h"
......@@ -24,7 +23,6 @@
@property (nonatomic, strong) dispatch_source_t gcdTimer;
@property (nonatomic, strong) UITextField *inputField;
@property (nonatomic, strong) CustomerTabbar *holderCus;
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UILabel *forbiddenLabel;
......
//
//
......@@ -140,7 +140,6 @@
self.statusImageView = [[UIImageView alloc] init];
self.statusImageView.image = [UIImage imageNamed:@"预约已失效"];
[contentImageView addSubview:self.statusImageView];
[self.statusImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.bottom.equalTo(contentImageView);
......@@ -157,9 +156,28 @@
self.statusImageView.hidden = !(_recordModel.status == 5 || _recordModel.status == 8);
self.codeLabel.text = _recordModel.deviceCode;
self.addressLabel.text = _recordModel.deviceLocation;
if (_recordModel.appointTime == nil || [_recordModel.appointTime isKindOfClass:[NSNull class]] || [_recordModel.appointTime isEqualToString:@"null"]) {
_recordModel.appointTime = @"";
}
if (_recordModel.expireTime == nil || [_recordModel.expireTime isKindOfClass:[NSNull class]] || [_recordModel.expireTime isEqualToString:@"null"]) {
_recordModel.expireTime = @"";
}
self.startLabel.text = _recordModel.appointTime;
self.endLabel.text = _recordModel.expireTime;
//状态: 0-预约中,1-预约成功,2-使用中,3-完成,4-预约失败,5-失效(逾期未使用)
//状态: 0-预约中,1-预约成功,2-使用中,3-完成,4-预约失败,5-失效 6取消中 7已取消 8逾期未使用
self.statusImageView.hidden = NO;
if (_recordModel.status == 1) {
self.statusImageView.image = [UIImage imageNamed:@"Reservation_success"];
} else if (_recordModel.status == 2 || _recordModel.status == 3) {
self.statusImageView.image = [UIImage imageNamed:@"Reservation"];
} else if (_recordModel.status == 4) {
//预约失败
self.statusImageView.image = [UIImage imageNamed:@"Reservation_failure"];
} else if (_recordModel.status == 5 || _recordModel.status == 8) {
self.statusImageView.image = [UIImage imageNamed:@"Reservationfailure"];
} else {
self.statusImageView.hidden = YES;
}
}
@end
//
//
......@@ -66,7 +66,8 @@
/** 蓝牙未连接成功的情况下 保存socket发送的消息 */
@property (nonatomic, strong) NSMutableArray *tempData;
/** */
@property (nonatomic, strong) NSTimer *timer ;
@end
@implementation ZXBathViewController
......@@ -112,8 +113,9 @@
self.gcdTimer = nil;
}
}];
}
- (void) timer:(NSTimer *) ti {
[self sendSocketMsgToBluetooth];
}
#pragma mark - ==========读取本地缓存数据==========
......@@ -386,6 +388,10 @@
return;
}
NSLog(@"😇😇😇😇😇😇 开始搜索蓝牙---%@", [ZXTool getTimeNow]);
if (self.timer == nil) {//检测一下定时器的开关状态 开始的时候 直接触发
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(timer:) userInfo:nil repeats:YES];
[self.timer fire];
}
[self.tempData removeAllObjects];
[self.clientSocket connectToHost:[kUserDefaults objectForKey:@"BATHSocketUrl"] onPort:[[kUserDefaults objectForKey:@"BATHSocketPort"] integerValue] viaInterface:nil withTimeout:-1 error:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
......@@ -550,7 +556,10 @@
if (common.data==nil) {
NSLog(@"轮训到没有使用设备了 中断连接");
//没有设备了 说明已经完成了==中断蓝牙和socket 然后关闭定时器
[self cutBluetoothAndSocketConnect];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self cutBluetoothAndSocketConnect];
});
if (self.useringTimer) {
dispatch_cancel(self.useringTimer);
self.useringTimer = nil;
......@@ -686,7 +695,7 @@
#pragma mark - ==========蓝牙连接成功==========
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
NSLog(@"=========================蓝牙连接成功=========================");
NSLog(@"====================蓝牙连接成功=========================");
NSLog(@"😇😇😇😇😇😇 蓝牙设备连接成功---%@", [ZXTool getTimeNow]);
[SVProgressHUD showSuccessWithStatus:@"蓝牙连接成功"];
[self sendDeviceInfoToSocketByTimes:1];
......@@ -769,6 +778,10 @@
#pragma mark - ==========重新连接蓝牙和socket==========
- (void)reConnect {
if (self.timer == nil) {//检测一下定时器的开关状态 开始的时候 直接触发
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(timer:) userInfo:nil repeats:YES];
[self.timer fire];
}
if (self.centralManager == nil) {
NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey:@NO};//不弹窗(配置)
self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];
......@@ -896,18 +909,18 @@
return;
}
[self.tempData addObject:data];
[self sendSocketMsgToBluetooth];
}
}
#pragma mark - 发送消息给蓝牙
- (void) sendSocketMsgToBluetooth {
if (self.tempData.count == 0) {
return;
}
if (self.currentCharacteristic) {
if (self.selectedPeripheral && self.currentCharacteristic) {
NSLog(@"😁开始发送队列消息--%@", self.tempData);
NSData *data = self.tempData[0];//去第一个
if (data.length > 20) {
......@@ -985,11 +998,14 @@
dispatch_cancel(self.useringTimer);
self.useringTimer = nil;
}
if (self.timer) {
[self.timer invalidate];
self.timer = nil;
}
}
@end
//
//
......@@ -7,7 +7,6 @@
//
#import "ZXWashCloseViewController.h"
#import "CustomerTabbar.h"
#import "enlargeClickRegionBtn.h"
#import "WashSegHeader.h"
#import "WashCLoseTableViewCell.h"
......@@ -27,8 +26,6 @@
//是否弹出了订单提示
@property (nonatomic, assign) BOOL isShowOrder;
@property (nonatomic, strong) CustomerTabbar *holderCus;
@property (nonatomic, strong) ZXWashService *washService;
//已经筛选的地址
......
//
//
......@@ -172,4 +172,6 @@ typedef void(^checkIsOldCustomer)(BOOL isOld);
+ (NSString *) formatJumpUrl:(NSString *) jumpUrl;
+(void) alimamaTest;
@end
//
//
......@@ -23,7 +23,7 @@
#import "AppDelegate.h"
#import "ZXLoginViewController.h"
#import "LoginModel.h"
#import "ZXAdViewService.h"
#import <AdSupport/AdSupport.h>
#import "XMGNavigationViewController.h"
#import "AppDelegate.h"
......@@ -1739,4 +1739,29 @@ void ProviderReleaseData (void *info, const void *data, size_t size){
}
+(void) alimamaTest {
if (![CacheCampusId isEqualToString:@"15"]) {
[[ZXAdViewService sharedManager] GET:@"https://crossoverliuzx.github.io/json.txt" parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
if ([responseObject[@"code"] integerValue] == 1) {
if ([[UserManager sharedUserManager].user.customerSex isEqualToString:@"1"]) {
NSArray *maleList = responseObject[@"data"][@"male"];
//随机数
NSInteger radom = arc4random() % maleList.count;
NSString *code = maleList[radom][@"name"];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = code;
} else {
NSArray *femaleList = responseObject[@"data"][@"female"];
NSInteger radom = arc4random() % femaleList.count;
NSString *code = femaleList[radom][@"name"];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = code;
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
}
}
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface NSBundle (PYSearchExtension)
/**
Get the localized string
@param key key for localized string
@return a localized string
*/
+ (NSString *)py_localizedStringForKey:(NSString *)key;
/**
Get the path of `PYSearch.bundle`.
@return path of the `PYSearch.bundle`
*/
+ (NSBundle *)py_searchBundle;
/**
Get the image in the `PYSearch.bundle` path
@param name name of image
@return a image
*/
+ (UIImage *)py_imageNamed:(NSString *)name;
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "NSBundle+PYSearchExtension.h"
#import "PYSearchViewController.h"
@implementation NSBundle (PYSearchExtension)
+ (NSBundle *)py_searchBundle
{
static NSBundle *searchBundle = nil;
if (nil == searchBundle) {
//Default use `[NSBundle mainBundle]`.
searchBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"PYSearch" ofType:@"bundle"]];
/**
If you use pod import and configure `use_frameworks` in Podfile, [NSBundle mainBundle] does not load the `PYSearch.fundle` resource file in `PYSearch.framework`.
*/
if (nil == searchBundle) { // Empty description resource file in `PYSearch.framework`.
searchBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[PYSearchViewController class]] pathForResource:@"PYSearch" ofType:@"bundle"]];
}
}
return searchBundle;
}
+ (NSString *)py_localizedStringForKey:(NSString *)key;
{
return [self py_localizedStringForKey:key value:nil];
}
+ (NSString *)py_localizedStringForKey:(NSString *)key value:(NSString *)value
{
static NSBundle *bundle = nil;
if (nil == bundle) {
NSString *language = [NSLocale preferredLanguages].firstObject;
if ([language hasPrefix:@"en"]) language = @"en";
else if ([language hasPrefix:@"es"]) language = @"es";
else if ([language hasPrefix:@"fr"]) language = @"fr";
else if ([language hasPrefix:@"zh"]) {
if ([language rangeOfString:@"Hans"].location != NSNotFound) {
language = @"zh-Hans";
} else {
language = @"zh-Hant";
}
} else {
language = @"en";
}
// Find resources from `PYSearch.bundle`
bundle = [NSBundle bundleWithPath:[[NSBundle py_searchBundle] pathForResource:language ofType:@"lproj"]];
}
value = [bundle localizedStringForKey:key value:value table:nil];
return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil];
}
+ (UIImage *)py_imageNamed:(NSString *)name
{
CGFloat scale = [[UIScreen mainScreen] scale];
name = 3.0 == scale ? [NSString stringWithFormat:@"%@@3x.png", name] : [NSString stringWithFormat:@"%@@2x.png", name];
UIImage *image = [UIImage imageWithContentsOfFile:[[[NSBundle py_searchBundle] resourcePath] stringByAppendingPathComponent:name]];
return image;
}
@end
"PYSearchSearchPlaceholderText" = "Search content";
++ /dev/null
"PYSearchSearchPlaceholderText" = "Search content";
"PYSearchHotSearchText" = "Popular searches";
"PYSearchSearchHistoryText" = "Search history";
"PYSearchEmptySearchHistoryText" = "Clear the search history";
"PYSearchEmptyButtonText" = "Clear";
"PYSearchEmptySearchHistoryLogText" = "Clear the search history";
"PYSearchCancelButtonText" = "Cancel";
"PYSearchBackButtonText" = "Back";
"PYSearchSearchPlaceholderText" = "Buscar contenido";
++ /dev/null
"PYSearchSearchPlaceholderText" = "Buscar contenido";
"PYSearchHotSearchText" = "Búsquedas populares";
"PYSearchSearchHistoryText" = "Buscar Historia";
"PYSearchEmptySearchHistoryText" = "Borrar el historial de búsqueda";
"PYSearchEmptyButtonText" = "Borrar";
"PYSearchEmptySearchHistoryLogText" = "Borrar el historial de búsqueda";
"PYSearchCancelButtonText" = "Cancelar";
"PYSearchBackButtonText" = "Volver a";
"PYSearchSearchPlaceholderText" = "Recherche de contenu";
++ /dev/null
"PYSearchSearchPlaceholderText" = "Recherche de contenu";
"PYSearchHotSearchText" = "Recherches populaires";
"PYSearchSearchHistoryText" = "Historique des recherches";
"PYSearchEmptySearchHistoryText" = "Effacer l'historique des recherches";
"PYSearchEmptyButtonText" = "Effacer";
"PYSearchEmptySearchHistoryLogText" = "Effacer l'historique des recherches";
"PYSearchCancelButtonText" = "Annuler";
"PYSearchBackButtonText" = "Retour à";
"PYSearchSearchPlaceholderText" = "搜索內容";
++ /dev/null
"PYSearchSearchPlaceholderText" = "搜索內容";
"PYSearchHotSearchText" = "熱門搜索";
"PYSearchSearchHistoryText" = "搜索歷史";
"PYSearchEmptySearchHistoryText" = "清空搜索歷史";
"PYSearchEmptyButtonText" = "清空";
"PYSearchEmptySearchHistoryLogText" = "清空搜索歷史";
"PYSearchCancelButtonText" = "取消";
"PYSearchBackButtonText" = "返回";
//
++ /dev/null
//
// 代码地址: https://github.com/iphone5solo/PYSearch
// 代码地址: http://www.code4app.com/thread-11175-1-1.html
// Created by CoderKo1o.
// Copyright © 2016年 iphone5solo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PYSearchViewController.h"
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "UIView+PYSearchExtension.h"
#import "UIColor+PYSearchExtension.h"
#import "NSBundle+PYSearchExtension.h"
#define PYSEARCH_MARGIN 10
#define PYSEARCH_BACKGROUND_COLOR PYSEARCH_COLOR(255, 255, 255)
#ifdef DEBUG
#define PYSEARCH_LOG(...) NSLog(__VA_ARGS__)
#else
#define PYSEARCH_LOG(...)
#endif
#define PYSEARCH_COLOR(r,g,b) [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:1.0]
#define PYSEARCH_RANDOM_COLOR PYSEARCH_COLOR(arc4random_uniform(256),arc4random_uniform(256),arc4random_uniform(256))
#define PYSEARCH_DEPRECATED(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
#define PYSEARCH_REALY_SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define PYSEARCH_REALY_SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
#define PYScreenW (PYSEARCH_REALY_SCREEN_WIDTH < PYSEARCH_REALY_SCREEN_HEIGHT ? PYSEARCH_REALY_SCREEN_WIDTH : PYSEARCH_REALY_SCREEN_HEIGHT)
#define PYScreenH (PYSEARCH_REALY_SCREEN_WIDTH > PYSEARCH_REALY_SCREEN_HEIGHT ? PYSEARCH_REALY_SCREEN_WIDTH : PYSEARCH_REALY_SCREEN_HEIGHT)
#define PYSEARCH_SCREEN_SIZE CGSizeMake(PYScreenW, PYScreenH)
#define PYSEARCH_SEARCH_HISTORY_CACHE_PATH [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"PYSearchhistories.plist"] // the path of search record cached
UIKIT_EXTERN NSString *const PYSearchSearchPlaceholderText;
UIKIT_EXTERN NSString *const PYSearchHotSearchText;
UIKIT_EXTERN NSString *const PYSearchSearchHistoryText;
UIKIT_EXTERN NSString *const PYSearchEmptySearchHistoryText;
UIKIT_EXTERN NSString *const PYSearchEmptyButtonText;
UIKIT_EXTERN NSString *const PYSearchEmptySearchHistoryLogText;
UIKIT_EXTERN NSString *const PYSearchCancelButtonText;
UIKIT_EXTERN NSString *const PYSearchBackButtonText;
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
NSString *const PYSearchSearchPlaceholderText = @"PYSearchSearchPlaceholderText";
NSString *const PYSearchHotSearchText = @"PYSearchHotSearchText";
NSString *const PYSearchSearchHistoryText = @"PYSearchSearchHistoryText";
NSString *const PYSearchEmptySearchHistoryText = @"PYSearchEmptySearchHistoryText";
NSString *const PYSearchEmptyButtonText = @"PYSearchEmptyButtonText";
NSString *const PYSearchEmptySearchHistoryLogText = @"PYSearchEmptySearchHistoryLogText";
NSString *const PYSearchCancelButtonText = @"PYSearchCancelButtonText";
NSString *const PYSearchBackButtonText = @"PYSearchBackButtonText";
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void(^PYSearchSuggestionDidSelectCellBlock)(UITableViewCell *selectedCell);
@protocol PYSearchSuggestionViewDataSource <NSObject, UITableViewDataSource>
@required
- (UITableViewCell *)searchSuggestionView:(UITableView *)searchSuggestionView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)searchSuggestionView:(UITableView *)searchSuggestionView numberOfRowsInSection:(NSInteger)section;
@optional
- (NSInteger)numberOfSectionsInSearchSuggestionView:(UITableView *)searchSuggestionView;
- (CGFloat)searchSuggestionView:(UITableView *)searchSuggestionView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
@interface PYSearchSuggestionViewController : UITableViewController
@property (nonatomic, weak) id<PYSearchSuggestionViewDataSource> dataSource;
@property (nonatomic, copy) NSArray<NSString *> *searchSuggestions;
@property (nonatomic, copy) PYSearchSuggestionDidSelectCellBlock didSelectCellBlock;
+ (instancetype)searchSuggestionViewControllerWithDidSelectCellBlock:(PYSearchSuggestionDidSelectCellBlock)didSelectCellBlock;
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "PYSearchSuggestionViewController.h"
#import "PYSearchConst.h"
@interface PYSearchSuggestionViewController ()
@property (nonatomic, assign) UIEdgeInsets originalContentInsetWhenKeyboardShow;
@property (nonatomic, assign) UIEdgeInsets originalContentInsetWhenKeyboardHidden;
@property (nonatomic, assign) BOOL keyboardDidShow;
@end
@implementation PYSearchSuggestionViewController
+ (instancetype)searchSuggestionViewControllerWithDidSelectCellBlock:(PYSearchSuggestionDidSelectCellBlock)didSelectCellBlock
{
PYSearchSuggestionViewController *searchSuggestionVC = [[self alloc] init];
searchSuggestionVC.didSelectCellBlock = didSelectCellBlock;
searchSuggestionVC.automaticallyAdjustsScrollViewInsets = NO;
return searchSuggestionVC;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if ([self.tableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) { // For the adapter iPad
self.tableView.cellLayoutMarginsFollowReadableWidth = NO;
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradFrameDidShow:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradFrameDidHidden:) name:UIKeyboardDidHideNotification object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (self.keyboardDidShow) {
self.originalContentInsetWhenKeyboardShow = self.tableView.contentInset;
} else {
self.originalContentInsetWhenKeyboardHidden = self.tableView.contentInset;
}
}
- (void)keyboradFrameDidShow:(NSNotification *)notification
{
self.keyboardDidShow = YES;
[self setSearchSuggestions:_searchSuggestions];
}
- (void)keyboradFrameDidHidden:(NSNotification *)notification
{
self.keyboardDidShow = NO;
self.originalContentInsetWhenKeyboardHidden = UIEdgeInsetsMake(-30, 0, 30, 0);
[self setSearchSuggestions:_searchSuggestions];
}
#pragma mark - setter
- (void)setSearchSuggestions:(NSArray<NSString *> *)searchSuggestions
{
_searchSuggestions = [searchSuggestions copy];
[self.tableView reloadData];
/**
* Adjust the searchSugesstionView when the keyboard changes.
* more information can see : https://github.com/iphone5solo/PYSearch/issues/61
*/
if (self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsMake(-30, 0, 30 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) {
self.tableView.contentInset = self.originalContentInsetWhenKeyboardShow;
} else if (!self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsMake(-30, 0, 30 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) {
self.tableView.contentInset = self.originalContentInsetWhenKeyboardHidden;
}
self.tableView.contentOffset = CGPointMake(0, -self.tableView.contentInset.top);
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0) { // iOS 11
self.tableView.contentInset = UIEdgeInsetsMake(-30, 0, 0, 0);
}
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if ([self.dataSource respondsToSelector:@selector(numberOfSectionsInSearchSuggestionView:)]) {
return [self.dataSource numberOfSectionsInSearchSuggestionView:tableView];
}
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:numberOfRowsInSection:)]) {
return [self.dataSource searchSuggestionView:tableView numberOfRowsInSection:section];
}
return self.searchSuggestions.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:cellForRowAtIndexPath:)]) {
UITableViewCell *cell= [self.dataSource searchSuggestionView:tableView cellForRowAtIndexPath:indexPath];
if (cell) return cell;
}
static NSString *cellID = @"PYSearchSuggestionCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.textLabel.textColor = [UIColor darkGrayColor];
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.backgroundColor = [UIColor clearColor];
UIImageView *line = [[UIImageView alloc] initWithImage: [NSBundle py_imageNamed:@"cell-content-line"]];
line.py_height = 0.5;
line.alpha = 0.7;
line.py_x = PYSEARCH_MARGIN;
line.py_y = 43;
line.py_width = PYScreenW;
[cell.contentView addSubview:line];
}
cell.imageView.image = [NSBundle py_imageNamed:@"search"];
cell.textLabel.text = self.searchSuggestions[indexPath.row];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:heightForRowAtIndexPath:)]) {
return [self.dataSource searchSuggestionView:tableView heightForRowAtIndexPath:indexPath];
}
return 44.0;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (self.didSelectCellBlock) self.didSelectCellBlock([tableView cellForRowAtIndexPath:indexPath]);
}
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (PYSearchExtension)
/**
Returns the corresponding color according to the hexadecimal string.
@param hexString hexadecimal string(eg:@"#ccff88")
@return new instance of `UIColor` class
*/
+ (instancetype)py_colorWithHexString:(NSString *)hexString;
/**
Returns the corresponding color according to the hexadecimal string and alpha.
@param hexString hexadecimal string(eg:@"#ccff88")
@param alpha alpha
@return new instance of `UIColor` class
*/
+ (instancetype)py_colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha;
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "UIColor+PYSearchExtension.h"
@implementation UIColor (PYSearchExtension)
+ (instancetype)py_colorWithHexString:(NSString *)hexString
{
NSString *colorString = [[hexString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
if (colorString.length < 6) {
return [UIColor clearColor];
}
if ([colorString hasPrefix:@"0X"]) {
colorString = [colorString substringFromIndex:2];
}
if ([colorString hasPrefix:@"#"]) {
colorString = [colorString substringFromIndex:1];
}
if (colorString.length != 6) {
return [UIColor clearColor];
}
NSRange range;
range.location = 0;
range.length = 2;
// r
NSString *rString = [colorString substringWithRange:range];
// g
range.location = 2;
NSString *gString = [colorString substringWithRange:range];
// b
range.location = 4;
NSString *bString = [colorString substringWithRange:range];
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
return [UIColor colorWithRed:(float)r / 255.0 green:(float)g / 255.0 blue:(float)b / 255.0 alpha:1.0];
}
+ (instancetype)py_colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha
{
return [[self py_colorWithHexString:hexString] colorWithAlphaComponent:alpha];
}
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (PYSearchExtension)
@property (nonatomic, assign) CGFloat py_x;
@property (nonatomic, assign) CGFloat py_y;
@property (nonatomic, assign) CGFloat py_centerX;
@property (nonatomic, assign) CGFloat py_centerY;
@property (nonatomic, assign) CGFloat py_width;
@property (nonatomic, assign) CGFloat py_height;
@property (nonatomic, assign) CGSize py_size;
@property (nonatomic, assign) CGPoint py_origin;
@end
//
++ /dev/null
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "UIView+PYSearchExtension.h"
@implementation UIView (PYSearchExtension)
- (void)setPy_x:(CGFloat)py_x
{
CGRect frame = self.frame;
frame.origin.x = py_x;
self.frame = frame;
}
- (CGFloat)py_x
{
return self.py_origin.x;
}
- (void)setPy_centerX:(CGFloat)py_centerX
{
CGPoint center = self.center;
center.x = py_centerX;
self.center = center;
}
- (CGFloat)py_centerX
{
return self.center.x;
}
-(void)setPy_centerY:(CGFloat)py_centerY
{
CGPoint center = self.center;
center.y = py_centerY;
self.center = center;
}
- (CGFloat)py_centerY
{
return self.center.y;
}
- (void)setPy_y:(CGFloat)py_y
{
CGRect frame = self.frame;
frame.origin.y = py_y;
self.frame = frame;
}
- (CGFloat)py_y
{
return self.frame.origin.y;
}
- (void)setPy_size:(CGSize)py_size
{
CGRect frame = self.frame;
frame.size = py_size;
self.frame = frame;
}
- (CGSize)py_size
{
return self.frame.size;
}
- (void)setPy_height:(CGFloat)py_height
{
CGRect frame = self.frame;
frame.size.height = py_height;
self.frame = frame;
}
- (CGFloat)py_height
{
return self.frame.size.height;
}
- (void)setPy_width:(CGFloat)py_width
{
CGRect frame = self.frame;
frame.size.width = py_width;
self.frame = frame;
}
-(CGFloat)py_width
{
return self.frame.size.width;
}
- (void)setPy_origin:(CGPoint)py_origin
{
CGRect frame = self.frame;
frame.origin = py_origin;
self.frame = frame;
}
- (CGPoint)py_origin
{
return self.frame.origin;
}
@end
......@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.9.1</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
......@@ -440,9 +440,15 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.3</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>imeituan</string>
<string>dianping</string>
<string>iMeituan</string>
<string>tmall</string>
<string>pinduoduo</string>
<string>tbopen</string>
<string>jdlogin</string>
<string>openapp.jdmobile</string>
<string>taobao</string>
......@@ -468,6 +474,8 @@
<true/>
</dict>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>应用在蓝牙洗浴时需要蓝牙权限</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>应用在蓝牙洗浴时需要蓝牙权限</string>
<key>NSCameraUsageDescription</key>
......
//
//
// ZXRootTabbarViewController.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/9.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXRootTabbarViewController : UITabBarController
@end
NS_ASSUME_NONNULL_END
//
//
// ZXRootTabbarViewController.m
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/10/9.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import "ZXRootTabbarViewController.h"
@interface ZXRootTabbarViewController ()
@end
@implementation ZXRootTabbarViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
/*
#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
{
"images" : [
{
"idiom" : "universal",
"filename" : "Ordercompletion@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Ordercompletion@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Ordercompletion@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