|
|
@@ -56,12 +56,12 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
|
|
|
|
|
|
+(NSMutableDictionary*) prepare_addtional_params:(NSMutableDictionary* ) params
|
|
|
{
|
|
|
- __block AppDelegate *appDelegate = nil;
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
|
- dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
//some UI methods ej
|
|
|
appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
- });
|
|
|
+
|
|
|
// if(appDelegate.user!=nil)
|
|
|
// [params setValue:[AESCrypt AES128Encrypt:appDelegate.user key:@"usai"] forKey:@"user"];
|
|
|
// if(appDelegate.password!=nil)
|
|
|
@@ -4972,4 +4972,179 @@ repeat:
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark 2020 new interface
|
|
|
+// 新接口逐步替换以前的网络请求,2020
|
|
|
+
|
|
|
++(void)request_home:(int) price_template customid:(int) customid completionHandler:(resultHandler)result
|
|
|
+{
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
+
|
|
|
+
|
|
|
+ //some UI methods ej
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+
|
|
|
+
|
|
|
+ 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:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
+
|
|
|
+ [params setObject:ScreenCodeHomeView forKey:kScreenName];
|
|
|
+
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_home] mutableCopy];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ result(json);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [self request_interface:URL_LOAD_HOME parameters:params err_record_url:nil completionHandler:result retry:0];
|
|
|
+
|
|
|
+ return;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
++(void)request_category:(resultHandler)result
|
|
|
+{
|
|
|
+ // DebugLog(@"@@@@@@@@@@@@@@@@@@@LOADING CATEGORY MENU");
|
|
|
+
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
+
|
|
|
+
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_category_menu] mutableCopy];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ result(json);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+ [self request_interface:URL_REQUEST_CATMENU parameters:[NSMutableDictionary new] err_record_url:nil completionHandler:result retry:0];
|
|
|
+
|
|
|
+//
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
+// {
|
|
|
+// DebugLog(@"NET ERR");
|
|
|
+//
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
+// // return nil;
|
|
|
+// }
|
|
|
+//
|
|
|
+// NSData* json=[self get_json:URL_REQUEST_CATMENU parameters:nil];
|
|
|
+// //if(json==nil)
|
|
|
+//
|
|
|
+//
|
|
|
+// if(json==nil)
|
|
|
+// return nil;
|
|
|
+// NSError *error=nil;
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
+// return jsobj;
|
|
|
+}
|
|
|
++(void)request_categorylist: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip completionHandler:(resultHandler)result
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
+
|
|
|
+
|
|
|
+ //some UI methods ej
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+ 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"];
|
|
|
+ if(appDelegate.order_code!=nil)
|
|
|
+ [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
+
|
|
|
+ [params setValue:alert forKey:@"alert"];
|
|
|
+ [params setValue:qty forKey:@"sold_by_qty"];
|
|
|
+ [params setValue:available forKey:@"available"];
|
|
|
+ [params setValue:price forKey:@"price"];
|
|
|
+ [params setValue:bestseller forKey:@"bestseller"];
|
|
|
+ [params setValue:modelname forKey:@"modelName"];
|
|
|
+ [params setValue:modeldescrip forKey:@"modelDescription"];
|
|
|
+
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
+ [params setValue:category forKey:@"category"];
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
+ [params setValue:filter forKey:@"filter"];
|
|
|
+ [params setValue:keyword forKey:@"keyword"];
|
|
|
+
|
|
|
+ [params setObject:ScreenCodeCategory forKey:kScreenName];
|
|
|
+ if (alert) {
|
|
|
+ [params setObject:@"Filter" forKey:kAction];
|
|
|
+ }
|
|
|
+ if ([Singleton sharedInstance].homeItemClick) {
|
|
|
+ [params setObject:@"Brow A Particular Category On Home" forKey:kAction];
|
|
|
+ [Singleton sharedInstance].homeItemClick = NO;
|
|
|
+
|
|
|
+ NSDictionary *extra = @{@"CoverName" : [Singleton sharedInstance].homeClickedItemName};
|
|
|
+ [Singleton sharedInstance].homeClickedItemName = nil;
|
|
|
+ [params setObject:extra forKey:kExtra];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_category:params] mutableCopy];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ result(json);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+ [self request_interface:URL_CATEGORY parameters:params err_record_url:nil completionHandler:result retry:0];
|
|
|
+
|
|
|
+ return ;
|
|
|
+
|
|
|
+
|
|
|
+//
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
+//
|
|
|
+// NSData* json=[self get_json:URL_CATEGORY parameters:params];
|
|
|
+// if(json==nil)
|
|
|
+// return nil;
|
|
|
+// NSError *error=nil;
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
+// return jsobj;
|
|
|
+//
|
|
|
+}
|
|
|
@end
|