AppDelegate.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. //
  2. // AppDelegate.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/21.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. #import "TabBarController.h"
  10. #import "WorkFlowTabbarController.h"
  11. #import "WXApi.h"
  12. #import "HKFloatManager.h"
  13. #import "JPUSHService.h"
  14. @interface AppDelegate ()<JPUSHRegisterDelegate,WXApiDelegate,JPUSHRegisterDelegate>
  15. @property (nonatomic, strong) TabBarController *tabBar;
  16. @end
  17. @implementation AppDelegate
  18. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  19. // Override point for customization after application launch.
  20. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  21. self.tabBar = [TabBarController sharedTabBarController];
  22. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  23. [[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];
  24. ///友盟分享
  25. [self checkDraft];
  26. [self configUSharePlatforms];
  27. //初始化环信
  28. [[EaseSDKHelper shareHelper] hyphenateApplication:application appkey:kHuanXinAppKey apnsCertName:kHuanXinApnsName];
  29. [WXApi registerApp:wxAppKey universalLink:@"https://apk.tederen.com"];
  30. [self settingPush: launchOptions];
  31. WS(weakSelf);
  32. if (![UserManager checkStringNull:kToken]){
  33. self.window.rootViewController = weakSelf.tabBar;
  34. [[EMClient sharedClient] logout:YES completion:^(EMError *aError) {
  35. NSData * data = USERDEFAULTSGET(@"USERINFO");
  36. AppUserModel * model = (AppUserModel*) [NSKeyedUnarchiver unarchiveObjectWithData:data];
  37. [[EMClient sharedClient] loginWithUsername:model.ImId password:@"123456" completion:^(NSString *aUsername, EMError *aError) {
  38. EMError *error = aError;
  39. dispatch_async(dispatch_get_main_queue(), ^{
  40. if (!error) {
  41. //设置是否自动登录
  42. [[EMClient sharedClient].options setIsAutoLogin:YES];
  43. weakSelf.window.rootViewController = weakSelf.tabBar;
  44. } else {
  45. weakSelf.window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  46. }
  47. });
  48. }];
  49. }];
  50. }else{
  51. self.window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  52. }
  53. [self.window makeKeyAndVisible];
  54. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkDraft) name:CHECKDRAFT object:nil];
  55. [HKFloatManager addFloatVcs:@[@"HKSecondViewController"]];
  56. return YES;
  57. }
  58. - (void)dealloc
  59. {
  60. [[NSNotificationCenter defaultCenter] removeObserver:self];
  61. }
  62. - (void)configUSharePlatforms
  63. {
  64. [[UMSocialGlobal shareInstance] setUniversalLinkDic:@{@(UMSocialPlatformType_WechatSession):@"https://apk.tederen.com",
  65. @(UMSocialPlatformType_WechatTimeLine):@"https://apk.tederen.com",
  66. @(UMSocialPlatformType_QQ):@"https://apk.tederen.com/qq_conn/101901983",
  67. @(UMSocialPlatformType_Sina):@"https://apk.tederen.com",
  68. }];
  69. [UMConfigure initWithAppkey:UMengAppKey channel:nil];
  70. /* 设置微信的appKey和appSecret */
  71. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:wxAppKey appSecret:wxAppSecret redirectURL:@"https://apk.tederen.com"];
  72. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatTimeLine appKey:wxAppKey appSecret:wxAppSecret redirectURL:@"https://apk.tederen.com"];
  73. /* 设置分享到QQ互联的appID
  74. * U-Share SDK为了兼容大部分平台命名,统一用appKey和appSecret进行参数设置,而QQ平台仅需将appID作为U-Share的appKey参数传进即可。
  75. */
  76. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:QQAppKey/*设置QQ平台的appID*/ appSecret:QQAppSecret redirectURL:@"https://apk.tederen.com"];
  77. /* 设置新浪的appKey和appSecret */
  78. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:WBAppKey appSecret:WBAppSecret redirectURL:@"https://apk.tederen.com"];
  79. }
  80. //- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
  81. //{
  82. // NSString * str = [url absoluteString];
  83. // if ([str hasPrefix:@"iostedeapp"]) {
  84. // if (![UserManager checkStringNull:kToken]){
  85. // str = [str substringFromIndex:17];
  86. // NSArray *array = [str componentsSeparatedByString:@"&"];
  87. // NSLog(@"%@",array);
  88. // NSDictionary * dict= @{@"Id":array[0],@"type":array[1],@"userId":array[2],@"name":array[3],@"describe":array[4]};
  89. // [self pushVC:dict];
  90. // }else{
  91. // UIWindow *window = [UtilsTools getWindow];
  92. // window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  93. // [window makeKeyAndVisible];
  94. // }
  95. // return YES;
  96. // }
  97. // return [WXApi handleOpenURL:url delegate:self];
  98. //}
  99. /// 分享回调
  100. - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
  101. {
  102. NSString * str = [url absoluteString];
  103. if ([str hasPrefix:@"iostedeapp"]) {
  104. if (![UserManager checkStringNull:kToken]){
  105. str = [str substringFromIndex:17];
  106. NSArray *array = [str componentsSeparatedByString:@"&"];
  107. NSLog(@"%@",array);
  108. NSDictionary * dict= @{@"Id":array[0],@"type":array[1],@"userId":array[2],@"name":array[3],@"describe":array[4]};
  109. [self pushVC:dict];
  110. }else{
  111. UIWindow *window = [UtilsTools getWindow];
  112. window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  113. [window makeKeyAndVisible];
  114. }
  115. return YES;
  116. }
  117. return [WXApi handleOpenURL:url delegate:self];
  118. }
  119. -(void)pushVC:(NSDictionary *)dict
  120. {
  121. UIWindow *window = [UtilsTools getWindow];
  122. window.rootViewController = [TabBarController sharedTabBarController];
  123. [[TabBarController sharedTabBarController] setSelectedIndex:0];
  124. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  125. [[NSNotificationCenter defaultCenter] postNotificationName:SHARERETURNSUCCESS object:nil userInfo:dict];
  126. });
  127. [window makeKeyAndVisible];
  128. }
  129. + (UINavigationController *)getRootController {
  130. return (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;
  131. }
  132. + (UIViewController *)getTopView {
  133. UINavigationController *rootNavigation = [self getRootController];
  134. return rootNavigation.topViewController;
  135. }
  136. + (instancetype)appdelegate {
  137. return (AppDelegate *)[UIApplication sharedApplication].delegate;
  138. }
  139. - (void)applicationWillResignActive:(UIApplication *)application {
  140. NSLog(@"applicationWillResignActive");
  141. // [[NSNotificationCenter defaultCenter] postNotificationName:NOTEBOOKSAVE object:nil];
  142. }
  143. - (void)applicationDidEnterBackground:(UIApplication *)application {
  144. NSLog(@"applicationDidEnterBackground");
  145. }
  146. - (void)applicationWillEnterForeground:(UIApplication *)application {
  147. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  148. [JPUSHService setBadge:0];
  149. }
  150. - (void)applicationDidBecomeActive:(UIApplication *)application {
  151. NSLog(@"applicationDidBecomeActive");
  152. }
  153. - (void)applicationWillTerminate:(UIApplication *)application {
  154. NSLog(@"applicationWillTerminate");
  155. }
  156. #pragma mark - 极光
  157. - (void)settingPush:(NSDictionary *)launchOptions {
  158. JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
  159. entity.types = JPAuthorizationOptionAlert | JPAuthorizationOptionBadge | JPAuthorizationOptionSound;
  160. [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
  161. [JPUSHService setupWithOption:launchOptions appKey:kJGAppKey
  162. channel:@"tederen"
  163. apsForProduction:NO // 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
  164. advertisingIdentifier:nil];
  165. [JpushTool setAlias:[AppUserModel sharedAppUserModel].Phone completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
  166. NSLog(@"====%@",iAlias);
  167. } seq:[[AppUserModel sharedAppUserModel].Phone integerValue]];
  168. }
  169. // 此方法是必须要有实现,否则SDK将无法处理应用注册的Token,推送也就不会成功
  170. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  171. NSLog(@"%@",deviceToken);
  172. [JPUSHService registerDeviceToken:deviceToken];
  173. }
  174. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
  175. }
  176. #pragma mark- JPUSHRegisterDelegate
  177. // iOS 12 Support
  178. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification{
  179. NSDictionary * userInfo = notification.request.content.userInfo;
  180. if (notification && [notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
  181. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  182. [JPUSHService setBadge:0];
  183. [self JPushToVC:userInfo[@"data"]];
  184. }else{
  185. //从通知设置界面进入应用
  186. }
  187. }
  188. // iOS 10 Support
  189. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
  190. // Required
  191. // NSDictionary * userInfo = notification.request.content.userInfo;
  192. if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
  193. [JPUSHService setBadge:0];
  194. }
  195. completionHandler(UNNotificationPresentationOptionSound);
  196. // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
  197. }
  198. // iOS 10 Support
  199. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
  200. // Required
  201. NSDictionary * userInfo = response.notification.request.content.userInfo;
  202. if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
  203. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  204. [JPUSHService setBadge:0];
  205. [self JPushToVC:userInfo[@"data"]];
  206. }
  207. completionHandler(); // 系统要求
  208. }
  209. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  210. [JPUSHService handleRemoteNotification:userInfo];
  211. completionHandler(UIBackgroundFetchResultNewData);
  212. }
  213. //#pragma mark 关闭第三方键盘
  214. //- (BOOL)application:(UIApplication*)application shouldAllowExtensionPointIdentifier:(NSString*)extensionPointIdentifier {
  215. // if([extensionPointIdentifier isEqualToString:UIApplicationKeyboardExtensionPointIdentifier]) {
  216. // return NO;
  217. // }
  218. // return YES;
  219. //}
  220. #pragma mark - 微信登录
  221. - (void)onResp:(BaseResp *)resp{
  222. // =============== 获得的微信登录授权回调 ============
  223. if ([resp isMemberOfClass:[SendAuthResp class]]) {
  224. NSLog(@"******************获得的微信登录授权******************");
  225. SendAuthResp *aresp = (SendAuthResp *)resp;
  226. if (aresp.errCode != 0 ) {
  227. dispatch_async(dispatch_get_main_queue(), ^{
  228. dispatch_async(dispatch_get_main_queue(), ^{
  229. SHOWERROR(@"微信授权失败");
  230. });
  231. });
  232. return;
  233. }
  234. //授权成功获取 OpenId
  235. NSString *code = aresp.code;
  236. [self getWeiXinOpenId:code];
  237. }
  238. }
  239. - (void)getWeiXinOpenId:(NSString *)code{
  240. /*
  241. appid 是 应用唯一标识,在微信开放平台提交应用审核通过后获得
  242. secret 是 应用密钥AppSecret,在微信开放平台提交应用审核通过后获得
  243. code 是 填写第一步获取的code参数
  244. grant_type 是 填authorization_code
  245. */
  246. NSString *url =[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=authorization_code",wxAppKey,wxAppSecret,code];
  247. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  248. NSURL *zoneUrl = [NSURL URLWithString:url];
  249. NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];
  250. NSData *data1 = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];
  251. if (!data1) {
  252. dispatch_async(dispatch_get_main_queue(), ^{
  253. SHOWERROR(@"微信授权失败");
  254. });
  255. return ;
  256. }
  257. // 授权成功,获取token、openID字典
  258. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data1 options:NSJSONReadingMutableContainers error:nil];
  259. NSLog(@"token、openID字典===%@",dic);
  260. // NSString *access_token = dic[@"access_token"];
  261. // NSString *openid= dic[@"openid"];
  262. if ([dic[@"openid"] length] > 0) {
  263. [[NSNotificationCenter defaultCenter] postNotificationName:WeiChatSuccess object:nil userInfo:dic];
  264. }else{
  265. dispatch_async(dispatch_get_main_queue(), ^{
  266. SHOWERROR(@"微信授权失败");
  267. });
  268. return ;
  269. }
  270. });
  271. }
  272. - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  273. if (![[UMSocialManager defaultManager] handleUniversalLink:userActivity options:nil]) {
  274. // 其他SDK的回调
  275. }
  276. if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
  277. NSURL *webpageURL = userActivity.webpageURL;
  278. NSString * str = [webpageURL absoluteString];
  279. if ([str hasPrefix:@"iossmartrhino"]) {
  280. if (![UserManager checkStringNull:kToken]){
  281. str = [str substringFromIndex:20];
  282. NSArray *array = [str componentsSeparatedByString:@"&"];
  283. NSDictionary * dict= @{@"Id":array[0],@"type":array[1],@"userId":array[2],@"name":array[3],@"describe":array[4]};
  284. [[NSNotificationCenter defaultCenter] postNotificationName:SHARERETURNSUCCESS object:nil userInfo:dict];
  285. UIWindow *window = [UtilsTools getWindow];
  286. window.rootViewController = [TabBarController sharedTabBarController];
  287. [[TabBarController sharedTabBarController] setSelectedIndex:0];
  288. [window makeKeyAndVisible];
  289. }else{
  290. UIWindow *window = [UtilsTools getWindow];
  291. window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  292. [window makeKeyAndVisible];
  293. }
  294. }
  295. // TODO 根据需求进行处理
  296. }
  297. // TODO 根据需求进行处理
  298. return YES;
  299. }
  300. - (void)checkDraft
  301. {
  302. id data = USERDEFAULTSGET(DRAFT);
  303. if ([data isKindOfClass:[NSDictionary class]]) {
  304. NSLog(@"=======%@",data);
  305. switch ([data[@"Type"] integerValue]) {
  306. case CollectModel_Toipc:
  307. {
  308. [self submitTopic:data];
  309. }
  310. break;
  311. case CollectModel_NoteBook:
  312. {
  313. [self submitNoteBook:data withType:CollectModel_NoteBook];
  314. }
  315. break;
  316. case CollectModel_NewTopic:
  317. {
  318. [self submitNoteBook:data withType:CollectModel_NewTopic];
  319. }
  320. break;
  321. case CollectModel_Notice:
  322. {
  323. [self submitNotice:data];
  324. }
  325. break;
  326. case CollectModel_InterMail:
  327. {
  328. [self submitMail:data];
  329. }
  330. break;
  331. default:
  332. break;
  333. }
  334. }
  335. }
  336. - (void)submitTopic:(NSDictionary *)dict
  337. {
  338. if ([dict[@"GroupId"] integerValue] == 0) {
  339. return;
  340. }
  341. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  342. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  343. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  344. [paraDict setObject:dict[@"GroupId"] forKey:@"GroupId"];
  345. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  346. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  347. [paraDict setObject:dict[@"IsDraft"] forKey:@"IsDraft"];
  348. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  349. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Add) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  350. NSLog(@"%@",responseObject);
  351. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject[@"Data"]];
  352. NSMutableDictionary * DraftDict = [NSMutableDictionary dictionary];
  353. [DraftDict setObject:dict[@"Type"] forKey:@"Type"];
  354. [DraftDict setObject:InfoDict[@"FolderId"] forKey:@"FolderId"];
  355. [DraftDict setObject:InfoDict[@"GroupId"] forKey:@"GroupId"];
  356. [DraftDict setObject:InfoDict[@"Id"] forKey:@"Id"];
  357. [DraftDict setObject:InfoDict[@"UserId"] forKey:@"UserId"];
  358. [DraftDict setObject:InfoDict[@"UserId"] forKey:@"UserId"];
  359. USERDEFAULTSSET(DraftDict, GROUPTOPICDRAFTINFO);
  360. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  361. } failure:^(NSError * _Nonnull error) {
  362. SHOWERROR([ZYCTool handerResultData:error])
  363. }];
  364. }
  365. - (void)submitNoteBook:(NSDictionary *)dict withType:(CollectModelType)type
  366. {
  367. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  368. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  369. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  370. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  371. [paraDict setObject:dict[@"IsDraft"] forKey:@"IsDraft"];
  372. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  373. [paraDict setObject:dict[@"IsTopic"] forKey:@"IsTopic"];
  374. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  375. [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateNoteBook) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  376. NSLog(@"%@",responseObject);
  377. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
  378. [InfoDict setObject:dict[@"Type"] forKey:@"Type"];
  379. USERDEFAULTSSET(InfoDict, type == CollectModel_NoteBook ? NOTEBOOKDRAFTINFO : TOPICBOOKDRAFTINFO);
  380. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  381. } failure:^(NSError * _Nonnull error) {
  382. SHOWERROR([ZYCTool handerResultData:error]);
  383. }];
  384. }
  385. - (void)submitNotice:(NSDictionary *)dict
  386. {
  387. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  388. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  389. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  390. [paraDict setObject:dict[@"NoticeType"] forKey:@"NoticeType"];
  391. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  392. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  393. [paraDict setObject:dict[@"TypeValue"] forKey:@"TypeValue"];
  394. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  395. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  396. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  397. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADD) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  398. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
  399. [InfoDict setObject:dict[@"Type"] forKey:@"Type"];
  400. USERDEFAULTSSET(InfoDict, NOTICERAFTINFO);
  401. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  402. } failure:^(NSError * _Nonnull error) {
  403. SHOWERROR([ZYCTool handerResultData:error]);
  404. }];
  405. }
  406. - (void)submitMail:(NSDictionary *)dict
  407. {
  408. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  409. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  410. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  411. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  412. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  413. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  414. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  415. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  416. [paraDict setObject:dict[@"MissiveType"] forKey:@"MissiveType"];///1 正常 2 匿名
  417. [paraDict setObject:dict[@"ParentId"] forKey:@"ParentId"];///回复ID
  418. [paraDict setObject:dict[@"TypeValue"] forKey:@"TypeValue"];
  419. [paraDict setObject:dict[@"MissiveAttributeType"] forKey:@"MissiveAttributeType"];///1 发送 2 草稿
  420. [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  421. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
  422. [InfoDict setObject:dict[@"Type"] forKey:@"Type"];
  423. USERDEFAULTSSET(InfoDict, MAILRAFTINFO);
  424. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  425. } failure:^(NSError * _Nonnull error) {
  426. SHOWERROR([ZYCTool handerResultData:error]);
  427. }];
  428. }
  429. - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
  430. // 可以这么写
  431. if (self.allowOrentitaionRotation) {
  432. return UIInterfaceOrientationMaskAllButUpsideDown;
  433. }
  434. return UIInterfaceOrientationMaskPortrait;
  435. }
  436. #pragma mark - JPushToVC
  437. - (void)JPushToVC:(NSDictionary *)dict
  438. {
  439. UIWindow *window = [UtilsTools getWindow];
  440. window.rootViewController = [TabBarController sharedTabBarController];
  441. [[TabBarController sharedTabBarController] setSelectedIndex:0];
  442. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  443. [[NSNotificationCenter defaultCenter] postNotificationName:JPUSHSUCCESS object:nil userInfo:dict];
  444. });
  445. [window makeKeyAndVisible];
  446. }
  447. @end