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

Order List、Category 网络请求加入队列。
Category、Item Search、Search、Cart、Model Detail、Order Detail图片根据标识加载。
Category、Item Search、Search在Customer登陆时去掉Add To Portfolio按钮。
Model Detail中在Customer登陆时,点击Add To Portfolio按钮,弹出警告提示,无权操作。

Pen Li 9 лет назад
Родитель
Сommit
35e5b7ed9f
20 измененных файлов с 658 добавлено и 408 удалено
  1. BIN
      RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate
  2. 41 34
      RedAnt ERP Mobile/common/Functions/cart/CartViewController.m
  3. 1 0
      RedAnt ERP Mobile/common/Functions/cart/ModelItemCell.h
  4. 2 0
      RedAnt ERP Mobile/common/Functions/category/CategoryCellSmall.h
  5. 235 150
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m
  6. 1 1
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.h
  7. 7 0
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m
  8. 4 1
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailTopicCell.m
  9. 27 0
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m
  10. 1 1
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m
  11. 3 0
      RedAnt ERP Mobile/common/Functions/order/OrderDetailModelCell.h
  12. 33 29
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m
  13. 44 9
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m
  14. 127 90
      RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m
  15. 122 90
      RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m
  16. 2 2
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m
  17. 1 1
      RedAnt ERP Mobile/iSales-NPD/Base.lproj/Main.storyboard
  18. 3 0
      RedAnt ERP Mobile/iSales-NPD/CategoryCellNPD.h
  19. 2 0
      RedAnt ERP Mobile/iSales-NPD/NotificationNameCenter.h
  20. 2 0
      RedAnt ERP Mobile/iSales-NPD/NotificationNameCenter.m

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 41 - 34
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -553,17 +553,19 @@
         //    reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
         
         self.mum.center = self.view.center;
-        self.mum.hidden = false;
-        [self.mum startAnimating];
+        self.mum.hidden = YES;
+//        [self.mum startAnimating];
         NSLog(@"reloading...");
+        UIAlertView *loadingView = [RAUtils waiting_alert:@"Please Wait" title:@"Loading"];
+        
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             NSLog(@"BEGIN LOAD CART");
             NSDictionary* cart_json = [iSalesNetwork request_Cart:self.sortIndex];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 //
-                [self.mum stopAnimating];
-                
+//                [self.mum stopAnimating];
+                [loadingView dismissWithClickedButtonIndex:0 animated:YES];
                 
                 //            self.content_data = [cart_json mutableCopy];
                 self.freejson = [cart_json objectForKey:@"freeGiveaway"];
@@ -1561,43 +1563,48 @@
     
     
     [cell set_Count:count];
