123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705 |
- //
- // MyTDTopicSearchVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/19.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "TDGroupDraftSearchVC.h"
- #import "TDGroupInfoDetailVC.h"
- #import "TDGroupInfoListModel.h"
- #import "TDGroupInfoListCell.h"
- #import "TopicListModel.h"
- #import "MyTDGroupView.h"
- #import "MyTDTopicDetailVC.h"
- #import "MyTDTopicSearchVC.h"
- #import "MyTDGroupViewController.h"
- #import "TDGroupInfoListVC.h"
- #import "WorkFlowDetailsController.h"
- #import "MyApprovalPageDetail.h"
- #import "DownFileViewController.h"
- #import "MailListDetailVC.h"
- #import "ShareListVC.h"
- #import "TopicBookCell.h"
- @interface TDGroupDraftSearchVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, assign) NSUInteger currentPage;
- @property (nonatomic, assign) NSUInteger totalPage;
- @property (nonatomic, assign) NSUInteger totalRecord;
- @property (nonatomic, assign) BOOL isFresh;
- @property (strong, nonatomic) NSMutableArray * groupListArray;
- @property (strong, nonatomic) NSMutableArray * dataArray;
- @end
- @implementation TDGroupDraftSearchVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = RGB(255, 255, 255);
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self setTableViewRefresh];
- self.historySearchType = HistorySearchType_GroupDraft;
- [self addObserver:self forKeyPath:@"searchText" options:NSKeyValueObservingOptionNew context:nil];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
- {
- id obj = [change objectForKey:@"new"];
- NSString * text = @"";
- if ([obj isKindOfClass:[NSString class]]) {
- text = obj;
- }else{
- text = [obj stringValue];
- }
- if (text.length > 0) {
- [self headRefresh];
- }
- }
- #pragma mark - UItableView刷新
- - (NSMutableArray *)dataArray
- {
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- - (void)setTableViewRefresh{
- WeakSelf(self)
- self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakself headRefresh];
- }];
- self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
- [weakself footerRefresh];
- }];
- }
- - (void)headRefresh{
- self.currentPage = 1;
- self.totalPage = 0;
- [self.dataArray removeAllObjects];
- [self getData];
- }
- - (void)footerRefresh{
- self.currentPage += 1;
- if (self.totalRecord == self.dataArray.count) {
- self.currentPage --;
- [self.tableView.mj_footer endRefreshing];
- return ;
- }
- [self getData];
- }
- #pragma mark - 网络请求
- - (void)getData
- {
- WS(weakSelf);
- NSDictionary * paraDict = @{@"GroupIds":@[@(self.GroupId)],
- @"UserId":@([AppUserModel sharedAppUserModel].Id),
- @"Key": self.searchText,
- @"Page":@(self.currentPage),
- @"PerPage": @(10),
- @"Sort":@"",
- @"IsDraft":@(1)
- };
- SHOWLOADING
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Topic_Page) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- REMOVESHOW
- TopicListModel * model = [TopicListModel modelWithDictionary:responseObject];
- weakSelf.totalRecord = model.Total;
- [weakSelf.dataArray addObjectsFromArray:model.Items];
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }
- #pragma mark - UITableViewDelegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return self.dataArray.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- WS(weakSelf);
- TopicListItemModel * model = [self.dataArray objectAtIndex:(indexPath.section)];
- switch (model.DataType) {
- case TopiclistCellImage:
- {
- TDGroupInfoListCell * cell;
- switch (model.Data.count) {
- case 1:
- {
- cell = [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = YES;
- cell.cellImagV3.hidden = YES;
- cell.cellImagV4.hidden = YES;
- cell.cellImagV5.hidden = YES;
- cell.cellImagV6.hidden = YES;
- cell.cellImagV7.hidden = YES;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 2:
- {
- cell = [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = YES;
- cell.cellImagV4.hidden = YES;
- cell.cellImagV5.hidden = YES;
- cell.cellImagV6.hidden = YES;
- cell.cellImagV7.hidden = YES;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 3:
- {
- cell = [TDGroupInfoListCell configCell2:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = YES;
- cell.cellImagV5.hidden = YES;
- cell.cellImagV6.hidden = YES;
- cell.cellImagV7.hidden = YES;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 4:
- {
- cell = [TDGroupInfoListCell configCell3:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = NO;
- cell.cellImagV5.hidden = YES;
- cell.cellImagV6.hidden = YES;
- cell.cellImagV7.hidden = YES;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel3 = model.Data[3];
- [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 5:
- {
- cell = [TDGroupInfoListCell configCell4:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = NO;
- cell.cellImagV5.hidden = NO;
- cell.cellImagV6.hidden = YES;
- cell.cellImagV7.hidden = YES;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel3 = model.Data[3];
- [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel4 = model.Data[4];
- [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 6:
- {
- cell = [TDGroupInfoListCell configCell4:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = NO;
- cell.cellImagV5.hidden = NO;
- cell.cellImagV6.hidden = NO;
- cell.cellImagV7.hidden = YES;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel3 = model.Data[3];
- [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel4 = model.Data[4];
- [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel5 = model.Data[5];
- [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 7:
- {
- cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = NO;
- cell.cellImagV5.hidden = NO;
- cell.cellImagV6.hidden = NO;
- cell.cellImagV7.hidden = NO;
- cell.cellImagV8.hidden = YES;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel3 = model.Data[3];
- [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel4 = model.Data[4];
- [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel5 = model.Data[5];
- [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel6 = model.Data[6];
- [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- case 8:
- {
- cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = NO;
- cell.cellImagV5.hidden = NO;
- cell.cellImagV6.hidden = NO;
- cell.cellImagV7.hidden = NO;
- cell.cellImagV8.hidden = NO;
- cell.cellImagV9.hidden = YES;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel3 = model.Data[3];
- [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel4 = model.Data[4];
- [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel5 = model.Data[5];
- [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel6 = model.Data[6];
- [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel7 = model.Data[7];
- [cell.cellImagV8 sd_setImageWithURL:[NSURL URLWithString:subModel7.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- default:
- {
- cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
- cell.cellImagV1.hidden = NO;
- cell.cellImagV2.hidden = NO;
- cell.cellImagV3.hidden = NO;
- cell.cellImagV4.hidden = NO;
- cell.cellImagV5.hidden = NO;
- cell.cellImagV6.hidden = NO;
- cell.cellImagV7.hidden = NO;
- cell.cellImagV8.hidden = NO;
- cell.cellImagV9.hidden = NO;
- TopicListSubModel * subModel0 = model.Data[0];
- [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel1 = model.Data[1];
- [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel2 = model.Data[2];
- [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel3 = model.Data[3];
- [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel4 = model.Data[4];
- [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel5 = model.Data[5];
- [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel6 = model.Data[6];
- [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel7 = model.Data[7];
- [cell.cellImagV8 sd_setImageWithURL:[NSURL URLWithString:subModel7.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- TopicListSubModel * subModel8 = model.Data[8];
- [cell.cellImagV9 sd_setImageWithURL:[NSURL URLWithString:subModel8.File] placeholderImage:IMG(@"img_placeHolderVertical")];
- }
- break;
- }
-
- [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- cell.fileBtn.hidden = YES;
- cell.rightView.hidden = YES;
- cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
- cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
- cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
- cell.cellNameL.text = model.UserName;
- cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
- [cell.cellLikeBtn setAction:^{
- NSDictionary * paraDict = @{@"SourceId":@(model.Id),
- @"TypeValue":@(2),
- @"AnalyzeType":@(1)
- };
- cell.cellLikeBtn.enabled = NO;
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- cell.cellLikeBtn.enabled = YES;
- model.IsPraise = !model.IsPraise;
- model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- });
- } failure:^(NSError * _Nonnull error) {
- cell.cellLikeBtn.enabled = YES;
- }];
- }];
- if (model.CommentCount > 0) {
- [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
- }else{
- [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
- }
- if (model.PraiseCount > 0) {
- if (!model.IsPraise) {
- [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
- }else{
- [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
- }
- }else{
- [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
- }
- if (model.IsPraise) {
- [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
- [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
- }else{
- [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
- [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
- }
- [cell.cellPingBtn setAction:^{
- }];
- [cell.cellSendBtn setAction:^{
- }];
- if (model.Title.length == 0) {
- cell.TitleConstant.constant = 0;
- }else{
- cell.TitleConstant.constant = 10.f;
- }
- if (model.Content.length == 0) {
- cell.subTitleContant.constant = 0.f;
- }else{
- cell.subTitleContant.constant = 7.5f;
- }
- cell.ClickUserBlock = ^{
- [weakSelf showUserInfo:model.UserId];
- };
- cell.bottomView.hidden = YES;
- cell.bottomHeight.constant = 0.f;
- return cell;
- }
- break;
- case TopiclistCellNone:
- {
- TDGroupInfoListCell * cell = [TDGroupInfoListCell configCell0:tableView indexPath:indexPath];
- [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- cell.fileBtn.hidden = YES;
- cell.rightView.hidden = YES;
- cell.cellNameL.text = model.UserName;
- cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
- cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
- cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
- cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
- [cell.cellLikeBtn setAction:^{
- NSDictionary * paraDict = @{@"SourceId":@(model.Id),
- @"TypeValue":@(2),
- @"AnalyzeType":@(1)
- };
- cell.cellLikeBtn.enabled = NO;
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- cell.cellLikeBtn.enabled = YES;
- model.IsPraise = !model.IsPraise;
- model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- });
- } failure:^(NSError * _Nonnull error) {
- cell.cellLikeBtn.enabled = YES;
- }];
- }];
- if (model.CommentCount > 0) {
- [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
- }else{
- [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
- }
- if (model.PraiseCount > 0) {
- if (!model.IsPraise) {
- [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
- }else{
- [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
- }
- }else{
- [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
- }
- if (model.IsPraise) {
- [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
- [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
- }else{
- [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
- [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
- }
- [cell.cellPingBtn setAction:^{
- }];
- [cell.cellSendBtn setAction:^{
- }];
- if (model.Title.length == 0) {
- cell.TitleConstant.constant = 0;
- }else{
- cell.TitleConstant.constant = 10.f;
- }
- if (model.Content.length == 0) {
- cell.subTitleContant.constant = 0.f;
- }else{
- cell.subTitleContant.constant = 7.5f;
- }
- cell.ClickUserBlock = ^{
- [weakSelf showUserInfo:model.UserId];
- };
- cell.bottomView.hidden = YES;
- cell.bottomHeight.constant = 0.f;
- return cell;
- }
- break;
- case TopiclistCellFile:
- {
- TDGroupInfoListCell * cell = [TDGroupInfoListCell configCell6:tableView indexPath:indexPath];
- [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- cell.fileBtn.hidden = YES;
- cell.rightView.hidden = YES;
- cell.cellNameL.text = model.UserName;
- cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
- cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
- cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
- cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
- [cell.cellLikeBtn setAction:^{
- NSDictionary * paraDict = @{@"SourceId":@(model.Id),
- @"TypeValue":@(2),
- @"AnalyzeType":@(1)
- };
- cell.cellLikeBtn.enabled = NO;
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
- cell.cellLikeBtn.enabled = YES;
- model.IsPraise = !model.IsPraise;
- model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- });
- } failure:^(NSError * _Nonnull error) {
- cell.cellLikeBtn.enabled = YES;
- }];
- }];
- [cell.ClickFileAction setAction:^{
- }];
- [cell setDataWithCell6:model.Data.firstObject];
- if (model.CommentCount > 0) {
- [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
- }else{
- [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
- }
- if (model.PraiseCount > 0) {
- if (!model.IsPraise) {
- [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
- }else{
- [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
- }
- }else{
- [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
- }
- if (model.IsPraise) {
- [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
- [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
- }else{
- [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
- [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
- }
- [cell.cellPingBtn setAction:^{
- }];
- [cell.cellSendBtn setAction:^{
- }];
- if (model.Title.length == 0) {
- cell.TitleConstant.constant = 0;
- }else{
- cell.TitleConstant.constant = 10.f;
- }
- if (model.Content.length == 0) {
- cell.subTitleContant.constant = 0.f;
- }else{
- cell.subTitleContant.constant = 7.5f;
- }
- cell.ClickUserBlock = ^{
- [weakSelf showUserInfo:model.UserId];
- };
- cell.bottomView.hidden = YES;
- cell.bottomHeight.constant = 0.f;
- return cell;
- }
- break;
- default:
- {
- TopicBookCell * cell = [TopicBookCell configCell0:tableView indexPath:indexPath];
- cell.titleL.text = model.Title;
- cell.imagV.image = IMG(@"Draft_Icon");
- cell.countL.text = [NSString stringWithFormat:@"%ld",model.FileCount];
- cell.enterBtn.hidden = YES;
- return cell;
- }
- break;
- }
- }
- - (void)showUserInfo:(NSInteger)userId
- {
- MailListDetailVC * vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 0.01f;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return 8.f;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- return [UIView new];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- {
- UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 8)];
- view.backgroundColor = UIColorHex(#F5F6F8);
- return view;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- WS(weakSelf);
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- TopicListItemModel * model = [self.dataArray objectAtIndex:(indexPath.section)];
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.type = CollectModel_Toipc;
- vc.isEdit = YES;
- vc.replayType = MailReplayEdit;
- vc.Id = model.Id;
- vc.FolderId = model.GroupId;
- vc.isFromDraft = YES;
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - UISwipeActionsConfiguration
- - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){
- WS(weakSelf);
- TopicListItemModel * model = [self.dataArray objectAtIndex:(indexPath.section)];
- UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
- [tableView setEditing:NO animated:YES];
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"删除草稿后将无法恢复" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- }];
- [ok setValue:k9 forKey:@"_titleTextColor"];
- UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf deleteFind:model indexPath:indexPath];
- }];
- [noOk setValue:UIColorHex(0x0F7FD9) forKey:@"_titleTextColor"];
- [alertVC addAction:ok];
- [alertVC addAction:noOk];
- [weakSelf presentViewController:alertVC animated:YES completion:nil];
- completionHandler(YES);
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1]];
- actions.performsFirstActionWithFullSwipe = NO;
- return actions;
- }
- - (void)deleteFind:(TopicListItemModel *)model indexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Topic_User_Get),model.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (NSAttributedString *)setTextWithStr:(NSString *)str
- {
- if (str.length == 0) {
- return [[NSAttributedString alloc] initWithString:@""];
- }
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
- [attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFang SC" size:16] range:NSMakeRange(0, str.length)];
- [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(#484848) range:NSMakeRange(0, str.length)];
- [attributedString addAttribute:(NSString *)NSForegroundColorAttributeName
- value:UIColorHex(0xFF5252)
- range:[str rangeOfString:self.searchText]];
- NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
- paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
- [paraStyle setLineSpacing:5];//行间距
- [attributedString addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, str.length)];
- [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(0, str.length)];
- return attributedString;
- }
- - (NSAttributedString *)setTitleWithStr:(NSString *)str
- {
- if (str.length == 0) {
- return [[NSAttributedString alloc] initWithString:@""];
- }
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
- [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0, str.length)];
- [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x0a0a0a) range:NSMakeRange(0, str.length)];
- [attributedString addAttribute:(NSString *)NSForegroundColorAttributeName
- value:UIColorHex(0xFF5252)
- range:[str rangeOfString:self.searchText]];
- NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
- paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
- [paraStyle setLineSpacing:5];//行间距
- [attributedString addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, str.length)];
- [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(0, str.length)];
- return attributedString;
- }
- @end
|