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

实现Email Cart方法,修改Email Cart按钮调用,将请求置于子线程处理。

Pen Li 9 лет назад
Родитель
Сommit
21ef0cc372

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


+ 18 - 0
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2,4 +2,22 @@
 <Bucket
    type = "0"
    version = "2.0">
+   <Breakpoints>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/data_provider/iSalesNetwork.m"
+            timestampString = "502876660.806895"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "3935"
+            endingLineNumber = "3935"
+            landmarkName = "+quoteOrder:emailAddr:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+   </Breakpoints>
 </Bucket>

+ 30 - 12
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -2684,7 +2684,7 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 
 - (IBAction)emailButtonClick:(UIButton *)sender {
     
-//    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
 
     JKMessageBoxController *emailAddrVC = [JKMessageBoxController messageBoxControllerWithTip:@"Please enter email address"];
     emailAddrVC.textFiled.secureTextEntry = NO;
@@ -2704,18 +2704,36 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
             // 验证是邮件地址,发送邮件
             [weakVC dismissViewControllerAnimated:YES completion:^{
                 
-                NSDictionary *result = [iSalesNetwork quoteOrder:self.orderid emailAddr:text];
-                if ([[result objectForKey:@"result"] integerValue] != RESULT_TRUE) {
+                UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waitting"];
+                
+                dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                   
+                    NSDictionary *result = [iSalesNetwork quoteOrder:appDelegate.order_code emailAddr:text];
+                    DebugLog(@"email cart result: %@",result);
+                   dispatch_async(dispatch_get_main_queue(), ^{
+                      
+                       [waitting_alert dismissWithClickedButtonIndex:0 animated:YES];
+                       
+                       if ([[result objectForKey:@"result"] integerValue] != RESULT_TRUE) {
+                           
+                           UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"The email send to %@ failed",text] preferredStyle:UIAlertControllerStyleAlert];
+                           UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                               
+                           }];
+                           
+                           [errorAlertVC addAction:action];
+                           [weakself presentViewController:errorAlertVC animated:YES completion:nil];
+                           
+                       }else {
+                           
+                           
+                           
+                       }
+                       
+                   });
                     
-                    UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"The email send to %@ failed",text] preferredStyle:UIAlertControllerStyleAlert];
-                    UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-                        
-                    }];
-                    
-                    [errorAlertVC addAction:action];
-                    [weakself presentViewController:errorAlertVC animated:YES completion:nil];
-                    
-                }
+                });
+                
             }];
             
         } else {

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

@@ -3909,9 +3909,39 @@ repeat:
 
 + (NSDictionary *)quoteOrder:(NSString *)so_id emailAddr:(NSString *)addr {
     
-    NSDictionary *result = @{@"result":@(RESULT_FALSE)};
+    NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [dic setValue:appDelegate.user forKey:@"user"];
+    
+    if(appDelegate.password!=nil)
+        [dic setValue:appDelegate.password forKey:@"password"];
+    
+    [dic setValue:[NSNumber numberWithInteger:[so_id integerValue]] forKey:@"order_id"];
+    [dic setValue:addr forKey:@"email"];
+    
+    NSData* json=nil;
+    if(appDelegate.offline_mode)
+    {
+        return [OLDataProvider offline_notimpl];
+    }
+    else
+    {
+        if(![self IsNetworkAvailable])
+            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+        
+        json = [iSalesNetwork get_json:URL_EMAIL_CART parameters:dic];
+    }
+    if(json!=nil)
+    {
+        NSError *error=nil;
+        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+        
+        
+        return jsobj;
+    }
     
-    return result;
+    return @{@"result" : @(RESULT_FALSE)};
 }
 
 @end

+ 4 - 0
RedAnt ERP Mobile/iSales-NPD/config.h

@@ -159,6 +159,8 @@
 
 #define URL_REQUEST_LOGIN @"http://192.168.0.158:8080/site/isales/requestLogin.htm"
 
+#define URL_EMAIL_CART @"http://192.168.0.158:8080/site/isales/sendCartEmail.htm"
+
 #else
 
 
@@ -278,6 +280,8 @@
 
 #define URL_REQUEST_LOGIN @"https://www.newpacificdirect.com/isales/requestLogin.htm"
 
+#define URL_EMAIL_CART @"https://www.newpacificdirect.com/isales/sendCartEmail.htm"
+
 
 #endif