Explorar el Código

1.修改Apex Mobile,增加登出清除数据。
2.修改Apex Mobile Result Row Action实现。

Pen Li hace 8 años
padre
commit
fbe9ad7ad8
Se han modificado 21 ficheros con 227 adiciones y 10 borrados
  1. 105 2
      Apex Mobile/Apex Mobile/AMResultViewController.m
  2. 3 0
      Apex Mobile/Apex Mobile/AppDelegate.h
  3. 7 0
      Apex Mobile/Apex Mobile/AppDelegate.m
  4. 2 0
      Apex Mobile/Apex Mobile/ChangePasswordViewController.m
  5. 34 5
      Apex Mobile/Apex Mobile/DetailTabBarController.m
  6. 11 1
      Apex Mobile/Apex Mobile/HomeViewController.m
  7. 2 1
      Apex Mobile/Apex Mobile/Main.storyboard
  8. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_exit.imageset/ic_exit.png
  9. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_exit.imageset/ic_exit@2x.png
  10. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_exit.imageset/ic_exit@3x.png
  11. 23 0
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/Contents.json
  12. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/ic_save.png
  13. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/ic_save@2x.png
  14. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/ic_save@3x.png
  15. 23 0
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/Contents.json
  16. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/ic_setting.png
  17. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/ic_setting@2x.png
  18. BIN
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/ic_setting@3x.png
  19. 11 1
      Apex Mobile/Apex Mobile/OrderHistoryViewController.m
  20. 1 0
      Apex Mobile/Apex Mobile/RANetwork.h
  21. 5 0
      Apex Mobile/Apex Mobile/RANetwork.m

+ 105 - 2
Apex Mobile/Apex Mobile/AMResultViewController.m

@@ -11,6 +11,7 @@
 #import "RANetwork.h"
 #import "RAUtils.h"
 #import "DetailTabBarController.h"
+#import <QuickLook/QuickLook.h>
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored"-Wdeprecated-declarations"
@@ -231,15 +232,117 @@
     }
 }
 
