|
|
@@ -53,7 +53,142 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
|
|
|
@implementation iSalesNetwork
|
|
|
|
|
|
|
|
|
++(NSMutableDictionary*) prepare_addtional_params:(NSMutableDictionary* ) params
|
|
|
+{
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+// if(appDelegate.user!=nil)
|
|
|
+// [params setValue:[AESCrypt AES128Encrypt:appDelegate.user key:@"usai"] forKey:@"user"];
|
|
|
+// if(appDelegate.password!=nil)
|
|
|
+// [params setValue:[AESCrypt AES128Encrypt:appDelegate.password key:@"usai"] forKey:@"password"];
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+
|
|
|
+// if(appDelegate.user!=nil)
|
|
|
+// [params setValue:appDelegate.user forKey:@"user"];
|
|
|
+//
|
|
|
+// if(appDelegate.contact_id!=nil)
|
|
|
+// [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
+// if(appDelegate.password!=nil)
|
|
|
+// [params setValue:appDelegate.password forKey:@"password"];
|
|
|
+//
|
|
|
+// [params setValue:appDelegate.build forKey:@"app_ver"];
|
|
|
+//
|
|
|
+// NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
|
|
|
+// NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
|
|
|
+// [params setValue:short_version forKey:@"app_short_ver"];
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//#if TARGET_IPHONE_SIMULATOR//模拟器
|
|
|
+// [params setValue:@"simulator_uuid" forKey:@"deviceid"];
|
|
|
+//#elif TARGET_OS_IPHONE//真机
|
|
|
+// UIDevice * dev = [UIDevice currentDevice];
|
|
|
+// NSUUID* uuid =dev.identifierForVendor;
|
|
|
+// [params setValue:uuid.UUIDString forKey:@"deviceid"];
|
|
|
+//#endif
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
+
|
|
|
+
|
|
|
+ if(appDelegate.ipad_perm!=nil)
|
|
|
+ [params setValue:appDelegate.ipad_perm forKey:@"ipad_perm"];
|
|
|
+
|
|
|
+ [params setValue:appDelegate.build forKey:@"app_ver"];
|
|
|
+
|
|
|
+ NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
|
|
|
+ NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
|
|
|
+ [params setValue:short_version forKey:@"app_short_ver"];
|
|
|
+
|
|
|
+ UIDevice * dev = [UIDevice currentDevice];
|
|
|
+ NSUUID* uuid =dev.identifierForVendor;
|
|
|
+#if TARGET_IPHONE_SIMULATOR//模拟器
|
|
|
+ [params setValue:@"simulator_uuid" forKey:@"idfv"];
|
|
|
+#elif TARGET_OS_IPHONE//真机
|
|
|
+ [params setValue:uuid.UUIDString forKey:@"idfv"];
|
|
|
+#endif
|
|
|
+
|
|
|
+//
|
|
|
+// NSString *userAction = [params valueForKey:kAction];
|
|
|
+// NSMutableDictionary *extra = [[params valueForKey:kExtra] mutableCopy];
|
|
|
+// if ([userAction isEqualToString:@"Login"]) {
|
|
|
+// if (!extra) {
|
|
|
+// extra = [NSMutableDictionary dictionary];
|
|
|
+// }
|
|
|
+// [extra setObject:[params objectForKey:@"user"] forKey:@"user"];
|
|
|
+// }
|
|
|
+
|
|
|
+ return params;
|
|
|
+}
|
|
|
++(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params file:(NSString *) file //delegate:(id < NSURLConnectionDelegate >)delegate
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // NSString* e=[AESCrypt AES128Encrypt:@"密码学中的高级加密标准(Advanced Encryption Standard,AES),又称 高级加密标准Rijndael加密法,是美国联邦政府采用的一种区块加密标准。这个标准用来替代原先的DES,已经被多方分析且广为全世界所使用。经过五年的甄选流程,高级加密标准由美国国家标准与技术研究院 (NIST)于2001年11月26日发布于FIPS PUB 197,并在2002年5月26日成为有效的标准。2006年,高级加密标准已然成为对称密钥加密中最流行的算法之一。 " key:@"usai2010"];
|
|
|
+ // DebugLog(e);
|
|
|
+ // NSString* d=[AESCrypt decrypt:@"VzB4+lENfbzWX7ggHh2Os1P69l5YBzKmM51yqA37AfoKgPY8bJgdK8M4WvF+wDyOsLWP\/o8H5+bHMivQp1u8wM2QV7SYzgzPwV85QKtYWIzEgLe9T0HO69EdutWz7k1rdAT\/mftsRin0Hy5SHk7txTZT\/zPH5X+FQiExCTFm5Zus39HYvp+VxCX4+kYeymn8B63AUd3mRQyscUvDjfgU2olKR\/TP8PV3g+VQMZxpKfol3P1iOtz3XQlHZV0pM6SAf+SwT0sPfrdn6CZFfNQlrKA9QjMrnBdMeSCquSIWXnmLv6okzvnlJnT0SjvJuUeqNdBC5EZ0ACnhI0MrXVZEsq1EuM9al7oPzvU5EZbjZpmx+fSFIkMzTT8bYClTnG1bsL1MCcU4pSODDorUj8zalA==" password:@"usai2010"];
|
|
|
+ params = [self prepare_addtional_params:params];
|
|
|
+
|
|
|
+ return [super get_json:url parameters:params file:(NSString*)file err_recorder:URL_ERR_LOG result_handler:^NSMutableDictionary *(NSMutableDictionary *jsobj) {
|
|
|
+ int result=[[jsobj valueForKey:@"result"] intValue];
|
|
|
+ // UIApplication * app = [UIApplication sharedApplication];
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
|
|
|
+
|
|
|
+ switch (result) {
|
|
|
+ case 0:
|
|
|
+ [jsobj setValue:MSG_USERAUTH_ERROR forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ [jsobj setValue:MSG_SUCCESS forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ case 99:
|
|
|
+ [jsobj setValue:MSG_TIMEOUT forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // if([appDelegate.build intValue]< [[jsobj valueForKey:@"min_ver"]intValue])
|
|
|
+ // {
|
|
|
+ // [jsobj setValue:@"9" forKey:@"result"];
|
|
|
+ // [jsobj setValue:MSG_VER_LOW forKey:@"err_msg"];
|
|
|
+ // }
|
|
|
+ return jsobj;
|
|
|
+ } decrypt_handler:^NSMutableDictionary *(NSMutableDictionary *jsobj) {
|
|
|
+
|
|
|
+ return nil;
|
|
|
+// NSString* base64str = jsobj[@"str"];
|
|
|
+// NSString* decryptstr=[AESCrypt AES128Decrypt:base64str key:@"usai2010"];
|
|
|
+// jsobj=[[RAUtils string2dict:decryptstr] mutableCopy];
|
|
|
+// return jsobj;
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
+ return nil;
|
|
|
+}
|
|
|
|
|
|
+(void) LoadImage:(NSString*) url into:(UIImageView*) container
|
|
|
{
|
|
|
@@ -141,6 +276,9 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
|
|
|
//}
|
|
|
+(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params //delegate:(id < NSURLConnectionDelegate >)delegate
|
|
|
{
|
|
|
+
|
|
|
+ return [self get_json:url parameters:params file:nil];
|
|
|
+
|
|
|
int retry = 0;
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|