12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340 |
- //
- // ChangeTopicVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/25.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ChangeTopicVC.h"
- #import "SmartBar.h"
- #import "NewTopicModel.h"
- #import "NewTopicCell.h"
- #import "NewTopicTextView.h"
- #import "LYLPhotoTailoringTool.h"
- #import "FWZFileGetTool.h"
- #import "FWZGetNoteBookTool.h"
- #define BARHEIGHT 42.5f
- #define TextViewTag 1000
- @interface ChangeTopicVC ()<SmartBarDelegate,UITextViewDelegate,UITableViewDelegate,UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UIView *NavBarV;
- @property (weak, nonatomic) IBOutlet UIButton *DoneBtn;
- @property (strong, nonatomic) UITableView *tableView;
- @property (strong, nonatomic) SmartBar *SmartBar;
- @property (strong, nonatomic) NSMutableArray *dataArray;
- @property (strong, nonatomic) NewTopicTextView *defualtView;
- @end
- @implementation ChangeTopicVC
- + (ChangeTopicVC *)initChangeTopicVC{
- ChangeTopicVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"ChangeTopicVC"];
- return controller;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [[IQKeyboardManager sharedManager] setEnable:YES];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- [self.view addSubview:self.tableView];
- self.SmartBar.delegate = self;
- [self.view addSubview:self.SmartBar];
- [self.SmartBar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.height.mas_offset(BARHEIGHT);
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
- } else {
- make.bottom.equalTo(self.view.mas_bottom).offset(BARHEIGHT);
- }
- }];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.NavBarV.mas_bottom);
- make.bottom.mas_equalTo(self.SmartBar.mas_top);
- }];
- WS(weakSelf);
- [self.DoneBtn setAction:^{
- [weakSelf editTopicPut];
- }];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- [self editData:self.dataDict];
- }
- - (void)editData:(NSDictionary *)dict
- {
- [self.dataArray removeAllObjects];
- NewTopicModel * titleModel = [[NewTopicModel alloc] init];
- titleModel.title = @"编辑标题";
- titleModel.content = [dict objectForKey:@"Title"];
- titleModel.type = CollectDataType_Text;
- [self.dataArray addObject:titleModel];
- if ([[dict objectForKey:@"Data"] isKindOfClass:[NSArray class]]) {
- NSArray * array = [dict objectForKey:@"Data"];
- for (NSInteger i = 0; i < array.count; i ++) {
- NSDictionary * dataDic = array[i];
- NewTopicModel * model = [[NewTopicModel alloc] initWithDict:dataDic];
- switch (model.type) {
- case CollectDataType_Text:
- {
- if (i == 0) {
- [self.dataArray addObject:model];
- }
- }
- break;
- case CollectDataType_IMG:
- {
- NSDictionary * pdDict = array[i + 1];
- if ([[pdDict objectForKey:@"Type"] integerValue] == CollectDataType_Text) {
- model.content = [pdDict objectForKey:@"Text"];
- }else{
- model.content = @"";
- }
- [self.dataArray addObject:model];
- }
- break;
- default:
- {
- if (array.count == i + 1) {
- break;
- }
- NSDictionary * pdDict = array[i + 1];
- if ([[pdDict objectForKey:@"Type"] integerValue] == CollectDataType_Text) {
- model.content = [pdDict objectForKey:@"Text"];
- }else{
- model.content = @"";
- }
- [self.dataArray addObject:model];
- }
- break;
- }
- }
- }
- [self.tableView reloadData];
- }
- #pragma -mark UItableViewDelegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- WS(weakSelf);
- NewTopicModel *model = [self.dataArray objectAtIndex:indexPath.row];
- if (indexPath.row == 0) {
- NewTopicCell *cell = [NewTopicCell configCell0:tableView indexPath:indexPath];
- if (!self.defualtView) {
- self.defualtView = cell.textView;
- }
- cell.textView.placeholder = model.title;
- cell.textView.text = model.content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- return cell;
- }
- switch (model.type) {
- case CollectDataType_Text:
- {
- NewTopicCell *cell = [NewTopicCell configCell1:tableView indexPath:indexPath];
- cell.textView.placeholder = model.title;
- cell.textView.text = model.content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- return cell;
- }
- break;
- case CollectDataType_File:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.cell2SubTitleL.text = model.fileSize;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- NSString * imageName = [ZYCTool getFileNameImage:model.File];
- if (imageName.length > 0) {
- cell.cell2ImagV.image = IMG(imageName);
- }else{
- [cell.cell2ImagV sd_setImageWithURL:[NSURL URLWithString:model.File] placeholderImage:IMG(@"icon_weizhiwenjian")];
- }
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_IMG:
- {
- NewTopicCell *cell = [NewTopicCell configCell3:tableView indexPath:indexPath];
- cell.textView.placeholder =@"";
- cell.textView.text = model.content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- [cell.cell3ImagV sd_setImageWithURL:[NSURL URLWithString:model.imageUrl]];
-
- [cell.cell3CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_Collect:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.text = model.content;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2TitleL.text = model.FileName;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"收藏");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_Note:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"noteBook_icon");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }
- break;
- case CollectDataType_NoteFile:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记文件夹",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"find_1");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_CollectFile:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏文件夹",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"find_1");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Group:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@小组",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"笔记小组");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Topic:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"话题");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_InterMail:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的站内信",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"站内信");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Notice:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的通知",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"通知图标");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Meeting:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.hidden = YES;
- cell.cell2ImagV.image = IMG(@"会议");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Article:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的文章",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"文章");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- case CollectDataType_Approval:
- {
- NewTopicCell *cell = [NewTopicCell configCell2:tableView indexPath:indexPath];
- cell.textView.placeholder = @"";
- cell.textView.text = model.content;
- cell.cell2TitleL.text = model.FileName;
- cell.bgLabel.text = cell.textView.text;
- cell.textView.tag = TextViewTag + indexPath.row;
- cell.textView.delegate = self;
- cell.cell2SubTitleL.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的审批",model.AuthorName] KeyString:model.AuthorName];
- cell.cell2ImagV.image = IMG(@"审批");
- [cell.cell2CloseBtn setAction:^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- [weakSelf.tableView reloadData];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- return cell;
- }break;
- default:
- {
- NewTopicCell *cell = [NewTopicCell configCell0:tableView indexPath:indexPath];
- return cell;
- }
- break;
- }
- }
- #pragma -mark loadView
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- }
- return _tableView;
- }
- - (SmartBar *)SmartBar
- {
- if (!_SmartBar) {
- _SmartBar = [[SmartBar alloc] init];
- }
- return _SmartBar;
- }
- - (NSMutableArray *)dataArray
- {
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- #pragma -mark UItextViewDelegate
- - (void)textViewDidBeginEditing:(UITextView *)textView
- {
- self.defualtView = (NewTopicTextView *)textView;
- }
- - (void)textViewDidChange:(UITextView *)textView
- {
- self.defualtView = (NewTopicTextView *)textView;
- NSInteger index = textView.tag - TextViewTag;
- NewTopicModel * model = [self.dataArray objectAtIndex:index];
- model.content = textView.text;
- CGRect bounds = textView.bounds;
- CGSize maxSize = CGSizeMake(bounds.size.width, CGFLOAT_MAX);
- CGSize newSize = [textView sizeThatFits:maxSize];
- if (model.height != newSize.height) {
- [self.tableView beginUpdates];
- [self.tableView endUpdates];
- model.height = newSize.height;
- }
- }
- #pragma mark - SmartBarDelegate
- - (void)didSelectBarWithType:(SmartBarType)type
- {
- WS(weakSelf);
- switch (type) {
- case SmartBarPhoto:
- {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera1 crop:YES showImgBlock:^(NSString *imageUrlStr) {
-
- } choosImgBlock:^(UIImage *image) {
- [weakSelf didSelectImage:image];
- }];
- }
- break;
- case SmartBarCamera:
- {
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
-
- } choosImgBlock:^(UIImage *image) {
- [weakSelf didSelectImage:image];
- }];
- }
- break;
- case SmartBarNotes:
- {
- [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
- NSLog(@"SmartBarNotes %@",noteArr);
- [weakSelf disSelectNoteBook:noteArr];
- }];
- }
- break;
- case SmartBarCollection:
- {
- [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
- NSLog(@"SmartBarCollection %@",collectArr);
- [weakSelf disSelectCollect:collectArr];
- }];
- }
- break;
- case SmartBarFile:
- {
- WS(weakSelf);
- [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
-
- } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
- REMOVESHOW
- NSLog(@"上传成功的文件%@",responseObject);
- [weakSelf fileSizeWithData:fileData withDict:responseObject[0]];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }];
- }
- break;
- default:
- break;
- }
- }
- - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
- for (MyNoteBookSubModel *dataModel in noteArr ) {
- if (dataModel.AttributeValue == 1) {
- NewTopicModel * model = [[NewTopicModel alloc] init];
- model.ID = dataModel.MiddleId;
- model.FileId =dataModel.MiddleId;
- model.imageUrl = dataModel.AvatarUrl;
- model.AuthorName = dataModel.Name;
- model.FileName = dataModel.Title;
- model.type = CollectDataType_Note;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }else{
- NewTopicModel * model = [[NewTopicModel alloc] init];
- model.ID = dataModel.Id;
- model.FileId = dataModel.Id;
- model.imageUrl = dataModel.AvatarUrl;
- model.AuthorName = [AppUserModel sharedAppUserModel].Name;
- model.FileName = dataModel.FolderName;
- model.type = CollectDataType_NoteFile;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }
- }
- }
- - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
- for (MyFavoriteSubModel *dataModel in collectArr ) {
- if(dataModel.AttributeValue == 1)
- {
- NewTopicModel * model = [[NewTopicModel alloc] init];
- model.ID = dataModel.CollectionDataId;
- model.FileId = dataModel.CollectionDataId;
- model.imageUrl = dataModel.Data.AvatarUrl;
- model.AuthorName = dataModel.Data.Author;
- model.FileName = dataModel.Title;
- model.type = [ZYCTool returnDataType:dataModel.CollectionType];
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }else{
- NewTopicModel * model = [[NewTopicModel alloc] init];
- model.ID = dataModel.Id;
- model.FileId = dataModel.Id;
- model.imageUrl = dataModel.Data.AvatarUrl;
- model.AuthorName = [AppUserModel sharedAppUserModel].Name;
- model.FileName = dataModel.FolderName;
- model.type = CollectDataType_CollectFile;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }
- }
- }
- - (void)fileSizeWithData:(NSData *)fileData withDict:(NSDictionary *)dict
- {
- unsigned long long size = [fileData length];
- NSString * fileZise;
- if (size >= pow(10, 9)) { // size >= 1GB
- fileZise = [NSString stringWithFormat:@"%.2fGB", size / pow(10, 9)];
- } else if (size >= pow(10, 6)) { // 1GB > size >= 1MB
- fileZise = [NSString stringWithFormat:@"%.2fMB", size / pow(10, 6)];
- } else if (size >= pow(10, 3)) { // 1MB > size >= 1KB
- fileZise = [NSString stringWithFormat:@"%.2fKB", size / pow(10, 3)];
- } else { // 1KB > size
- fileZise = [NSString stringWithFormat:@"%lluB", size];
- }
- [self didSelectFile:dict withSize:fileZise];
- }
- - (void)didSelectImage:(UIImage *)image
- {
- WS(weakSelf);
- NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
- [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:@[UIImageJPEGRepresentation(image,1.0f)] pictureKey:@"file" success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- NSDictionary * dict = responseObject[0];
- NewTopicModel * model = [[NewTopicModel alloc] init];
- model.title = @"";
- model.content = @"";
- model.imageUrl = dict[@"AbsolutePath"];
- model.FileId = [dict[@"FileId"] integerValue];
- model.FileName = dict[@"FileName"];
- model.type = CollectDataType_IMG;
- [weakSelf.dataArray addObject:model];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)didSelectFile:(NSDictionary *)dict withSize:(NSString *)fileSize
- {
- NewTopicModel * model = [[NewTopicModel alloc] init];
- model.title = @"";
- model.content = @"";
- model.imageUrl = dict[@"AbsolutePath"];
- model.FileId = [dict[@"FileId"] integerValue];
- model.FileName = dict[@"FileName"];
- model.type = CollectDataType_File;
- model.fileSize = fileSize;
- [self.dataArray addObject:model];
- WS(weakSelf);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.tableView scrollToRow:weakSelf.dataArray.count - 1 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];
- });
- });
- }
- - (void)didSelectBarAddBtnIsShow:(BOOL)isShow
- {
- [self.view endEditing:YES];
- }
- - (void)didSelectBarKeyBtnIsShow:(BOOL)isShow
- {
- [self.defualtView resignFirstResponder];
- }
- #pragma mark - KeyBoard
- - (void)keyBoardWillShow:(NSNotification *)note
- {
- // 获取用户信息
- NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
- // 获取键盘高度
- CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGFloat keyBoardHeight = keyBoardBounds.size.height;
- // 获取键盘动画时间
- CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
-
-
- // 定义好动作
- WS(weakSelf);
- void (^animation)(void) = ^void(void) {
- [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(-keyBoardHeight);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-keyBoardHeight);
- }
- }];
- };
-
- if (animationTime > 0) {
- [UIView animateWithDuration:animationTime animations:animation completion:^(BOOL finished) {
-
- }];
- } else {
- animation();
- }
- }
- - (void)keyBoardWillHide:(NSNotification *)note
- {
- // 获取用户信息
- NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
- // 获取键盘动画时间
- CGFloat animationTime = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
-
- // 定义好动作
- WS(weakSelf);
- void (^animation)(void) = ^void(void) {
- [weakSelf.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT);
- }
- }];
- };
-
- if (animationTime > 0) {
- [UIView animateWithDuration:animationTime animations:animation];
- } else {
- animation();
- }
- }
- #pragma mark - 修改话题
- - (void)editTopicPut
- {
- NSMutableArray * array = [NSMutableArray array];
- for (NSInteger i = 1; i < self.dataArray.count; i ++) {
- NewTopicModel * model = self.dataArray[i];
- switch (model.type) {
- case CollectDataType_Text:
- {
- if (model.content.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:dict];
- }
- break;
- case CollectDataType_IMG:
- {
- if (model.imageUrl.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":@"",
- @"Type":@(CollectDataType_IMG),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }
- break;
- case CollectDataType_File:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.File,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":@"",
- @"Type":@(CollectDataType_File),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }
- break;
- case CollectDataType_Group:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":@"",
- @"Type":@(CollectDataType_Group),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }
- break;
- case CollectDataType_Collect:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Collect),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Note:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Note),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_CollectFile:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_CollectFile),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_NoteFile:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_NoteFile),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Notice:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":model.FileName,
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Notice),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_InterMail:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_InterMail),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Meeting:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Meeting),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Approval:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Approval),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- case CollectDataType_Article:
- {
- if (model.FileName.length == 0) {
- break;
- }
- NSDictionary * dict = @{@"TextType":@"",
- @"File":model.imageUrl,
- @"FileName":@"",
- @"Text":@"",
- @"Title":model.FileName,
- @"Type":@(CollectDataType_Article),
- @"Author":model.AuthorName,
- @"Content":@"",
- @"Id":@(model.FileId),
- @"CreatedData":@""
- };
- [array addObject:dict];
- if (model.content.length > 0) {
- NSDictionary * subDict = @{@"TextType":@"",
- @"File":@"",
- @"FileName":@"",
- @"Text":model.content,
- @"Title":@"",
- @"Type":@(CollectDataType_Text),
- @"Author":@"",
- @"Content":@"",
- @"Id":@(0),
- @"CreatedData":@""
- };
- [array addObject:subDict];
- }
- }break;
- default:
- break;
- }
- }
- NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
- NewTopicModel * fristModel = [self.dataArray firstObject];
- [paraDict setObject:fristModel.content forKey:@"Title"];
- [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [paraDict setObject:@(self.topicId) forKey:@"Id"];
- if (array.count == 0 && fristModel.content.length == 0) {
- SHOWERROR(@"话题标题和内容不能都为空");
- return;
- }
- [paraDict setObject:[self arrayToJSONString:array] forKey:@"Content"];
- WS(weakSelf);
- SHOWLOADING
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Topic_Update) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- REMOVESHOW
- SHOWSUCCESS(@"创建成功");
- if (weakSelf.upDateBlock) {
- weakSelf.upDateBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
-
- }];
- }
- - (NSString *)arrayToJSONString:(NSArray *)array
- {
- NSError *error = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
-
- return jsonString;
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [[IQKeyboardManager sharedManager] setEnable:NO];
- WS(weakSelf);
- [self.view endEditing:YES];
- [self.SmartBar downBar];
- [self.SmartBar mas_updateConstraints:^(MASConstraintMaker *make) {
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(BARHEIGHT);
- } else {
- make.bottom.equalTo(weakSelf.view.mas_bottom).offset(BARHEIGHT);
- }
- }];
- }
- - (NSString *)getFileNameImage:(NSString *)fileName
- {
- if ([fileName hasPrefix:@".doc"]) {
- return @"icon_word";
- }else if([fileName hasPrefix:@".xls"]){
- return @"icon_excel";
- }else if([fileName hasPrefix:@".ppt"]){
- return @"icon_ppt";
- }else if([fileName hasPrefix:@".pdf"]){
- return @"icon_pdf";
- }else if([fileName hasPrefix:@".zip"]){
- return @"icon_yasuowenjian";
- }else if([fileName hasPrefix:@".psd"]){
- return @"icon_psd";
- }else if([fileName hasPrefix:@".ai"]){
- return @"icon_ai";
- }else if([fileName hasPrefix:@".txt"]){
- return @"icon_txt";
- }else if([fileName hasPrefix:@".html"]){
- return @"icon_html";
- }else{
- return @"icon_weizhiwenjian";
- }
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- @end
|