|
@@ -15,9 +15,11 @@
|
|
#import <AFNetworking.h>
|
|
#import <AFNetworking.h>
|
|
#import "NoNetView.h"
|
|
#import "NoNetView.h"
|
|
//#import <WebKit/WebKit.h>
|
|
//#import <WebKit/WebKit.h>
|
|
|
|
+#import <CommonCrypto/CommonCryptor.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#define LocalStr_None @""//空字符串
|
|
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
|
|
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
|
|
|
|
|
|
@protocol ViewControllerMain<JSExport>
|
|
@protocol ViewControllerMain<JSExport>
|
|
@@ -27,6 +29,8 @@
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@protocol ViewControllerJSExport<JSExport>
|
|
@protocol ViewControllerJSExport<JSExport>
|
|
|
|
|
|
JSExportAs(loginByWeixin, -(NSString *)jsLoginByWeixin:(NSString *)str);// 微信登录 openid
|
|
JSExportAs(loginByWeixin, -(NSString *)jsLoginByWeixin:(NSString *)str);// 微信登录 openid
|
|
@@ -48,22 +52,24 @@ JSExportAs(openExternalLink, -(void)jsOpenExternalLink:(NSString *)url title:(NS
|
|
JSExportAs(getVersion, -(NSString *)jsGetVersion:(NSString *)str);// 获取当前版本号
|
|
JSExportAs(getVersion, -(NSString *)jsGetVersion:(NSString *)str);// 获取当前版本号
|
|
JSExportAs(alert, -(void)jsAlert:(NSString *)content);// 弹框
|
|
JSExportAs(alert, -(void)jsAlert:(NSString *)content);// 弹框
|
|
JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否安装微信
|
|
JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否安装微信
|
|
-
|
|
|
|
-
|
|
|
|
JSExportAs(changeMessageType, -(void)jsChangeMessageType:(NSString *)link);//已读操作处理
|
|
JSExportAs(changeMessageType, -(void)jsChangeMessageType:(NSString *)link);//已读操作处理
|
|
JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(NSString *)rectype openid:(NSString *)openid);
|
|
JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(NSString *)rectype openid:(NSString *)openid);
|
|
|
|
|
|
|
|
+JSExportAs(getCipherText, -(NSString *)jsGGetCipherText:(NSString *)phone);
|
|
|
|
|
|
|
|
+JSExportAs(business, -(NSInteger)jsBusiness:(NSInteger)shooID shopType:(NSInteger )shopType);
|
|
|
|
|
|
|
|
|
|
-@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+@end
|
|
|
|
+
|
|
|
|
|
|
@interface ViewController ()<UIWebViewDelegate, ViewControllerJSExport>
|
|
@interface ViewController ()<UIWebViewDelegate, ViewControllerJSExport>
|
|
{
|
|
{
|
|
CGPoint startTouch;
|
|
CGPoint startTouch;
|
|
BOOL _isMoving;
|
|
BOOL _isMoving;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@property (weak, nonatomic) IBOutlet UIWebView *webView;
|
|
@property (weak, nonatomic) IBOutlet UIWebView *webView;
|
|
@@ -81,6 +87,10 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
+NSString *const kInitVector = @"1389461544135476";
|
|
|
|
+size_t const kKeySize = kCCKeySizeAES128;
|
|
|
|
+NSString *const AesKey = @"mGlAgnIBB8bx2nch";
|
|
|
|
+
|
|
@implementation ViewController
|
|
@implementation ViewController
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
- (void)viewDidLoad {
|
|
@@ -114,7 +124,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-// [self clearWeb];
|
|
|
|
|
|
+ [self clearWeb];
|
|
|
|
|
|
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
|
|
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
|
|
[recognizer delaysTouchesBegan];
|
|
[recognizer delaysTouchesBegan];
|
|
@@ -589,7 +599,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
if (arr.count > 0) {
|
|
if (arr.count > 0) {
|
|
return [[LXViewControllerManager shareViewControllerManager] getJsonStr:arr];
|
|
return [[LXViewControllerManager shareViewControllerManager] getJsonStr:arr];
|
|
}
|
|
}
|
|
- return@"";
|
|
|
|
|
|
+ return @"";
|
|
}
|
|
}
|
|
|
|
|
|
// 更新消息状态
|
|
// 更新消息状态
|
|
@@ -712,6 +722,69 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+-(NSString *)jsGGetCipherText:(NSString *)phone
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ NSDate *date=[NSDate date];
|
|
|
|
+ NSDateFormatter *format1=[[NSDateFormatter alloc] init];
|
|
|
|
+ [format1 setDateFormat:@"yyyyMMddhhmmss"];
|
|
|
|
+ NSString *dateStr;
|
|
|
|
+ dateStr=[format1 stringFromDate:date];
|
|
|
|
+ NSLog(@"%@",dateStr);
|
|
|
|
+
|
|
|
|
+ NSString *content = [[NSString stringWithFormat:@"%@_%@",phone,dateStr] stringByAppendingString:[NSString stringWithFormat:@"_%@",[LXMD5 md532BitLower:[NSString stringWithFormat:@"%@&%@",phone,dateStr]]]];
|
|
|
|
+ NSData *contentData = [content dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
+ NSUInteger dataLength = contentData.length;
|
|
|
|
+ // 为结束符'\\0' +1
|
|
|
|
+ char keyPtr[kKeySize + 1];
|
|
|
|
+ memset(keyPtr, 0, sizeof(keyPtr));
|
|
|
|
+ [AesKey getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
|
|
|
|
+ // 密文长度 <= 明文长度 + BlockSize
|
|
|
|
+ size_t encryptSize = dataLength + kCCBlockSizeAES128;
|
|
|
|
+ void *encryptedBytes = malloc(encryptSize);
|
|
|
|
+ size_t actualOutSize = 0;
|
|
|
|
+ NSData *initVector = [kInitVector dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
+ CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
|
|
|
|
+ kCCAlgorithmAES,
|
|
|
|
+ kCCOptionPKCS7Padding, // 系统默认使用 CBC,然后指明使用 PKCS7Padding
|
|
|
|
+ keyPtr,
|
|
|
|
+ kKeySize,
|
|
|
|
+ initVector.bytes,
|
|
|
|
+ contentData.bytes,
|
|
|
|
+ dataLength,
|
|
|
|
+ encryptedBytes,
|
|
|
|
+ encryptSize,
|
|
|
|
+ &actualOutSize);
|
|
|
|
+ if (cryptStatus == kCCSuccess) {
|
|
|
|
+ // 对加密后的数据进行 base64 编码
|
|
|
|
+ return [[NSData dataWithBytesNoCopy:encryptedBytes length:actualOutSize] base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
|
|
|
|
+ }
|
|
|
|
+ free(encryptedBytes);
|
|
|
|
+ return nil;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|