Commit 916b95fa authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

1.logCollection

parent efa65d43
......@@ -75,6 +75,7 @@
A95BD59624AC500A00962B06 /* HCSortString.m in Sources */ = {isa = PBXBuildFile; fileRef = A95BD58A24AC500A00962B06 /* HCSortString.m */; };
A95BD59724AC500A00962B06 /* UIAlertController+HCAdd.m in Sources */ = {isa = PBXBuildFile; fileRef = A95BD58B24AC500A00962B06 /* UIAlertController+HCAdd.m */; };
A95BD59D24ACBF0100962B06 /* Location.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A95BD59F24ACBF0100962B06 /* Location.storyboard */; };
A95BD5AE24AD8E8D00962B06 /* AESCipher.m in Sources */ = {isa = PBXBuildFile; fileRef = A95BD5AC24AD8E8D00962B06 /* AESCipher.m */; };
A95F5C58248DDE81001DB97E /* UIButton+HExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = A95F5BC3248DDE81001DB97E /* UIButton+HExtension.m */; };
A95F5C59248DDE81001DB97E /* NSArray+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = A95F5BC4248DDE81001DB97E /* NSArray+Category.m */; };
A95F5C5A248DDE81001DB97E /* UIControl+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = A95F5BC5248DDE81001DB97E /* UIControl+Extension.m */; };
......@@ -307,6 +308,8 @@
A95BD5A424ACBF4A00962B06 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Location.storyboard; sourceTree = "<group>"; };
A95BD5A924ACBF7C00962B06 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Location.strings; sourceTree = "<group>"; };
A95BD5AA24ACBF8500962B06 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Location.strings"; sourceTree = "<group>"; };
A95BD5AC24AD8E8D00962B06 /* AESCipher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AESCipher.m; sourceTree = "<group>"; };
A95BD5AD24AD8E8D00962B06 /* AESCipher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AESCipher.h; sourceTree = "<group>"; };
A95F5BBF248DDE80001DB97E /* UIButton+ImageTitleSpacing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+ImageTitleSpacing.h"; sourceTree = "<group>"; };
A95F5BC0248DDE80001DB97E /* UIView+HExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+HExtension.h"; sourceTree = "<group>"; };
A95F5BC1248DDE80001DB97E /* UIColor+HExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+HExtension.h"; sourceTree = "<group>"; };
......@@ -767,6 +770,15 @@
path = HCSortString;
sourceTree = "<group>";
};
A95BD5AB24AD8E8D00962B06 /* AESCipher */ = {
isa = PBXGroup;
children = (
A95BD5AC24AD8E8D00962B06 /* AESCipher.m */,
A95BD5AD24AD8E8D00962B06 /* AESCipher.h */,
);
path = AESCipher;
sourceTree = "<group>";
};
A95F5BBB248DDE80001DB97E /* Classes */ = {
isa = PBXGroup;
children = (
......@@ -888,6 +900,7 @@
A95F5BEB248DDE81001DB97E /* Network */ = {
isa = PBXGroup;
children = (
A95BD5AB24AD8E8D00962B06 /* AESCipher */,
A95F5BEC248DDE81001DB97E /* TQNetworkTools.h */,
A95F5BED248DDE81001DB97E /* TQNetworkTools.m */,
64F5D6372490DDFA0034758E /* ZJAESCommonCrypto.h */,
......@@ -1524,6 +1537,7 @@
642A43F424921CAD0064A98B /* ZJLocationRemindFriendSelectView.m in Sources */,
68F6DEB62499CA940034F8D5 /* ZJZhiFuViewController.m in Sources */,
A95F5C96248DDE81001DB97E /* SDLayoutExtention.swift in Sources */,
A95BD5AE24AD8E8D00962B06 /* AESCipher.m in Sources */,
A948C504249B887B00C22D69 /* ZJGoodsModel.m in Sources */,
A95F5C68248DDE81001DB97E /* UITextField+LimitLength.m in Sources */,
A9619E8B24AB0813009A2012 /* ZJShareManager.m in Sources */,
......
......@@ -59,10 +59,7 @@
- (void)logCollection {
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"app_start", @"value": @""}.mutableCopy;
Data * data = [[Data alloc] init];
if ([[data Read] objectForKey:@"idfa"]) {
[dict setValue:[[data Read] objectForKey:@"idfa"] forKey:@"idfa"];
}
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) {
} failure:^(NSError * _Nonnull error) {
......
......@@ -42,6 +42,15 @@
[self setUI];
}
- (void)logCollection {
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"app_phone_code_login", @"value": @""}.mutableCopy;
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) {
} failure:^(NSError * _Nonnull error) {
}];
}
- (void)setUI{
self.view.backgroundColor = [UIColor whiteColor];
......@@ -107,7 +116,6 @@
phoneTextfield.leftView = leftView;
phoneTextfield.leftViewMode = UITextFieldViewModeAlways;
sendBtn = [[UIButton alloc] init];
[sendBtn setTitle:kLocalizedString(@"login_send_code") forState:UIControlStateNormal];
[sendBtn setTitleColor:kColorWithRGB(85, 142, 252) forState:UIControlStateNormal];
......@@ -245,6 +253,8 @@
return;
}
[self logCollection];
[[TQNetworkTools shared] postWithAction:loginWithPhone parameters:@{@"phoneNo":phoneTextfield.text, @"code":codeTextfield.text} success:^(id _Nonnull response) {
NSLog(@"---------------loginWithPhone %@", response);
......
......@@ -112,20 +112,15 @@
- (void)uploadLog:(NSInteger)index{
NSArray * array = @[@"我关心的人", @"定位", @"我的"];
NSArray * array = @[@"我关心的人", @"定位", @"我的"];
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"tab_imp", @"tab_imp": array[index]}.mutableCopy;
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"tab_imp", @"tab_imp": array[index]}.mutableCopy;
Data * data = [[Data alloc] init];
if ([[data Read] objectForKey:@"idfa"]) {
[dict setValue:[[data Read] objectForKey:@"idfa"] forKey:@"idfa"];
}
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) {
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) {
} failure:^(NSError * _Nonnull error) {
} failure:^(NSError * _Nonnull error) {
}];
}];
}
- (void)setDYTSelectIndex:(DYTTabBarIndex)DYTSelectIndex {
......
......@@ -39,6 +39,18 @@
[super viewDidLoad];
[self setUI];
[self getIpaList];
[self logCollection];
}
- (void)logCollection {
NSMutableDictionary *dict = @{@"event": @"guazinovel", @"action": @"app_pay", @"value": @""}.mutableCopy;
[[TQNetworkTools shared] postWithLogCollection:logCollection parameters: dict success:^(__autoreleasing id *response) {
NSLog(@"log app_pay");
} failure:^(NSError * _Nonnull error) {
}];
}
- (void)setUI{
......
//
// AESCipher.h
// AESCipher
//
// Created by Welkin Xie on 8/13/16.
// Copyright © 2016 WelkinXie. All rights reserved.
//
// https://github.com/WelkinXie/AESCipher-iOS
//
#import <Foundation/Foundation.h>
NSString * aesEncryptString(NSString *content, NSString *key);
NSString * aesDecryptString(NSString *content, NSString *key);
NSData * aesEncryptData(NSData *data, NSData *key);
NSData * aesDecryptData(NSData *data, NSData *key);
//
// AESCipher.m
// AESCipher
//
// Created by Welkin Xie on 8/13/16.
// Copyright © 2016 WelkinXie. All rights reserved.
//
// https://github.com/WelkinXie/AESCipher-iOS
//
#import "AESCipher.h"
#import <CommonCrypto/CommonCryptor.h>
NSString const *kInitVector = @"e2e7d664d72f710b";
size_t const kKeySize = kCCKeySizeAES128;
NSData * cipherOperation(NSData *contentData, NSData *keyData, CCOperation operation) {
NSUInteger dataLength = contentData.length;
void const *initVectorBytes = [kInitVector dataUsingEncoding:NSUTF8StringEncoding].bytes;
void const *contentBytes = contentData.bytes;
void const *keyBytes = keyData.bytes;
size_t operationSize = dataLength + kCCBlockSizeAES128;
void *operationBytes = malloc(operationSize);
if (operationBytes == NULL) {
return nil;
}
size_t actualOutSize = 0;
CCCryptorStatus cryptStatus = CCCrypt(operation,
kCCAlgorithmAES,
kCCOptionPKCS7Padding,
keyBytes,
kKeySize,
initVectorBytes,
contentBytes,
dataLength,
operationBytes,
operationSize,
&actualOutSize);
if (cryptStatus == kCCSuccess) {
return [NSData dataWithBytesNoCopy:operationBytes length:actualOutSize];
}
free(operationBytes);
operationBytes = NULL;
return nil;
}
NSString * aesEncryptString(NSString *content, NSString *key) {
NSCParameterAssert(content);
NSCParameterAssert(key);
NSData *contentData = [content dataUsingEncoding:NSUTF8StringEncoding];
NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];
NSData *encrptedData = aesEncryptData(contentData, keyData);
return [encrptedData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn];
}
NSString * aesDecryptString(NSString *content, NSString *key) {
NSCParameterAssert(content);
NSCParameterAssert(key);
NSData *contentData = [[NSData alloc] initWithBase64EncodedString:content options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding];
NSData *decryptedData = aesDecryptData(contentData, keyData);
return [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
}
NSData * aesEncryptData(NSData *contentData, NSData *keyData) {
NSCParameterAssert(contentData);
NSCParameterAssert(keyData);
NSString *hint = [NSString stringWithFormat:@"The key size of AES-%lu should be %lu bytes!", kKeySize * 8, kKeySize];
NSCAssert(keyData.length == kKeySize, hint);
return cipherOperation(contentData, keyData, kCCEncrypt);
}
NSData * aesDecryptData(NSData *contentData, NSData *keyData) {
NSCParameterAssert(contentData);
NSCParameterAssert(keyData);
NSString *hint = [NSString stringWithFormat:@"The key size of AES-%lu should be %lu bytes!", kKeySize * 8, kKeySize];
NSCAssert(keyData.length == kKeySize, hint);
return cipherOperation(contentData, keyData, kCCDecrypt);
}
......@@ -11,6 +11,7 @@
#import <CommonCrypto/CommonDigest.h>
#import "Data.h"
#import "ZJAESCommonCrypto.h"
#import "AESCipher.h"
@interface TQNetworkTools () <NSCopying, NSMutableCopying>
......@@ -408,19 +409,65 @@ static TQNetworkTools* _tools = nil;
NSString *urlString = [ServerReport stringByAppendingPathComponent: [self convertPostActionToString:action]];
NSDictionary *dic= parameters;
NSData *data= [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingFragmentsAllowed error:nil];
NSString *jsonString =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"ZJAESCommonjsonString成功了 %@", jsonString);
NSString *encryptStr = [[ZJAESCommonCrypto shared] AES128Encrypt: jsonString key:aesKey];
[self POST: urlString parameters: @{@"behavior": encryptStr} headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"log collection 成功了%@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
failure(error);
NSLog(@"log collection 失败了%@",error);
}];
}
// NSString *cipherText = aesEncryptString(jsonString, aesKey);
NSString *encryptStr = aesEncryptString(jsonString, aesKey);
//[[ZJAESCommonCrypto shared] AES128Encrypt: jsonString key:aesKey];
NSString *Decrypt = aesDecryptString(encryptStr, aesKey);
//[[ZJAESCommonCrypto shared] AES128Decrypt:encryptStr key:aesKey];
NSLog(@"ZJAESCommonCrypto成功了 %@", encryptStr);
NSLog(@"ZJAESCommonDecrypt成功了 %@", Decrypt);
NSMutableDictionary *mutaDict = @{}.mutableCopy;
Data * data1 = [[Data alloc] init];
if ([[data1 Read] objectForKey:@"idfa"]) {
mutaDict[@"idfa"] = [[data1 Read] objectForKey:@"idfa"];
}
NSDictionary *ddd = [self setRequestParams: mutaDict];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
// NSDictionary *ddd = [self setRequestParams: mutaDict];
NSString *aaa = @"";
for (NSString *key in ddd.allKeys) {
NSString *bb = [key stringByAppendingFormat:@"=%@", ddd[key]];
aaa = [aaa stringByAppendingFormat:@"&%@", bb];
}
NSMutableURLRequest *req = [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString: [urlString stringByAppendingFormat:@"?%@", aaa] parameters:nil error:nil];
req.timeoutInterval= 10;
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[req setValue:@"application/json" forHTTPHeaderField:@"Accept"];
// NSMutableData *postBodyData = [NSMutableData data];
// NSDictionary *dic= body;
// NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
// NSString *dd = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingFragmentsAllowed error:nil];
// [postBodyData appendData:[@"key=value" dataUsingEncoding:NSUTF8StringEncoding]];
[req setHTTPBody:[encryptStr dataUsingEncoding: NSUTF8StringEncoding]];
NSLog(@"ZJAESCommonDecrypt----成功了 %@", [encryptStr dataUsingEncoding: NSUTF8StringEncoding]);
// NSLog(@"NSJSONSerialization成功了%@", dd);
[[manager dataTaskWithRequest:req uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
NSLog(@"post成功了%@", responseObject);
}] resume];
// [self POST: urlString parameters: ddd headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// NSLog(@"log collection 成功了%@",responseObject);
// } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// failure(error);
// NSLog(@"log collection 失败了%@",error);
// }];
}
//支付验证
// POST 请求
- (void)postWithBodyAction: (TQNetwortPostAction)action parameters:(id) parameters body: (id)body success: (void(^)(NSDictionary *response))success failure:(void(^)(NSError * error)) failure {
......
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