Ver Fonte

修改Notify Me按钮不可点击时使之变灰。

Pen Li há 9 anos atrás
pai
commit
5d8a5be569

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


+ 69 - 67
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -967,74 +967,76 @@ self.isrefreshing=false;
         if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
             cell.btnaddPortfolio.hidden = YES;
             
-            cell.btnNotifyMe.hidden = YES;
-            CGRect wishListFrame = cell.btnaddWish.frame;
-            CGRect cartFrame = cell.btnaddCart.frame;
-            cartFrame.origin.x = wishListFrame.origin.x;
-            cell.btnaddCart.frame = cartFrame;
+//            cell.btnNotifyMe.hidden = YES;
+//            CGRect wishListFrame = cell.btnaddWish.frame;
+//            CGRect cartFrame = cell.btnaddCart.frame;
+//            cartFrame.origin.x = wishListFrame.origin.x;
+//            cell.btnaddCart.frame = cartFrame;
+            
+            __weak typeof(self) weakself = self;
+            cell.notifyMeBlock = ^{
+                
+                NSString *emailAddr = [appDelegate.customerInfo valueForKey:@"customer_email"];
+                
+                if (!emailAddr.length) {
+                    
+                    [self showEmailAddrBox];
+                    
+                } else {
+                    
+                    UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waitting"];
+                    dispatch_async(dispatch_get_global_queue(0,0), ^{
+                       
+                        NSDictionary *dic = [iSalesNetwork notifyModel:self.product_id emailAddr:nil];
+                            
+                        dispatch_async(dispatch_get_main_queue(), ^{
+                            
+                            [waitting_alert dismissWithClickedButtonIndex:0 animated:YES];
+                            
+                            if ([[dic valueForKey:@"result"] integerValue] != RESULT_TRUE) {
+                                
+                                NSString *msg = [NSString stringWithFormat:@"The email send to %@ failed",emailAddr];
+                                if ([[dic valueForKey:@"result"] integerValue] == 8) {
+                                    if ([dic valueForKey:@"err_msg"]) {
+                                        msg = [dic valueForKey:@"err_msg"];
+                                    }
+                                }
+                                
+                                UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                                UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                                    
+                                }];
+                                
+                                [errorAlertVC addAction:action];
+                                [weakself presentViewController:errorAlertVC animated:YES completion:nil];
+                            
+                            } else {
+                                
+                            }
+                        });
+                        
+                        
+                    });
+                    
+                }
+                
+            };
+            
+            cell.btnNotifyMe.layer.borderColor = [UIColor blackColor].CGColor;
+            cell.btnNotifyMe.layer.borderWidth = 1.0f;
+            cell.btnNotifyMe.layer.cornerRadius = 3.0f;
+            cell.btnNotifyMe.layer.masksToBounds = YES;
+            NSString *qtyStr = [section_json valueForKey:@"Availability"];
+            if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) {
+                cell.btnaddCart.enabled = NO;
+                cell.btnNotifyMe.alpha = 1.0;
+                cell.btnNotifyMe.enabled = YES;
+            } else {
+                cell.btnNotifyMe.enabled = NO;
+                cell.btnNotifyMe.alpha = 0.4;
+                cell.btnaddCart.enabled = YES;
+            }
             
-//            __weak typeof(self) weakself = self;
-//            cell.notifyMeBlock = ^{
-//                
-//                NSString *emailAddr = [appDelegate.customerInfo valueForKey:@"customer_email"];
-//                
-//                if (!emailAddr.length) {
-//                    
-//                    [self showEmailAddrBox];
-//                    
-//                } else {
-//                    
-//                    UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waitting"];
-//                    dispatch_async(dispatch_get_global_queue(0,0), ^{
-//                       
-//                        NSDictionary *dic = [iSalesNetwork notifyModel:self.product_id emailAddr:nil];
-//                            
-//                        dispatch_async(dispatch_get_main_queue(), ^{
-//                            
-//                            [waitting_alert dismissWithClickedButtonIndex:0 animated:YES];
-//                            
-//                            if ([[dic valueForKey:@"result"] integerValue] != RESULT_TRUE) {
-//                                
-//                                NSString *msg = [NSString stringWithFormat:@"The email send to %@ failed",emailAddr];
-//                                if ([[dic valueForKey:@"result"] integerValue] == 8) {
-//                                    if ([dic valueForKey:@"err_msg"]) {
-//                                        msg = [dic valueForKey:@"err_msg"];
-//                                    }
-//                                }
-//                                
-//                                UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
-//                                UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-//                                    
-//                                }];
-//                                
-//                                [errorAlertVC addAction:action];
-//                                [weakself presentViewController:errorAlertVC animated:YES completion:nil];
-//                            
-//                            } else {
-//                                
-//                            }
-//                        });
-//                        
-//                        
-//                    });
-//                    
-//                }
-//                
-//            };
-//            
-//            cell.btnNotifyMe.layer.borderColor = [UIColor blackColor].CGColor;
-//            cell.btnNotifyMe.layer.borderWidth = 1.0f;
-//            cell.btnNotifyMe.layer.cornerRadius = 3.0f;
-//            cell.btnNotifyMe.layer.masksToBounds = YES;
-//            NSString *qtyStr = [section_json valueForKey:@"Availability"];
-//            if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) {
-//                cell.btnaddCart.enabled = NO;
-//                cell.btnNotifyMe.enabled = YES;
-//            } else {
-//                cell.btnNotifyMe.enabled = NO;
-//                cell.btnaddCart.enabled = YES;
-//            }
-//            
         } else {
             cell.btnNotifyMe.hidden = YES;
         }