cdts/xdts-ios 3/TreeHole/Code/Features/Chat/ViewController/C2CChatViewController.m

61 lines
2.1 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// C2CChatViewController.m
// TreeHole
//
// Created by on 2022/5/7.
//
#import "C2CChatViewController.h"
#import "TZImagePickerController+MTImagePicker.h"
2023-08-18 14:05:39 +08:00
#import "PYHTTPManager.h"
2023-07-27 09:20:00 +08:00
2023-08-18 14:05:39 +08:00
@interface C2CChatViewController ()<TInputControllerDelegate>
2023-07-27 09:20:00 +08:00
@end
@implementation C2CChatViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)selectPhotoForSendV2 {
TZImagePickerController *imagePicker = [TZImagePickerController mt_imagePickerWithMaxImagesCount:9 didFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
for (UIImage *photo in photos) {
NSData *data = UIImageJPEGRepresentation(photo, 0.75);
NSString *path = [TUIKit_Image_Path stringByAppendingString:[TUITool genImageName:nil]];
[[NSFileManager defaultManager] createFileAtPath:path contents:data attributes:nil];
V2TIMMessage *message = [[V2TIMManager sharedInstance] createImageMessage:path];
[self sendMessage:message];
// if ([self.inputController.delegate respondsToSelector:@selector(inputController:didSendMessage:)]) {
// [self.inputController.delegate inputController:self.inputController didSendMessage:message];
// }
usleep(1);
}
}];
[self.navigationController presentViewController:imagePicker animated:YES completion:nil];
}
2023-08-18 14:05:39 +08:00
- (void)inputController:(TUIInputController *)inputController didSendMessage:(V2TIMMessage *)msg {
[PYHTTPManager getWithPath:@"friend" params:@{
@"uid":[self.conversationData.userID componentsSeparatedByString:@"_"].lastObject,
} callback:^(id _Nullable rsp, NSError * _Nullable error) {
NSLog(@"%@",rsp);
if (error == nil) {
[self.messageController sendMessage:msg];
} else {
NSString *codeStr = [NSString stringWithFormat:@"%@",error.userInfo[@"code"]];
if (codeStr.intValue == 10) {
[PYAppService showVipVC:@"vip_page"];
}
}
}];
}
2023-07-27 09:20:00 +08:00
@end