|
@@ -1677,6 +1677,81 @@
|
|
|
|
|
|
|
|
- (void)commEditCell:(AMCommEditCell *)cell clickToSendEmail:(NSString *)email {
|
|
- (void)commEditCell:(AMCommEditCell *)cell clickToSendEmail:(NSString *)email {
|
|
|
|
|
|
|
|
|
|
+ // 检查Email内容是否为空
|
|
|
|
|
+ if (!email || email.length == 0) {
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"The communication message that will be sent is blank" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+ [alert addAction:okAction];
|
|
|
|
|
+ [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSIndexPath *indexPath = [self.table indexPathForCell:cell];
|
|
|
|
|
+ NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
|
|
|
|
|
+ NSString *cc = [segment objectForKey:@"cc"];
|
|
|
|
|
+ if (cc && cc.length > 0) {
|
|
|
|
|
+
|
|
|
|
|
+ // 校验邮箱地址格式是否有效
|
|
|
|
|
+ NSArray *ccArr = [cc componentsSeparatedByString:@";"];
|
|
|
|
|
+ for (NSString *ccStr in ccArr) {
|
|
|
|
|
+ if (ccStr.length > 0) {
|
|
|
|
|
+ BOOL isEmail = [self validateEmail:ccStr];
|
|
|
|
|
+ if (!isEmail) {
|
|
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"The communication cc is not right" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+ [alert addAction:okAction];
|
|
|
|
|
+ [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验通过
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"send email" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+ [self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+ NSDictionary *sendResponse = [RANetwork sendEmail:email CC:cc];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+
|
|
|
|
|
+ [alert dismissViewControllerAnimated:YES completion:^{
|
|
|
|
|
+
|
|
|
|
|
+ if (weakSelf) {
|
|
|
|
|
+ __strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
|
|
+ int result = [[sendResponse objectForKey:@"result"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ if (result == RESULT_TRUE) {
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ NSString *msg = [sendResponse objectForKey:@"err_msg"];
|
|
|
|
|
+ if (msg == nil) {
|
|
|
|
|
+ msg = @"Sorry,something wrong";
|
|
|
|
|
+ }
|
|
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+ [alert addAction:okAction];
|
|
|
|
|
+ [strongSelf presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)commEditCell:(AMCommEditCell *)cell didChangeEmail:(NSString *)email {
|
|
- (void)commEditCell:(AMCommEditCell *)cell didChangeEmail:(NSString *)email {
|
|
@@ -1715,4 +1790,15 @@
|
|
|
self.editingIndexPath = nil;
|
|
self.editingIndexPath = nil;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#pragma mark - Utils
|
|
|
|
|
+
|
|
|
|
|
+- (BOOL)validateEmail:(NSString *)email {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *emailRegex =@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
|
|
|
|
|
+
|
|
|
|
|
+ NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
|
|
|
|
|
+
|
|
|
|
|
+ return [emailTest evaluateWithObject:email];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|