-    [cell.btnImage setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
-    NSString* file_name=[img_url lastPathComponent];
-    NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-    if(img_data!=nil)
-    {
-        
-        UIImage * img =[UIImage imageWithData:img_data];
-        [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
-    }
-    else
-    {
-        
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    
+    
+    if (![cell.imageName isEqualToString:img_url]) {
+        cell.imageName = img_url;
+        [cell.btnImage setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
+        NSString* file_name=[img_url lastPathComponent];
+        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+        if(img_data!=nil)
+        {
             
-            NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+            UIImage * img =[UIImage imageWithData:img_data];
+            [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
+        }
+        else
+        {
             
-            dispatch_async(dispatch_get_main_queue(), ^{
-                
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                 
+                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                 
-                if(downloadimg_data!=nil)
-                {
+                dispatch_async(dispatch_get_main_queue(), ^{
                     
-                    [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                     
-                    UIImage * img =[UIImage imageWithData:downloadimg_data];
-                    [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
-                }
-                else
-                {
-                    [cell.btnImage setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
-                }
-                
+                    
+                    if(downloadimg_data!=nil)
+                    {
+                        
+                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                        
+                        UIImage * img =[UIImage imageWithData:downloadimg_data];
+                        [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
+                    }
+                    else
+                    {
+                        [cell.btnImage setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
+                    }
+                    
+                });
             });
-        });
-        
-        
+            
+            
+        }
     }
     cell.backgroundColor = [UIColor whiteColor];
     

+ 1 - 0
RedAnt ERP Mobile/common/Functions/cart/ModelItemCell.h

@@ -62,6 +62,7 @@
 
 @property int totalchange;
 
+@property (nonatomic,copy) NSString *imageName;///<图片标识,若图片更改则标识更改,那么就重新加载图片
 
 -(void) cancel_setQTY;
 //@property (strong,nonatomic) NSString* last_edit;

+ 2 - 0
RedAnt ERP Mobile/common/Functions/category/CategoryCellSmall.h

@@ -14,4 +14,6 @@
 @property (strong, nonatomic) IBOutlet StrikethroughLabel *oldPrice;
 @property (strong, nonatomic) IBOutlet UILabel *Price;
 
+@property (nonatomic,copy) NSString *imageName;///<图片标识
+
 @end

+ 235 - 150
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -39,13 +39,22 @@
 #define  CELL_MARGIN 0
 #define  LABEL_MARGIN 5
 
+
 @interface CategoryViewController ()
 
 @property (nonatomic,assign) BOOL addAll;
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
 
 @end
 
 @implementation CategoryViewController
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
 -(void) logout
 {
     self.offset = 0;
@@ -918,8 +927,11 @@
     });
 }
 #pragma mark get data
--(void) loadMore
+-(void)operation_loadMore
 {
+    if (self.dataOperationQueue.operationCount > 1) {
+        return ;
+    }
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.loadall)
         {
@@ -943,6 +955,10 @@
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 [self.mum stopAnimating];
+                self.isrefreshing=false;
+                if (self.dataOperationQueue.operationCount > 1) {
+                    return ;
+                }
                 
                 NSDictionary* more_items=[category_more objectForKey:@"items"];
                 if([[category_more valueForKey:@"result"] intValue]==2)
@@ -983,90 +999,126 @@
                 {
                     [RAUtils message_alert:[category_more valueForKey:@"err_msg"] title:@"Loading Category" controller:self] ;
                 }
-                self.isrefreshing=false;
+//                self.isrefreshing=false;
                 
             });
         });
     });
 }
