61 lines
2.1 KiB
Objective-C
61 lines
2.1 KiB
Objective-C
//
|
|
// C2CChatViewController.m
|
|
// TreeHole
|
|
//
|
|
// Created by 谢培艺 on 2022/5/7.
|
|
//
|
|
|
|
#import "C2CChatViewController.h"
|
|
#import "TZImagePickerController+MTImagePicker.h"
|
|
#import "PYHTTPManager.h"
|
|
|
|
@interface C2CChatViewController ()<TInputControllerDelegate>
|
|
|
|
@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];
|
|
}
|
|
|
|
- (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"];
|
|
}
|
|
}
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
@end
|