Commit ffbd672e by 刘卓鑫

长按识别二维码 跳转逻辑敲定。

parent b1790d27
......@@ -3,4 +3,22 @@
uuid = "0B73904D-2C2A-44A2-88D3-64B4C86B59B2"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CC8FF129-01A5-452D-A8CD-2E8213FEB701"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/CustomViews(&#x81ea;&#x5b9a;&#x4e49;)/ZXLongPressWebView.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "65"
endingLineNumber = "65"
landmarkName = "-handleLongPress:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......@@ -73,7 +73,7 @@
_isPlaying = NO;
//启动环境
[APIManager sharedAPIManager].lauchEnvironment = ZXColorfulSchoolEnvironmentProduct;
[APIManager sharedAPIManager].lauchEnvironment = ZXColorfulSchoolEnvironmentTest;
//极光推送
[self initPushWithOptions:launchOptions isProduct:YES];
......
//
//
......@@ -68,7 +68,6 @@
// if (lauch.whether == NO) {
// return ;
// }
dispatch_async(dispatch_get_main_queue(), ^{
if (lauch.isButt) {
......
//
//
......@@ -10,7 +10,6 @@
#import "UIImage+InsetEdge.h"
#import "FSActionSheet.h"
@interface ZXLongPressWebView ()<FSActionSheetDelegate, UIGestureRecognizerDelegate>
/** */
@property (nonatomic, copy) NSString *qrCodeString;
......@@ -22,6 +21,9 @@
- (instancetype)init {
if (self = [super init]) {
self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.contentMode = UIViewContentModeRedraw;
self.opaque = YES;
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1;
longPress.delegate = self;
......@@ -30,6 +32,12 @@
}
return self;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
#pragma mark - 长按相关============
- (BOOL)isAvailableQRcodeIn:(UIImage *)img{
UIImage *image = [img imageByInsetEdge:UIEdgeInsetsMake(-20, -20, -20, -20) withColor:[UIColor lightGrayColor]];
......@@ -61,7 +69,7 @@
NSLog(@"读取图片失败");
return;
}
FSActionSheet *actionSheet = nil;
if ([self isAvailableQRcodeIn:image]) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *ac1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
......@@ -74,17 +82,7 @@
}];
UIAlertAction *ac3 = [UIAlertAction actionWithTitle:@"打开二维码" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
@strongify(self);
NSArray *arr = [self.qrCodeString componentsSeparatedByString:@";"];
if (arr && arr.count == 2) {
NSString *appid = arr.firstObject;
NSString *path = arr.lastObject;
[WXApi registerApp:appid];
WXLaunchMiniProgramReq *req = [[WXLaunchMiniProgramReq alloc] init];
req.userName = @"gh_c6510fd44b5f";
req.path = path;
req.miniProgramType = WXMiniProgramTypePreview;
[WXApi sendReq:req];
}
[ZXTool longPresessQrcode:self.qrCodeString];
}];
[alertController addAction:ac2];
......@@ -95,7 +93,6 @@
}];
}
}
}];
}
......
//
//
......@@ -61,7 +61,10 @@
}
[ZXTool hideLoadingAnimation];
// 不执行前段界面弹出列表的JS代码
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:^(id _Nullable res, NSError * _Nullable error) {
}];
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitUserSelect='none';"completionHandler:nil];
}
#pragma mark - ========== 加载失败 ==========
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
......
//
//
......@@ -74,17 +74,7 @@
}];
UIAlertAction *ac3 = [UIAlertAction actionWithTitle:@"打开二维码" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
@strongify(self);
NSArray *arr = [self.qrCodeString componentsSeparatedByString:@";"];
if (arr && arr.count == 2) {
NSString *appid = arr.firstObject;
NSString *path = arr.lastObject;
[WXApi registerApp:appid];
WXLaunchMiniProgramReq *req = [[WXLaunchMiniProgramReq alloc] init];
req.userName = @"gh_c6510fd44b5f";
req.path = path;
req.miniProgramType = WXMiniProgramTypePreview;
[WXApi sendReq:req];
}
[ZXTool longPresessQrcode:self.qrCodeString];
}];
[alertController addAction:ac2];
......
......@@ -113,6 +113,7 @@
[ZXTool hideLoadingAnimation];
// 不执行前段界面弹出列表的JS代码
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];
[self.webView evaluateJavaScript:@"document.documentElement.style.webkitUserSelect='none';"completionHandler:nil];
}
#pragma mark - ==========确定事件==========
- (void) okAction:(UIButton *) sender {
......
//
//
......@@ -175,4 +175,7 @@ typedef void(^checkIsOldCustomer)(BOOL isOld);
//ip
+ (NSString*)getCurentLocalIP;
+ (void) longPresessQrcode:(NSString *) qrCodeStr;
@end
//
//
......@@ -43,6 +43,10 @@
#import "enlargeClickRegionBtn.h"
#import "oneWangTong.h"
#import "ZXNotPay.h"
#import "ZXHomePageWebViewController.h"
#import "ZXBannerJumpViewController.h"
#import <JDSDK/KeplerApiManager.h>
#import "ZXAdViewService.h"
#define kUserDefaults [NSUserDefaults standardUserDefaults]
......@@ -1784,4 +1788,126 @@ void ProviderReleaseData (void *info, const void *data, size_t size){
}
#pragma mark - 长按二维码事件
+ (void) longPresessQrcode:(NSString *) qrCodeStr {
NSDictionary *dic = [ZXTool dictionaryWithJsonString:qrCodeStr];
if (dic && dic[@"jType"]) {
NSString *type = dic[@"jType"];
NSString *url = dic[@"url"];
if ([type isEqualToString:@"3"] && url && ![url isEqualToString:@""]) {
//内部跳转
ZXHomePageWebViewController *bannerVc = [[ZXHomePageWebViewController alloc] init];
bannerVc.jumpUrl = url;
bannerVc.hidesBottomBarWhenPushed = YES;
[[ZXTool getCurrentVC].navigationController pushViewController:bannerVc animated:YES];
} else if ([type isEqualToString:@"4"] && url && ![url isEqualToString:@""]) {
//外部部跳转
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
} else if ([type isEqualToString:@"5"]) {
//呼第三方
NSString *sType = dic[@"sType"];
if ([sType isEqualToString:@"jd"]) {
if ([url containsString:@"?"]) {
url = [url stringByAppendingString:@"isopen=1&ad_od=1&allowJDApp=1"];
} else {
url = [url stringByAppendingString:@"?isopen=1&ad_od=1&allowJDApp=1"];
}
[[KeplerApiManager sharedKPService] openKeplerPageWithURL:url userInfo:nil failedCallback:^(NSInteger code, NSString *url) {
if (code == 422) {
//跳转webview打开
ZXHomePageWebViewController *bannerVc = [[ZXHomePageWebViewController alloc] init];
bannerVc.jumpUrl = url;
bannerVc.hidesBottomBarWhenPushed = YES;
[[ZXTool getCurrentVC].navigationController pushViewController:bannerVc animated:YES];
}
}];
} else if ([sType isEqualToString:@"taobaoke"]) {
[self taobaoWxMiniJumpWithDic:dic];
} else if ([sType isEqualToString:@"wxmini"]) {
[self taobaoWxMiniJumpWithDic:dic];
} else {
[ZXTool showText:[NSString stringWithFormat:@"二维码内容:%@", dic]];
}
}
}
}
#pragma mark - 淘宝/小程序等跳转 - - - - -
+ (void) taobaoWxMiniJumpWithDic:(NSDictionary *) dic {
if ([dic[@"sType"] isEqualToString:@"taobaoke"]) {
NSString *item_id = dic[@"item_id"];
NSInteger hasCoupon = 0;
if (dic[@"hasCoupon"] && ([dic[@"hasCoupon"] integerValue] == 1)) {
hasCoupon = 1;
}
NSString *url = [NSString stringWithFormat:@"%@/alimama/tbk/dg/material/optional/forItemId?pageNo=1&q=%@&deviceType=IMEI&deviceValue=02399123192391293123&cat=hot&itemId=%@&hasCoupon=%ld", [kUserDefaults objectForKey:@"HomePage"], dic[@"title"], item_id, (long)hasCoupon];
[[ZXAdViewService sharedManager] GET:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
id res = responseObject[@"data"];
if (res) {
if (res[@"couponShareUrl"] && ![res[@"couponShareUrl"] isKindOfClass:[NSNull class]] && ![res[@"couponShareUrl"] isEqualToString:@""]) {
[self jumpTaobaoWithItem:res[@"couponShareUrl"]];
} else {
if (res[@"url"] && ![res[@"url"] isKindOfClass:[NSNull class]] && ![res[@"url"] isEqualToString:@""]) {
[self jumpTaobaoWithItem:res[@"url"]];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:@"活动已下架,请关注后续活动!"];
});
}
}
} else {
if ([responseObject[@"code"] integerValue] == -2) {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
[ZXTool showText:responseObject[@"msg"]];
[ZXTool backToLogin];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:@"活动已下架,请关注后续活动!"];
});
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:error.description];
});
}];
} else if ([dic[@"sType"] isEqualToString:@"wxmini"]) {
//跳转微信小程序
NSString *appID = dic[@"appId"];
[WXApi registerApp:appID?appID:@"wx41cd01f1eb664e21"];
WXLaunchMiniProgramReq *req = [[WXLaunchMiniProgramReq alloc] init];
req.userName = dic[@"orgId"];
req.path = dic[@"url"];
req.miniProgramType = WXMiniProgramTypePreview;
[WXApi sendReq:req];
}
}
+ (void) jumpTaobaoWithItem:(NSString *) couponShareUrl {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *url = [@"taobao:" stringByAppendingString:couponShareUrl];
NSURL *URL = [NSURL URLWithString:url];
if ([[UIApplication sharedApplication] canOpenURL:URL]) {
[[UIApplication sharedApplication] openURL:URL];
} else {
ZXBannerJumpViewController *jumpVc = [[ZXBannerJumpViewController alloc] init];
jumpVc.jumpUrl = [@"https:" stringByAppendingString:couponShareUrl];
jumpVc.hidesBottomBarWhenPushed = YES;
[ZXTool.getCurrentVC.navigationController pushViewController:jumpVc animated:YES];
}
});
}
@end
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