+- (void)showQuickLookAtIndexPath:(NSIndexPath *)indexPath Action:(NSDictionary *)action {
+    
+    
+    NSMutableDictionary *params = [NSMutableDictionary new];
+    
+    NSMutableDictionary *criteria =[NSMutableDictionary new];
+    for(NSString* key in [action[@"params"] allKeys] )
+    {
+        NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
+        int idx =[action[@"params"][key] intValue];
+        criteria[key]=item[ idx];
+    }
+
+
+    params[@"criteria"]=[RAConvertor dict2string:criteria] ;
+    
+    NSString* URL =action[@"url"];
+    __weak typeof(self) weakSelf = self;
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+
+        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+        NSString *documents = [paths objectAtIndex:0];
+        NSString *path = [documents stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
+        
+        [RANetwork download_file:params url:URL toCachePath:path progressHandler:^(NSURLSessionTask *task, double progress) {
+            
+        } completionHandler:^(NSMutableDictionary *result) {
+            
+            weakSelf.documentPath = path;
+            
+            if (path) {
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
+                });
+            }
+            
+        }];
+        
+        
+    });
+    
+}
+
+- (void)handleRowAction:(NSIndexPath *)indexPath {
+    
+    if(self.content_action!=nil)
+    {
+        
+        if(self.content_action.count==1)
+        {
+            NSDictionary* action =self.content_action.firstObject;
+            NSString * module =  action[@"module"];
+            if([module isEqualToString:@"quick_look"])
+            {
+                [self showQuickLookAtIndexPath:indexPath Action:action];
+            }
+            else if([module isEqualToString:@"detail"])
+            {
+                [self showDetailForIndexPath:indexPath];
+            }
+        }
+        else
+        {
+            
+            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleAlert];
+            
+            __weak typeof(self) weakSelf = self;
+            for(int i=0;i<self.content_action.count;i++)
+            {
+                NSMutableDictionary* json = self.content_action[i];
+                NSString* title =json[@"title"];
+                NSString* module = json[@"module"];
+                UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                    
+                    
+                    if([module isEqualToString:@"quick_look"])
+                    {
+                        [weakSelf showQuickLookAtIndexPath:indexPath Action:json];
+                    }
+                    else if([module isEqualToString:@"order_detail"])
+                    {
+                        [weakSelf showDetailForIndexPath:indexPath];
+                    }
+                    
+                }];
+                [alertControl addAction:actioni];
+            }
+            
+            UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                
+            }];
+            [alertControl addAction:actionCancel];
+            
+            [self presentViewController:alertControl animated:NO completion:nil];
+            
+        }
+        
+    }
+}
+
 -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
 {
     UITableViewCell *cell = (UITableViewCell *)[gestureRecognizer view];
     NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
-    [self showDetailForIndexPath:indexPath];
+//    [self showDetailForIndexPath:indexPath];
+    [self handleRowAction:indexPath];
 }
 
 - (void)presses3DTouchForIndexPath:(NSIndexPath *)indexPath {
-    [self showDetailForIndexPath:indexPath];
+//    [self showDetailForIndexPath:indexPath];
+    [self handleRowAction:indexPath];
 }
 
 /*

+ 3 - 0
Apex Mobile/Apex Mobile/AppDelegate.h

@@ -8,6 +8,9 @@
 
 #import <UIKit/UIKit.h>
 #import <GoogleMaps/GoogleMaps.h>
+
+UIKIT_EXTERN NSString * const APLogoutNotification;
+
 @interface AppDelegate : UIResponder <UIApplicationDelegate>
 
 @property (strong, nonatomic) UIWindow *window;

+ 7 - 0
Apex Mobile/Apex Mobile/AppDelegate.m

@@ -11,6 +11,11 @@
 #import "ApexMobileDB.h"
 #import "RANetwork.h"
 #import "AESCrypt.h"
+
+
+NSString * const APLogoutNotification = @"LogoutNofitication";
+
+
 @implementation AppDelegate
 
 
@@ -171,6 +176,8 @@ void UncaughtExceptionHandler(NSException *exception) {
     [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
     [[UIApplication sharedApplication] cancelAllLocalNotifications ];
     //self.duid = nil;
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName:APLogoutNotification object:nil];
 }
 - (void)applicationWillResignActive:(UIApplication *)application
 {

+ 2 - 0
Apex Mobile/Apex Mobile/ChangePasswordViewController.m

@@ -7,6 +7,7 @@
 //
 
 #import "ChangePasswordViewController.h"
+#import "AESCrypt.h"
 
 @interface ChangePasswordViewController ()
 
@@ -87,6 +88,7 @@
             {
                  AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
                 appDelegate.password = newpass;
+                [[NSUserDefaults standardUserDefaults] setValue:[AESCrypt encrypt:newpass password:@"usai"] forKey:@"password"];
                 
                 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"alert_title_success", nil) message:NSLocalizedString(@"alert_msg_change_success", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
                 [alert show];

+ 34 - 5
Apex Mobile/Apex Mobile/DetailTabBarController.m

@@ -82,7 +82,7 @@
             [params setValue:self.actions[i] forKey:@"action_type"];
             [params setValue:self.function_name forKey:@"module_name"];
             [params setValue:[self.params valueForKey:@"id"] forKey:@"id"];
-            [params setValue:[self.params valueForKey:@"sessionid"] forKey:@"sessionid"];
+//            [params setValue:[self.params valueForKey:@"sessionid"] forKey:@"sessionid"];
             
             if([self.function_name isEqualToString:@"Cargo Tracking"])
             {
@@ -199,13 +199,21 @@
     [alert show];
 }
 
+- (void)closeClick:(id)sender {
+    [self.navigationController popToRootViewControllerAnimated:YES];
+}
+
 - (void)viewDidLoad
 {
     [super viewDidLoad];
-    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"save", nil) style:UIBarButtonItemStylePlain target:self action:@selector(saveDetail:)];
-//    saveButton.title = @"Save";
-    
-    self.navigationItem.rightBarButtonItem = saveButton;
+//    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"save", nil) style:UIBarButtonItemStylePlain target:self action:@selector(saveDetail:)];
+////    saveButton.title = @"Save";
+//
+////    self.navigationItem.rightBarButtonItem = saveButton;
+//
+//    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(closeClick:)];
+//
+//    self.navigationItem.rightBarButtonItems = @[saveButton,closeButton];
     
     // self.navigationController.view.frame.size.height;
     
@@ -221,6 +229,27 @@
     //    self.navigationItem.rightBarButtonItems=items;
 //    self.navigationItem.backBarButtonItem = backButton;
 
+    
+    UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    saveBtn.frame = CGRectMake(0, 0, 30, 30);
+    [saveBtn setImage:[UIImage imageNamed:@"ic_save"] forState:UIControlStateNormal];
+//    [saveBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -15)]; // 右移
+    [saveBtn addTarget:self action:@selector(saveDetail:) forControlEvents:UIControlEventTouchUpInside];
+    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithCustomView:saveBtn];
+
+    UIBarButtonItem *fixBtn = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:nil action:nil];
+    fixBtn.width = 0;
+    
+    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    closeBtn.frame = CGRectMake(0, 0, 30, 30);
+    [closeBtn setImage:[UIImage imageNamed:@"ic_exit"] forState:UIControlStateNormal];
+//    [closeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -15)]; // 右移,调整和屏幕大间距
+    [closeBtn addTarget:self action:@selector(closeClick:) forControlEvents:UIControlEventTouchUpInside];
+    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithCustomView:closeBtn];
+
+    
+    self.navigationItem.rightBarButtonItems = @[closeButton,fixBtn,saveButton];
+
 
 }
 

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

@@ -47,7 +47,8 @@
     
     [self configureTableView];
     self.shipSearchBar.delegate =self;
-    [self loadData];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logout) name:APLogoutNotification object:nil];
 }
 
 - (void)didReceiveMemoryWarning {
@@ -61,6 +62,10 @@
 
     [self clearNavigationbar];
     [self configureNavigationBar];
+    
+    if (self.shipArray.count == 0) {
+        [self loadData];
+    }
 }
 
 - (void)clearNavigationbar {
@@ -101,6 +106,11 @@
     self.refreshControl = refresh;
 }
 
+- (void)logout {
+    [self.shipArray removeAllObjects];
+    [self.shipTableView reloadData];
+}
+
 #pragma mark - Load Data
 
 - (NSMutableArray *)shipArray {

+ 2 - 1
Apex Mobile/Apex Mobile/Main.storyboard

@@ -824,7 +824,7 @@
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     </view>
                     <navigationItem key="navigationItem" title="Search" id="OwC-ot-lOg">
-                        <barButtonItem key="rightBarButtonItem" title="Items" id="cmN-H2-3ne">
+                        <barButtonItem key="rightBarButtonItem" image="ic_setting" id="cmN-H2-3ne">
                             <connections>
                                 <action selector="onCustomize:" destination="C3t-ED-9dx" id="2HU-8j-YCr"/>
                             </connections>
@@ -1646,6 +1646,7 @@
     <resources>
         <image name="apexlogo-2" width="129" height="32"/>
         <image name="ic_pdf128" width="64" height="64"/>
+        <image name="ic_setting" width="30" height="30"/>
         <image name="map (1)" width="32" height="32"/>
         <image name="rect_announcements" width="64" height="64"/>
         <image name="rect_market_news" width="48" height="48"/>

BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_exit.imageset/ic_exit.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_exit.imageset/ic_exit@2x.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_exit.imageset/ic_exit@3x.png


+ 23 - 0
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "ic_save.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_save@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_save@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/ic_save.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/ic_save@2x.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_save.imageset/ic_save@3x.png


+ 23 - 0
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "ic_setting.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_setting@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_setting@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/ic_setting.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/ic_setting@2x.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_setting.imageset/ic_setting@3x.png


+ 11 - 1
Apex Mobile/Apex Mobile/OrderHistoryViewController.m

@@ -48,7 +48,8 @@ static const int history_delta = 7;
     
     [self.loadIndicator stopAnimating];
     [self configureTableView];
-    [self loadData];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logout) name:APLogoutNotification object:nil];
 }
 
 - (void)didReceiveMemoryWarning {
@@ -62,6 +63,10 @@ static const int history_delta = 7;
     
     [self clearNavigationbar];
     [self configureNavigationBar];
+    
+    if (self.shipArray.count == 0) {
+        [self loadData];
+    }
 }
 
 - (void)clearNavigationbar {
@@ -102,6 +107,11 @@ static const int history_delta = 7;
     self.shipTableView.jl_footer = self.refreshFooter;
 }
 
+- (void)logout {
+    [self.shipArray removeAllObjects];
+    [self.shipTableView reloadData];
+}
+
 #pragma mark - Load Data
 
 - (NSMutableArray *)shipArray {

+ 1 - 0
Apex Mobile/Apex Mobile/RANetwork.h

@@ -40,4 +40,5 @@
 + (NSDictionary *)requestHome;
 + (NSDictionary *)search:(NSMutableDictionary *)params;
 + (NSDictionary *)requestOrderHistory:(NSMutableDictionary *)params;
++ (void)download_file:(NSDictionary *)params url:(NSString *)url toCachePath:(NSString *)path progressHandler:(progressHandler)progressHandler completionHandler:(resultHandler)result;
 @end

+ 5 - 0
Apex Mobile/Apex Mobile/RANetwork.m

@@ -1267,4 +1267,9 @@
     return resultDic;
 }
 
++ (void)download_file:(NSDictionary *)params url:(NSString *)url toCachePath:(NSString *)path progressHandler:(progressHandler)progressHandler completionHandler:(resultHandler)result {
+    
+    [NetworkUtils downloadFileOffset:0 Param:params from:url method:@"POST" toPath:path progressHandler:progressHandler completionHandler:result];
+}
+
 @end