123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640 |
- //
- // YOUPAILCReportVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/9/10.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCReportVC.h"
- #import "YOUPAILCReportModel.h"
- #import "YOUPAILZTextView.h"
- #import "UIViewController+TFPresent.h"
- #import "YOUPAILCIMSessionVC.h"
- #import "YOUPAILZReportCell.h"
- #import "LZAlertWindow.h"
- #import "YOUPAIBrowserPhotoCell.h"
- #import "TZImagePickerController.h"
- #import "UIView+NTES.h"
- #import "TZImageManager.h"
- @interface YOUPAILCReportVC ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,TZImagePickerControllerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
- @property(nonatomic,strong)UITableView* tableView;
- //@property(nonatomic,strong)NSIndexPath *lastPath;
- @property(nonatomic,strong)NSArray* reportArray;
- @property(nonatomic,strong)UIButton* uploadBtn;
- @property(nonatomic,strong)YOUPAILZTextView *liveTextView;
- @property (nonatomic, strong)YOUPAILCReportModel *currentModel;
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) NSMutableArray *selectedPhotos;
- @property (nonatomic, strong) NSMutableArray *selectedAssets;
- @property (nonatomic, strong) UIImagePickerController *imagePickerVc;
- @property(nonatomic,strong)NSString *youpaipimageUrl;//上传后返回的图片数组
- @end
- @implementation YOUPAILCReportVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"举报";
- self.selectedPhotos = [NSMutableArray new];
- self.selectedAssets = [NSMutableArray new];
- [self youpaifsetupView];
- [self youpaifinitData];
- }
- - (void)youpaifinitData{
- [LCHttpHelper requestWithURLString:ReportInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- self.reportArray = [YOUPAILCReportModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
- [self.tableView reloadData];
- }
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)youpaifsetupView{
- self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight) style:(UITableViewStylePlain)];
- self.tableView.showsVerticalScrollIndicator = NO;
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.backgroundColor = [UIColor whiteColor];
- self.tableView.rowHeight = 54.0f;
- self.tableView.delegate = self;
- self.tableView.dataSource= self;
- if (@available(iOS 15.0, *)) {
- self.tableView.sectionHeaderTopPadding = 0;
- }
- [self.view addSubview:self.tableView];
-
- UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, 54.0f)];
- self.tableView.tableHeaderView = headerView;
-
- UILabel *headerL = [[UILabel alloc] initWithFrame:CGRectMake(14.0f, 0.0f, KScreenWidth - 28.0f, 54.0f)];
- headerL.font = LCBoldFont(16.0f);
- headerL.textColor = LZ273145Color;
- headerL.text = @"选择举报原因";
- [headerView addSubview:headerL];
-
- UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, 54.0f + 148 + 50.0f + 49.0f * 2.0f+63)];
- self.tableView.tableFooterView = footerView;
-
- UILabel *footerL = [[UILabel alloc] initWithFrame:CGRectMake(14.0f, 0.0f, KScreenWidth - 28.0f, 54.0f)];
- footerL.font = LCBoldFont(16.0f);
- footerL.textColor = LZ273145Color;
- [footerView addSubview:footerL];
- NSString *footerText = @"举报描述(选填)";
- NSRange range = [footerText rangeOfString:@"(选填)"];
- NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc]initWithString:footerText];
- [attrStr addAttribute:NSFontAttributeName value:LCFont(14) range:range];
- [attrStr addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0x9F9DA5) range:range];
- footerL.attributedText = attrStr;
- //图片选择
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.itemSize = CGSizeMake(63, 63);
- layout.minimumInteritemSpacing = 9;
- UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- [footerView addSubview:collectionView];
- [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(footerL.mas_bottom);
- make.left.mas_equalTo(12);
- make.right.mas_equalTo(-12);
- make.height.mas_equalTo(63);
- }];
- self.collectionView = collectionView;
- collectionView.alwaysBounceVertical = YES;
- collectionView.backgroundColor = [UIColor whiteColor];
- collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
- collectionView.dataSource = self;
- collectionView.delegate = self;
- collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
- [self.collectionView registerClass:[YOUPAIBrowserPhotoCell class] forCellWithReuseIdentifier:@"YOUPAIBrowserPhotoCell"];
-
-
-
- // self.liveTextView = [[ZCLiveTextView alloc]initWithFrame:CGRectMake(14, 54.0f, KScreenWidth - 28.0f, 148) TopMargin:8.0 LeftMargin:5.0];
- // self.liveTextView.layer.cornerRadius = 5.0f;
- // self.liveTextView.backgroundColor = HexColorFromRGB(0x4F4B5B);
- // self.liveTextView.placeholderColor = HexColorFromRGB(0x6C6B70);
- // self.liveTextView.textView.textColor = [UIColor whiteColor];
- // self.liveTextView.placeholder = @"更详细说明举报内容(选填)";
- // self.liveTextView.textView.text = @"";
- // self.liveTextView.textLength = 120;
- // self.liveTextView.timeoutAlertColor = LCRedColor;
- // [footerView addSubview:self.liveTextView];
-
- YOUPAILZTextView *textView = [[YOUPAILZTextView alloc] initWithMaxCount:120];
- textView.frame = CGRectMake(14, 54.0f+63+9, KScreenWidth - 28.0f, 148);
- textView.youpaiptextViewPadding = UIEdgeInsetsMake(14.0f, 14.0f, 10.0f, 14.0f);
- textView.youpaiptextLengthDefaultColor = HexColorFromRGB(0xD3D1D7);
- textView.youpaiptextLengthHigtColor = ZYPinkColor;
- textView.youpaiptextLengthFont = LCFont(14.0f);
- textView.youpaiptextLengthRight = 14.0f;
- textView.youpaiptextLengthBottom = 14.0f;
- textView.youpaiptextView.placeholderFont = LCFont(14.0f);
- textView.youpaiptextView.placeholderTextColor = HexColorFromRGB(0xD3D1D7);
- textView.youpaiptextView.placeholderText = @"更详细说明举报内容(选填)";
- textView.youpaiptextView.font = LCFont(14.0f);
- textView.layer.cornerRadius = 5.0f;
- textView.clipsToBounds = YES;
- textView.tintColor = ZYPinkColor;
- [footerView addSubview:textView];
- textView.youpaiptextView.textColor = LZ273145Color;
- self.liveTextView = textView;
- textView.backgroundColor = LZF7F8FAColor;
-
- UIButton* uploadBtn = [[UIButton alloc]initWithFrame:CGRectMake(47.5, footerView.mj_h - 49.0f * 2.0f, KScreenWidth-47.5*2, 49.0f)];
- uploadBtn.titleLabel.font = LCFont16;
- uploadBtn.backgroundColor = HexColorFromRGB(0xD3D1D7);
-
- uploadBtn.layer.cornerRadius = 24.5f;
- uploadBtn.layer.masksToBounds = YES;
- [uploadBtn setTitle:@"提交" forState:(UIControlStateNormal)];
- [uploadBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [uploadBtn addTarget:self action:@selector(youpaifuploadBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- uploadBtn.userInteractionEnabled = NO;
- self.uploadBtn = uploadBtn;
- [footerView addSubview:uploadBtn];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifkeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifkeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
-
- }
- #pragma mark UICollectionView
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- if (_selectedPhotos.count >= 5) {
- return _selectedPhotos.count;
- }
-
- return _selectedPhotos.count + 1;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- YOUPAIBrowserPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAIBrowserPhotoCell" forIndexPath:indexPath];
-
-
- if (indexPath.item == _selectedPhotos.count) {
- cell.imageView.image = [UIImage imageNamed:@"vqu_images_AlbumAddBtn"];
- cell.deleteBtn.hidden = YES;
-
- } else {
- cell.imageView.image = _selectedPhotos[indexPath.item];
- cell.asset = _selectedAssets[indexPath.item];
- cell.deleteBtn.hidden = NO;
- }
-
- cell.deleteBtn.tag = indexPath.item;
- [cell.deleteBtn addTarget:self action:@selector(deleteBtnClik:) forControlEvents:UIControlEventTouchUpInside];
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.item == _selectedPhotos.count) {
-
- NSString *takePhotoTitle = @"拍照";
-
- UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *takePhotoAction = [UIAlertAction actionWithTitle:takePhotoTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self takePhoto];
- }];
- [alertVc addAction:takePhotoAction];
- UIAlertAction *imagePickerAction = [UIAlertAction actionWithTitle:@"去相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self pushTZImagePickerController];
- }];
- [alertVc addAction:imagePickerAction];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
- [alertVc addAction:cancelAction];
- UIPopoverPresentationController *popover = alertVc.popoverPresentationController;
- UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
- if (popover) {
- popover.sourceView = cell;
- popover.sourceRect = cell.bounds;
- popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
- }
- [self presentViewController:alertVc animated:YES completion:nil];
-
- } else { // preview photos or video / 预览照片或者视频
- // preview photos / 预览照片
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.item];
- imagePickerVc.maxImagesCount = 4;
- imagePickerVc.allowPickingGif = NO;
-
- imagePickerVc.allowPickingOriginalPhoto = YES;
- imagePickerVc.allowPickingMultipleVideo = YES;
- imagePickerVc.showSelectedIndex = YES;
-
- imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
- [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- self->_selectedPhotos = [NSMutableArray arrayWithArray:photos];
- self->_selectedAssets = [NSMutableArray arrayWithArray:assets];
-
- [self->_collectionView reloadData];
-
- }];
- [self presentViewController:imagePickerVc animated:YES completion:nil];
-
- }
- }
- #pragma mark - UIImagePickerController
- - (void)takePhoto {
- AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
- if (authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) {
- // 无相机权限 做一个友好的提示
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"打开相册失败" message:@"相机打开失败。设备不支持访问相机,请在设置->花蝶->相机中进行设置" preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alertController addAction:[UIAlertAction actionWithTitle:@"设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
- }]];
- [self presentViewController:alertController animated:YES completion:nil];
- } else if (authStatus == AVAuthorizationStatusNotDetermined) {
- // fix issue 466, 防止用户首次拍照拒绝授权时相机页黑屏
- [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
- if (granted) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self takePhoto];
- });
- }
- }];
- // 拍照之前还需要检查相册权限
- } else if ([PHPhotoLibrary authorizationStatus] == 2) { // 已被拒绝,没有相册权限,将无法保存拍的照片
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"无法访问相册" message:@"相册打开失败。设备不支持访问相册,请在设置->隐私->照片中进行设置" preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alertController addAction:[UIAlertAction actionWithTitle:@"设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
- }]];
- [self presentViewController:alertController animated:YES completion:nil];
- } else if ([PHPhotoLibrary authorizationStatus] == 0) { // 未请求过相册权限
- [[TZImageManager manager] requestAuthorizationWithCompletion:^{
- [self takePhoto];
- }];
- } else {
- [self pushImagePickerController];
- }
- }
- // 调用相机
- - (void)pushImagePickerController {
-
-
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
- if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
- self.imagePickerVc.sourceType = sourceType;
- NSMutableArray *mediaTypes = [NSMutableArray array];
-
- [mediaTypes addObject:(NSString *)kUTTypeMovie];
-
- [mediaTypes addObject:(NSString *)kUTTypeImage];
-
- if (mediaTypes.count) {
- _imagePickerVc.mediaTypes = mediaTypes;
- }
- [self presentViewController:_imagePickerVc animated:YES completion:nil];
- } else {
- NSLog(@"模拟器中无法打开照相机,请在真机中使用");
- }
- }
- #pragma mark - Click Event
- - (void)deleteBtnClik:(UIButton *)sender {
- if ([self collectionView:self.collectionView numberOfItemsInSection:0] <= _selectedPhotos.count) {
- [_selectedPhotos removeObjectAtIndex:sender.tag];
- [_selectedAssets removeObjectAtIndex:sender.tag];
- [self.collectionView reloadData];
- return;
- }
-
- [_selectedPhotos removeObjectAtIndex:sender.tag];
- [_selectedAssets removeObjectAtIndex:sender.tag];
- [_collectionView performBatchUpdates:^{
- NSIndexPath *indexPath = [NSIndexPath indexPathForItem:sender.tag inSection:0];
- [self->_collectionView deleteItemsAtIndexPaths:@[indexPath]];
- } completion:^(BOOL finished) {
- [self->_collectionView reloadData];
- }];
- }
- #pragma mark - TZImagePickerController
- - (UIImagePickerController *)imagePickerVc {
- if (_imagePickerVc == nil) {
- _imagePickerVc = [[UIImagePickerController alloc] init];
- _imagePickerVc.delegate = self;
- // set appearance / 改变相册选择页的导航栏外观
- _imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
- _imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
- UIBarButtonItem *tzBarItem, *BarItem;
- if (@available(iOS 9, *)) {
- tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
- BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
- } else {
- tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
- BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
- }
- NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
- [BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
-
- }
- return _imagePickerVc;
- }
- - (void)pushTZImagePickerController {
-
- // 设置languageBundle以使用其它语言,必须在TZImagePickerController初始化前设置 / Set languageBundle to use other language
- // [TZImagePickerConfig sharedInstance].languageBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"tz-ru" ofType:@"lproj"]];
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:5 columnNumber:5 delegate:self pushPhotoPickerVc:YES];
-
- imagePickerVc.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
- imagePickerVc.showPhotoCannotSelectLayer = YES;
- imagePickerVc.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
- // 1.设置目前已经选中的图片数组
- imagePickerVc.selectedAssets = _selectedAssets;
-
- // 3. 设置是否可以选择视频/图片/原图
- imagePickerVc.allowPickingVideo = NO;
- imagePickerVc.allowPickingImage = YES;
- imagePickerVc.allowPickingOriginalPhoto = NO;
- imagePickerVc.allowPickingGif = NO;
- imagePickerVc.allowPickingMultipleVideo = NO; // 是否可以多选视频
-
- // 4. 照片排列按修改时间升序
- imagePickerVc.sortAscendingByModificationDate = YES;
-
- // imagePickerVc.minImagesCount = 3;
- // imagePickerVc.alwaysEnableDoneBtn = YES;
-
- // imagePickerVc.minPhotoWidthSelectable = 3000;
- // imagePickerVc.minPhotoHeightSelectable = 2000;
-
- /// 5. Single selection mode, valid when maxImagesCount = 1
- /// 5. 单选模式,maxImagesCount为1时才生效
- // imagePickerVc.showSelectBtn = NO;
- // 设置竖屏下的裁剪尺寸
- NSInteger left = 30;
- NSInteger widthHeight = self.view.width - 2 * left;
- NSInteger top = (self.view.height - widthHeight) / 2;
- imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
-
- // 设置横屏下的裁剪尺寸
- // imagePickerVc.cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, left, widthHeight, widthHeight);
- /*
- [imagePickerVc setCropViewSettingBlock:^(UIView *cropView) {
- cropView.layer.borderColor = [UIColor redColor].CGColor;
- cropView.layer.borderWidth = 2.0;
- }];*/
-
- // imagePickerVc.allowPreview = NO;
- // 自定义导航栏上的返回按钮
- /*
- [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
- [leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
- [leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 20)];
- }];
- imagePickerVc.delegate = self;
- */
-
- // Deprecated, Use statusBarStyle
- // imagePickerVc.isStatusBarDefault = NO;
- imagePickerVc.statusBarStyle = UIStatusBarStyleLightContent;
-
- // 设置是否显示图片序号
- imagePickerVc.showSelectedIndex = YES;
-
- // 设置拍照时是否需要定位,仅对选择器内部拍照有效,外部拍照的,请拷贝demo时手动把pushImagePickerController里定位方法的调用删掉
- // imagePickerVc.allowCameraLocation = NO;
-
-
-
- // 设置首选语言 / Set preferred language
- // imagePickerVc.preferredLanguage = @"zh-Hans";
-
- #pragma mark - 到这里为止
-
- // You can get the photos by block, the same as by delegate.
- // 你可以通过block或者代理,来得到用户选择的照片.
- [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- }];
-
- imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- }
- - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos {
- _selectedPhotos = [NSMutableArray arrayWithArray:photos];
- _selectedAssets = [NSMutableArray arrayWithArray:assets];
-
- [_collectionView reloadData];
- // _collectionView.contentSize = CGSizeMake(0, ((_selectedPhotos.count + 2) / 3 ) * (_margin + _itemWH));
- [self updataImagesOSS:_selectedPhotos];
- // 1.打印图片名字
- [self printAssetsName:assets];
- // 2.图片位置信息
- for (PHAsset *phAsset in assets) {
- NSLog(@"location:%@",phAsset.location);
- }
-
- }
- - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
- [picker dismissViewControllerAnimated:YES completion:nil];
- NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
-
- TZImagePickerController *tzImagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
- tzImagePickerVc.sortAscendingByModificationDate = YES;
- [tzImagePickerVc showProgressHUD];
- if ([type isEqualToString:@"public.image"]) {
- UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
- NSDictionary *meta = [info objectForKey:UIImagePickerControllerMediaMetadata];
- // save photo and get asset / 保存图片,获取到asset
- [[TZImageManager manager] savePhotoWithImage:image meta:meta location:nil completion:^(PHAsset *asset, NSError *error){
- [tzImagePickerVc hideProgressHUD];
- if (error) {
- NSLog(@"图片保存失败 %@",error);
- } else {
- TZAssetModel *assetModel = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypePhoto];
-
- [self refreshCollectionViewWithAddedAsset:assetModel.asset image:image];
-
- }
- }];
-
-
- }
- }
- - (void)refreshCollectionViewWithAddedAsset:(PHAsset *)asset image:(UIImage *)image {
- [_selectedAssets addObject:asset];
- [_selectedPhotos addObject:image];
- [_collectionView reloadData];
-
- [self updataImagesOSS:_selectedPhotos];
- }
- -(void)updataImagesOSS:(NSArray*)imagesArr{
- // 1通过,0待审核,2,未通过
-
- @weakify(self)
- [LCCommonHttp uploadWithImages:imagesArr Type:@"album" successBlock:^(NSArray<NSString *> *ossImagePaths) {
- @strongify(self)
- ;
-
- self.youpaipimageUrl =[ossImagePaths componentsJoinedByString:@","];
- }];
-
- }
- /// 打印图片名字
- - (void)printAssetsName:(NSArray *)assets {
- NSString *fileName;
- for (PHAsset *asset in assets) {
- fileName = [asset valueForKey:@"filename"];
- // NSLog(@"图片名字:%@",fileName);
- }
- }
- - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
- if ([picker isKindOfClass:[UIImagePickerController class]]) {
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- }
- #pragma mark - 键盘交互事件
- //键盘即将隐藏
- - (void)youpaifkeyboardWillHide:(NSNotification *)note
- {
- // CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
- [UIView animateWithDuration:0.25 animations:^{
- //KScreenHeight-KScreenHeight/3-60
- self.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
- }];
-
- }
- //键盘即将弹出
- - (void)youpaifkeyboardWillShow:(NSNotification *)note
- {
- CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGFloat keyboardH = keyboardF.size.height;
- [UIView animateWithDuration:0.25 animations:^{
- self.view.frame = CGRectMake(0, 0-keyboardH, KScreenWidth, KScreenHeight);
- }];
-
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- [self.view endEditing:YES];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.reportArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 50;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAILCReportModel* model = self.reportArray[indexPath.row];
- NSString *cellID = @"YOUPAILZReportCell";
- YOUPAILZReportCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[YOUPAILZReportCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- [cell youpaifreloadWithModel:model];
-
- // UITableViewCell* cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"reportCell"];
- // cell.backgroundColor = [UIColor whiteColor];
- // cell.textLabel.text = model.name;
- // cell.textLabel.font = LCFont17;
- // cell.textLabel.textColor = LCTextBlack;
- // cell.textLabel.textAlignment = NSTextAlignmentLeft;
- //
- // NSInteger row = [indexPath row];
- // NSInteger oldRow = [self.lastPath row];
- // if (row == oldRow && self.lastPath!=nil) {
- // cell.accessoryType = UITableViewCellAccessoryCheckmark;
- // }else{
- // cell.accessoryType = UITableViewCellAccessoryNone;
- // }
-
- return cell;
-
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- self.currentModel.youpaipisSelected = NO;
- YOUPAILCReportModel* model = self.reportArray[indexPath.row];
- self.currentModel = model;
- self.currentModel.youpaipisSelected = YES;
- // NSInteger newRow = [indexPath row];
- // NSInteger oldRow = (self .lastPath !=nil)?[self .lastPath row]:-1;
- // if (newRow != oldRow) {
- // UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
- // newCell.accessoryType = UITableViewCellAccessoryCheckmark;
- // UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:self.lastPath];
- // oldCell.accessoryType = UITableViewCellAccessoryNone;
- // self .lastPath = indexPath;
- // }
- [tableView reloadData];
- [self youpaifupdateBtnStatus];
- }
- - (void)youpaifupdateBtnStatus{
- if (self.currentModel != nil) {
- [self.uploadBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-47.5*2, 49) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
- self.uploadBtn.userInteractionEnabled = YES;
- }
- }
- - (void)youpaifuploadBtnClick{
- YOUPAILCReportModel* model = self.currentModel;
- @weakify(self);
- NSMutableDictionary *dict = [NSMutableDictionary new];
- [dict setObject:@(self.youpaiptype) forKey:@"type"];
- [dict setObject:model.youpaipid forKey:@"cate_id"];
- if (self.youpaipimageUrl.length == 0) {
- self.youpaipimageUrl = @"";
- }
- [dict setObject:self.youpaipimageUrl forKey:@"images"];
- [dict setObject:self.youpaipreport_uid forKey:@"report_uid"];
- [dict setObject:self.liveTextView.youpaiptextView.text forKey:@"content"];
- [LCHttpHelper requestWithURLString:ReportUpload parameters:dict needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"需紧急处理" handler:^(LZAlertAction *action) {
- NIMSession *session = [NIMSession session:@"4" type:NIMSessionTypeP2P];
- [ZCHUDHelper show];
- [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
- @strongify(self);
- [ZCHUDHelper dismiss];
- YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
- [self.navigationController pushViewController:vc animated:YES];
- }];
- }];
- cancelAction.cornerRadius = 24.0f;
- cancelAction.color = LZ273145Color;
- cancelAction.bgColor = LZF5F4F7Color;
- LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"返回" handler:^(LZAlertAction *action) {
- @strongify(self);
- [self.navigationController popViewControllerAnimated:YES];
- }];
- confimAction.cornerRadius = 24.0f;
- confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
- LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"举报成功" content:@" 我们已接收到您的举报内容,非常重视您的举报。每一条举报都会被认真核实,并依据国家法律法规及本平台条款积极处理,感谢您的配合。" action:@[cancelAction,confimAction]];
- [self TFPresentVC:alert completion:^{}];
-
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- -(void)youpaifclickconfirmAction
- {
- NIMSession *session = [NIMSession session:[LCSaveData getServerId] type:NIMSessionTypeP2P];
- if (session) {
- @weakify(self);
- [ZCHUDHelper show];
- [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
- @strongify(self);
- [ZCHUDHelper dismiss];
- YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
- [self.navigationController pushViewController:vc animated:YES];
- }];
- }
- }
- @end
|