--(void) reload
-{
-    
-    dispatch_async(dispatch_get_main_queue(), ^{
-        if(self.isrefreshing)
-            return;
-        self.showalert=true;
-        self.isrefreshing=true;
-        
-        self.loadall = false;
-        //    UICollectionViewFlowLayout*  layout =(UICollectionViewFlowLayout*)self.collectionview.collectionViewLayout;
-        
-        
-        //    UICollectionViewFlowLayout *flowLayout =[self.collectionview collectionViewLayout];
-        
-        //    layout.scrollDirection= UICollectionViewScrollDirectionVertical;
-        UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-        
-        [reF endRefreshing];
-        
-        reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
-        //
-        //
-        
-        self.mum.hidden = false;
-        [self.mum startAnimating];
-        self.mum.center = self.view.center;
-        
-        self.label_net_err.hidden=true;
+
+- (void)loadMore {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
         
-        self.collectionview.hidden=true;
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_loadMore];
+        }
         
-        //        self.collectionview.userInteractionEnabled = false;
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+}
+
+- (void)operation_reload {
+    {
+        if (self.dataOperationQueue.operationCount > 1) {
+            return;
+        }
         
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        dispatch_async(dispatch_get_main_queue(), ^{
+            if(self.isrefreshing)
+                return;
+            self.showalert=true;
+            self.isrefreshing=true;
             
-            NSDictionary* category_data=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:0 limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip];
+            self.loadall = false;
+            //    UICollectionViewFlowLayout*  layout =(UICollectionViewFlowLayout*)self.collectionview.collectionViewLayout;
             
-            dispatch_async(dispatch_get_main_queue(), ^{
-                
-                [self.mum stopAnimating];
+            
+            //    UICollectionViewFlowLayout *flowLayout =[self.collectionview collectionViewLayout];
+            
+            //    layout.scrollDirection= UICollectionViewScrollDirectionVertical;
+            UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
+            
+            [reF endRefreshing];
+            
+            reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
+            //
+            //
+            
+            self.mum.hidden = false;
+            [self.mum startAnimating];
+            self.mum.center = self.view.center;
+            
+            self.label_net_err.hidden=true;
+            
+            self.collectionview.hidden=true;
+            
+            //        self.collectionview.userInteractionEnabled = false;
+            
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                 
+                NSDictionary* category_data=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:0 limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip];
                 
-                //                self.collectionview.userInteractionEnabled = true;
-                self.category_data = [category_data mutableCopy];
-                [self.collectionview reloadData];
-                if([[category_data valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    self.collectionview.hidden=false;
-                    NSDictionary * item_json = [self.category_data objectForKey:@"items"];
-                    self.offset =[[item_json valueForKey:@"count"] intValue];
+                dispatch_async(dispatch_get_main_queue(), ^{
                     
-                    int total = [[self.category_data valueForKey:@"item_total_count"]intValue];
+                    [self.mum stopAnimating];
+                    self.isrefreshing=false;
+                    if (self.dataOperationQueue.operationCount > 1) {
+                        return ;
+                    }
                     
-                    if(total<2)
-                        self.labelTotal.text = [NSString stringWithFormat:@"Total %d item",total];
+                    //                self.collectionview.userInteractionEnabled = true;
+                    self.category_data = [category_data mutableCopy];
+                    [self.collectionview reloadData];
+                    if([[category_data valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        self.collectionview.hidden=false;
+                        NSDictionary * item_json = [self.category_data objectForKey:@"items"];
+                        self.offset =[[item_json valueForKey:@"count"] intValue];
+                        
+                        int total = [[self.category_data valueForKey:@"item_total_count"]intValue];
+                        
+                        if(total<2)
+                            self.labelTotal.text = [NSString stringWithFormat:@"Total %d item",total];
+                        else
+                            self.labelTotal.text = [NSString stringWithFormat:@"Total %d items",total];
+                        
+                    }
+                    else if([[category_data valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
+                    {
+                        self.collectionview.hidden=true;
+                        self.label_net_err.hidden=false;
+                    }
                     else
-                        self.labelTotal.text = [NSString stringWithFormat:@"Total %d items",total];
+                    {
+                        [RAUtils message_alert:[category_data valueForKey:@"err_msg"]  title:@"Loading Category" controller:self] ;
+                    }
                     
-                }
-                else if([[category_data valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
-                {
-                    self.collectionview.hidden=true;
-                    self.label_net_err.hidden=false;
-                }
-                else
-                {
-                    [RAUtils message_alert:[category_data valueForKey:@"err_msg"]  title:@"Loading Category" controller:self] ;
-                }
-                self.isrefreshing=false;
-                
-                
-                
+                    
+                    
+                    
+                });
             });
+            
         });
+    }
+}
+-(void) reload
+{
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
         
-    });
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_reload];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
 }
 #pragma mark - CategoryMenuDelegate
 -(void)SelectCategory:(NSString *)category
@@ -1309,6 +1361,26 @@
 //    
 //    [appDelegate test_onDecodedDataResult:@"371252"];
 
+    // customer 隐藏add to portfolio
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    NSMutableArray *items = [self.selectToolbar.items mutableCopy];
+    if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        
+        if ([items containsObject:self.addPortfolioBtn]) {
+            
+            [items removeObject:self.addPortfolioBtn];
+            self.selectToolbar.items = items;
+        }
+        
+    } else {
+        
+        if (![items containsObject:self.addPortfolioBtn]) {
+            
+            [items insertObject:self.addPortfolioBtn atIndex:4];
+            self.selectToolbar.items = items;
+        }
+        
+    }
     
 }
 - (void)viewDidLoad
@@ -1559,50 +1631,55 @@
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
         
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_s"];
+        
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
         
         NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_s"];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                    {
                         
-                        //                    UIImage * img=[UIImage imageNamed:@"notfound_s"];
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_s"];
-                    }
-                    
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                        {
+                            
+                            //                    UIImage * img=[UIImage imageNamed:@"notfound_s"];
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_s"];
+                        }
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
 
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
@@ -1659,46 +1736,50 @@
         
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+        
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
         
         NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;
@@ -1756,46 +1837,50 @@
         
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+       
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
         
         NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;

+ 1 - 1
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.h

@@ -9,7 +9,7 @@
 #import <UIKit/UIKit.h>
 #import "PhotoStackView.h"
 #import "RTLabel.h"
-
+#import "NotificationNameCenter.h"
 
 @class DetailHeaderCell;
 @protocol DetailHeaderCellDelegate <NSObject>

+ 7 - 0
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -59,6 +59,13 @@
     //    int count=[self.quantity_text.text intValue];
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:No_Rights_Notification object:nil];
+        return;
+    }
+    
+    
     MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
     if(appDelegate.bLogin==false)
     {

+ 4 - 1
RedAnt ERP Mobile/common/Functions/modelDetail/DetailTopicCell.m

@@ -91,7 +91,9 @@
         cell.cellDescription.text = description;
 //        cell.oldPrice.text = old_price;
 //        cell.Price.text = price;
-    cell.cellImageView.image = [UIImage imageNamed:@"loading_s"];
+    if (![cell.imageName isEqualToString:img_url]) {
+        cell.imageName = img_url;
+        cell.cellImageView.image = [UIImage imageNamed:@"loading_s"];
         NSString* file_name=[img_url lastPathComponent];
         NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
         if(img_data!=nil)
@@ -127,6 +129,7 @@
             
             
         }
+    }
     
     
     cell.layer.borderColor = UIColorFromRGB(color).CGColor;

+ 27 - 0
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -211,6 +211,7 @@ self.isrefreshing=false;
     
     [super viewDidLoad];
     
+    [self registeObserver];
     self.refresh_type =  REFRESH_VIEW;
     
     UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
@@ -1687,4 +1688,30 @@ self.isrefreshing=false;
     
     
 }
