123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196 |
- //
- // MyTDTopicDetailVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/19.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyTDTopicDetailVC.h"
- #import "NoteBookDetailCell.h"
- #import "NoteBookShareVC.h"
- #import "MoveViewController.h"
- #import "ChangeTopicVC.h"
- #import "TDGroupInfoListVC.h"
- #import "TextInputView.h"
- #import "MHTopicCell.h"
- #import "MHTopic.h"
- #import "MHTopicFrame.h"
- #import "ClickOKViewController.h"
- #import "ReadListVC.h"
- #import "HomeDetailController.h"
- #import "ChatMsgNoticeDetailVC.h"
- #import "NoteBookDetailVC.h"
- #import "MyFavoriteVC.h"
- #import "NoteBookVC.h"
- #import "TDInterLeterDetailVC.h"
- #import "FileOpenViewController.h"
- #import "EMChatFileShowVC.h"
- #import "MyTDTopicCreateVC.h"
- #import "NoticeUnreadVC.h"
- #import "DownFileViewController.h"
- #import "CountDataVC.h"
- #import "WorkFlowDetailsController.h"
- #import "MyTDGroupViewController.h"
- #import "MoveViewController.h"
- #import "MyApprovalPageDetail.h"
- #import "WorkFlowDetailsController.h"
- #import "OtherFavoriteVC.h"
- #import "OtherNoteBookVC.h"
- #import "MailListDetailVC.h"
- #import "ReadListVC.h"
- @interface MyTDTopicDetailVC ()<UITableViewDataSource,UITableViewDelegate,NoteBookShareVCDelegate,MHTopicCellDelegate,WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
- @property (strong,nonatomic) IBOutlet UITableView *tableView;
- @property (nonatomic,assign) NSUInteger currentPage;
- @property (nonatomic,strong) MyNoteBookDetailModel *currentNoteModel;
- @property (nonatomic,strong) MyNodeBookZanModel *currentZanModel;
- @property (nonatomic,strong) MyNoteBookCommentModel *currentNoteCommentModel;
- @property (nonatomic,strong) NSMutableArray *commentArray;
- @property (nonatomic,assign) BOOL isFresh;
- @property (weak, nonatomic) IBOutlet UILabel *titleL;
- @property (weak, nonatomic) IBOutlet UIButton *commentButton;
- @property (weak, nonatomic) IBOutlet UIButton *commentScrollBtn;
- @property (weak, nonatomic) IBOutlet UILabel *commentNumberLabel;
- @property (weak, nonatomic) IBOutlet UIButton *zanButton;
- @property (weak, nonatomic) IBOutlet UILabel *zanNumberLabel;
- @property (weak, nonatomic) IBOutlet UIButton *collectButton;
- @property (weak, nonatomic) IBOutlet UILabel *collectNumberLabel;
- @property (weak, nonatomic) IBOutlet UIButton *shareButton;
- @property (weak, nonatomic) IBOutlet UILabel *shareNumberLabel;
- @property (weak, nonatomic) IBOutlet UILabel *commentCountL;
- @property (weak, nonatomic) IBOutlet UIImageView *zanImgV;
- @property (weak, nonatomic) IBOutlet UILabel *zanCountL;
- @property (weak, nonatomic) IBOutlet UIImageView *collectImgV;
- @property (weak, nonatomic) IBOutlet UILabel *collectL;
- @property (weak, nonatomic) IBOutlet UIImageView *shareImgV;
- @property (weak, nonatomic) IBOutlet UILabel *shareCountL;
- @property (weak, nonatomic) IBOutlet UIView *TalkView;
- @property (weak, nonatomic) IBOutlet UIView *ReplayView;
- @property (weak, nonatomic) IBOutlet UIButton *ReplayBtn;
- @property (weak, nonatomic) IBOutlet UIView *BottomView;
- @property (nonatomic, strong) TextInputView *commentInputView;
- @property (assign, nonatomic) NSInteger countComment;
- @property (strong, nonatomic) NoteBookShareVC *noteBookShareVC;
- @property (nonatomic,assign) BOOL isSort;
- @property (nonatomic,assign) BOOL isScrComment;
- @property (nonatomic,assign) CGFloat webH;
- @property (nonatomic,strong) WKWebView * webView;
- @property (nonatomic,assign) BOOL dismissSelf;
- @property (nonatomic,copy) NSString * shareText;
- @property (nonatomic,assign) BOOL IsShareText;
- @property (nonatomic,assign) NSInteger commentId;
- @property (nonatomic,assign) NSInteger sendUserId;
- @end
- @implementation MyTDTopicDetailVC
- +(MyTDTopicDetailVC *)initMyTDTopicDetailVC{
- MyTDTopicDetailVC *controller = [StoryboardManager.shared.myTDTopic instantiateViewControllerWithIdentifier:@"MyTDTopicDetailVC"];
- return controller;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- WS(weakSelf);
- switch (self.type) {
- case CollectModel_InterMail:
- {
- [self setMailBottomView:YES];
- [self.ReplayBtn setAction:^{
- [weakSelf ReplayAction];
- }];
- self.titleL.text = @"站内信";
- }
- break;
- case CollectModel_NewTopic:
- {
- self.titleL.text = @"话题";
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_Toipc:
- {
- self.titleL.text = @"话题";
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_Notice:
- {
- self.titleL.text = @"通知";
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_NoteBook:
- {
- self.titleL.text = @"笔记";
- [self setMailBottomView:NO];
- }
- break;
- default:
- {
- self.titleL.text = @"话题";
- [self setMailBottomView:NO];
- }
- break;
- }
- }
- - (void)setMailBottomView:(BOOL)isSet
- {
- if (isSet) {
- self.TalkView.hidden = YES;
- self.ReplayView.hidden = NO;
- self.ReplayBtn.layer.cornerRadius = 5.f;
- self.ReplayBtn.layer.masksToBounds = YES;
- self.ReplayBtn.layer.borderColor = UIColorHex(0x0F8AE3).CGColor;
- self.ReplayBtn.layer.borderWidth = 0.5f;
- [self.BottomView setBackgroundColor:UIColorHex(0xF5F5F5)];
- }else{
- [self.BottomView setBackgroundColor:[UIColor whiteColor]];
- self.TalkView.hidden = NO;
- self.TalkView.layer.cornerRadius = 4.f;
- self.TalkView.layer.masksToBounds = YES;
- self.TalkView.layer.borderColor = UIColorHex(0xE5E5E5).CGColor;
- self.TalkView.layer.borderWidth = 0.5f;
- self.ReplayView.hidden = YES;
- }
- }
- - (void)ReplayAction{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-
- UIAlertAction *alertAction1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alertAction1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- WS(weakSelf);
- UIAlertAction *alertAction2 = [UIAlertAction actionWithTitle:@"回复" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- weakSelf.webH = 0;
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- vc.replayType = MailReplayOne;
- vc.type = weakSelf.type;
- vc.isEdit = YES;
- vc.Id = weakSelf.Id;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [alertAction2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- UIAlertAction *alertAction3 = [UIAlertAction actionWithTitle:@"回复全部" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- weakSelf.webH = 0;
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- vc.replayType = MailReplayAll;
- vc.isEdit = YES;
- vc.type = weakSelf.type;
- vc.Id = weakSelf.Id;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [alertAction3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- [alert addAction:alertAction2];
- [alert addAction:alertAction3];
- [alert addAction:alertAction1];
- [self presentViewController:alert animated:YES completion:^{
-
- }];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
-
- [self setTableViewRefresh];
- WS(weakSelf);
- [self.shareButton setAction:^{
- [weakSelf ShareDetail];
- }];
- [self.zanButton setAction:^{
- [weakSelf gotoZanHander];
- }];
- if (self.type != CollectModel_InterMail) {
- [self.commentButton setAction:^{
- [weakSelf commentHander];
- }];
- [self.commentScrollBtn setAction:^{
- weakSelf.isScrComment = !weakSelf.isScrComment;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf scrollToCommentViewTop];
- });
- }];
- }
-
- [self.view addSubview:self.noteBookShareVC.view];
- [self.view addSubview:self.commentInputView];
- self.tableView.tableHeaderView = self.webView;
- self.webView.UIDelegate = self;
- self.webView.navigationDelegate = self;
- self.webView.scrollView.delegate = self;
- [self headRefresh];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuShow) name:UIMenuControllerDidShowMenuNotification object:nil];
- //
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuHide) name:UIMenuControllerWillHideMenuNotification object:nil];
- // 通知-监听键盘弹出事件
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeKeyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil];
- // 通知-监听键盘回收事
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeKeyboardWillHideNotification:) name:UIKeyboardWillHideNotification object:nil];
- }
- #pragma mark - UIKeyBoradNotification
- - (void)changeKeyboardWillShowNotification:(NSNotification*)notification
- {
- WS(weakSelf);
- NSDictionary *userInfo = [notification userInfo];
- // 键盘弹出后的frame的结构体对象
- NSValue *valueEndFrame = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
- // 得到键盘弹出后的键盘视图所在y坐标
- CGFloat keyBoardEndY = valueEndFrame.CGRectValue.origin.y;
- // 键盘弹出的动画时间
- NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
- // 键盘弹出的动画曲线
- NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
- // 添加移动动画,使视图跟随键盘移动(动画时间和曲线都保持一致)
- [UIView animateWithDuration:[duration doubleValue] animations:^{
- [UIView setAnimationBeginsFromCurrentState:YES];
- [UIView setAnimationCurve:[curve intValue]];
- [UIView animateWithDuration:0.5 animations:^{
- [weakSelf.commentInputView startAnimationWithY:keyBoardEndY - 150.f];
- }];
- } completion:^(BOOL finished) {
-
- }];
- }
- - (void)changeKeyboardWillHideNotification:(NSNotification*)notification
- {
- WS(weakSelf);
- NSDictionary *userInfo = [notification userInfo];
- // 键盘弹出的动画时间
- NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
- // 键盘弹出的动画曲线
- NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
- [UIView animateWithDuration:[duration doubleValue]animations:^{
- [weakSelf.commentInputView startAnimationWithY:SCREEN_HEIGHT];
- [UIView setAnimationBeginsFromCurrentState:YES];
- [UIView setAnimationCurve:[curve intValue]];
- } completion:^(BOOL finished) {
-
- }];
- }
- - (void)setTableViewRefresh{
- WS(weakSelf);
- self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakSelf headRefresh];
- }];
- self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
- [weakSelf footerRefresh];
- }];
- }
- - (void)setBottomViewData:(MyNoteBookDetailModel *)model
- {
- self.countComment = model.CommentCount;
- if (model.CommentCount == 0) {
- self.commentCountL.text = [NSString stringWithFormat:@"评 论"];
- }else{
- if (model.CommentCount > 10000) {
- self.commentCountL.text = [NSString stringWithFormat:@"%.1f万\n评 论",model.CommentCount / 10000.0];
- }else{
- self.commentCountL.text = [NSString stringWithFormat:@"%ld\n评 论",(long)model.CommentCount];
- }
- }
- self.zanCountL.text = [NSString stringWithFormat:@"%ld",(long)model.PraiseCount];
- self.collectL.text = [NSString stringWithFormat:@"%ld",(long)model.CollectCount];
- self.shareCountL.text = [NSString stringWithFormat:@"%ld",(long)model.RetransmissionCount];
-
- self.zanCountL.hidden = model.PraiseCount == 0 ? YES : NO;
- self.collectL.hidden = model.CollectCount == 0 ? YES : NO;
- self.shareCountL.hidden = model.RetransmissionCount == 0 ? YES : NO;
-
- self.zanImgV.image = model.IsPraise ? IMG(@"zan_yes"):IMG(@"zan_no");
- self.collectImgV.image = model.IsCollect ? IMG(@"icon_collect_off"):IMG(@"收藏五角星");
- self.shareImgV.image = IMG(@"icon_share");
- WS(weakSelf);
- [self.collectButton setAction:^{
- if (model.IsCollect) {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"真的取消收藏吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
- [dic setValue:@(self.Id) forKey:@"CollectionDataId"];
- /// 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
- [dic setValue:@(self.type) forKey:@"CollectionType"];
- [dic setValue:@(0) forKey:@"FolderId"];
- [dic setValue:@(0) forKey:@"SourceUserId"];
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateCollect) parameters:dic success:^(id _Nonnull responseObject) {
- [weakSelf refreshData];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }];
- UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:actionYes];
- [alert addAction:actionNo];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }else{
- [weakSelf gotoCollectHander];
- }
- }];
- self.zanCountL.textColor = model.IsPraise ? UIColorHex(#009AFF):UIColorHex(#999999);
- self.collectL.textColor = model.IsCollect ? UIColorHex(#009AFF):UIColorHex(#999999);
- self.shareCountL.textColor = UIColorHex(#009AFF);
- }
- #pragma mark - 网络请求数据
- - (void)getNoticeData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_Notice_Detail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"通知正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- weakSelf.sendUserId = weakSelf.currentNoteModel.UserId;
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
-
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@(2),//通知 2
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
-
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(2),//通知 2
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- });
- });
- }
- - (void)getTopic{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_App_Detail) parameters:@{@"Id":@(self.Id),@"UserId":@([AppUserModel sharedAppUserModel].Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"话题正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@(1),//话题 1
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(1),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- });
- });
- }
- - (void)getMeeting{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSString * meetId = [NSString stringWithFormat:@"%ld",(long)weakSelf.Id];
- [[HttpManager sharedHttpManager] GETUrl:Host(UpdateMeeting(meetId)) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@(10),//会议 10
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(10),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- });
- });
- }
- - (void)getNote{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_NoteBook_Detail,(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"笔记正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@(3),//会议 10
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(3),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- });
- });
- }
- - (void)getMail
- {
- WS(weakSelf);
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_InterLetterDetail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- NSArray * array = responseObject[@"Items"];
- if ([array.firstObject isKindOfClass:[NSDictionary class]]) {
- weakSelf.sendUserId = [[array.firstObject objectForKey:@"UserId"] integerValue];
- }
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:array.firstObject error:nil];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- #pragma mark - 刷新点赞数据
- - (void)refreshNoticeData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_Notice_Detail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"通知正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
-
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(2),//通知 2
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshTopicData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_App_Detail) parameters:@{@"Id":@(self.Id),@"UserId":@([AppUserModel sharedAppUserModel].Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"话题正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(1),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshMeetingData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSString * meetId = [NSString stringWithFormat:@"%ld",(long)weakSelf.Id];
- [[HttpManager sharedHttpManager] GETUrl:Host(UpdateMeeting(meetId)) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(10),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshNoteData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_NoteBook_Detail,(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"话题正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@(3),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (MHTopicFrame *)_topicFrameWithTopic:(MHTopic *)topic
- {
- MHTopicFrame *topicFrame = [[MHTopicFrame alloc] init];
- // 传递微博模型数据,计算所有子控件的frame
- topicFrame.topic = topic;
-
- return topicFrame;
- }
- - (void)sortCommentList
- {
- WS(weakSelf);
- NSArray * array = self.commentArray;
- self.commentArray =[NSMutableArray arrayWithArray:[[array reverseObjectEnumerator] allObjects]];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- }
- - (void)RefreshCommentList
- {
- WS(weakSelf);
- [self.commentArray removeAllObjects];
- self.currentPage = 1;
- NSDictionary * paraDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- });
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)headRefresh{
- self.isFresh = YES;
- self.currentPage = 1;
- [self.commentArray removeAllObjects];
- [self loadDataWebView];
- switch (self.type) {
- case CollectModel_Notice:
- {
- [self getNoticeData];
- }
- break;
- case CollectModel_Toipc:
- {
- [self getTopic];
- }
- break;
- case CollectModel_NewTopic:
- {
- [self getNote];
- }
- break;
- case CollectModel_Group:
- {
- [self getTopic];
- }
- break;
- case CollectModel_meetMian:
- {
- [self getMeeting];
- }
- break;
-
- case CollectModel_NoteBook:
- {
- [self getNote];
- }
- break;
- case CollectModel_InterMail:
- {
- [self getMail];
- }
- break;
- case CollectModel_Aritle:
- {
- [self getTopic];
- }
- break;
- default:
- break;
- }
- }
- - (void)footerRefresh{
- self.isFresh = NO;
- self.currentPage += 1;
- if (self.commentArray.count == self.currentNoteCommentModel.Total) {
- self.tableView.mj_footer.hidden = YES;
- [self.tableView.mj_footer resetNoMoreData];
- return;
- }
- NSDictionary * paraDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":self.isSort ? @"asc":@"desc"
- };
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- weakSelf.currentPage -= 1;
- }];
- [self.tableView.mj_footer endRefreshing];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- if (self.type == CollectModel_InterMail) {
- return 0;
- }
- return 2;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
- switch (section) {
- case 0:
- return 0;
- break;
- default:
- return self.commentArray.count;
- break;
- }
- }else{
- switch (section) {
- case 0:
- return 1;
- break;
- default:
- return self.commentArray.count;
- break;
- }
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- if (topicFrame.tableViewFrame.size.height == 0) {
- return topicFrame.height+topicFrame.tableViewFrame.size.height;
- }else{
- return topicFrame.height+topicFrame.tableViewFrame.size.height+MHTopicVerticalSpace;
- }
- }else{
- switch (indexPath.section) {
- case 0:
- return UITableViewAutomaticDimension;
- break;
- default:
- {
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- if (topicFrame.tableViewFrame.size.height == 0) {
- return topicFrame.height + topicFrame.tableViewFrame.size.height;
- }else{
- return topicFrame.height + topicFrame.tableViewFrame.size.height;
- }
- }
- break;
- }
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
- MHTopicCell *cell = [MHTopicCell cellWithTableView:tableView];
- cell.backgroundColor = [UIColor whiteColor];
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- cell.topicFrame = topicFrame;
- cell.createTimeLabel.text = [NSString stringWithFormat:@"%@ %@",topicFrame.topic.FloorCount,topicFrame.topic.CreatedTime];
- [cell.thumbBtn setAction:^{
- [weakSelf gotoZanCommentHanderModel:topicFrame.topic indexPath:indexPath];
- }];
- cell.replyContentBlock = ^{
- [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // if (topicFrame.topic.UserId != [AppUserModel sharedAppUserModel].Id) {
- // [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // }
- };
- __block MHTopicCell * bCell = cell;
- cell.longBlock = ^{
- weakSelf.commentId = topicFrame.topic.Id;
- [weakSelf longDeleteSelf:bCell];
- };
- cell.longSubBlock = ^(NSInteger commentId,UILabel * label) {
- weakSelf.commentId = commentId;
- [weakSelf longDeleteSubCell:label];
- };
- cell.delegate = self;
- return cell;
- }else{
- switch (indexPath.section) {
- case 0:{
- WS(weakSelf);
- NoteBookDetailCell *cell = [NoteBookDetailCell configCell3:tableView indexPath:indexPath];
- cell.commentSortBtn.hidden = self.commentArray.count == 0 ? YES : NO;
- [cell.commentSortBtn setAction:^{
- weakSelf.isSort = !weakSelf.isSort;
- cell.commentSortBtn.selected = !cell.commentSortBtn.isSelected;
- [weakSelf sortCommentList];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- }];
- switch (self.currentZanModel.Items.count) {
- case 0:{
- cell.zanNameLabel.text = @"";
- cell.zanNumberlabel.text = @"";
- }break;
- case 1:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- cell.zanNameLabel.text = model.UserName;
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
- }break;
- case 2:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
- cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@",model.UserName,model1.UserName];
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
- }break;
- case 3:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
- MyNoteBookZanSubModel *model2 = self.currentZanModel.Items[2];
- cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",model.UserName,model1.UserName,model2.UserName];
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
- }break;
- default:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
- MyNoteBookZanSubModel *model2 = self.currentZanModel.Items[2];
- cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",model.UserName,model1.UserName,model2.UserName];
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" 等%lu人点赞",(unsigned long)self.currentZanModel.Total];
- }break;
- }
- return cell;
- }break;
- default:{
- MHTopicCell *cell = [MHTopicCell cellWithTableView:tableView];
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- cell.topicFrame = topicFrame;
- cell.createTimeLabel.text = [NSString stringWithFormat:@"%@ %@",topicFrame.topic.FloorCount,topicFrame.topic.CreatedTime];
- [cell.thumbBtn setAction:^{
- [weakSelf gotoZanCommentHanderModel:topicFrame.topic indexPath:indexPath];
- }];
- cell.replyContentBlock = ^{
- [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // if (topicFrame.topic.UserId != [AppUserModel sharedAppUserModel].Id) {
- // [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // }
- };
- __block MHTopicCell * bCell = cell;
- cell.longBlock = ^{
- weakSelf.commentId = topicFrame.topic.Id;
- [weakSelf longDeleteSelf:bCell];
- };
- cell.longSubBlock = ^(NSInteger commentId,UILabel * label) {
- weakSelf.commentId = commentId;
- [weakSelf longDeleteSubCell:label];
- };
- cell.delegate = self;
- return cell;
- }break;
- }
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.currentZanModel.Items.count > 0) {
- switch (indexPath.section) {
- case 0://点赞
- {
- ClickOKViewController *vc = [ClickOKViewController initClickOKViewController];
- vc.indexId = self.Id;
- vc.zanToTal = self.currentZanModel.Items.count;
- vc.type = [self backTypeValue];
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- default:
- break;
- }
- }
- }
- #pragma mark - 点击文件跳转
- - (void)pushVCWithDict:(NSDictionary *)dict
- {
- NSInteger Id = [dict[@"id"] integerValue];
- NSInteger userId = [dict[@"userId"] integerValue];
- NSString * title = dict[@"title"];
- WS(weakSelf);
- switch ([dict[@"type"] integerValue]) {
- case CollectModel_Group:
- {
- TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
- vc.GroupId = Id;
- vc.titleStr = title;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_file:{
- DownFileViewController * vc = [[DownFileViewController alloc] init];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.Title = title;
- model.SoureId = Id;
- model.Url = dict[@"bigurl"];
- model.MinUrl = dict[@"smallurl"];
- model.SoureTypeId = CollectModel_file;
- vc.model = model;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Image:{
- DownFileViewController * vc = [[DownFileViewController alloc] init];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.Title = title;
- model.SoureId = Id;
- model.Url = dict[@"bigurl"];
- model.MinUrl = dict[@"smallurl"];
- model.SoureTypeId = CollectModel_Image;
- vc.model = model;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Aritle:{
- SHOWLOADING
- [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)Id] parameters:@{} success:^(id _Nonnull responseObject) {
- REMOVESHOW;
- Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
- HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
- [homeDetail loadCurrentModel:itemModel];
- [weakSelf.navigationController pushViewController:homeDetail animated:YES];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }break;
- case CollectModel_Notice:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Notice;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Toipc:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Toipc;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NewTopic:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_NewTopic;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NoteBook:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_NoteBook;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Collect:{
-
- }break;
- case CollectModel_CollectFile:{
- if (userId == [AppUserModel sharedAppUserModel].Id) {
- MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }break;
- case CollectModel_NoteFile:{
- if (userId == [AppUserModel sharedAppUserModel].Id) {
- NoteBookVC *vc = [NoteBookVC initNoteBookVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.VisitUserId = 0;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }break;
- case CollectModel_InterMail:{
- TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC];
- vc.detailType = InterLeterDetialType_Sign;
- vc.interLeterID = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_work:{
- MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
- vc.pageType = Type_ONEC;
- vc.indexId = Id;
- vc.title = title;
- vc.TodoId = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_meetDetail:{
- WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_meetMian:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_meetMian;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_financeCount:{
- CountDataVC *vc = [CountDataVC initCountDataVC];
- vc.index = 0;
- vc.titleStr = @"财务统计";
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_affairsCount:{
- CountDataVC *vc = [CountDataVC initCountDataVC];
- vc.index = 1;
- vc.titleStr = @"人事统计";
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_publishCount:{
- CountDataVC *vc = [CountDataVC initCountDataVC];
- vc.index = 2;
- vc.titleStr = @"出版统计";
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- default:
- break;
- }
- }
- #pragma mark - 操作 (删除 | 编辑 | 点赞列表 | 点赞正文 | 评论正文 | 转发正文 | 点赞评论 )
- /// 删除
- - (void)deleteButtonHander{
- WS(weakSelf);
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认撤回" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf cancelAction];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
- }];
- }
- - (void)cancelAction
- {
- WS(weakSelf);
- switch (self.type) {
- case CollectModel_Toipc:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Topic),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.deleteTopicBlock) {
- weakSelf.deleteTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
-
- }];
- }
- break;
- case CollectModel_NewTopic:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.deleteTopicBlock) {
- weakSelf.deleteTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- break;
- case CollectModel_Group:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.deleteTopicBlock) {
- weakSelf.deleteTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_Notice:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NOTICE_RECALL),(long)self.Id];
- [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.deleteTopicBlock) {
- weakSelf.deleteTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_NoteBook:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.deleteTopicBlock) {
- weakSelf.deleteTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_meetMian:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/api/app/meeting/summary/"),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.deleteTopicBlock) {
- weakSelf.deleteTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- break;
- default:
- break;
- }
- }
- /// 编辑
- - (void)editorButtonHander{
- self.webH = 0;
- WS(weakSelf);
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- vc.isEdit = YES;
- vc.FolderId = self.currentNoteModel.FolderId;
- vc.FolderName = self.currentNoteModel.FolderId == 0 ? @"根目录" :self.currentNoteModel.FolderName;
- vc.replayType = MailReplayEdit;
- vc.type = self.type;
- vc.Id = self.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /// 转发正文
- - (void)ShareDetail{
- SHOWLOADING
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.Id) forKey:@"SourceId"];
- [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setValue:@(4) forKey:@"AnalyzeType"];///转发
- [dic setValue:@(0) forKey:@"CommentId"];
- [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- [weakSelf refreshData];
- weakSelf.IsShareText = NO;
- [weakSelf shareHander];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 点赞正文
- - (void)gotoZanHander{
- SHOWLOADING
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.Id) forKey:@"SourceId"];
- [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setValue:@(1) forKey:@"AnalyzeType"];//详情点赞
- [dic setValue:@(0) forKey:@"CommentId"];
- [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- [weakSelf refreshData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 评论正文
- - (void)commentHander{
- [_commentInputView startEditing];
- WEAKSELF
- self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
- NSLog(@"%@",content);
- [weakSelf sendCommentToServerWithcontent:content];
- };
- }
- - (void)sendCommentToServerWithcontent:(NSString *)content
- {
- WS(weakSelf);
- NSMutableDictionary *dicc = [NSMutableDictionary dictionary];
- [dicc setValue:@(self.Id) forKey:@"ArticleId"];
- [dicc setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dicc setValue:content forKey:@"Content"];
- [dicc setValue:@(0) forKey:@"Pid"];//回复评论时用到的ID
- [dicc setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- NSLog(@"%@",dicc);
-
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_Add) parameters:dicc responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"评论成功");
- weakSelf.countComment ++;
- if (weakSelf.countComment == 0) {
- self.commentCountL.text = [NSString stringWithFormat:@"评 论"];
- }else{
- if (weakSelf.countComment > 10000) {
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"%.1f万\n评 论",weakSelf.countComment / 10000.0];
- }else{
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"%ld\n评 论",(long)weakSelf.countComment];
- }
- }
- [weakSelf RefreshCommentList];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 转发正文
- - (void)shareHander{
- [self.noteBookShareVC initNoteBookShareData];
- self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
- }
- - (NoteBookShareVC *)noteBookShareVC{
- if (_noteBookShareVC == nil) {
- _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC];
- [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
- [_noteBookShareVC.view setHidden:YES];
- _noteBookShareVC.delegate = self;
- }
- return _noteBookShareVC;
- }
- -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{
- self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
- if ([typeName isEqualToString:@"发给微信好友"]) {
-
- }else if ([typeName isEqualToString:@"发到朋友圈"]){
-
- }else if ([typeName isEqualToString:@"发到微博"]){
-
- }else if ([typeName isEqualToString:@"发给QQ好友"]){
-
- }else if ([typeName isEqualToString:@"发到消息"]){
-
- }else if ([typeName isEqualToString:@"发到小组"]){
- [self returnToGroup];
- }else if ([typeName isEqualToString:@"发到笔记"]){
- [self returnToNote];
- }else if ([typeName isEqualToString:@"发到话题"]){
- [self returnToTopic];
- }else{
- }
- }
- #pragma mark - 分享功能
- - (void)returnToGroup
- {
- MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init];
- vc.type = CollectModel_Group;
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName;
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)returnToNote
- {
- MoveViewController * vc = [MoveViewController initMoveViewController];
- vc.isFromCreateBookVc = YES;
- vc.TypeId = CreateNotesType;
- vc.ParentId = 0;
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- if (self.IsShareText) {
- model.Title = self.shareText;
- model.SoureTypeId = 1;
- }else{
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName;
- vc.type = CollectModel_NoteBook;
- }
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)returnToTopic
- {
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.type = CollectModel_NewTopic;
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- if (self.IsShareText) {
- model.Title = self.shareText;
- model.SoureTypeId = 1;
- }else{
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName;
- vc.type = CollectModel_NewTopic;
- }
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /// 点赞评论
- - (void)gotoZanCommentHanderModel:(MHTopic *)model indexPath:(NSIndexPath *)indexPath{
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.Id) forKey:@"SourceId"];
- [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setValue:@(2) forKey:@"AnalyzeType"];//详情点赞
- [dic setValue:@(model.Id) forKey:@"CommentId"];
- [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- WS(weakSelf);
-
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- model.IsLaud = !model.IsLaud;
- if (model.IsLaud) {
- SHOWSUCCESS(@"点赞成功");
- }else{
- SHOWSUCCESS(@"取消点赞");
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- });
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)gotoCollectHander{
- MoveViewController *vc = [MoveViewController initMoveViewController];
- // NSInteger meetId = [self.dataDict[@"MeetingId"] integerValue];
- vc.CollectionDataId = self.Id;
- vc.collectType = CollectHanderType_Collect;
- vc.ParentId = 0;
- vc.titleStr = @"我的收藏";
- vc.TypeId = CreateCollectionType;
- vc.FolderIds = @[].mutableCopy;
- // 收藏类型 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
- vc.CollectionType = self.type == CreateMeetingType ? 400 : self.type;
- WS(weakSelf);
- vc.actionSuss = ^(NSString * _Nonnull status) {
- if ([status isEqualToString:@"YES"]) {
- [weakSelf refreshData];
- }
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (NSMutableArray<MyNoteBookCommentSubModel *> *)commentArray{
- if (!_commentArray) {
- _commentArray = [NSMutableArray array];
- }
- return _commentArray;
- }
- - (TextInputView *)commentInputView {
- if (!_commentInputView) {
- _commentInputView = [[TextInputView alloc] initWithFrame:[UIScreen mainScreen].bounds];
- }
- return _commentInputView;
- }
- #pragma mark - MHTopicCellDelegate
- - (void)topicCellForClickedThumbAction:(MHTopicCell *)topicCell
- {
- /**
- * 这里点击事件自行根据自己UI处理
- *
- */
- NSLog(@"---点击👍按钮---");
- }
- - (void)topicCellForClickedMoreAction:(MHTopicCell *)topicCell
- {
- /**
- * 这里点击事件自行根据自己UI处理
- *
- */
- // 修改数据源方法
- MHTopic *topic = topicCell.topicFrame.topic;
- topic.IsLaud = !topic.IsLaud;
- if (topic.IsLaud) {
- // topic.thumbNums+=1;
- // }else{
- // topic.thumbNums-=1;
- }
-
- // 刷新数据
- [self.tableView reloadData];
- }
- - (void)topicCellDidClickedUser:(MHTopicCell *)topicCell
- {
- NSLog(@"======%ld",(long)topicCell.topicFrame.topic.UserId);
- MailListDetailVC * vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = topicCell.topicFrame.topic.UserId;
- [self.navigationController pushViewController:vc animated:YES];
- // MHUserInfoController *userInfo = [[MHUserInfoController alloc] init];
- // userInfo.user = topicCell.topicFrame.topic.user;
- // [self.navigationController pushViewController:userInfo animated:YES];
- }
- - (void)topicCell:(MHTopicCell *)topicCell didClickedUser:(NSString *)userId
- {
- NSLog(@"======%@",userId);
-
- // MHUserInfoController *userInfo = [[MHUserInfoController alloc] init];
- // userInfo.user = user;
- // [self.navigationController pushViewController:userInfo animated:YES];
- }
- - (void)topicCell:(MHTopicCell *)topicCell didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- MHTopicFrame *topicFrame = topicCell.topicFrame;
- MHCommentFrame *commentFrame = topicFrame.commentFrames[indexPath.row];
- NSLog(@"这里回复 -- :%@",commentFrame.comment.Id);
- if (commentFrame.comment.UserId != [AppUserModel sharedAppUserModel].Id) {
- [self replyCommentName:commentFrame.comment.Name andId:commentFrame.comment.Id];
- }
- }
- #pragma mark - 长按删除评论Cell
- - (void)longDeleteSelf:(MHTopicCell *)cell
- {
- [self becomeFirstResponder];
- UIMenuController *menu = [UIMenuController sharedMenuController];
- UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemAction:)];
- [menu setMenuItems: @[deleteItem]];
- NSLog(@"%@",NSStringFromCGRect(cell.frame));
- [menu setTargetRect:cell.contentLabel.frame inView:cell];
- [menu setMenuVisible:YES animated:NO];
- }
- - (void)longDeleteSubCell:(UILabel *)label
- {
- [self becomeFirstResponder];
- UIMenuController *menu = [UIMenuController sharedMenuController];
- UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemAction:)];
- [menu setMenuItems: @[deleteItem]];
- [menu setTargetRect:label.frame inView:label];
- [menu setMenuVisible:YES animated:NO];
- }
- -(BOOL)canBecomeFirstResponder
- {
- return YES;
- }
- //是否可以接收某些菜单的某些交互操作
- -(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
- return (action == @selector(deleteItemAction:));
- }
- - (void)deleteItemAction:(UIMenuItem *)item
- {
- WS(weakSelf);
- SHOWLOADING
- [[HttpManager sharedHttpManager] DeleteUrl:Host(API_APP_Comment_Delete) parameters:@{@"ArticleId":@(self.Id),@"CommentId":@(self.commentId)} responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- SHOWSUCCESS(@"删除成功");
- [weakSelf RefreshCommentList];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }
- - (void)replyCommentName:(NSString *)name andId:(NSString *)commentId{
- [_commentInputView startEditing];
- [_commentInputView setPlaceText:[NSString stringWithFormat:@"回复%@:",name]];
- WEAKSELF
- self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
- NSLog(@"%@",content);
- [weakSelf replyCommentWithcontent:content andId:commentId];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- };
- }
- - (void)replyCommentWithcontent:(NSString *)content andId:(NSString *)commentId
- {
- WS(weakSelf);
- NSMutableDictionary *dicc = [NSMutableDictionary dictionary];
- [dicc setValue:@(self.Id) forKey:@"ArticleId"];
- [dicc setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dicc setValue:content forKey:@"Content"];
- [dicc setValue:commentId forKey:@"Pid"];//回复评论时用到的ID
- [dicc setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- NSLog(@"%@",dicc);
-
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_Add) parameters:dicc responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"评论成功");
- [weakSelf RefreshCommentList];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)scrollToCommentViewTop
- {
- if (self.isScrComment) {
- if (self.commentArray.count > 0 || self.currentZanModel.Items.count > 0) {
- NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
- [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
- }
- }else{
- [self.tableView scrollToTop];
- }
- }
- - (WKWebView *)webView
- {
- if (!_webView) {
- WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
- // 实例化对象
- WKUserContentController* userContent = [[WKUserContentController alloc] init];
- [userContent addScriptMessageHandler:self name:@"delelteAction"];
- [userContent addScriptMessageHandler:self name:@"editAction"];
- [userContent addScriptMessageHandler:self name:@"postTopicDetailsData"];
- [userContent addScriptMessageHandler:self name:@"alreadyRead"];
- [userContent addScriptMessageHandler:self name:@"to"];
- [userContent addScriptMessageHandler:self name:@"goMeeting"];
- [userContent addScriptMessageHandler:self name:@"goUser"];
- [userContent addScriptMessageHandler:self name:@"goRead"];
- [userContent addScriptMessageHandler:self name:@"postH"];
- [userContent addScriptMessageHandler:self name:@"postSave"];
- NSMutableString *javascript = [NSMutableString string];
- [javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
- // [javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
- WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:javascript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
- [userContent addUserScript:noneSelectScript];
- configuration.userContentController = userContent;
- WKPreferences *preferences = [WKPreferences new];
- preferences.javaScriptCanOpenWindowsAutomatically = YES;
- preferences.minimumFontSize = 10.0;
- configuration.preferences = preferences;
- // 初始化WKWebView
- _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
- _webView.scrollView.scrollEnabled = NO;
- _webView.scrollView.bounces = NO;
- _webView.scrollView.showsVerticalScrollIndicator = NO;
- _webView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- }
- return _webView;
- }
- - (void)loadDataWebView
- {
- NSString * url = nil;
- switch (self.type) {
- case CollectModel_Group:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_Toipc:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_NewTopic:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_NoteBook:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_Notice:
- {
- url = @"/mobile/noticeDetails";
- }
- break;
- case CollectModel_InterMail:
- {
- url = @"/mobile/mail";
- }
- break;
- case CollectModel_meetMian:
- {
- url = @"/mobile/minutesMeeting";
- }
- break;
- default:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- }
- NSURL *pathUrl = [NSURL URLWithString:HtmlHost(url)];
- // NSURL *pathUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.0.119:8080%@",url]];
- NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
- [self.webView loadRequest:request];
- [self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
- /** < 法2 > */
- /** < loading:防止滚动一直刷新,出现闪屏 > */
- if ([keyPath isEqualToString:@"contentSize"]) {
- CGFloat H = self.webView.scrollView.contentSize.height;
- NSLog(@"=========== webH :%f",H);
- if (self.webH != H && H != 0) {
- self.webH = H;
- self.tableView.sectionHeaderHeight = self.webH;
- [self.webView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.webH)];
- [self setBottomViewData:self.currentNoteModel];
- [self.tableView reloadData];
- }
- }
- }
- #pragma mark - WKScriptMessageHandler
- - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
- if ([message.name isEqualToString:@"delelteAction"]) {
- [self deleteButtonHander];
- }
- if ([message.name isEqualToString:@"editAction"]) {
- [self editorButtonHander];
- }
- if ([message.name isEqualToString:@"postTopicDetailsData"]) {
- NSString *jsonString = [NSString stringWithFormat:@"getData('%ld','%@','%ld')",(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.type];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- }
- if ([message.name isEqualToString:@"postH"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger H = [message.body integerValue];
- self.tableView.sectionHeaderHeight = self.webH - H;
- [self.webView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.webH - H)];
- [self.tableView reloadData];
- }
- if ([message.name isEqualToString:@"postSave"]) {
- NSString * imgUrl = message.body;
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"保存图片" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- UIImage * img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgUrl]]];
- [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
- [PHAssetChangeRequest creationRequestForAssetFromImage:img];
- } completionHandler:^(BOOL success, NSError * _Nullable error) {
- dispatch_async(dispatch_get_main_queue(), ^{
- if (success) {
- SHOWSUCCESS(@"图片保存成功");
- }else{
- SHOWERROR(@"图片保存失败");
- }
- });
- }];
- }];
- UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:actionYes];
- [alert addAction:actionNo];
- [self presentViewController:alert animated:YES completion:^{
- }];
- }
- if ([message.name isEqualToString:@"alreadyRead"]) {
- NSLog(@"msgBody:%@",message.body);
- NSDictionary * dict = (NSDictionary *)message.body;
- NoticeUnreadVC *vc = [NoticeUnreadVC initNoticeUnreadVC];
- vc.Id = self.Id;
- switch (self.type) {
- case CollectModel_Notice:
- vc.type = ReadNoticeType;
- break;
- case CollectModel_InterMail:
- vc.type = ReadMissiveType;
- break;
- default:
- vc.type = ReadNoticeType;
- break;
- }
- vc.readCount = [dict[@"ReadCount"] integerValue];
- vc.unReadCount = [dict[@"AllCount"] integerValue] - [dict[@"ReadCount"] integerValue];
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([message.name isEqualToString:@"to"]) {
- NSLog(@"msgBody:%@",message.body);
- NSDictionary * dict = (NSDictionary *)message.body;
- [self pushVCWithDict:dict];
- }
- if ([message.name isEqualToString:@"goMeeting"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger meetId = [message.body integerValue];
- WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:meetId];
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([message.name isEqualToString:@"goUser"]) {
- NSLog(@"msgBody:%@",message.body);
- MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = self.sendUserId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([message.name isEqualToString:@"goRead"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger count = [message.body integerValue];
- ReadListVC * vc = [ReadListVC initReadListVC];
- vc.type = self.type == CollectModel_Aritle ? 1 : self.type;
- vc.indexId = self.Id;
- vc.ReadTotal = count;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- #pragma mark - WKScriptMessageHandler
- - (NSString *)convertToJson:(NSDictionary *)dict
- {
- NSError *error;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString;
- if (!jsonData) {
- NSLog(@"%@",error);
- }else{
- jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
- NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
- NSRange range = {0,jsonString.length};
- //去掉字符串中的空格
- [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
- NSRange range2 = {0,mutStr.length};
- //去掉字符串中的换行符
- [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
- return mutStr;
- }
- #pragma mark - WKUIDelegete
- - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
- {
- NSLog(@"Aleart=========%@",message);
- completionHandler();
- }
- - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(BOOL))completionHandler
- {
- completionHandler(YES);
- }
- - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(nonnull NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(NSString * _Nullable))completionHandler
- {
- completionHandler(@"111");
- }
- - (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)dealloc {
- WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
- [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
- completionHandler:^(NSArray * __nonnull records) {
- for (WKWebsiteDataRecord *record in records)
- {
- [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
- forDataRecords:@[record]
- completionHandler:^{
- NSLog(@"Cookies for %@ deleted successfully",record.displayName);
- }];
- }
- }];
-
- WKUserContentController *userCC = self.webView.configuration.userContentController;
- [userCC removeScriptMessageHandlerForName:@"delelteAction"];
- [userCC removeScriptMessageHandlerForName:@"editAction"];
- [userCC removeScriptMessageHandlerForName:@"postTopicDetailsData"];
- [userCC removeScriptMessageHandlerForName:@"alreadyRead"];
- [userCC removeScriptMessageHandlerForName:@"to"];
- [userCC removeScriptMessageHandlerForName:@"goMeeting"];
- [userCC removeScriptMessageHandlerForName:@"goUser"];
- [userCC removeScriptMessageHandlerForName:@"goRead"];
- [userCC removeScriptMessageHandlerForName:@"postH"];
- [userCC removeScriptMessageHandlerForName:@"postSave"];
- [self.webView.scrollView removeObserver:self forKeyPath:@"contentSize"];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [self.webView stopLoading];
- self.webView.UIDelegate = nil;
- self.webView.navigationDelegate = nil;
- self.webView.scrollView.delegate = nil;
- [self.webView removeFromSuperview];
- }
- - (NSInteger)backTypeValue
- {
- switch (self.type) {
- case CollectModel_Group:
- {
- return 1;
- }
- break;
- case CollectModel_Toipc:
- {
- return 1;
- }
- break;
- case CollectModel_Notice:
- {
- return 2;
- }
- break;
- case CollectModel_NewTopic:
- {
- return 3;
- }
- break;
- case CollectModel_NoteBook:
- {
- return 3;
- }
- break;
- case CollectModel_meetMian:
- {
- return 10;
- }
- break;
- case CollectModel_InterMail:
- {
- return 4;
- }
- break;
- default:
- {
- return 1;
- }
- break;
- }
- }
- - (void)refreshData
- {
- switch (self.type) {
- case CollectModel_Group:
- {
- [self refreshTopicData];
- }
- break;
- case CollectModel_Toipc:
- {
- [self refreshTopicData];
- }
- break;
- case CollectModel_NewTopic:
- {
- [self refreshNoteData];
- }
- break;
- case CollectModel_Notice:
- {
- [self refreshNoticeData];
- }
- break;
- case CollectModel_NoteBook:
- {
- [self refreshNoteData];
- }
- break;
- case CollectModel_InterMail:
- {
- [self getMail];
- }
- break;
- case CollectModel_meetMian:
- {
- [self refreshMeetingData];
- }
- break;
- default:
- {
- [self refreshTopicData];
- }
- break;
- }
- }
- #pragma mark - UIMenuController
- //指定menu响应事件 屏蔽系统自带响应事件
- //- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
- // NSLog(@"%@", NSStringFromSelector(action));
- // if (action == @selector(tySelectedAll:)
- // ||action == @selector(shareSelectedText:)) {
- // return YES;
- // }
- // if (action == @selector(cut:)
- // ||action == @selector(select:)
- // ||action == @selector(selectAll:)
- // ||action == @selector(paste:)
- // ||action == @selector(delete:)
- // ||action == @selector(makeTextWritingDirectionRightToLeft:)
- // ||action == @selector(makeTextWritingDirectionLeftToRight:)) {
- // return NO;
- // }
- // return NO;
- //}
- //- (void)viewWillDisappear:(BOOL)animated{
- // [super viewWillDisappear:animated];
- // self.dismissSelf = YES;
- //}
- ////允许成为第一响应
- //- (BOOL)canBecomeFirstResponder {
- // return YES;
- //}
- //- (BOOL)canResignFirstResponder {
- // if (self.dismissSelf) {
- // return YES;
- // }
- // return NO;
- //}
- //
- //- (void)tySelectedAll:(UIMenuController *)menu{
- //
- // [self.webView selectAll:menu];
- // self.dismissSelf = YES;
- //}
- //#pragma mark 实现自定义方法
- //- (void)shareSelectedText:(UIMenuController *)menu {
- // WS(weakSelf);
- // [self.webView evaluateJavaScript:@"window.getSelection().toString()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- // NSLog(@"选中的文字为:%@", data);
- // [self.webView copy:data];
- // weakSelf.shareText = data;
- // if (weakSelf.shareText.length > 0) {
- // weakSelf.IsShareText = YES;
- // [weakSelf shareHander];
- // }
- // }];
- //}
- //- (void)createMenuItems
- //{
- // UIMenuController * menu = [UIMenuController sharedMenuController];
- // UIMenuItem *item1 = [[UIMenuItem alloc]initWithTitle:@"全选" action:@selector(tySelectedAll:)];
- // UIMenuItem *item2 = [[UIMenuItem alloc]initWithTitle:@"转发" action:@selector(shareSelectedText:)];
- // [menu setMenuItems:@[item1, item2]];
- // menu.menuVisible = YES;
- //}
- @end
|