|
@@ -1891,6 +1891,14 @@
|
|
|
self.indexPath=indexPath;
|
|
self.indexPath=indexPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ NSMutableDictionary * item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* productID = [item_json valueForKey:@"product_id"];
|
|
|
|
|
+ BOOL outOfStock = [[item_json valueForKey:@"is_out_of_stock"] boolValue];
|
|
|
|
|
+
|
|
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Delete " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Delete " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
|
|
|
|
|
|
DebugLog(@"delete click");
|
|
DebugLog(@"delete click");
|
|
@@ -1911,6 +1919,60 @@
|
|
|
|
|
|
|
|
deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
|
|
deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
|
|
|
|
|
|
|
|
|
|
+ UITableViewRowAction *notifyMeAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Notify Me" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waiting"];
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0,0), ^{
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary *dic = [iSalesNetwork notifyModel:productID emailAddr:nil];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+
|
|
|
|
|
+ [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
|
|
|
|
|
+
|
|
|
|
|
+ NSInteger result = [[dic valueForKey:@"result"] integerValue];
|
|
|
|
|
+
|
|
|
|
|
+ if (result != RESULT_TRUE && result != RESULT_NO_EMAIL_ADDRESS) {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *msg = [NSString stringWithFormat:@"The email send failed"];
|
|
|
|
|
+
|
|
|
|
|
+ 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 if (result == RESULT_TRUE){
|
|
|
|
|
+
|
|
|
|
|
+ [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
|
|
|
|
|
+
|
|
|
|
|
+ } else if (result == RESULT_NO_EMAIL_ADDRESS) {
|
|
|
|
|
+
|
|
|
|
|
+ [weakself showAddressBoxToEmailProduct:productID];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ notifyMeAction.backgroundColor = UIColorFromRGB(0x9BBF5A);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
UITableViewRowAction *addWatchAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Move To Wish List" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
UITableViewRowAction *addWatchAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Move To Wish List" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
|
|
|
|
|
@@ -1977,7 +2039,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加一个编辑按钮
|
|
// 添加一个编辑按钮
|
|
|
- __weak typeof(self) weakself = self;
|
|
|
|
|
UITableViewRowAction *editRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Edit Price"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
UITableViewRowAction *editRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Edit Price"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
|
|
|
|
|
|
DebugLog(@"edit click");
|
|
DebugLog(@"edit click");
|
|
@@ -2273,6 +2334,11 @@
|
|
|
int is_rate = [item_json[@"is_rate"] intValue];
|
|
int is_rate = [item_json[@"is_rate"] intValue];
|
|
|
|
|
|
|
|
NSMutableArray* arr=[@[] mutableCopy];
|
|
NSMutableArray* arr=[@[] mutableCopy];
|
|
|
|
|
+#ifdef BUILD_NPD
|
|
|
|
|
+ if (!appDelegate.offline_mode && outOfStock) {
|
|
|
|
|
+ [arr addObject:notifyMeAction];
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
if(product_id.length>0)
|
|
if(product_id.length>0)
|
|
|
[arr addObject:noteRowAction];
|
|
[arr addObject:noteRowAction];
|
|
@@ -2293,7 +2359,7 @@
|
|
|
return arr;
|
|
return arr;
|
|
|
// return @[deleteRowAction,addWatchAction, editRowAction,freeRowAction];
|
|
// return @[deleteRowAction,addWatchAction, editRowAction,freeRowAction];
|
|
|
} else if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
|
|
} else if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
|
|
|
- return @[deleteRowAction,addWatchAction,editRowAction];
|
|
|
|
|
|
|
+ return @[notifyMeAction,deleteRowAction,addWatchAction,editRowAction];
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
return @[deleteRowAction,addWatchAction];
|
|
return @[deleteRowAction,addWatchAction];
|
|
@@ -2864,5 +2930,82 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)showAddressBoxToEmailProduct:(NSString *)productID {
|
|
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+ JKMessageBoxController *emailAddrVC = [JKMessageBoxController messageBoxControllerWithTip:@"E-mail not setup, please enter your default e-mail address" ContentSize:CGSizeMake(400, 150)];
|
|
|
|
|
+ emailAddrVC.textFiled.secureTextEntry = NO;
|
|
|
|
|
+ emailAddrVC.yesButtonTitle = @"send";
|
|
|
|
|
+
|
|
|
|
|
+ __weak typeof(emailAddrVC) weakVC = emailAddrVC;
|
|
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
|
|
+
|
|
|
|
|
+ emailAddrVC.textHandler = ^(NSString *text){
|
|
|
|
|
+
|
|
|
|
|
+ // 验证邮箱格式是否正确
|
|
|
|
|
+ NSString *match = EMAIL_MATCHES;
|
|
|
|
|
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",match];
|
|
|
|
|
+ BOOL isEmailAddr = [predicate evaluateWithObject:text];
|
|
|
|
|
+ if (isEmailAddr) {
|
|
|
|
|
+
|
|
|
|
|
+ // 验证是邮件地址,发送邮件
|
|
|
|
|
+ [weakVC dismissViewControllerAnimated:YES completion:^{
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waiting"];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary *result = [iSalesNetwork notifyModel:productID emailAddr:text];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+
|
|
|
|
|
+ [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
|
|
|
|
|
+
|
|
|
|
|
+ int resultStatus = [[result objectForKey:@"result"] intValue];
|
|
|
|
|
+ if (resultStatus != RESULT_TRUE && resultStatus != RESULT_NO_EMAIL_ADDRESS) {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *msg = [NSString stringWithFormat:@"The email send failed"];
|
|
|
|
|
+ if (resultStatus == 8) {
|
|
|
|
|
+ if ([result valueForKey:@"err_msg"]) {
|
|
|
|
|
+ msg = [result 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 if(resultStatus == RESULT_TRUE){
|
|
|
|
|
+
|
|
|
|
|
+ [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
|
|
|
|
|
+
|
|
|
|
|
+ } else if (resultStatus == RESULT_NO_EMAIL_ADDRESS) {
|
|
|
|
|
+
|
|
|
|
|
+ [weakself showAddressBoxToEmailProduct:productID];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ // 非邮件地址,警告
|
|
|
|
|
+ [weakVC warning:@"Please enter right email address"];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ [self presentViewController:emailAddrVC animated:YES completion:nil];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@end
|
|
@end
|