Просмотр исходного кода

完成了Apex Mobile 登陆接口和对应调用的修改;
Apex Mobile增加新的首页网络请求接口,替换旧接口;
Apex Mobile增加新的kpi网络请求接口,替换旧接口;
Apex Mobile增加新的detail网络请求接口,未完成。

!!! 此为中间版本,无法正常运行 !!!

Ray Zhang 6 лет назад
Родитель
Сommit
d56b7c2796

+ 98 - 1
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -415,7 +415,48 @@ typedef enum {
     
     [self showProgressDialog];
     
-    __weak typeof(self) weakSelf = self;
+     __weak typeof(self) weakSelf = self;
+    [RANetwork request_home:^(NSMutableDictionary *result) {
+       NSDictionary *json =result ;
+        
+                    
+                    if (self.refreshControl.isRefreshing) {
+                        [self.refreshControl endRefreshing];
+                    }
+                    
+                    [weakSelf.ShipLoading stopAnimating];
+                    
+                    int result_code = [[json objectForKey:@"result"] intValue];
+                    
+                    [weakSelf dismissProgressDialog:^{
+                        
+                        if (result_code == RESULT_TRUE) {
+                            
+                            [self.shipArray removeAllObjects];
+                            [self.shipArray addObjectsFromArray:[json objectForKey:@"container_list"]];
+                            self.iconSelectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+                            [self showMapAnnotaionWithIndexPath:self.iconSelectedIndexPath];
+                            [self.shipTableView reloadData];
+                            
+        //                    [self checkDatabase];
+                            
+                        } else {
+                            NSString *msg = [json objectForKey:@"err_msg"];
+                            [RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
+                        }
+                        
+                        self.ShipNoDataBtn.hidden = self.shipArray.count > 0;
+                        if (self.shipArray.count) {
+                            [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
+                        }
+                        weakSelf.recentRefresh = NO;
+                        
+                    }];// dismiss
+
+                
+    }];
+    return;
+
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
         NSDictionary *json = [RANetwork requestHome];
@@ -473,6 +514,62 @@ typedef enum {
     [self showProgressDialog];
     
     __weak typeof(self) weakSelf = self;
+    
+    [RANetwork request_kpi:^(NSMutableDictionary *result) {
+        
+        NSDictionary *json = result;
+        if (weakSelf.KPIRefresh.isRefreshing) {
+            [weakSelf.KPIRefresh endRefreshing];
+        }
+        
+        [weakSelf.KPILoading stopAnimating];
+        
+        int result_code = [[json objectForKey:@"result"] intValue];
+
+        [weakSelf dismissProgressDialog:^{
+            
+            if (result_code == RESULT_TRUE) {
+                //                self.currentKPI = 1;
+                weakSelf.monthArray = [json objectForKey:@"month"];
+                
+                [weakSelf.KPIArray removeAllObjects];
+                NSArray *kpiArr = [json objectForKey:@"KPI"];
+                
+                //                [self.KPIArray addObject:[[kpiArr firstObject] mutableCopy]];
+                for (int i = 0; i < kpiArr.count; i++) {
+                    NSMutableDictionary *kpiModel = [[kpiArr objectAtIndex:i] mutableCopy];
+                    NSMutableArray *itemMutArr = [NSMutableArray array];
+                    NSArray *itemArr = [kpiModel objectForKey:@"arr_val"];
+                    for (int j = 0; j < itemArr.count; j++) {
+                        NSMutableDictionary *item = [[itemArr objectAtIndex:j] mutableCopy];
+                        [itemMutArr addObject:item];
+                    }
+                    [kpiModel setObject:itemMutArr forKey:@"arr_val"];
+                    
+                    //                    [self.KPIArray addObjectsFromArray:kpiArr];
+                    [weakSelf.KPIArray addObject:kpiModel];
+                }
+                //                [self.KPIArray addObject:[[kpiArr lastObject] mutableCopy]];
+                
+                
+                [weakSelf.KPITableView reloadData];
+                
+                if (((UITabBarController *)weakSelf.parentViewController).selectedIndex == 0) {
+                    NSString *str = [NSString stringWithFormat:@"%ld / %ld",self.currentKPI,self.KPIArray.count];
+                    weakSelf.parentViewController.title = str;
+                }
+                
+            } else {
+                NSString *msg = [json objectForKey:@"err_msg"];
+                [RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
+            }
+            weakSelf.KPINoDataBtn.hidden = self.KPIArray.count > 0;
+            weakSelf.kpiRefresh = NO;
+        }];
+        
+    }];
+    
+    return;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
         
         NSDictionary *json = [RANetwork requestKPI];

+ 74 - 0
Apex Mobile/Apex Mobile/LoginViewController.m

@@ -73,6 +73,80 @@
     NSString *request_user = self.editUser.text.lowercaseString;
     NSString *request_password = self.editPassword.text;
     
+    [RANetwork request_login:request_user password:request_password completionHandler:^(NSMutableDictionary *result) {
+        int ret=[result[@"result"] intValue];
+        
+        
+        
+                    self.mum.hidden=true;
+                    self.loginButton.enabled = true;
+                    
+                    if (ret==RESULT_TRUE)
+                    {
+                        
+                        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+                        [defaults removeObjectForKey:@"user"];
+                        [defaults removeObjectForKey:@"password"];
+                        //                if(self.checkSavePassword.selected)
+                        {
+                            
+                            
+                            [defaults setValue:[AESCrypt encrypt:self.editUser.text.lowercaseString password:@"usai"] forKey:@"user"];
+                            [defaults setValue:[AESCrypt encrypt:self.editPassword.text password:@"usai"] forKey:@"password"];
+                            [defaults setBool:TRUE forKey:@"autologin"];
+                        }
+                        [defaults synchronize];
+                        
+                        if(self.loginSuccessful)
+                            self.loginSuccessful();
+        //                [self dismissViewControllerAnimated:true completion:^{
+        //                    ;
+        //                }];
+                        
+                        //                [self performSegueWithIdentifier:@"LOGIN" sender:self];
+                        
+                        
+                    }
+                    else
+                    {
+                        //                int a = RESULT_NET_NOTAVAILABLE;
+                        NSString* message = nil;
+                        switch (ret) {
+                            case RESULT_NET_NOTAVAILABLE:
+                                message = NSLocalizedString(@"net_not_available", nil);
+                                break;
+                            case RESULT_NET_ERROR:
+                                message = NSLocalizedString(@"net_error", nil);
+                                break;
+                            case RESULT_FALSE:
+                                message = NSLocalizedString(@"auth_error", nil);
+                                break;
+                            case RESULT_VER_LOW:
+                                message = NSLocalizedString(@"ver_low", nil);
+                                break;
+                                
+                            default:
+                                message=[NSString stringWithFormat:@"Failed to login code %d",ret];
+                                break;
+                        }
+                        
+                        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
+                        UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                            
+                        }];
+                        
+                        [alertVC addAction:action];
+                        
+                        [self presentViewController:alertVC animated:YES completion:nil];
+                    }
+                    
+                    
+                    
+                
+    }];
+    
+    return;
+    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         

+ 6 - 3
Apex Mobile/Apex Mobile/RANetwork.h

@@ -53,7 +53,10 @@
 
 
 // 新接口逐步替换以前的网络请求,2020
-+(void)request_marketnews : (NSString*) lastid limit: (int) limit completionHandler:(resultHandler)result;
-+(void)request_announcements : (NSString*) lastid limit: (int) limit completionHandler:(resultHandler)result;
-+(void) request_servicelocatin:(resultHandler)result;
++ (void)request_marketnews : (NSString*) lastid limit: (int) limit completionHandler:(resultHandler)result;
++ (void)request_announcements : (NSString*) lastid limit: (int) limit completionHandler:(resultHandler)result;
++ (void) request_servicelocatin:(resultHandler)result;
++ (void)request_login : (NSString*) user password:(NSString*) password completionHandler:(resultHandler)result;
++ (void)request_home:(resultHandler)result;
++ (void)request_kpi:(resultHandler)result;
 @end

+ 475 - 8
Apex Mobile/Apex Mobile/RANetwork.m

@@ -1822,12 +1822,11 @@
     __block long ver = 0;
     NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
     
-    dispatch_async(dispatch_get_main_queue(), ^{
+
         AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
         ver = appDelegate.authVer;
         if(appDelegate.duid !=nil)
             [params setValue:appDelegate.duid forKey:@"udid"];
-    });
     
     [params setValue:@"handset_login" forKey:@"action"];
     //    [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
@@ -1840,15 +1839,483 @@
 #else
     [params setValue:@"false" forKey:@"is_debug"];
 #endif
-    NSData* json=[self get_json:URL_UPDATE_AUTH parameters:params  file:nil];
-    if(json==nil)
-        return ;
     
-    int ret = [self parse_authinfo:json user:user password:password];
-    DebugLog(@"parse_authinfo return %d ",ret);
     
+    [self request_interface:URL_UPDATE_AUTH parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *chresult) {
+       int ret = [self parse_logininfo:chresult user:user password:password] ;
+        
+        NSMutableDictionary * retjson = [NSMutableDictionary new];
+        
+        retjson[@"result"]= [NSNumber numberWithInt:ret];
+        
+        result(retjson);
+        
+        
+    } retry:0];
     
-    return ;
+//     [self request_interface:URL_UPDATE_AUTH parameters:params err_record_url:nil completionHandler:result retry:0];
+//
+//    NSData* json=[self get_json:URL_UPDATE_AUTH parameters:params  file:nil];
+//    if(json==nil)
+//        return ;
+//
+//    int ret = [self parse_authinfo:json user:user password:password];
+//    DebugLog(@"parse_authinfo return %d ",ret);
+//
+//
+//    return ;
+    
+}
+
+
++(int)parse_logininfo : (NSDictionary *) jsobj user:(NSString*) user password:(NSString*) password
+{
+    DebugLog(@"parse_authinfo");
+//    NSError *error=nil;
+    
+    sqlite3 *db =[ApexMobileDB get_db];
+    
+    
+    
+    
+//    NSDictionary *jsobj = //[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+    if(jsobj)
+    {
+        
+        UIApplication * app = [UIApplication sharedApplication];
+        AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+        int result = [[jsobj valueForKey:@"result"] intValue];
+        if(result!=AP_USER_AUTH)
+        {
+            DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
+            [appDelegate Logout];
+            return RESULT_FALSE;
+            
+        }
+        NSDictionary* objheader = [jsobj objectForKey:@"header"];
+        
+        NSString* required_ver=[objheader objectForKey:@"client_ver"] ;
+        DebugLog(@"required_ver=%@ ",required_ver);
+        NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
+        NSString* versionNum =[infoDict valueForKey:@"CFBundleVersion"];
+        versionNum = [NSString stringWithFormat:@"A%@",versionNum];
+        int ibadge = [[objheader valueForKey:@"badge"] intValue];
+        
+        //        if([ibadge isEqual:[NSNull null]])
+        //            strbadge=@"0";
+        //        if(ibadge==nil)
+        //            ibadge=@"0";
+        //        if([strbadge isEqualToString:@"null"])
+        //            strbadge=@"0";
+        app.applicationIconBadgeNumber = ibadge;//[strbadge intValue];
+        
+        BOOL bigger = [versionNum compare:required_ver] ;
+        if(!bigger)
+            return RESULT_VER_LOW;
+//        appDelegate.sessionid = [objheader valueForKey:@"sessionid"];
+        appDelegate.user = user;
+        appDelegate.password = password;
+//        DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
+        if ([[objheader valueForKey:@"update"] boolValue]==false)
+        {
+            // no update on the server;
+            return RESULT_TRUE;
+        }
+        int Auth_InfoVer = [[objheader valueForKey:@"ver"] intValue];
+//        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+//        [defaults removeObjectForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
+//        [defaults setInteger:Auth_InfoVer forKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
+        
+        [ApexMobileDB execSql:@"delete from auth_ver;" db:db];
+        [ApexMobileDB execSql:[NSString stringWithFormat:@"insert into auth_ver (ver) values (%d);",Auth_InfoVer] db:db];
+        
+        //        [defaults synchronize];
+        
+        NSDictionary* objfuncs = [jsobj objectForKey:@"functions"];
+        NSArray* keys= [objfuncs allKeys];
+        
+        
+        
+        [ApexMobileDB execSql: [NSString stringWithFormat: @"update fields_info set abandon = 1 where user ='%@'",user] db:db];
+        [ApexMobileDB execSql: [NSString stringWithFormat: @"update actions_info set abandon = 1 where user ='%@'",user] db:db];
+        char* sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
+        char* sql1 = "insert into actions_info(name,function_name,user,priority) values(?,?,?,?)";
+        
+        sqlite3_stmt *stmt;
+        sqlite3_stmt *stmt1;
+        sqlite3_prepare_v2(db, sql, -1, &stmt, nil);
+        sqlite3_prepare_v2(db, sql1, -1, &stmt1, nil);
+        
+        // db.beginTransaction();
+        for(int i=0;i<keys.count;i++)
+        {
+            NSString* func_name = keys[i];
+            NSDictionary *objfun = [objfuncs objectForKey:func_name];
+            int behavior, priority = 999;
+            int show =1;
+            NSDictionary *objbehavior = [objfun objectForKey:@"search"];
+            NSArray* keysbehavior= [objbehavior allKeys];
+            behavior = BEHAVIOR_SEARCH;
+            for(int j=0;j<keysbehavior.count;j++)
+            {
+                NSString* field = keysbehavior[j];
+                NSDictionary* field_info = [objbehavior objectForKey:field];
+                NSString* field_name =[field_info valueForKey:@"name"] ;
+                NSString* field_type = [field_info valueForKey:@"type"] ;
+                NSString* alias_name = [field_info valueForKey:@"alias"] ;
+                priority = [[field_info valueForKey:@"priority"] intValue];
+                if(priority==999)
+                    show=0;
+                else
+                    show=1;
+                int id = [ApexMobileDB get_recordid:db table:@"fields_info" where:[NSString stringWithFormat:@"name='%@' and behavior=%d and function_name='%@' and user='%@'",field_name,behavior,func_name,user]];
+                if(id>=0)
+                    [ApexMobileDB execSql:[NSString stringWithFormat:@"update fields_info set abandon = 0 where _id=%d",id] db:db];
+                else
+                {
+                    
+                    sqlite3_bind_text(stmt, 1, [field_name UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt, 2, [alias_name UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt, 3, [field_type UTF8String], -1, NULL);
+                    
+                    sqlite3_bind_text(stmt, 4, [func_name UTF8String], -1, NULL);
+                    
+                    sqlite3_bind_int(stmt, 5, behavior);
+                    sqlite3_bind_int(stmt, 6, priority);
+                    sqlite3_bind_int(stmt, 7, show);
+                    sqlite3_bind_text(stmt, 8, [user UTF8String], -1, NULL);
+                    
+                    
+                    if (sqlite3_step(stmt) != SQLITE_DONE)
+                    {
+                        fprintf(stderr, "Error: insert search failed, error infomation: %s\n", sqlite3_errmsg(db));
+                    }
+                    sqlite3_reset(stmt);
+                    
+                }
+                
+                
+            }
+            
+            objbehavior = [objfun objectForKey:@"result"];
+            NSArray* keysresult= [objbehavior allKeys];
+            behavior = BEHAVIOR_RESULT;
+            for(int j=0;j<keysresult.count;j++)
+            {
+                NSString* field = keysresult[j];
+                NSDictionary* field_info = [objbehavior objectForKey:field];
+                NSString* field_name =[field_info valueForKey:@"name"] ;
+                NSString* field_type = [field_info valueForKey:@"type"] ;
+                NSString* alias_name = [field_info valueForKey:@"alias"] ;
+                priority = [[field_info valueForKey:@"priority"] intValue];
+                if(priority==999)
+                    show=0;
+                else
+                    show=1;
+                int id = [ApexMobileDB get_recordid:db table:@"fields_info" where:[NSString stringWithFormat:@"name='%@' and behavior=%d and function_name='%@' and user='%@'",field_name,behavior,func_name,user]];
+                if(id>=0)
+                    [ApexMobileDB execSql:[NSString stringWithFormat:@"update fields_info set abandon = 0 where _id=%d",id] db:db];
+                else
+                {
+                    sqlite3_bind_text(stmt, 1, [field_name UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt, 2, [alias_name UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt, 3, [field_type UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt, 4, [func_name UTF8String], -1, NULL);
+                    sqlite3_bind_int(stmt, 5, behavior);
+                    sqlite3_bind_int(stmt, 6, priority);
+                    sqlite3_bind_int(stmt, 7, show);
+                    sqlite3_bind_text(stmt, 8, [user UTF8String], -1, NULL);
+                    
+                    if (sqlite3_step(stmt) != SQLITE_DONE)
+                    {
+                        fprintf(stderr, "Error: insert result failed, error infomation: %s\n", sqlite3_errmsg(db));
+                    }
+                    sqlite3_reset(stmt);
+                    
+                }
+            }
+            objbehavior = [objfun objectForKey:@"actions"];
+            NSArray* keysactions= [objbehavior allKeys];
+            behavior = BEHAVIOR_SEARCH;
+            for(int j=0;j<keysactions.count;j++)
+            {
+                NSString* actionname = keysactions[j];
+                int action_priority = [[objbehavior valueForKey:actionname] intValue];
+                int id = [ApexMobileDB get_recordid:db table:@"actions_info" where:[NSString stringWithFormat:@"name='%@' and function_name='%@' and user='%@'",actionname,func_name,user]];
+                if(id>=0)
+                    [ApexMobileDB execSql:[NSString stringWithFormat:@"update actions_info set abandon = 0 , priority=%d where _id=%d",action_priority,id] db:db];
+                else
+                {
+                    
+                    sqlite3_bind_text(stmt1, 1, [actionname UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt1, 2, [func_name UTF8String], -1, NULL);
+                    sqlite3_bind_text(stmt1, 3, [user UTF8String], -1, NULL);
+                    sqlite3_bind_int(stmt1, 4, action_priority);
+                    
+                    if (sqlite3_step(stmt1) != SQLITE_DONE)
+                    {
+                        fprintf(stderr, "Error: insert action_info failed, error infomation: %s\n", sqlite3_errmsg(db));
+                    }
+                    sqlite3_reset(stmt1);
+                }
+            }
+        }
+        [ApexMobileDB execSql:@"delete from fields_info where abandon = 1" db:db];
+        [ApexMobileDB execSql:@"delete from actions_info where abandon = 1" db:db];
+        
+        sqlite3_finalize(stmt);
+        sqlite3_finalize(stmt1);
+        sqlite3_close(db);
+        
+        [ApexMobileDB deleteResultFields];
+        [ApexMobileDB updateResultDisplayFields];
+        /*
+         
+         db.setTransactionSuccessful();
+         db.endTransaction();
+         */
+        return RESULT_TRUE;
+        
+    }
+    //    NSDictionary *weatherInfo = [jsobj objectForKey:@"weatherinfo"];
+    //    txtView.text = [NSString stringWithFormat:@"今天是 %@  %@  %@  的天气状况是:%@  %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
+    //      DebugLog(@"weatherInfo字典里面的内容为--》%@", weatherDic );
+    
+    
+    
+    return RESULT_USERAUTH_ERROR;
+}
+
++ (void)request_home:(resultHandler)result
+{
+    
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    
+//    action=hand_new_home_list
+    [params setObject:@"hand_new_home_list" forKey:@"action"];
+    [params setObject:@(YES) forKey:@"request_location"];
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.personalmode)
+        params[@"personal_mode"] = @"true";
+    else
+        params[@"personal_mode"] = @"false";
+    
+    
+    [self request_interface:URL_HOME parameters:params err_record_url:nil completionHandler:result retry:0];
+    
+//    NSData* json=[self get_json:URL_HOME parameters:params  file:nil];
+//
+//    if (json==nil)
+//    {
+//        return @{
+//                 @"result" : @RESULT_NET_ERROR,
+//                 @"err_msg" : MSG_NET_ERROR
+//                 };
+//    }
+//
+//    NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil];
+//
+//    return resultDic;
+    
+}
++ (void)request_kpi:(resultHandler)result
+{
+    
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    
+    [params setObject:@"hand_new_kpi" forKey:@"action"];
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.personalmode)
+        params[@"personal_mode"] = @"true";
+    else
+        params[@"personal_mode"] = @"false";
+    
+    
+    [self request_interface:URL_KPI parameters:params err_record_url:nil completionHandler:result retry:0];
+//
+//    NSData* json=[self get_json:URL_KPI parameters:params  file:nil];
+//
+//    if (json==nil)
+//    {
+//        return @{
+//                 @"result" : @RESULT_NET_ERROR,
+//                 @"err_msg" : MSG_NET_ERROR
+//                 };
+//    }
+//
+//    NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil];
+//
+//    return resultDic;
+//
+}
+
+
++(void) request_detail: (NSMutableDictionary *) params completionHandler:(resultHandler)result
+{
+    DebugLog(@"get_detailcontent");
+    DetailContent * detailContent = [[DetailContent alloc] init];
+    NSMutableArray* segments = [[NSMutableArray alloc] init];
+    detailContent.segments = segments;
+    if(![NetworkUtils IsNetworkAvailable])
+    {
+        detailContent.result_code = RESULT_NET_NOTAVAILABLE;
+//        return detailContent;
+        return;
+    }
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+        [params setValue:@"handset_search" forKey:@"action"];
+//    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
+    
+    
+    [self request_interface:URL_REQUEST_RECORDS parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *chresult) {
+       NSString *str = [RAConvertor dict2string: chresult];
+       
+
+       
+       str=[str stringByReplacingOccurrencesOfString:@"<table " withString:@"<table style=font-size:12px "];
+       
+       
+           DebugLog(@"hack string: %@",str);
+       //------- hack-----------
+       NSDictionary *retjson=[RAConvertor string2dict:str];
+        
+        result([retjson mutableCopy]);
+        
+        
+    } retry:0];
+    return;
+    
+    NSData* json=[self get_json:URL_REQUEST_RECORDS parameters:params file:nil];
+    if (json==nil)
+    {
+        DebugLog(@"json is wrong");
+        detailContent.result_code = RESULT_NET_ERROR;
+        //return detailContent;
+        return;
+    }
+    
+    
+    //------------hack detail html 字体大小-----------
+    NSString *str = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
+    
+
+    
+    str=[str stringByReplacingOccurrencesOfString:@"<table " withString:@"<table style=font-size:12px "];
+    
+    
+        DebugLog(@"hack string: %@",str);
+    //------- hack-----------
+    NSDictionary *jsobj=[RAConvertor string2dict:str];
+    
+    
+    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//
+//
+    if(jsobj)
+    {
+        int result = [[jsobj valueForKey:@"result"] intValue];
+        if(result== AP_SESSION_EXPIRED)
+        {
+            [self Authorize:appDelegate.user password:appDelegate.password];
+            json=[self get_json:URL_REQUEST_RECORDS parameters:params  file:nil];
+            if (json==nil)
+            {
+                DebugLog(@"json is wrong");
+                detailContent.result_code = RESULT_NET_ERROR;
+//                return detailContent;
+                return;
+            }
+            jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+            result = [[jsobj valueForKey:@"result"] intValue];
+            
+        }
+        if(result!=AP_USER_AUTH)
+        {
+            DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
+            detailContent.result_code = result;
+//            return detailContent;
+            return;
+            
+        }
+        
+        
+//        if([params[@"action_type"] isEqualToString:@"Tracking"])
+//        {
+//            NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_tracking.json" ofType:nil];
+//            NSData *data = [[NSData alloc] initWithContentsOfFile:path];
+//            NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
+//            jsobj = json;
+//        }
+        
+        int count =[[jsobj valueForKey:@"count"] intValue];
+        
+//        if ([[params objectForKey:@"action_type"] isEqualToString:@"Detail"]) {
+//            NSMutableDictionary *mJson = [jsobj mutableCopy];
+//            NSDictionary *comm = @{
+//                                   @"_name": @"Communication",
+//                                   @"_type": @"communication",
+//                                   @"cc": @"",
+//                                   @"receipt": @"",
+//                                   @"count": @2,
+//                                   @"item0": @{
+//                                           @"Sender": @"user name",
+//                                           @"msg": @"content bla bla bla...",
+//                                           @"mst_time": @"04/28/2018 20:15:33",
+//                                           @"email_url": @"https://www.baidu.com"
+//                                           },
+//                                   @"item1": @{
+//                                           @"Sender": @"user name",
+//                                           @"msg": @"content bla bla bla...",
+//                                           @"mst_time": @"04/28/2018 20:15:33"
+//                                           }
+//                                   };
+//            [mJson setObject:comm forKey:[NSString stringWithFormat:@"group%d",count]];
+//
+//            [mJson setObject:@(++count) forKey:@"count"];
+//
+//            jsobj = mJson;
+//        }
+        
+        detailContent.result_code = RESULT_TRUE;
+        if(count==0)
+        {
+            
+//            return detailContent;
+            return;
+        }
+        
+        for(int i=0;i<count;i++)
+        {
+            
+            NSDictionary* segment = [jsobj objectForKey:[NSString stringWithFormat:@"group%d",i]];
+            [segments addObject:segment];
+            
+            /*
+             JSONObject groupobj = jsonObj.getJSONObject("group" + i);
+             View v = inflater.inflate(R.layout.group_tag, null);
+             v.setOnClickListener(this);
+             
+             TextView tvgroup = (TextView) v.findViewById(R.id.tv_group);
+             String group_name = groupobj.getString("_name");
+             tvgroup.setText(group_name);
+             v.setId(commonUtil.generateViewId());
+             ll_root.addView(v);
+             String grouptype = groupobj.getString("_type");
+             
+             */
+        }
+        
+        //   NSDictionary* objrecords = [jsobj objectForKey:@"records"];
+        
+        detailContent.originContent = jsobj;
+        
+//        return detailContent;
+        return;
+        
+    }
+//    return nil;
     
 }
 @end