MyTDTopicCreateVC.m 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101
  1. //
  2. // MyTDTopicCreateVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicCreateVC.h"
  9. #import "LYLPhotoTailoringTool.h"
  10. #import "FWZFileGetTool.h"
  11. #import "FWZGetNoteBookTool.h"
  12. #import "RichTextEditViewController.h"
  13. #import "AddLookUpUserSecondVC.h"
  14. #import "MyTDTopicSelectExtentVC.h"
  15. #import "FecordJoinWorkFlowListController.h"
  16. #import "_NoInputAccessoryView.h"
  17. #import "SelectSaveVC.h"
  18. #import "ShowBtn.h"
  19. #import "HomeDetailController.h"
  20. #import "ChatMsgNoticeDetailVC.h"
  21. #import "NoteBookDetailVC.h"
  22. #import "MyFavoriteVC.h"
  23. #import "NoteBookVC.h"
  24. #import "TDInterLeterDetailVC.h"
  25. #import "FileOpenViewController.h"
  26. #import "EMChatFileShowVC.h"
  27. #import "NoticeUnreadVC.h"
  28. #import "TDGroupInfoListVC.h"
  29. #import "DownFileViewController.h"
  30. #import "CountDataVC.h"
  31. #import "WorkFlowDetailsController.h"
  32. #import "MyTDGroupViewController.h"
  33. #import "MoveViewController.h"
  34. #import "ShowKeepNoticeAlert.h"
  35. #import "YCMenuView.h"
  36. #import "MyApprovalPageDetail.h"
  37. #import "OtherNoteBookVC.h"
  38. #import "OtherFavoriteVC.h"
  39. #import "TopicShowListView.h"
  40. #import "MyTDTopicBookVC.h"
  41. #import <objc/runtime.h>
  42. #import "GroupShowListView.h"
  43. #import "BookWCDetailVC.h"
  44. #import "BookListenVC.h"
  45. @interface MyTDTopicCreateVC ()<WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
  46. @property (weak, nonatomic) IBOutlet UIView *NavBarV;
  47. @property (weak, nonatomic) IBOutlet UIButton *DoneBtn;
  48. @property (nonatomic,strong) WKWebView *webView;
  49. @property (weak, nonatomic) IBOutlet UILabel *TitleL;
  50. @property (nonatomic,assign) CGFloat keyBoardH;
  51. @property (nonatomic,assign) BOOL isShoujianren;
  52. @property (nonatomic,assign) BOOL isChaosongren;
  53. @property (nonatomic,assign) BOOL isNull;
  54. @property (nonatomic,assign) NSInteger meetingId;
  55. @property (nonatomic,assign) NSInteger shouType;
  56. @property (nonatomic,strong) NSMutableArray <SelectModel *> *chaoShongArray;
  57. @property (nonatomic,strong) NSMutableArray <SelectModel *> *shouJianArray;
  58. @property (nonatomic,strong) NSMutableArray * MeetingArray;
  59. @property (strong, nonatomic) ShowBtn * titleBtn;
  60. @property (strong, nonatomic) TopicShowListView * menuListView;
  61. @property (assign, nonatomic) BOOL menuIsShow;
  62. @property (strong, nonatomic) GroupShowListView * GroupListView;
  63. @property (assign, nonatomic) BOOL GroupIsShow;
  64. @property (copy, nonatomic) NSDictionary * H5JsonDict;
  65. @end
  66. @implementation MyTDTopicCreateVC
  67. + (MyTDTopicCreateVC *)initMyTDTopicCreateVC{
  68. MyTDTopicCreateVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicCreateVC"];
  69. return controller;
  70. }
  71. - (TopicShowListView *)menuListView
  72. {
  73. if (!_menuListView) {
  74. _menuListView = [TopicShowListView share:self.NavBarV];
  75. }
  76. return _menuListView;
  77. }
  78. - (GroupShowListView *)GroupListView
  79. {
  80. if (!_GroupListView) {
  81. _GroupListView = [GroupShowListView share:self.NavBarV];
  82. }
  83. return _GroupListView;
  84. }
  85. - (void)viewWillDisappear:(BOOL)animated
  86. {
  87. [super viewWillDisappear:animated];
  88. [self.titleBtn dismiss];
  89. self.menuIsShow = NO;
  90. [self.menuListView dismiss];
  91. self.GroupIsShow = NO;
  92. [self.GroupListView dismiss];
  93. }
  94. - (ShowBtn *)titleBtn
  95. {
  96. if (!_titleBtn) {
  97. _titleBtn = [[ShowBtn alloc] init];
  98. }
  99. return _titleBtn;
  100. }
  101. - (void)setShowTopicData
  102. {
  103. self.menuIsShow = NO;
  104. WS(weakSelf);
  105. [self.titleBtn setAction:^{
  106. if (!weakSelf.menuIsShow) {
  107. [weakSelf.menuListView show];
  108. [weakSelf.titleBtn show];
  109. weakSelf.menuListView.ClickRowBlock = ^(BOOL isPush, NSInteger Id, NSString * _Nonnull Name) {
  110. [weakSelf.titleBtn dismiss];
  111. [weakSelf.menuListView dismiss];
  112. if (isPush) {
  113. MyTDTopicBookVC * vc = [MyTDTopicBookVC initMyTDTopicBookVC];
  114. vc.isSelect = YES;
  115. [weakSelf.navigationController pushViewController:vc animated:YES];
  116. }else{
  117. weakSelf.FolderId = Id;
  118. weakSelf.FolderName = Name;
  119. [weakSelf setSelectTopicBook:Name];
  120. }
  121. };
  122. weakSelf.menuListView.dismissBlock = ^{
  123. [weakSelf.titleBtn dismiss];
  124. };
  125. weakSelf.menuIsShow = YES;
  126. }else{
  127. weakSelf.menuIsShow = NO;
  128. [weakSelf.titleBtn dismiss];
  129. [weakSelf.menuListView dismiss];
  130. }
  131. }];
  132. }
  133. - (void)setShowGroupData
  134. {
  135. self.GroupIsShow = NO;
  136. WS(weakSelf);
  137. [self.titleBtn setAction:^{
  138. if (!weakSelf.GroupIsShow) {
  139. [weakSelf.GroupListView show];
  140. [weakSelf.titleBtn show];
  141. weakSelf.GroupListView.ClickRowBlock = ^(BOOL isPush, NSInteger Id, NSString * _Nonnull Name) {
  142. [weakSelf.titleBtn dismiss];
  143. [weakSelf.GroupListView dismiss];
  144. if (isPush) {
  145. MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init];
  146. vc.isSelect = YES;
  147. [weakSelf.navigationController pushViewController:vc animated:YES];
  148. }else{
  149. weakSelf.FolderId = Id;
  150. weakSelf.FolderName = Name;
  151. [weakSelf setSelectTopicBook:Name];
  152. }
  153. };
  154. weakSelf.GroupListView.dismissBlock = ^{
  155. [weakSelf.titleBtn dismiss];
  156. };
  157. weakSelf.GroupIsShow = YES;
  158. }else{
  159. weakSelf.GroupIsShow = NO;
  160. [weakSelf.titleBtn dismiss];
  161. [weakSelf.GroupListView dismiss];
  162. }
  163. }];
  164. }
  165. -(NSMutableArray *)getMenuDataSource{
  166. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  167. NSArray * titleArray = @[@"写通知",@"写信件",@"匿名信"];
  168. for(int i = 0;i < titleArray.count;i ++){
  169. NSString *titleStr = [titleArray objectAtIndex:i];
  170. WS(weakSelf);
  171. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  172. [weakSelf autoSizeBtn:action.title];
  173. if([@"写通知" isEqualToString:action.title]){
  174. weakSelf.MailType = 3;
  175. weakSelf.type = CollectModel_Notice;
  176. weakSelf.shouType = 5;
  177. }else if([@"写信件" isEqualToString:action.title]){
  178. weakSelf.MailType = 1;
  179. weakSelf.type = CollectModel_InterMail;
  180. weakSelf.shouType = 6;
  181. }else{
  182. weakSelf.MailType = 2;
  183. weakSelf.type = CollectModel_InterMail;
  184. weakSelf.shouType = 18;
  185. }
  186. }];
  187. [menuDataSourceArray addObject:actionMenu];
  188. }
  189. return menuDataSourceArray;
  190. }
  191. - (void)autoSizeBtn:(NSString *)title
  192. {
  193. if (![title isKindOfClass:[NSNull class]]) {
  194. if (title.length > 8) {
  195. NSRange range1 = NSMakeRange(8, title.length - 8);
  196. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  197. [self.titleBtn setLabelTitle:resultStr1];
  198. }else{
  199. [self.titleBtn setLabelTitle:title];
  200. }
  201. WS(weakSelf);
  202. [self.titleBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  203. make.center.mas_equalTo(weakSelf.NavBarV);
  204. }];
  205. [self.NavBarV layoutIfNeeded];
  206. }
  207. }
  208. - (void)viewDidLoad {
  209. [super viewDidLoad];
  210. [self.DoneBtn setEnabled:NO];
  211. self.isNull = YES;
  212. self.fd_prefersNavigationBarHidden = YES;
  213. WS(weakSelf);
  214. [self.DoneBtn setAction:^{
  215. weakSelf.isDraft = NO;
  216. [weakSelf submit];
  217. }];
  218. [self.NavBarV addSubview:self.titleBtn];
  219. [self.titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.center.mas_equalTo(weakSelf.NavBarV);
  221. }];
  222. [self.view addSubview:self.webView];
  223. [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
  224. make.top.mas_equalTo(weakSelf.NavBarV.mas_bottom);
  225. make.left.right.mas_equalTo(weakSelf.view);
  226. if (@available(iOS 11.0, *)) {
  227. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  228. } else {
  229. make.bottom.equalTo(weakSelf.view.mas_bottom);
  230. }
  231. }];
  232. self.webView.UIDelegate = self;
  233. self.shouType = 5;
  234. // 导航代理
  235. self.webView.navigationDelegate = self;
  236. self.webView.scrollView.delegate = self;
  237. // self.automaticallyAdjustsScrollViewInsets = YES;
  238. NSURL *pathUrl = [NSURL URLWithString:HtmlHost(@"/mobile/appeditor")];
  239. // NSURL *pathUrl = [NSURL URLWithString:@"http://192.168.0.111:8080/admin/mobile/editor"];
  240. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  241. [self.webView loadRequest:request];
  242. // [self hideWKWebviewKeyboardShortcutBar:self.webView];
  243. switch (self.type) {
  244. case CollectModel_Notice:
  245. {
  246. self.TitleL.hidden = YES;
  247. self.titleBtn.hidden = NO;
  248. // self.TitleL.text = @"写通知";
  249. [self selectMailType];
  250. switch (self.MailType) {
  251. case 1:
  252. {
  253. [self autoSizeBtn:@"写信件"];
  254. self.MailType = 1;
  255. }
  256. break;
  257. case 2:
  258. {
  259. [self autoSizeBtn:@"匿名信"];
  260. self.MailType = 2;
  261. }
  262. break;
  263. default:
  264. {
  265. [self autoSizeBtn:@"写通知"];
  266. self.MailType = 3;
  267. }
  268. break;
  269. }
  270. }
  271. break;
  272. case CollectModel_Toipc:
  273. {
  274. if (self.isGroupRoot) {
  275. [self setShowGroupData];
  276. self.TitleL.hidden = YES;
  277. self.titleBtn.hidden = NO;
  278. [self autoSizeBtn:@"选择小组"];
  279. }else{
  280. self.TitleL.hidden = NO;
  281. self.titleBtn.hidden = YES;
  282. self.TitleL.text = @"新建话题";
  283. }
  284. }
  285. break;
  286. case CollectModel_NewTopic:
  287. {
  288. [self setShowTopicData];
  289. self.TitleL.hidden = YES;
  290. self.titleBtn.hidden = NO;
  291. if (self.FolderName.length > 0) {
  292. [self autoSizeBtn:self.FolderName];
  293. }else{
  294. [self getTopicDefault];
  295. }
  296. }
  297. break;
  298. case CollectModel_NoteBook:
  299. {
  300. [self selectFold];
  301. self.TitleL.hidden = YES;
  302. self.titleBtn.hidden = NO;
  303. if (self.FolderId > 0) {
  304. [self autoSizeBtn:self.FolderName];
  305. }else{
  306. [self getNoteDefault];
  307. }
  308. }
  309. break;
  310. case CollectModel_Group:
  311. {
  312. self.TitleL.hidden = NO;
  313. self.titleBtn.hidden = YES;
  314. self.TitleL.text = @"新建话题";
  315. }
  316. break;
  317. case CollectModel_InterMail:
  318. {
  319. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  320. self.TitleL.hidden = NO;
  321. self.titleBtn.hidden = YES;
  322. self.TitleL.text = @"回复信函";
  323. self.shouType = 6;
  324. }else{
  325. self.TitleL.hidden = YES;
  326. self.titleBtn.hidden = NO;
  327. [self selectMailType];
  328. switch (self.MailType) {
  329. case 1:
  330. {
  331. [self autoSizeBtn:@"写信件"];
  332. }
  333. break;
  334. case 2:
  335. {
  336. [self autoSizeBtn:@"匿名信"];
  337. }
  338. break;
  339. default:
  340. {
  341. [self autoSizeBtn:@"写通知"];
  342. }
  343. break;
  344. }
  345. }
  346. }
  347. break;
  348. case CollectModel_meetMian:
  349. {
  350. self.TitleL.hidden = NO;
  351. self.titleBtn.hidden = YES;
  352. self.TitleL.text = @"会议纪要";
  353. }
  354. break;
  355. case CollectModel_NoSignMail:
  356. {
  357. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  358. self.TitleL.hidden = NO;
  359. self.titleBtn.hidden = YES;
  360. self.TitleL.text = @"回复信函";
  361. self.shouType = 6;
  362. }else{
  363. self.TitleL.hidden = YES;
  364. self.titleBtn.hidden = NO;
  365. [self selectMailType];
  366. [self autoSizeBtn:@"匿名信"];
  367. }
  368. }
  369. break;
  370. default:
  371. break;
  372. }
  373. if (self.isReturn) {
  374. [self.DoneBtn setTitle:@"完成" forState:UIControlStateNormal];
  375. }else{
  376. if (self.type == CollectModel_NewTopic || self.type == CollectModel_Toipc || self.type == CollectModel_NoteBook) {
  377. [self.DoneBtn setTitle:@"完成" forState:UIControlStateNormal];
  378. }else{
  379. [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
  380. }
  381. }
  382. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangeTopicBookBtn:) name:SELECTETOPICBOOK object:nil];
  383. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangetitleBtn:) name:SELECTEXTENTSUCCESS object:nil];
  384. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectMeetSearch:) name:SELECTMEETFECORD object:nil];
  385. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  386. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
  387. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
  388. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectFolder:) name:NOTIFI_SELECTCREATENOTEFOLDER object:nil];
  389. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newFileSuccess:) name:NEWFILESUCCESS object:nil];
  390. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(SaveNoteBook:) name:NOTEBOOKSAVE object:nil];
  391. }
  392. - (void)selectMailType
  393. {
  394. WS(weakSelf);
  395. [self.titleBtn setAction:^{
  396. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource];
  397. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:114 relyonView:weakSelf.titleBtn];
  398. view.menuColor = RGB(255, 255, 255);
  399. view.separatorColor = RGB(234, 234, 234);
  400. view.textColor = RGB(102, 102, 102);
  401. view.textFont = [UIFont systemFontOfSize:16.0];
  402. view.menuCellHeight = 43.5;
  403. view.maxDisplayCount = 10;
  404. view.offset = -6;
  405. [view show];
  406. }];
  407. }
  408. - (void)upDateAction:(NSString *)action
  409. {
  410. [self.webView evaluateJavaScript:action completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  411. NSLog(@"data=====%@",data);
  412. NSLog(@"error=====%@",error);
  413. }];
  414. }
  415. - (void)getTopicDefault
  416. {
  417. WS(weakSelf);
  418. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),-4];
  419. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  420. dispatch_async(dispatch_get_main_queue(), ^{
  421. NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  422. if (MiddleId > 0) {
  423. weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  424. [weakSelf setSelectTopicBook:[responseObject objectForKey:@"FolderName"]];
  425. }else{
  426. weakSelf.FolderId = 0;
  427. [weakSelf autoSizeBtn:@"公开"];
  428. }
  429. });
  430. } failure:^(NSError * _Nonnull error) {
  431. }];
  432. }
  433. - (void)getNoteDefault
  434. {
  435. WS(weakSelf);
  436. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),4];
  437. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  438. dispatch_async(dispatch_get_main_queue(), ^{
  439. NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  440. if (MiddleId > 0) {
  441. weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  442. [weakSelf autoSizeBtn:[responseObject objectForKey:@"FolderName"]];
  443. }else{
  444. weakSelf.FolderId = 0;
  445. [weakSelf autoSizeBtn:@"根目录"];
  446. }
  447. });
  448. } failure:^(NSError * _Nonnull error) {
  449. }];
  450. }
  451. - (void)selectFold{
  452. WS(weakSelf);
  453. [self.titleBtn setAction:^{
  454. SelectSaveVC * vc = [SelectSaveVC initSelectSaveVC];
  455. vc.isFromCreateBookVc = YES;
  456. vc.TypeId = CreateNotesType;
  457. vc.ParentId = 0;
  458. vc.FolderIds = @[].mutableCopy;
  459. vc.titleStr = @"我的笔记";
  460. [weakSelf.navigationController pushViewController:vc animated:YES];
  461. }];
  462. }
  463. - (void)newFileSuccess:(NSNotification *)noti
  464. {
  465. NSDictionary * dict = noti.userInfo;
  466. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  467. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  468. if (title.length > 0) {
  469. [self setSelectTopicBook:title];
  470. }
  471. }
  472. //- (void)SaveNoteBook:(NSNotification *)noti
  473. //{
  474. // NSLog(@"SaveNoteBook");
  475. //}
  476. - (void)selectFolder:(NSNotification *)noti
  477. {
  478. NSDictionary * dict = noti.userInfo;
  479. if (dict) {
  480. [self autoSizeBtn:[dict objectForKey:@"FolderName"]];
  481. self.FolderId = [[dict objectForKey:@"FolderId"] integerValue];
  482. }
  483. }
  484. - (void)ChangeTopicBookBtn:(NSNotification *)notification
  485. {
  486. NSDictionary * dict = notification.userInfo;
  487. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  488. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  489. if (title.length > 0) {
  490. [self setSelectTopicBook:title];
  491. }
  492. }
  493. - (void)ChangetitleBtn:(NSNotification *)notification
  494. {
  495. NSDictionary * dict = notification.userInfo;
  496. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  497. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  498. if (title.length > 0) {
  499. [self setSelectExtentText:title];
  500. }
  501. }
  502. - (void)setDowntitleBtn
  503. {
  504. WS(weakSelf);
  505. [self.titleBtn setAction:^{
  506. MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
  507. vc.isSubVC = NO;
  508. vc.isNoteBook = weakSelf.type == CollectModel_NoteBook ? YES : NO;
  509. vc.titleStr = @"选择发布范围";
  510. [weakSelf.navigationController pushViewController:vc animated:YES];
  511. }];
  512. }
  513. - (void)setSelectTopicBook:(NSString *)title
  514. {
  515. if (title.length > 8) {
  516. NSRange range1 = NSMakeRange(8, title.length - 8);
  517. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  518. NSString * title = [NSString stringWithFormat:@"%@",resultStr1];
  519. [self autoSizeBtn:title];
  520. }else{
  521. NSString * cusTitle = [NSString stringWithFormat:@"%@",title];
  522. [self autoSizeBtn:cusTitle];
  523. }
  524. }
  525. - (void)setSelectExtentText:(NSString *)title
  526. {
  527. if (title.length > 5) {
  528. NSRange range1 = NSMakeRange(5, title.length - 5);
  529. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  530. NSString * title = [NSString stringWithFormat:@"发布范围:%@",resultStr1];
  531. [self autoSizeBtn:title];
  532. }else{
  533. NSString * cusTitle = [NSString stringWithFormat:@"发布范围:%@",title];
  534. [self autoSizeBtn:cusTitle];
  535. }
  536. }
  537. #pragma mark - layload
  538. - (WKWebView *)webView
  539. {
  540. if (!_webView) {
  541. WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
  542. // 实例化对象
  543. WKUserContentController* userContent = [[WKUserContentController alloc] init];
  544. [userContent addScriptMessageHandler:self name:@"chosePic"];
  545. [userContent addScriptMessageHandler:self name:@"toPZ"];
  546. [userContent addScriptMessageHandler:self name:@"toBJ"];
  547. [userContent addScriptMessageHandler:self name:@"toSC"];
  548. [userContent addScriptMessageHandler:self name:@"toWJ"];
  549. [userContent addScriptMessageHandler:self name:@"keyBoard"];
  550. [userContent addScriptMessageHandler:self name:@"approverCheckUsers"];
  551. [userContent addScriptMessageHandler:self name:@"carbonCopyUsers"];
  552. [userContent addScriptMessageHandler:self name:@"changeState"];
  553. [userContent addScriptMessageHandler:self name:@"getType"];
  554. [userContent addScriptMessageHandler:self name:@"to"];
  555. [userContent addScriptMessageHandler:self name:@"getJp"];
  556. [userContent addScriptMessageHandler:self name:@"postH"];
  557. [userContent addScriptMessageHandler:self name:@"saveDrafts"];
  558. [userContent addScriptMessageHandler:self name:@"keyBoradblur"];
  559. configuration.userContentController = userContent;
  560. WKPreferences *preferences = [WKPreferences new];
  561. preferences.javaScriptCanOpenWindowsAutomatically = YES;
  562. preferences.minimumFontSize = 10.0;
  563. configuration.preferences = preferences;
  564. // 初始化WKWebView
  565. _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
  566. _NoInputAccessoryView *noInputView = [[_NoInputAccessoryView alloc] init];
  567. [noInputView removeInputAccessoryViewFromWKWebView:_webView];
  568. // UI代理
  569. }
  570. return _webView;
  571. }
  572. -(NSMutableArray<SelectModel *> *)shouJianArray{
  573. if(!_shouJianArray){
  574. _shouJianArray = [[NSMutableArray alloc] init];
  575. }
  576. return _shouJianArray;
  577. }
  578. -(NSMutableArray<SelectModel *> *)chaoShongArray{
  579. if(!_chaoShongArray){
  580. _chaoShongArray = [[NSMutableArray alloc] init];
  581. }
  582. return _chaoShongArray;
  583. }
  584. #pragma mark - KeyBoard
  585. - (void)keyBoardWillShow:(NSNotification *)note
  586. {
  587. // 获取用户信息
  588. NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
  589. // 获取键盘高度
  590. CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
  591. if (IS_IPHONEX) {
  592. self.keyBoardH = keyBoardBounds.size.height - 34;
  593. }else{
  594. self.keyBoardH = keyBoardBounds.size.height;
  595. }
  596. NSString *jsonString = [NSString stringWithFormat:@"getIosKeyBorad('%f')",self.keyBoardH];
  597. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  598. }];
  599. WS(weakSelf);
  600. [self.webView evaluateJavaScript:@"textFocus()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  601. if (weakSelf.shouModel) {
  602. NSDictionary * dict = @{@"SourceId":@(weakSelf.shouModel.SourceId),@"SourceName":weakSelf.shouModel.SourceName};
  603. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[weakSelf arrayToJSONModel:@[dict]]];
  604. [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  605. NSLog(@"%@",error);
  606. }];
  607. }
  608. NSLog(@"keyShow");
  609. }];
  610. }
  611. - (void)keyBoardWillHide:(NSNotification *)note
  612. {
  613. self.keyBoardH = 0.f;
  614. [self.webView evaluateJavaScript:@"textBlur()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  615. NSLog(@"keyHidden");
  616. }];
  617. }
  618. #pragma mark - WKScriptMessageHandler
  619. - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
  620. WS(weakSelf);
  621. NSLog(@"messageName:%@",message.name);
  622. if ([message.name isEqualToString:@"chosePic"]) {
  623. [self chatBarDidPhotoAction];
  624. }
  625. if ([message.name isEqualToString:@"toPZ"]) {
  626. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  627. } choosImgBlock:^(UIImage *image) {
  628. [weakSelf didSelectImage:@[image]];
  629. }];
  630. }
  631. if ([message.name isEqualToString:@"toBJ"]) {
  632. [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
  633. NSLog(@"SmartBarNotes %@",noteArr);
  634. [weakSelf disSelectNoteBook:noteArr];
  635. }];
  636. }
  637. if ([message.name isEqualToString:@"toSC"]) {
  638. [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
  639. NSLog(@"SmartBarCollection %@",collectArr);
  640. [weakSelf disSelectCollect:collectArr];
  641. }];
  642. }
  643. if ([message.name isEqualToString:@"toWJ"]) {
  644. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  645. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  646. SHOWLOADING
  647. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  648. REMOVESHOW
  649. NSDictionary * dict = responseObject[0];
  650. if ([dict[@"FileType"] isEqualToString:@"image"]) {
  651. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_Image,dict[@"FileName"],(long)[dict[@"FileId"] integerValue],@"",dict[@"MinAbsolutePath"],dict[@"AbsolutePath"],(long)[AppUserModel sharedAppUserModel].Id];
  652. [weakSelf upDateAction:jsonString];
  653. }else{
  654. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_file,dict[@"FileName"],(long)[dict[@"FileId"] integerValue],@"",dict[@"MinAbsolutePath"],dict[@"AbsolutePath"],(long)[AppUserModel sharedAppUserModel].Id];
  655. [weakSelf upDateAction:jsonString];
  656. }
  657. } failure:^(NSError * _Nonnull error) {
  658. REMOVESHOW
  659. }];
  660. }];
  661. }
  662. if ([message.name isEqualToString:@"keyBoradblur"]) {
  663. [self.webView resignFirstResponder];
  664. }
  665. // if ([message.name isEqualToString:@"keyBoard"]) {
  666. //
  667. // }
  668. if ([message.name isEqualToString:@"changeState"]) {
  669. NSInteger status = [message.body integerValue];
  670. if (status == 1) {
  671. self.isNull = NO;
  672. [self.DoneBtn setEnabled:YES];
  673. }else{
  674. self.isNull = YES;
  675. [self.DoneBtn setEnabled:NO];
  676. }
  677. }
  678. if ([message.name isEqualToString:@"approverCheckUsers"]) {
  679. if (self.type == CollectModel_meetMian) {
  680. [self selectMeeting];
  681. }else{
  682. self.isShoujianren = YES;
  683. self.isChaosongren = NO;
  684. [self selectPeopleWithType:1];
  685. }
  686. }
  687. if ([message.name isEqualToString:@"getJp"]) {
  688. [self allowDisplayingKeyboardWithoutUserAction];
  689. }
  690. if ([message.name isEqualToString:@"carbonCopyUsers"]) {
  691. self.isShoujianren = NO;
  692. self.isChaosongren = YES;
  693. [self selectPeopleWithType:2];
  694. }
  695. if ([message.name isEqualToString:@"getType"]) {
  696. NSString *jsonString = [NSString stringWithFormat:@"getType('%d','%d','%ld','%@','%ld')",self.type,self.isEdit,(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.replayType];
  697. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  698. NSLog(@"%@\n%@",data,error);
  699. if (weakSelf.isReturn) {
  700. FlowAttachmentsModel * model = weakSelf.sendModel;
  701. NSInteger fileType = model.SoureTypeId;
  702. if (fileType == CollectModel_file) {
  703. if (model.MinUrl.length > 0) {
  704. fileType = CollectModel_Image;
  705. NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",model.Url,model.Title,(long)[self returnType:model.Url]];
  706. [weakSelf upDateAction:jsonString];
  707. }else{
  708. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)model.SoureTypeId,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,model.SourceUserId];
  709. [weakSelf upDateAction:jsonString];
  710. }
  711. }else if(fileType == CollectModel_Text){
  712. [weakSelf.webView paste:weakSelf.sendModel.Title];
  713. }else if(fileType == CollectModel_Image){
  714. [weakSelf didSelectImage:@[weakSelf.sendImage]];
  715. }else if(fileType == CollectModel_NoSignMail){
  716. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%d','%@','%ld','%@','%@','%@','%ld')",CollectModel_InterMail,model.Title,(long)model.SoureId, @"匿名",model.MinUrl,model.Url,model.SourceUserId];
  717. [weakSelf upDateAction:jsonString];
  718. }else if(fileType == CollectModel_Toipc){
  719. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%d','%@','%ld','%@','%@','%@','%ld','%@','%ld')",CollectModel_Toipc,model.Title,(long)model.SoureId, model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,model.SourceUserId,model.GroupName,model.GroupId];
  720. [weakSelf upDateAction:jsonString];
  721. }else if(fileType == CollectModel_StoreSound){
  722. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%d','%@','%ld','%@','%@','%@','%ld','%@','%ld')",CollectModel_StoreSound,model.Title,(long)model.SoureId, model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,model.SourceUserId,model.GroupName,model.GroupId];
  723. [weakSelf upDateAction:jsonString];
  724. }else if(fileType == CollectModel_StoreVideo){
  725. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%d','%@','%ld','%@','%@','%@','%ld','%@','%ld')",CollectModel_StoreVideo,model.Title,(long)model.SoureId, model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,model.SourceUserId,model.GroupName,model.GroupId];
  726. [weakSelf upDateAction:jsonString];
  727. }else if(fileType == CollectModel_Group){
  728. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%d','%@','%ld','%@','%@','%@','%ld')",CollectModel_Toipc,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,model.SourceUserId];
  729. [weakSelf upDateAction:jsonString];
  730. }else{
  731. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)model.SoureTypeId,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,model.SourceUserId];
  732. [weakSelf upDateAction:jsonString];
  733. }
  734. }
  735. }];
  736. }
  737. if ([message.name isEqualToString:@"to"]) {
  738. NSDictionary * dict = (NSDictionary *)message.body;
  739. [self pushVCWithDict:dict];
  740. }
  741. if ([message.name isEqualToString:@"postH"]) {
  742. NSInteger H = [message.body integerValue];
  743. if (H < 0) {
  744. [self.webView mas_updateConstraints:^(MASConstraintMaker *make) {
  745. if (@available(iOS 11.0, *)) {
  746. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom).offset(H);
  747. } else {
  748. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(H);
  749. }
  750. }];
  751. }else{
  752. [self.webView mas_updateConstraints:^(MASConstraintMaker *make) {
  753. if (@available(iOS 11.0, *)) {
  754. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  755. } else {
  756. make.bottom.equalTo(weakSelf.view.mas_bottom);
  757. }
  758. }];
  759. }
  760. [self.view setNeedsLayout];
  761. [self.view layoutIfNeeded];
  762. NSLog(@"%@",NSStringFromCGRect(self.webView.frame));
  763. }
  764. if ([message.name isEqualToString:@"saveDrafts"]) {
  765. if ([message.body isKindOfClass:[NSDictionary class]]) {
  766. NSDictionary * dict = message.body;
  767. NSString * html = @"";
  768. NSString * Title = @"";
  769. if (![dict[@"html"] isKindOfClass:[NSNull class]]) {
  770. html = dict[@"html"];
  771. }
  772. if (![dict[@"Title"] isKindOfClass:[NSNull class]]) {
  773. Title = dict[@"Title"];
  774. }
  775. if ([Title length] > 0 || [html length] > 0 ) {
  776. self.isNull = NO;
  777. [self.DoneBtn setEnabled:YES];
  778. }else{
  779. self.isNull = YES;
  780. [self.DoneBtn setEnabled:NO];
  781. }
  782. [self saveDraft:message.body];
  783. }
  784. }
  785. }
  786. - (void)pushVCWithDict:(NSDictionary *)dict
  787. {
  788. NSInteger Id = [dict[@"id"] integerValue];
  789. NSInteger userId = [dict[@"userId"] integerValue];
  790. NSString * title = dict[@"title"];
  791. WS(weakSelf);
  792. switch ([dict[@"type"] integerValue]) {
  793. case CollectModel_Group:
  794. {
  795. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  796. vc.GroupId = Id;
  797. vc.titleStr = title;
  798. [self.navigationController pushViewController:vc animated:YES];
  799. }break;
  800. case CollectModel_file:{
  801. DownFileViewController * vc = [[DownFileViewController alloc] init];
  802. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  803. model.Title = title;
  804. model.SoureId = Id;
  805. model.Url = dict[@"bigurl"];
  806. model.MinUrl = dict[@"smallurl"];
  807. vc.model = model;
  808. [self.navigationController pushViewController:vc animated:YES];
  809. }break;
  810. case CollectModel_Image:{
  811. DownFileViewController * vc = [[DownFileViewController alloc] init];
  812. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  813. model.Title = title;
  814. model.SoureId = Id;
  815. model.Url = dict[@"bigurl"];
  816. model.MinUrl = dict[@"smallurl"];
  817. vc.model = model;
  818. [self.navigationController pushViewController:vc animated:YES];
  819. }break;
  820. case CollectModel_Aritle:{
  821. SHOWLOADING
  822. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)Id] parameters:@{} success:^(id _Nonnull responseObject) {
  823. REMOVESHOW;
  824. Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
  825. // HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  826. // [homeDetail loadCurrentModel:itemModel];
  827. // [weakSelf.navigationController pushViewController:homeDetail animated:YES];
  828. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  829. vc.type = CollectModel_Aritle;
  830. vc.Id = itemModel.Id;
  831. [weakSelf.navigationController pushViewController:vc animated:YES];
  832. } failure:^(NSError * _Nonnull error) {
  833. SHOWERROR([ZYCTool handerResultData:error]);
  834. }];
  835. }break;
  836. case CollectModel_Notice:{
  837. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  838. vc.type = CollectModel_Notice;
  839. vc.Id = Id;
  840. [self.navigationController pushViewController:vc animated:YES];
  841. }break;
  842. case CollectModel_Toipc:{
  843. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  844. vc.type = CollectModel_Toipc;
  845. vc.Id = Id;
  846. [self.navigationController pushViewController:vc animated:YES];
  847. }break;
  848. case CollectModel_NewTopic:{
  849. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  850. vc.type = CollectModel_NewTopic;
  851. vc.Id = Id;
  852. [self.navigationController pushViewController:vc animated:YES];
  853. }break;
  854. case CollectModel_NoteBook:{
  855. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  856. vc.type = CollectModel_NoteBook;
  857. vc.Id = Id;
  858. [self.navigationController pushViewController:vc animated:YES];
  859. }break;
  860. case CollectModel_Collect:{
  861. }break;
  862. case CollectModel_CollectFile:{
  863. if (userId == [AppUserModel sharedAppUserModel].Id) {
  864. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  865. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  866. vc.ParentId = 0;
  867. vc.FolderId = Id;
  868. vc.myTitle = title;
  869. [self.navigationController pushViewController:vc animated:YES];
  870. }else{
  871. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  872. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  873. vc.ParentId = 0;
  874. vc.FolderId = Id;
  875. vc.myTitle = title;
  876. vc.VisitUserId = userId;
  877. [self.navigationController pushViewController:vc animated:YES];
  878. }
  879. }break;
  880. case CollectModel_NoteFile:{
  881. if (userId == [AppUserModel sharedAppUserModel].Id) {
  882. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  883. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  884. vc.ParentId = 0;
  885. vc.FolderId = Id;
  886. vc.myTitle = title;
  887. vc.VisitUserId = 0;
  888. [self.navigationController pushViewController:vc animated:YES];
  889. }else{
  890. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  891. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  892. vc.ParentId = 0;
  893. vc.FolderId = Id;
  894. vc.myTitle = title;
  895. vc.TypeValue = 1;
  896. vc.VisitUserId = userId;
  897. [self.navigationController pushViewController:vc animated:YES];
  898. }
  899. }break;
  900. case CollectModel_InterMail:{
  901. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  902. vc.type = CollectModel_InterMail;
  903. vc.Id = Id;
  904. [self.navigationController pushViewController:vc animated:YES];
  905. }break;
  906. case CollectModel_meetDetail:{
  907. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  908. [self.navigationController pushViewController:vc animated:YES];
  909. }break;
  910. case CollectModel_work:{
  911. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  912. vc.pageType = Type_ONEC;
  913. vc.indexId = Id;
  914. vc.title = title;
  915. vc.TodoId = Id;
  916. [self.navigationController pushViewController:vc animated:YES];
  917. }break;
  918. case CollectModel_StoreSound:
  919. {
  920. BookListenVC * vc = [BookListenVC initBookListenVC];
  921. vc.Id = Id;
  922. vc.MediaType = MediaMusicType;
  923. [self.navigationController pushViewController:vc animated:YES];
  924. }
  925. break;
  926. case CollectModel_StoreVideo:
  927. {
  928. BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
  929. vc.Id = Id;
  930. [self.navigationController pushViewController:vc animated:YES];
  931. }
  932. break;
  933. case CollectModel_meetMian:{
  934. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  935. vc.type = CollectModel_meetMian;
  936. vc.Id = Id;
  937. [self.navigationController pushViewController:vc animated:YES];
  938. }break;
  939. case CollectModel_financeCount:{
  940. CountDataVC *vc = [CountDataVC initCountDataVC];
  941. vc.index = 0;
  942. vc.titleStr = @"财务统计";
  943. [self.navigationController pushViewController:vc animated:YES];
  944. }break;
  945. case CollectModel_affairsCount:{
  946. CountDataVC *vc = [CountDataVC initCountDataVC];
  947. vc.index = 1;
  948. vc.titleStr = @"人事统计";
  949. [self.navigationController pushViewController:vc animated:YES];
  950. }break;
  951. case CollectModel_publishCount:{
  952. CountDataVC *vc = [CountDataVC initCountDataVC];
  953. vc.index = 2;
  954. vc.titleStr = @"出版统计";
  955. [self.navigationController pushViewController:vc animated:YES];
  956. }break;
  957. default:
  958. break;
  959. }
  960. }
  961. #pragma mark - 选择关联会议
  962. - (void)selectMeeting
  963. {
  964. WS(weakSelf);
  965. FecordJoinWorkFlowListController *vc = [[FecordJoinWorkFlowListController alloc] init];
  966. [vc setSelectedMeetingBlock:^(NSString * _Nonnull mid, NSString * _Nonnull meetingName) {
  967. weakSelf.meetingId = [mid integerValue];
  968. NSDictionary * dict = @{@"SourceId":mid,@"SourceName":meetingName};
  969. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:@[dict]]];
  970. [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  971. NSLog(@"data:%@",data);
  972. NSLog(@"error:%@",error);
  973. }];
  974. }];
  975. vc.IsSelect = YES;
  976. [self.navigationController pushViewController:vc animated:YES];
  977. }
  978. - (void)selectMeetSearch:(NSNotification *)notification
  979. {
  980. NSDictionary * dict = notification.userInfo;
  981. self.meetingId = [[dict objectForKey:@"Id"] integerValue];
  982. NSDictionary * paraDict = @{@"SourceId":[dict objectForKey:@"Id"],@"SourceName":[dict objectForKey:@"Name"]};
  983. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:@[paraDict]]];
  984. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  985. NSLog(@"data:%@",data);
  986. NSLog(@"error:%@",error);
  987. }];
  988. }
  989. - (void)selectPeopleWithType:(NSInteger)type {
  990. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  991. vc.isAllSelected = YES;
  992. Department *defaltGroupSetion = [[Department alloc]init];
  993. defaltGroupSetion.Name = @"单位通讯录";
  994. defaltGroupSetion.Id = 0;
  995. defaltGroupSetion.SourceId = 0;
  996. defaltGroupSetion.SourceType = 1;
  997. defaltGroupSetion.SourceName = @"单位通讯录";
  998. defaltGroupSetion.MiddleType = type;
  999. Department *myGroupSetion = [[Department alloc]init];
  1000. myGroupSetion.Name = @"自建通讯录";
  1001. myGroupSetion.Id = 0;
  1002. myGroupSetion.MiddleType = type;
  1003. myGroupSetion.SourceType = 3;
  1004. myGroupSetion.SourceId = 0;
  1005. myGroupSetion.SourceName = @"自建通讯录";
  1006. vc.isAllSelected = YES;
  1007. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  1008. vc.isDefalutPage = 1;
  1009. vc.titleStr = self.type == CollectModel_meetMian ? @"发送范围" : @"选人";
  1010. USERDEFAULTSSET([NSMutableArray array], MAILSELECT);
  1011. [self.navigationController pushViewController:vc animated:YES];
  1012. }
  1013. - (void)recviveChaoSongRen:(NSNotification *)notification{
  1014. if (self.isShoujianren) {
  1015. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  1016. if (array.count > 0) {
  1017. NSLog(@"shouJianArray结果数据组%@",array);
  1018. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:array]];
  1019. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  1020. NSLog(@"data:%@",data);
  1021. NSLog(@"error:%@",error);
  1022. }];
  1023. }
  1024. }
  1025. if (self.isChaosongren) {
  1026. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  1027. if (array.count > 0) {
  1028. NSLog(@"chaoShongArray结果数据组%@",array);
  1029. NSString *jsonString = [NSString stringWithFormat:@"getCarbonCopyUsersList('%@')",[self arrayToJSONModel:array]];
  1030. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  1031. NSLog(@"data:%@",data);
  1032. NSLog(@"error:%@",error);
  1033. }];
  1034. }
  1035. }
  1036. }
  1037. #pragma mark - 选择图片
  1038. - (void)chatBarDidPhotoAction
  1039. {
  1040. WS(weakSelf);
  1041. [self.view endEditing:YES];
  1042. TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:nil];
  1043. [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
  1044. leftButton.hidden = YES;
  1045. }];
  1046. imagePickerVc.showSelectBtn = NO;
  1047. imagePickerVc.allowCrop = YES;
  1048. imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH);
  1049. imagePickerVc.allowTakePicture = NO;
  1050. imagePickerVc.allowTakeVideo = NO;
  1051. imagePickerVc.allowPickingOriginalPhoto = NO;
  1052. imagePickerVc.allowPickingGif = NO;
  1053. [imagePickerVc setIsStatusBarDefault:YES];
  1054. [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
  1055. [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
  1056. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  1057. PHAsset *asset = assets.firstObject;
  1058. switch (asset.mediaType) {
  1059. case PHAssetMediaTypeVideo: {
  1060. } break;
  1061. case PHAssetMediaTypeImage: {
  1062. [weakSelf didSelectImage:photos];
  1063. } break;
  1064. case PHAssetMediaTypeAudio:
  1065. break;
  1066. case PHAssetMediaTypeUnknown:
  1067. break;
  1068. default: break;
  1069. }
  1070. }];
  1071. [self presentViewController:imagePickerVc animated:YES completion:nil];
  1072. }
  1073. - (void)didSelectImage:(NSArray *)images
  1074. {
  1075. NSMutableArray * array = [NSMutableArray array];
  1076. for (UIImage * image in images) {
  1077. NSData *data = UIImageJPEGRepresentation(image, 1);
  1078. [array addObject:data];
  1079. }
  1080. WS(weakSelf);
  1081. NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
  1082. [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:array pictureKey:@"file" success:^(id _Nonnull responseObject) {
  1083. NSLog(@"%@",responseObject);
  1084. for (NSDictionary * dict in responseObject) {
  1085. NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",dict[@"AbsolutePath"],dict[@"FileName"],(long)CollectModel_Image];
  1086. [weakSelf upDateAction:jsonString];
  1087. }
  1088. } failure:^(NSError * _Nonnull error) {
  1089. }];
  1090. }
  1091. #pragma mark - 选择笔记
  1092. - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
  1093. NSMutableArray * daArray = [NSMutableArray array];
  1094. for (MyNoteBookSubModel *dataModel in noteArr ) {
  1095. if (dataModel.AttributeValue == 1) {
  1096. // NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteBook,dataModel.Title,(long)dataModel.MiddleId,dataModel.Name,@"",@"",(long)dataModel.UserId];
  1097. // [self upDateAction:jsonString];
  1098. // }else{
  1099. // NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)dataModel.UserId];
  1100. // [self upDateAction:jsonString];
  1101. // }
  1102. [daArray addObject:@{@"type":@(CollectModel_NoteBook),
  1103. @"title":dataModel.Title,
  1104. @"id":@(dataModel.MiddleId),
  1105. @"author":dataModel.Name,
  1106. @"smallurl":@"",
  1107. @"bigurl":@"",
  1108. @"userId":@(dataModel.UserId),
  1109. @"groupName":@"",
  1110. @"groupId":@(0)
  1111. }];
  1112. }else{
  1113. // NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_CollectFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId)];
  1114. // [self upDateAction:jsonString];
  1115. [daArray addObject:@{@"type":@(CollectModel_NoteFile),
  1116. @"title":dataModel.FolderName,
  1117. @"id":@(dataModel.Id),
  1118. @"author":[AppUserModel sharedAppUserModel].Name,
  1119. @"smallurl":@"",
  1120. @"bigurl":@"",
  1121. @"userId":@(dataModel.UserId),
  1122. @"groupName":@"",
  1123. @"groupId":@(0)
  1124. }];
  1125. }
  1126. }
  1127. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollectionList('%@')",[self toReadableJSONString:daArray]];
  1128. [self upDateAction:[self noWhiteSpaceString:jsonString]];
  1129. }
  1130. #pragma mark - 选择收藏
  1131. - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
  1132. NSMutableArray * daArray = [NSMutableArray array];
  1133. for (MyFavoriteSubModel *dataModel in collectArr ) {
  1134. if(dataModel.AttributeValue == 1)
  1135. {
  1136. NSString * author = @"";
  1137. switch (dataModel.CollectionType) {
  1138. case CollectModel_file:
  1139. {
  1140. if (dataModel.Data.MinFile.length > 0) {
  1141. dataModel.CollectionType = CollectModel_Image;
  1142. }
  1143. }
  1144. break;
  1145. case CollectModel_Text:///1
  1146. {
  1147. dataModel.CollectionType = CollectModel_Text;
  1148. }
  1149. break;
  1150. case CollectModel_Aritle:///1
  1151. {
  1152. dataModel.CollectionType = CollectModel_Aritle;
  1153. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的文章",dataModel.Data.Author] : @"";
  1154. }
  1155. break;
  1156. case CollectModel_CollectFile:
  1157. {
  1158. dataModel.CollectionType = CollectModel_CollectFile;
  1159. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的收藏",dataModel.Data.Author] : @"";
  1160. }
  1161. break;
  1162. case CollectModel_NoteFile:
  1163. {
  1164. dataModel.CollectionType = CollectModel_NoteFile;
  1165. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的笔记",dataModel.Data.Author] : @"";
  1166. }
  1167. break;
  1168. case CollectModel_TopicBooK:
  1169. {
  1170. dataModel.CollectionType = CollectModel_TopicBooK;
  1171. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的话题本",dataModel.Data.Author] : @"";
  1172. }
  1173. break;
  1174. case CollectModel_TopicSubBooK:
  1175. {
  1176. dataModel.CollectionType = CollectModel_TopicSubBooK;
  1177. author = dataModel.Data.Author.length > 0 ? [NSString stringWithFormat:@"来自-%@的话题本",dataModel.Data.Author] : @"";
  1178. }
  1179. break;
  1180. case CollectModel_StoreSound:
  1181. {
  1182. dataModel.Data.MinFile = dataModel.Data.ArticleImgUrl.firstObject;
  1183. dataModel.Data.File = dataModel.Data.ArticleImgUrl.firstObject;
  1184. author = dataModel.Data.Author.length > 0 ? dataModel.Data.Author : @"";
  1185. }
  1186. break;
  1187. case CollectModel_StoreVideo:
  1188. {
  1189. dataModel.Data.MinFile = dataModel.Data.ArticleImgUrl.firstObject;
  1190. dataModel.Data.File = dataModel.Data.ArticleImgUrl.firstObject;
  1191. author = dataModel.Data.Author.length > 0 ? dataModel.Data.Author : @"";
  1192. }
  1193. break;
  1194. default:
  1195. {
  1196. author = dataModel.Data.Author.length > 0 ? dataModel.Data.Author : @"";
  1197. }
  1198. break;
  1199. }
  1200. // NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld','%@','%ld')",(long)dataModel.CollectionType,dataModel.Title,(long)dataModel.CollectionDataId,author,dataModel.Data.MinFile,dataModel.Data.File,(long)(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId),dataModel.Data.GroupName,dataModel.Data.GroupId];
  1201. // [self upDateAction:jsonString];
  1202. [daArray addObject:@{@"type":@(dataModel.CollectionType),
  1203. @"title":dataModel.Title,
  1204. @"id":@(dataModel.CollectionDataId),
  1205. @"author":author,
  1206. @"smallurl":dataModel.Data.MinFile,
  1207. @"bigurl":dataModel.Data.File,
  1208. @"userId":@(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId),
  1209. @"groupName":dataModel.Data.GroupName ? dataModel.Data.GroupName : @"",
  1210. @"groupId":@(dataModel.Data.GroupId)
  1211. }];
  1212. }else{
  1213. // NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_CollectFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId)];
  1214. // [self upDateAction:jsonString];
  1215. [daArray addObject:@{@"type":@(CollectModel_CollectFile),
  1216. @"title":dataModel.FolderName,
  1217. @"id":@(dataModel.CollectionDataId),
  1218. @"author":[AppUserModel sharedAppUserModel].Name,
  1219. @"smallurl":@"",
  1220. @"bigurl":@"",
  1221. @"userId":@(dataModel.SourceUserId == 0 ? dataModel.UserId : dataModel.SourceUserId),
  1222. @"groupName":dataModel.Data.GroupName ? dataModel.Data.GroupName : @"",
  1223. @"groupId":@(dataModel.Data.GroupId)
  1224. }];
  1225. }
  1226. }
  1227. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollectionList('%@')",[self toReadableJSONString:daArray]];
  1228. [self upDateAction:[self noWhiteSpaceString:jsonString]];
  1229. }
  1230. - (NSString *)toReadableJSONString:(NSArray *)dataArr {
  1231. NSData *data = [NSJSONSerialization dataWithJSONObject:dataArr
  1232. options:NSJSONWritingPrettyPrinted
  1233. error:nil];
  1234. if (data == nil) {
  1235. return nil;
  1236. }
  1237. NSString *string = [[NSString alloc] initWithData:data
  1238. encoding:NSUTF8StringEncoding];
  1239. return string;
  1240. }
  1241. - (NSString *)DictJSONString:(NSDictionary *)dict {
  1242. NSData *data = [NSJSONSerialization dataWithJSONObject:dict
  1243. options:NSJSONWritingPrettyPrinted
  1244. error:nil];
  1245. if (data == nil) {
  1246. return nil;
  1247. }
  1248. NSString *string = [[NSString alloc] initWithData:data
  1249. encoding:NSUTF8StringEncoding];
  1250. return string;
  1251. }
  1252. - (NSString *)noWhiteSpaceString:(NSString *)str
  1253. {
  1254. NSString *newString = str;
  1255. //去除掉首尾的空白字符和换行字符
  1256. newString = [newString stringByReplacingOccurrencesOfString:@"\r" withString:@""];
  1257. newString = [newString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
  1258. newString = [newString stringByReplacingOccurrencesOfString:@"\\b" withString:@""];
  1259. newString = [newString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //去除掉首尾的空白字符和换行字符使用
  1260. newString = [newString stringByReplacingOccurrencesOfString:@" " withString:@""];
  1261. return newString;
  1262. }
  1263. #pragma mark - WKScriptMessageHandler
  1264. -(NSString *)convertToJson:(NSDictionary *)dict
  1265. {
  1266. NSError *error;
  1267. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
  1268. NSString *jsonString;
  1269. if (!jsonData) {
  1270. NSLog(@"%@",error);
  1271. }else{
  1272. jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  1273. }
  1274. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1275. NSRange range = {0,jsonString.length};
  1276. //去掉字符串中的空格
  1277. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  1278. NSRange range2 = {0,mutStr.length};
  1279. //去掉字符串中的换行符
  1280. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  1281. return mutStr;
  1282. }
  1283. #pragma mark - WKUIDelegete
  1284. - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
  1285. {
  1286. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:message?:@"" preferredStyle:UIAlertControllerStyleAlert];
  1287. [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1288. }])];
  1289. [self presentViewController:alertController animated:YES completion:nil];
  1290. NSLog(@"Aleart=========%@",message);
  1291. completionHandler();
  1292. }
  1293. - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler{
  1294. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:message?:@"" preferredStyle:UIAlertControllerStyleAlert];
  1295. [alertController addAction:([UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1296. }])];
  1297. [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1298. }])];
  1299. [self presentViewController:alertController animated:YES completion:nil];
  1300. }
  1301. - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * _Nullable))completionHandler{
  1302. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:prompt message:@"" preferredStyle:UIAlertControllerStyleAlert];
  1303. [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  1304. textField.text = defaultText;
  1305. }];
  1306. [alertController addAction:([UIAlertAction actionWithTitle:@"完成" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1307. }])];
  1308. [self presentViewController:alertController animated:YES completion:nil];
  1309. }
  1310. #pragma mark - 提交富文本
  1311. - (void)submit
  1312. {
  1313. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  1314. NSString *jsonString = [NSString stringWithFormat:@"getEditorText()"];
  1315. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  1316. NSLog(@"submit:%@",data);
  1317. if ([data isKindOfClass:[NSDictionary class]]) {
  1318. NSDictionary * dict = (NSDictionary *)data;
  1319. switch (self.type) {
  1320. case CollectModel_Notice:
  1321. {
  1322. [self submitNotice:dict];
  1323. }
  1324. break;
  1325. case CollectModel_Toipc:
  1326. {
  1327. if (self.isEdit) {
  1328. [self changeTopic:dict];
  1329. }else{
  1330. if (self.FolderId == 0 && self.isGroupRoot) {
  1331. SHOWERROR(@"请选择小组");
  1332. return;
  1333. }
  1334. [self submitTopic:dict];
  1335. }
  1336. }
  1337. break;
  1338. case CollectModel_NewTopic:
  1339. {
  1340. if (self.isEdit) {
  1341. [self changeNoteBook:dict];
  1342. }else{
  1343. [self submitNoteBook:dict];
  1344. }
  1345. }
  1346. break;
  1347. case CollectModel_Group:
  1348. {
  1349. if (self.isEdit) {
  1350. [self changeTopic:dict];
  1351. }else{
  1352. [self submitTopic:dict];
  1353. }
  1354. }
  1355. break;
  1356. case CollectModel_meetMian:
  1357. {
  1358. if (self.isEdit) {
  1359. [self changeMeeting:dict];
  1360. }else{
  1361. [self submitMeeting:dict];
  1362. }
  1363. }
  1364. break;
  1365. case CollectModel_NoteBook:
  1366. {
  1367. if (self.isEdit) {
  1368. [self changeNoteBook:dict];
  1369. }else{
  1370. [self submitNoteBook:dict];
  1371. }
  1372. }
  1373. break;
  1374. case CollectModel_InterMail:
  1375. {
  1376. [self submitNotice:dict];
  1377. }
  1378. break;
  1379. case CollectModel_NoSignMail:
  1380. {
  1381. [self submitNotice:dict];
  1382. }
  1383. break;
  1384. default:
  1385. break;
  1386. }
  1387. }
  1388. }];
  1389. }
  1390. #pragma mark - 提交通知
  1391. - (void)submitNotice:(NSDictionary *)dict
  1392. {
  1393. self.H5JsonDict = dict;
  1394. NSString * html = dict[@"html"];
  1395. NSArray * jsonArray = dict[@"json"];
  1396. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1397. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1398. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1399. [paraDict setValue:self.isDraft ? @(2) : @(1) forKey:@"NoticeType"];
  1400. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1401. [paraDict setObject:html forKey:@"HtmlContent"];
  1402. [paraDict setObject:@(self.shouType) forKey:@"TypeValue"];
  1403. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1404. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  1405. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  1406. NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
  1407. NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
  1408. if ([self.H5JsonDict[@"Title"] length] == 0 &&
  1409. [self.H5JsonDict[@"html"] length] == 0 &&
  1410. addArray.count == 0 &&
  1411. ccArray.count == 0) {
  1412. SHOWERROR(@"请填写标题或内容");
  1413. return;
  1414. }
  1415. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  1416. [paraDict setObject:@(self.Id) forKey:@"ParentId"];///回复ID
  1417. [self sentNoticeRequeast:paraDict withNoticeType:self.isDraft ? 2 : 1];
  1418. }else{
  1419. if (self.isEdit) {
  1420. [self sentChangeNotice:paraDict withNoticeType:self.isDraft ? 2 : 1];
  1421. }else{
  1422. [self sentNoticeRequeast:paraDict withNoticeType:self.isDraft ? 2 : 1];
  1423. }
  1424. }
  1425. }
  1426. - (void)sentChangeNotice:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  1427. WS(weakSelf);
  1428. NSLog(@"%@",[self DictJSONString:dic]);
  1429. [[HttpManager sharedHttpManager] POSTUrl:Host(API_NOTICE_EDIT) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1430. REMOVESHOW
  1431. if(NoticeType == 1){
  1432. SHOWSUCCESS(weakSelf.type == CollectModel_Notice ? @"通知已经发送" : @"站内信已经发送");
  1433. if (weakSelf.upDateBlock) {
  1434. weakSelf.upDateBlock();
  1435. }
  1436. }else{
  1437. SHOWSUCCESS(weakSelf.type == CollectModel_Notice ? @"通知已经存放草稿箱" : @"站内信已经存放草稿箱");
  1438. }
  1439. [weakSelf back1];
  1440. } failure:^(NSError * _Nonnull error) {
  1441. SHOWERROR([ZYCTool handerResultData:error]);
  1442. }];
  1443. }
  1444. - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  1445. WS(weakSelf);
  1446. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADD) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1447. REMOVESHOW
  1448. if(NoticeType == 1){
  1449. SHOWSUCCESS(weakSelf.type == CollectModel_Notice ? @"通知已经发送" : @"站内信已经发送");
  1450. if (weakSelf.upDateBlock) {
  1451. weakSelf.upDateBlock();
  1452. }
  1453. }else{
  1454. SHOWSUCCESS(weakSelf.type == CollectModel_Notice ? @"通知已经存放草稿箱" : @"站内信已经存放草稿箱");
  1455. }
  1456. [weakSelf back1];
  1457. } failure:^(NSError * _Nonnull error) {
  1458. SHOWERROR([ZYCTool handerResultData:error]);
  1459. }];
  1460. }
  1461. #pragma mark - 提交话题
  1462. - (void)submitTopic:(NSDictionary *)dict
  1463. {
  1464. NSString * html = dict[@"html"];
  1465. NSArray * jsonArray = dict[@"json"];
  1466. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1467. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1468. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1469. [paraDict setObject:@(self.FolderId) forKey:@"GroupId"];
  1470. [paraDict setObject:html forKey:@"HtmlContent"];
  1471. [paraDict setObject:@(self.isDraft) forKey:@"IsDraft"];
  1472. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1473. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1474. SHOWERROR(@"请填写标题或内容");
  1475. return;
  1476. }
  1477. if (self.FolderId == 0 && self.isGroupRoot) {
  1478. SHOWERROR(@"请选择小组");
  1479. return;
  1480. }
  1481. NSString * d = [self DictJSONString:paraDict];
  1482. NSLog(@"%@",d);
  1483. SHOWLOADING
  1484. WS(weakSelf);
  1485. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Add) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1486. NSLog(@"%@",responseObject);
  1487. REMOVESHOW
  1488. SHOWSUCCESS(@"创建成功");
  1489. if (weakSelf.upDateBlock) {
  1490. weakSelf.upDateBlock();
  1491. }
  1492. [weakSelf back1];
  1493. } failure:^(NSError * _Nonnull error) {
  1494. REMOVESHOW
  1495. SHOWERROR([ZYCTool handerResultData:error])
  1496. }];
  1497. }
  1498. #pragma mark - 修改话题
  1499. - (void)changeTopic:(NSDictionary *)dict
  1500. {
  1501. NSString * html = dict[@"html"];
  1502. NSArray * jsonArray = dict[@"json"];
  1503. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1504. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1505. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1506. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1507. [paraDict setObject:html forKey:@"HtmlContent"];
  1508. [paraDict setObject:@(self.isDraft) forKey:@"IsDraft"];
  1509. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1510. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1511. SHOWERROR(@"请填写标题或内容");
  1512. return;
  1513. }
  1514. WS(weakSelf);
  1515. SHOWLOADING
  1516. [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Topic_Update) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1517. NSLog(@"%@",responseObject);
  1518. REMOVESHOW
  1519. SHOWSUCCESS(@"创建成功");
  1520. if (weakSelf.upDateBlock) {
  1521. weakSelf.upDateBlock();
  1522. }
  1523. [weakSelf back1];
  1524. } failure:^(NSError * _Nonnull error) {
  1525. REMOVESHOW
  1526. }];
  1527. }
  1528. #pragma mark - 提交会议纪要
  1529. - (void)submitMeeting:(NSDictionary *)dict
  1530. {
  1531. NSString * html = dict[@"html"];
  1532. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1533. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1534. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1535. if (self.meetingId > 0) {
  1536. [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
  1537. }
  1538. [paraDict setObject:html forKey:@"Content"];
  1539. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1540. SHOWERROR(@"请填写标题或内容");
  1541. return;
  1542. }
  1543. NSArray * userArray = paraDict[@"AddresseeUserMiddles"];
  1544. if (userArray.count == 0) {
  1545. SHOWERROR(@"请选择发布范围");
  1546. return;
  1547. }
  1548. SHOWLOADING
  1549. WS(weakSelf);
  1550. [[HttpManager sharedHttpManager] POSTUrl:Host(MeetingSummary) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1551. REMOVESHOW
  1552. SHOWSUCCESS(@"创建成功");
  1553. if (weakSelf.upDateBlock) {
  1554. weakSelf.upDateBlock();
  1555. }
  1556. [weakSelf back1];
  1557. } failure:^(NSError * _Nonnull error) {
  1558. REMOVESHOW
  1559. SHOWERROR([ZYCTool handerResultData:error]);
  1560. }];
  1561. }
  1562. - (void)changeMeeting:(NSDictionary *)dict
  1563. {
  1564. NSString * html = dict[@"html"];
  1565. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1566. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1567. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1568. if (self.meetingId > 0) {
  1569. [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
  1570. }
  1571. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1572. SHOWERROR(@"请填写标题或内容");
  1573. return;
  1574. }
  1575. NSArray * userArray = paraDict[@"AddresseeUserMiddles"];
  1576. if (userArray.count == 0) {
  1577. SHOWERROR(@"请选择发布范围");
  1578. return;
  1579. }
  1580. [paraDict setObject:html forKey:@"Content"];
  1581. SHOWLOADING
  1582. WS(weakSelf);
  1583. NSString * meetId = [NSString stringWithFormat:@"%ld",(long)self.Id];
  1584. [[HttpManager sharedHttpManager] PUTUrl:Host(UpdateMeeting(meetId)) parameters:paraDict success:^(id _Nonnull responseObject) {
  1585. REMOVESHOW
  1586. SHOWSUCCESS(@"修改会议纪要成功");
  1587. if (weakSelf.upDateBlock) {
  1588. weakSelf.upDateBlock();
  1589. }
  1590. [weakSelf back1];
  1591. } failure:^(NSError * _Nonnull error) {
  1592. REMOVESHOW
  1593. SHOWERROR([ZYCTool handerResultData:error]);
  1594. }];
  1595. }
  1596. #pragma mark - 提交笔记
  1597. - (void)submitNoteBook:(NSDictionary *)dict
  1598. {
  1599. WS(weakSelf);
  1600. NSString * html = dict[@"html"];
  1601. NSArray * jsonArray = dict[@"json"];
  1602. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1603. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1604. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1605. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1606. [paraDict setObject:@(self.isDraft) forKey:@"IsDraft"];
  1607. [paraDict setObject:html forKey:@"HtmlContent"];
  1608. [paraDict setObject:(self.type == CollectModel_NewTopic ? @(1) : @(0)) forKey:@"IsTopic"];
  1609. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1610. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1611. SHOWERROR(@"请填写标题或内容");
  1612. return;
  1613. }
  1614. // if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
  1615. // SHOWERROR(@"请选择发布范围");
  1616. // return;
  1617. // }
  1618. [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateNoteBook) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1619. NSLog(@"%@",responseObject);
  1620. SHOWSUCCESS(@"创建成功");
  1621. if (weakSelf.upDateBlock) {
  1622. weakSelf.upDateBlock();
  1623. }
  1624. [weakSelf back1];
  1625. } failure:^(NSError * _Nonnull error) {
  1626. SHOWERROR([ZYCTool handerResultData:error]);
  1627. }];
  1628. }
  1629. - (void)changeNoteBook:(NSDictionary *)dict
  1630. {
  1631. WS(weakSelf);
  1632. NSString * html = dict[@"html"];
  1633. NSArray * jsonArray = dict[@"json"];
  1634. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1635. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1636. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1637. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1638. [paraDict setObject:@(self.isDraft) forKey:@"IsDraft"];
  1639. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1640. [paraDict setObject:html forKey:@"HtmlContent"];
  1641. [paraDict setObject:(self.type == CollectModel_NewTopic ? @(1) : @(0)) forKey:@"IsTopic"];
  1642. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1643. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1644. SHOWERROR(@"请填写标题或内容");
  1645. return;
  1646. }
  1647. // if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
  1648. // SHOWERROR(@"请选择发布范围");
  1649. // return;
  1650. // }
  1651. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NoteBook_Modify) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1652. NSLog(@"%@",responseObject);
  1653. if (weakSelf.upDateBlock) {
  1654. weakSelf.upDateBlock();
  1655. }
  1656. SHOWSUCCESS(@"修改成功");
  1657. [[NSNotificationCenter defaultCenter] postNotificationName:DRAFTUPDATESUCCESS object:nil];
  1658. [weakSelf back1];
  1659. } failure:^(NSError * _Nonnull error) {
  1660. SHOWERROR([ZYCTool handerResultData:error]);
  1661. }];
  1662. }
  1663. #pragma mark - 提交站内信
  1664. - (void)submitMail:(NSDictionary *)dict
  1665. {
  1666. self.H5JsonDict = dict;
  1667. NSString * html = dict[@"html"];
  1668. NSArray * jsonArray = dict[@"json"];
  1669. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1670. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1671. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1672. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1673. [paraDict setObject:html forKey:@"HtmlContent"];
  1674. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1675. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  1676. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  1677. [paraDict setObject:@(self.MailType) forKey:@"MissiveType"];///1 正常 2 匿名
  1678. [paraDict setObject:@(self.Id) forKey:@"ParentId"];///回复ID
  1679. [paraDict setObject:@(self.shouType) forKey:@"TypeValue"];
  1680. [paraDict setObject:@(self.isDraft ? 2 : 1) forKey:@"MissiveAttributeType"];///1 发送 2 草稿
  1681. NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
  1682. NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
  1683. if ([self.H5JsonDict[@"Title"] length] == 0 &&
  1684. [self.H5JsonDict[@"html"] length] == 0 &&
  1685. addArray.count == 0 &&
  1686. ccArray.count == 0) {
  1687. SHOWERROR(@"请填写标题或内容");
  1688. return;
  1689. }
  1690. if (self.isEdit) {
  1691. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  1692. }else{
  1693. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1694. }
  1695. }
  1696. [self sentMailRequeast:paraDict];
  1697. }
  1698. - (void)sentMailRequeast:(NSMutableDictionary *)dic
  1699. {
  1700. WS(weakSelf);
  1701. [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1702. if(weakSelf.isDraft){
  1703. SHOWSUCCESS(@"站内信已经存放草稿箱");
  1704. }else{
  1705. SHOWSUCCESS(@"站内信已经发送");
  1706. }
  1707. if (weakSelf.replayType == MailReplayOne || weakSelf.replayType == MailReplayAll) {
  1708. [weakSelf backMailList];
  1709. }else{
  1710. [weakSelf back1];
  1711. }
  1712. } failure:^(NSError * _Nonnull error) {
  1713. SHOWERROR([ZYCTool handerResultData:error]);
  1714. }];
  1715. }
  1716. - (NSString *)arrayToJSONModel:(NSArray *)array
  1717. {
  1718. NSMutableArray * mArray = [NSMutableArray array];
  1719. for (SelectModel * model in array) {
  1720. NSDictionary * dict = [model modelToJSONObject];
  1721. [mArray addObject:@{@"SourceType":dict[@"SourceType"],@"SourceId":dict[@"SourceId"],@"SourceName":dict[@"SourceName"],@"MiddleType":@(self.type)}];
  1722. }
  1723. return [self arrayToJSONString:mArray];
  1724. }
  1725. - (NSString *)arrayTosumbitString:(NSArray *)array
  1726. {
  1727. NSError *error = nil;
  1728. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1729. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1730. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1731. return mutStr;
  1732. }
  1733. - (NSString *)arrayToJSONString:(NSArray *)array
  1734. {
  1735. if (array.count == 0) {
  1736. return @"";
  1737. }
  1738. NSError *error = nil;
  1739. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1740. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1741. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1742. NSRange range = {0,jsonString.length};
  1743. //去掉字符串中的空格
  1744. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  1745. NSRange range2 = {0,mutStr.length};
  1746. //去掉字符串中的换行符
  1747. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  1748. return mutStr;
  1749. }
  1750. - (void)dealloc {
  1751. [self.webView stopLoading];
  1752. self.webView.UIDelegate = nil;
  1753. self.webView.navigationDelegate = nil;
  1754. self.webView.scrollView.delegate = nil;
  1755. [self.webView removeFromSuperview];
  1756. WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
  1757. [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
  1758. completionHandler:^(NSArray * __nonnull records) {
  1759. for (WKWebsiteDataRecord *record in records)
  1760. {
  1761. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
  1762. forDataRecords:@[record]
  1763. completionHandler:^{
  1764. NSLog(@"Cookies for %@ deleted successfully",record.displayName);
  1765. }];
  1766. }
  1767. }];
  1768. WKUserContentController *userCC = self.webView.configuration.userContentController;
  1769. [userCC removeScriptMessageHandlerForName:@"chosePic"];
  1770. [userCC removeScriptMessageHandlerForName:@"toPZ"];
  1771. [userCC removeScriptMessageHandlerForName:@"toBJ"];
  1772. [userCC removeScriptMessageHandlerForName:@"getJp"];
  1773. [userCC removeScriptMessageHandlerForName:@"toSC"];
  1774. [userCC removeScriptMessageHandlerForName:@"toWJ"];
  1775. [userCC removeScriptMessageHandlerForName:@"keyBoard"];
  1776. [userCC removeScriptMessageHandlerForName:@"getType"];
  1777. [userCC removeScriptMessageHandlerForName:@"approverCheckUsers"];
  1778. [userCC removeScriptMessageHandlerForName:@"carbonCopyUsers"];
  1779. [userCC removeScriptMessageHandlerForName:@"changeState"];
  1780. [userCC removeScriptMessageHandlerForName:@"to"];
  1781. [userCC removeScriptMessageHandlerForName:@"postH"];
  1782. [userCC removeAllUserScripts];
  1783. [[NSNotificationCenter defaultCenter] removeObserver:self];
  1784. }
  1785. //- (void)hideWKWebviewKeyboardShortcutBar:(WKWebView *)webView {
  1786. // UIView *targetView;
  1787. //
  1788. // for (UIView *view in webView.scrollView.subviews) {
  1789. // if([[view.class description] hasPrefix:@"WKContent"]) {
  1790. // targetView = view;
  1791. // }
  1792. // }
  1793. // if (!targetView) {
  1794. // return;
  1795. // }
  1796. // NSString *noInputAccessoryViewClassName = [NSString stringWithFormat:@"%@_NoInputAccessoryView", targetView.class.superclass];
  1797. // Class newClass = NSClassFromString(noInputAccessoryViewClassName);
  1798. //
  1799. // if(newClass == nil) {
  1800. // newClass = objc_allocateClassPair(targetView.class, [noInputAccessoryViewClassName cStringUsingEncoding:NSASCIIStringEncoding], 0);
  1801. // if(!newClass) {
  1802. // return;
  1803. // }
  1804. //
  1805. // Method method = class_getInstanceMethod([_NoInputAccessoryView class], @selector(inputAccessoryView));
  1806. //
  1807. // class_addMethod(newClass, @selector(inputAccessoryView), method_getImplementation(method), method_getTypeEncoding(method));
  1808. //
  1809. // objc_registerClassPair(newClass);
  1810. // }
  1811. //
  1812. // object_setClass(targetView, newClass);
  1813. //}
  1814. - (CollectModelType)returnType:(NSString *)url
  1815. {
  1816. NSString * name = [[url pathExtension] lowercaseString];
  1817. if([name hasSuffix:@"png"] || [name hasSuffix:@"jpg"] || [name hasSuffix:@"jpeg"] || [name hasSuffix:@"bmp"]){
  1818. return CollectModel_Image;
  1819. }else{
  1820. return CollectModel_file;
  1821. }
  1822. }
  1823. #pragma mark - 通知存草稿箱
  1824. - (void)backAction:(id)sender{
  1825. if (self.type == CollectModel_Notice
  1826. || self.type == CollectModel_InterMail
  1827. || self.type == CollectModel_NewTopic
  1828. || self.type == CollectModel_Toipc
  1829. || self.type == CollectModel_NoteBook) {
  1830. if (self.isNull) {
  1831. [super backAction:sender];
  1832. }else{
  1833. [self saveToDraftBox];
  1834. }
  1835. }else{
  1836. [super backAction:sender];
  1837. }
  1838. }
  1839. - (void)menuAction:(id)sender
  1840. {
  1841. [[NSNotificationCenter defaultCenter] postNotificationName:CHECKDRAFT object:nil];
  1842. [super menuAction:sender];
  1843. }
  1844. - (void)saveToDraftBox
  1845. {
  1846. WS(weakSelf);
  1847. [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{
  1848. weakSelf.isDraft = YES;
  1849. [weakSelf submit];
  1850. } cancle:^(ShowKeepNoticeCloseType colseType) {
  1851. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  1852. if(colseType == ShowKeepNoticeCloseType1){
  1853. [weakSelf.navigationController popViewControllerAnimated:YES];
  1854. }
  1855. }] show];
  1856. }
  1857. - (void)backMailList
  1858. {
  1859. for (UIViewController * vc in self.navigationController.viewControllers) {
  1860. if ([vc isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]) {
  1861. [self.navigationController popToViewController:vc animated:YES];
  1862. return;
  1863. }
  1864. }
  1865. }
  1866. - (void)back1
  1867. {
  1868. if (self.isEdit) {
  1869. for (NSInteger i = (self.navigationController.viewControllers.count - 1); i >= 0; i --) {
  1870. UIViewController *vc = self.navigationController.viewControllers[i];
  1871. if ([vc isKindOfClass:NSClassFromString(@"CountDataVC")]
  1872. || [vc isKindOfClass:NSClassFromString(@"MyApprovalPageDetail")]
  1873. || [vc isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
  1874. || [vc isKindOfClass:NSClassFromString(@"WorkFlowFecordController")]
  1875. || [vc isKindOfClass:NSClassFromString(@"WorkFlowDetailsController")]
  1876. || [vc isKindOfClass:NSClassFromString(@"TDGroupInfoListVC")]
  1877. || [vc isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]
  1878. || [vc isKindOfClass:NSClassFromString(@"OtherNoteBookVC")]
  1879. || [vc isKindOfClass:NSClassFromString(@"OtherFavoriteVC")]
  1880. || [vc isKindOfClass:NSClassFromString(@"NoteBookVC")]
  1881. || [vc isKindOfClass:NSClassFromString(@"CommonNoteVC")]
  1882. || [vc isKindOfClass:NSClassFromString(@"SourceHomeVC")]
  1883. || [vc isKindOfClass:NSClassFromString(@"SourceGroupVC")]
  1884. || [vc isKindOfClass:NSClassFromString(@"MyTDTopicBookVC")]
  1885. || [vc isKindOfClass:NSClassFromString(@"EMChatViewController")]
  1886. || [vc isKindOfClass:NSClassFromString(@"MyFavoriteVC")]
  1887. || [vc isKindOfClass:NSClassFromString(@"MyInfoVC")]
  1888. || [vc isKindOfClass:NSClassFromString(@"CommonHomeVC")]) {
  1889. [self.navigationController popToViewController:vc animated:YES];
  1890. return;
  1891. }
  1892. }
  1893. }else{
  1894. for (NSInteger i = (self.navigationController.viewControllers.count - 1); i >= 0; i --) {
  1895. UIViewController *vc = self.navigationController.viewControllers[i];
  1896. if ([vc isKindOfClass:NSClassFromString(@"CountDataVC")]
  1897. || [vc isKindOfClass:NSClassFromString(@"MyApprovalPageDetail")]
  1898. || [vc isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
  1899. || [vc isKindOfClass:NSClassFromString(@"WorkFlowFecordController")]
  1900. || [vc isKindOfClass:NSClassFromString(@"WorkFlowDetailsController")]
  1901. || [vc isKindOfClass:NSClassFromString(@"TDGroupInfoListVC")]
  1902. || [vc isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]
  1903. || [vc isKindOfClass:NSClassFromString(@"OtherNoteBookVC")]
  1904. || [vc isKindOfClass:NSClassFromString(@"OtherFavoriteVC")]
  1905. || [vc isKindOfClass:NSClassFromString(@"NoteBookVC")]
  1906. || [vc isKindOfClass:NSClassFromString(@"CommonNoteVC")]
  1907. || [vc isKindOfClass:NSClassFromString(@"SourceHomeVC")]
  1908. || [vc isKindOfClass:NSClassFromString(@"SourceGroupVC")]
  1909. || [vc isKindOfClass:NSClassFromString(@"MyTDTopicBookVC")]
  1910. || [vc isKindOfClass:NSClassFromString(@"MyTDTopicDetailVC")]
  1911. || [vc isKindOfClass:NSClassFromString(@"EMChatViewController")]
  1912. || [vc isKindOfClass:NSClassFromString(@"MyFavoriteVC")]
  1913. || [vc isKindOfClass:NSClassFromString(@"MyInfoVC")]
  1914. || [vc isKindOfClass:NSClassFromString(@"CommonHomeVC")]) {
  1915. [self.navigationController popToViewController:vc animated:YES];
  1916. return;
  1917. }
  1918. }
  1919. }
  1920. }
  1921. #pragma mark - JS调起键盘
  1922. - (void)allowDisplayingKeyboardWithoutUserAction {
  1923. Class class = NSClassFromString(@"WKContentView");
  1924. NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
  1925. NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
  1926. NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
  1927. char * methodSignature = "_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
  1928. if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_13_0_0]) {
  1929. methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:";
  1930. } else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
  1931. methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
  1932. }
  1933. if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
  1934. SEL selector = sel_getUid(methodSignature);
  1935. Method method = class_getInstanceMethod(class, selector);
  1936. IMP original = method_getImplementation(method);
  1937. IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
  1938. ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
  1939. });
  1940. method_setImplementation(method, override);
  1941. } else {
  1942. SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
  1943. Method method = class_getInstanceMethod(class, selector);
  1944. IMP original = method_getImplementation(method);
  1945. IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
  1946. ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
  1947. });
  1948. method_setImplementation(method, override);
  1949. }
  1950. }
  1951. #pragma mark - 存草稿
  1952. - (void)saveDraft:(NSDictionary *)dict
  1953. {
  1954. if (ISEmpty(dict[@"Title"]) && ISEmpty(dict[@"html"])) {
  1955. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  1956. return;
  1957. }
  1958. self.isDraft = YES;
  1959. switch (self.type) {
  1960. case CollectModel_Toipc:
  1961. {
  1962. [self GroupTopicDraft:dict];
  1963. }
  1964. break;
  1965. case CollectModel_NewTopic:
  1966. {
  1967. [self noteTopicDraft:dict];
  1968. }
  1969. break;
  1970. case CollectModel_NoteBook:
  1971. {
  1972. [self noteTopicDraft:dict];
  1973. }
  1974. break;
  1975. // case CollectModel_Notice:
  1976. // {
  1977. // [self noticeDraft:dict];
  1978. // }
  1979. // break;
  1980. // case CollectModel_InterMail:
  1981. // {
  1982. // [self MailDraft:dict];
  1983. // }
  1984. // break;
  1985. default:
  1986. break;
  1987. }
  1988. }
  1989. - (void)GroupTopicDraft:(NSDictionary *)dict
  1990. {
  1991. NSString * html = dict[@"html"];
  1992. NSArray * jsonArray = dict[@"json"];
  1993. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1994. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1995. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1996. [paraDict setObject:@(self.FolderId) forKey:@"GroupId"];
  1997. // [paraDict setObject:@() forKey:@"FolderId"];
  1998. [paraDict setObject:ISEmpty(html) ? @"": html forKey:@"HtmlContent"];
  1999. [paraDict setObject:@(self.isDraft) forKey:@"IsDraft"];
  2000. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  2001. [paraDict setObject:@(self.type) forKey:@"Type"];
  2002. USERDEFAULTSSET(paraDict,DRAFT);
  2003. }
  2004. - (void)noteTopicDraft:(NSDictionary *)dict
  2005. {
  2006. NSString * html = dict[@"html"];
  2007. NSArray * jsonArray = dict[@"json"];
  2008. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  2009. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  2010. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  2011. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  2012. [paraDict setObject:@(self.isDraft) forKey:@"IsDraft"];
  2013. [paraDict setObject:ISEmpty(html) ? @"": html forKey:@"HtmlContent"];
  2014. [paraDict setObject:(self.type == CollectModel_NewTopic ? @(1) : @(0)) forKey:@"IsTopic"];
  2015. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  2016. [paraDict setObject:@(self.type) forKey:@"Type"];
  2017. USERDEFAULTSSET(paraDict,DRAFT);
  2018. }
  2019. - (void)noticeDraft:(NSDictionary *)dict
  2020. {
  2021. NSString * html = dict[@"html"];
  2022. NSArray * jsonArray = dict[@"json"];
  2023. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  2024. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  2025. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  2026. [paraDict setValue:self.isDraft ? @(2) : @(1) forKey:@"NoticeType"];
  2027. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  2028. [paraDict setObject:ISEmpty(html) ? @"": html forKey:@"HtmlContent"];
  2029. [paraDict setObject:@(self.shouType) forKey:@"TypeValue"];
  2030. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  2031. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  2032. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  2033. [paraDict setObject:@(self.type) forKey:@"Type"];
  2034. USERDEFAULTSSET(paraDict,DRAFT);
  2035. }
  2036. - (void)MailDraft:(NSDictionary *)dict
  2037. {
  2038. NSString * html = dict[@"html"];
  2039. NSArray * jsonArray = dict[@"json"];
  2040. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  2041. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  2042. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  2043. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  2044. [paraDict setObject:ISEmpty(html) ? @"": html forKey:@"HtmlContent"];
  2045. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  2046. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  2047. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  2048. [paraDict setObject:@(self.MailType) forKey:@"MissiveType"];///1 正常 2 匿名
  2049. [paraDict setObject:@(self.Id) forKey:@"ParentId"];///回复ID
  2050. [paraDict setObject:@(self.shouType) forKey:@"TypeValue"];
  2051. [paraDict setObject:@(self.isDraft ? 2 : 1) forKey:@"MissiveAttributeType"];///1 发送 2 草稿
  2052. [paraDict setObject:@(self.type) forKey:@"Type"];
  2053. USERDEFAULTSSET(paraDict,DRAFT);
  2054. }
  2055. #pragma mark - UIScrollViewDelegate
  2056. -(UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView
  2057. {
  2058. return nil;
  2059. }
  2060. @end