+
+#pragma mark - Handle Notification
+
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (void)registeObserver {
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNoRightMsg:) name:No_Rights_Notification object:nil];
+}
+
+- (void)handleNoRightMsg:(NSNotification *)notification {
+    
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Warning" message:@"You have no rights to do that." preferredStyle:UIAlertControllerStyleAlert];
+                                          
+    UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        
+        [alertController dismissViewControllerAnimated:YES completion:nil];
+        
+    }];
+    
+    [alertController addAction:action];
+    
+    [self presentViewController:alertController animated:YES completion:nil];
+}
+
 @end

+ 1 - 1
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -10590,7 +10590,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     NSString *user = ((AppDelegate *)[UIApplication sharedApplication].delegate).user;
     user = [self translateSingleQuote:user];
     
-    NSString *insert_order_sql = [NSString stringWithFormat:@"insert into offline_order (so_id,status,submit_as,internal_notes,sales_rep,create_by,total_price,logist,lift_gate,logistic_note,customer_cid,customer_contact,customer_email,customer_phone,customer_fax,receive_cid,receive_name,receive_ext,receive_contact,receive_phone,receive_fax,receive_email,sender_cid,sender_name,sender_ext,sender_contact,sender_phone,sender_fax,sender_email,shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_phone,shipping_billto_fax,shipping_billto_email,billing_cid,billing_name,billing_ext,billing_contact,billing_phone,billing_fax,billing_email,returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_phone,returnto_fax,returnto_email,must_call,poNumber,comments,comments_ext) select '%@',1,submit_as,internal_notes,sales_rep,'%@',total_price,logist,lift_gate,logistic_note,customer_cid,customer_contact,customer_email,customer_phone,customer_fax,receive_cid,receive_name,receive_ext,receive_contact,receive_phone,receive_fax,receive_email,sender_cid,sender_name,sender_ext,sender_contact,sender_phone,sender_fax,sender_email,shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_phone,shipping_billto_fax,shipping_billto_email,billing_cid,billing_name,billing_ext,billing_contact,billing_phone,billing_fax,billing_email,returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_phone,returnto_fax,returnto_email,must_call,poNumber,comments,comments_ext from offline_order where so_id = '%@';",new_order_code,user,order_code]; // ,paymentsAndCredits,shipping,lift_gate_value,handling_fee_value
+    NSString *insert_order_sql = [NSString stringWithFormat:@"insert into offline_order (so_id,status,submit_as,internal_notes,sales_rep,create_by,logist,lift_gate,logistic_note,customer_cid,customer_contact,customer_email,customer_phone,customer_fax,receive_cid,receive_name,receive_ext,receive_contact,receive_phone,receive_fax,receive_email,sender_cid,sender_name,sender_ext,sender_contact,sender_phone,sender_fax,sender_email,shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_phone,shipping_billto_fax,shipping_billto_email,billing_cid,billing_name,billing_ext,billing_contact,billing_phone,billing_fax,billing_email,returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_phone,returnto_fax,returnto_email,must_call,poNumber,comments,comments_ext) select '%@',1,submit_as,internal_notes,sales_rep,'%@',logist,lift_gate,logistic_note,customer_cid,customer_contact,customer_email,customer_phone,customer_fax,receive_cid,receive_name,receive_ext,receive_contact,receive_phone,receive_fax,receive_email,sender_cid,sender_name,sender_ext,sender_contact,sender_phone,sender_fax,sender_email,shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_phone,shipping_billto_fax,shipping_billto_email,billing_cid,billing_name,billing_ext,billing_contact,billing_phone,billing_fax,billing_email,returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_phone,returnto_fax,returnto_email,must_call,poNumber,comments,comments_ext from offline_order where so_id = '%@';",new_order_code,user,order_code]; // ,paymentsAndCredits,shipping,lift_gate_value,handling_fee_value
     
     __block int result = 1;
     result = [iSalesDB execSql:insert_order_sql db:db];

+ 3 - 0
RedAnt ERP Mobile/common/Functions/order/OrderDetailModelCell.h

@@ -21,4 +21,7 @@
 @property (strong, nonatomic) IBOutlet StrikethroughLabel *labelOldPrice;
 @property (strong, nonatomic) IBOutlet UILabel *labelDiscount;
 @property (strong, nonatomic) NSDictionary* bundle_item;
+
+@property (nonatomic,copy) NSString *imageName;///<图片标识
+
 @end

+ 33 - 29
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -1531,44 +1531,48 @@
                 }
             }
             
-            [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
-            
-            NSString* file_name=[img_url lastPathComponent];
-            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-            if(img_data!=nil)
-            {
-                
-                UIImage * img =[UIImage imageWithData:img_data];
-                [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
-            }
-            else
-            {
+            if (![cell.imageName isEqualToString:img_url]) {
+                cell.imageName = img_url;
+                [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
                 
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSString* file_name=[img_url lastPathComponent];
+                NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+                if(img_data!=nil)
+                {
                     
-                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                    UIImage * img =[UIImage imageWithData:img_data];
+                    [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
+                }
+                else
+                {
                     
-                    dispatch_async(dispatch_get_main_queue(), ^{
-                        
+                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                         
+                        NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                         
-                        if(downloadimg_data!=nil)
-                        {
+                        dispatch_async(dispatch_get_main_queue(), ^{
                             
-                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                             
-                            UIImage * img =[UIImage imageWithData:downloadimg_data];
-                            [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
-                        }
-                        else
-                            [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
-                        
-                        
+                            
+                            if(downloadimg_data!=nil)
+                            {
+                                
+                                [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                                
+                                UIImage * img =[UIImage imageWithData:downloadimg_data];
+                                [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
+                            }
+                            else
+                                [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
+                            
+                            
+                        });
                     });
-                });
-                
-                
+                    
+                    
+                }
             }
+            
             cell.backgroundColor = [UIColor whiteColor];
             return cell;
             

+ 44 - 9
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -20,8 +20,10 @@
 #import "NotificationNameCenter.h"
 #import "Singleton.h"
 
+
 @interface OrderListViewController ()
 
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
 
 @property (nonatomic,strong) NSMutableArray *mergeList;
 
@@ -31,6 +33,14 @@
 
 @implementation OrderListViewController
 
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
+
 - (void)dealloc {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
@@ -344,11 +354,15 @@
     //   [self loadpage];
     
 }
--(void) loadpage
-{
 
-    dispatch_async(self.loading_queue, ^{
-        
+- (void)operation_loadPage {
+    NSLog(@"count %li",self.dataOperationQueue.operationCount);
+    if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
+        return;
+    }
+    
+//    dispatch_async(self.loading_queue, ^{
+    
         dispatch_sync(dispatch_get_main_queue(), ^{
             if(self.reset_result)
             {
@@ -391,8 +405,8 @@
             self.label_net_err.hidden=true;
             
         });
-    });
-    dispatch_async(self.loading_queue, ^{
+//    });
+//    dispatch_async(self.loading_queue, ^{
         if(self.isrefreshing)
             return;
         self.isrefreshing=true;
@@ -427,6 +441,9 @@
         
         NSMutableDictionary* content=nil;
         content=[[iSalesNetwork request_OrderList:self.offset limit : self.limit keywords:self.keywords status:str_status customer:self.customer_id] mutableCopy];
+        NSLog(@"operation count %lu",self.dataOperationQueue.operationCount);
+    
+        
         dispatch_sync(dispatch_get_main_queue(), ^{
             
             
@@ -434,7 +451,10 @@
             
             
             [self.mum stopAnimating];
-            
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
+                return ;
+            }
             int result=[[content valueForKey:@"result"] intValue];
             
             if(result==2||result==0)
@@ -484,7 +504,7 @@
                 [RAUtils message_alert:[content valueForKey:@"err_msg"]  title:@"Loading Order List" controller:self] ;
             }
             
-            self.isrefreshing=false;
+            
             
             
             
@@ -503,7 +523,22 @@
         });
         
         
-    });
+//    });
+}
+-(void) loadpage
+{
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_loadPage];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+    
 }
 
 - (void)loadmore

+ 127 - 90
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -447,7 +447,31 @@
 }
 - (void)viewWillAppear:(BOOL)animated
 {
+    [super viewWillAppear:animated];
     [[self navigationController] setNavigationBarHidden:YES animated:NO];
+    
+    // customer 隐藏add to portfolio
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    NSMutableArray *items = [self.selectToolbar.items mutableCopy];
+    if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        
+        if ([items containsObject:self.addPortfolioBtn]) {
+            
+            [items removeObject:self.addPortfolioBtn];
+            self.selectToolbar.items = items;
+        }
+        
+    } else {
+        
+        if (![items containsObject:self.addPortfolioBtn]) {
+            
+            [items insertObject:self.addPortfolioBtn atIndex:4];
+            self.selectToolbar.items = items;
+        }
+        
+    }
+
+    
 }
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
@@ -1458,47 +1482,54 @@
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
-        cell.cellImageView.image=[UIImage imageNamed:@"loading_s"];
-        NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image=[UIImage imageNamed:@"loading_s"];
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    
-                    else
-                    {
-                        UIImage * img =[UIImage imageNamed:@"notfound_s"];
-                        cell.cellImageView.image = img;
-                    }
-                    
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        
+                        else
+                        {
+                            UIImage * img =[UIImage imageNamed:@"notfound_s"];
+                            cell.cellImageView.image = img;
+                        }
+                        
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
+
         }
+        
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;
         //cell.layer.cornerRadius=15;
@@ -1552,44 +1583,47 @@
         
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=modelid;
-        cell.cellImageView.image=[UIImage imageNamed:@"loading_l"];
+        
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
-        
-        NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image=[UIImage imageNamed:@"loading_l"];
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    cell.cellImageView.image=[UIImage imageNamed:@"notfound_l"];
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        cell.cellImageView.image=[UIImage imageNamed:@"notfound_l"];
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;
@@ -1648,46 +1682,49 @@
         
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+        
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
-        
-        NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;

+ 122 - 90
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -527,6 +527,29 @@
 {
     [super viewWillAppear:animated];
     [[self navigationController] setNavigationBarHidden:YES animated:NO];
+    
+    // customer 隐藏add to portfolio
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    NSMutableArray *items = [self.selectToolbar.items mutableCopy];
+    if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
+        
+        if ([items containsObject:self.addPortfolioBtn]) {
+            
+            [items removeObject:self.addPortfolioBtn];
+            self.selectToolbar.items = items;
+        }
+        
+    } else {
+        
+        if (![items containsObject:self.addPortfolioBtn]) {
+            
+            [items insertObject:self.addPortfolioBtn atIndex:4];
+            self.selectToolbar.items = items;
+        }
+        
+    }
+
+    
 }
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
@@ -1468,50 +1491,53 @@
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
         
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_s"];
+        
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
-        
-        NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_s"];
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                    {
                         
-                        //                    UIImage * img=[UIImage imageNamed:@"notfound_s"];
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_s"];
-                    }
-                    
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                        {
+                            
+                            //                    UIImage * img=[UIImage imageNamed:@"notfound_s"];
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_s"];
+                        }
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;
@@ -1569,46 +1595,49 @@
         
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+        
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
-        
-        NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;
@@ -1666,46 +1695,49 @@
         
         cell.nameLabel.text = description;
         cell.modelNoLabel.text=name;
-        cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+        
         
         //    cell.cellDescription.text = description;
         //    cell.oldPrice.text = old_price;
         //    cell.Price.text = price;
-        
-        NSString* file_name=[img_url lastPathComponent];
-        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
-        if(img_data!=nil)
-        {
-            
-            UIImage * img =[UIImage imageWithData:img_data];
-            cell.cellImageView.image = img;
-        }
-        else
-        {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (![cell.imageName isEqualToString:img_url]) {
+            cell.imageName = img_url;
+            cell.cellImageView.image = [UIImage imageNamed:@"loading_l"];
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
+            if(img_data!=nil)
+            {
                 
-                NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.cellImageView.image = img;
+            }
+            else
+            {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    if(downloadimg_data!=nil)
-                    {
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
                         
-                        UIImage * img =[UIImage imageWithData:downloadimg_data];
-                        cell.cellImageView.image = img;
-                    }
-                    else
-                        cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
-                    
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            
+                            [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+                            
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.cellImageView.image = img;
+                        }
+                        else
+                            cell.cellImageView.image = [UIImage imageNamed:@"notfound_l"];
+                        
+                    });
                 });
-            });
-            
-            
+                
+                
+            }
         }
         cell.layer.borderColor = UIColorFromRGB(color).CGColor;
         cell.layer.borderWidth = 0.5;

+ 2 - 2
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -222,12 +222,12 @@ repeat:
         
         
         DebugLog(@"url: %@",url);
-        
+
         DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
         
         if (responseData==nil) {
             
-            DebugLog(@"response error:%@", [error localizedDescription]);
+//            DebugLog(@"response error:%@", [error localizedDescription]);
             
             
             NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];

+ 1 - 1
RedAnt ERP Mobile/iSales-NPD/Base.lproj/Main.storyboard

@@ -7864,7 +7864,7 @@ Email: redantsupport@united-us.net</string>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="HwF-54-hzr">
-                                                    <frame key="frameInset" minX="15" width="698" height="43.5"/>
+                                                    <frame key="frameInset" minX="28" width="672" height="43.5"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>

+ 3 - 0
RedAnt ERP Mobile/iSales-NPD/CategoryCellNPD.h

@@ -17,4 +17,7 @@
 @property (strong, nonatomic) IBOutlet UIImageView *mark_closeout;
 
 @property (strong, nonatomic) IBOutlet UIImageView *mark_wish;
+
+@property (nonatomic,copy) NSString *imageName;///<识别图片是否更改
+
 @end

+ 2 - 0
RedAnt ERP Mobile/iSales-NPD/NotificationNameCenter.h

@@ -14,4 +14,6 @@ UIKIT_EXTERN  NSString  *LoginOK_HandleUrgencyFile_Notification;///<登陆成功
 
 UIKIT_EXTERN  NSString  *Change_Price_Type_Notification;///<切换价格通知
 
+UIKIT_EXTERN  NSString  *No_Rights_Notification;///<无权
+
 @end

+ 2 - 0
RedAnt ERP Mobile/iSales-NPD/NotificationNameCenter.m

@@ -14,4 +14,6 @@ const NSString  *LoginOK_HandleUrgencyFile_Notification = @"LoginOK_HandleUrgenc
 
 const NSString  *Change_Price_Type_Notification = @"Change_Price_Type_Notification";
 
+const NSString  *No_Rights_Notification = @"No_Rights_Notification";
+
 @end