MeCenterVC.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. //
  2. // MeCenterVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/6.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #define defGreen [UIColor colorWithRed:35/255.0 green:160/255.0 blue:227/255.0 alpha:1]
  9. #import "MeCenterVC.h"
  10. #import "LoginVC.h"
  11. #import "NSString+ex.h"
  12. #import "InputView.h"
  13. #import "AboutVC.h"
  14. #import "MyMessageVC.h"
  15. //客服
  16. #import "QMChatRoomViewController.h"
  17. #import <QMChatSDK/QMChatSDK.h>
  18. #import "QMAlert.h"
  19. #define PersonVCTop_H kStatusHeight+20
  20. #define PersonVCRate 1.0/(PersonVCTop_H+100-kNavOffSet)//100为头视图上defgreen高度
  21. @interface MeCenterVC ()<UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate, UIImagePickerControllerDelegate,InputViewDelegate,UINavigationControllerDelegate>
  22. {
  23. NSArray *_contentArr; //要显示的内容
  24. NSArray *_imgArray; //菜单图片
  25. InputView *_inputVi; //照片选择
  26. UIImageView *_headImgV; //头像
  27. UILabel *nameLabel;
  28. UILabel *schoolNamelabel;
  29. //客服
  30. BOOL _isFirstClick; // 判断点击状态
  31. BOOL _isPushed; // 判断跳转状态
  32. }
  33. @property(nonatomic,strong)UIView *topView;
  34. //客服
  35. @property (nonatomic, assign) BOOL isPushed; // 控制跳转
  36. @property (nonatomic, assign) BOOL isConnecting; // 控制多次注册
  37. @property (nonatomic, copy) NSDictionary * dictionary; //客服一些配置
  38. @end
  39. @implementation MeCenterVC
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. self.navigationItem.title = @"个人";
  43. _contentArr = @[@[@"我的资料",@"绑定手机",@"修改密码"],
  44. @[@"使用手册",@"联系客服",@"关于我们"],
  45. @[@"退出登录"]
  46. ];
  47. _imgArray = @[@[@"center_img1",@"center_img2",@"center_img3"],
  48. @[@"center_img4",@"center_img5",@"center_img6"],
  49. @[@"center_img7"]];
  50. [self myInit];
  51. }
  52. - (void)viewWillAppear:(BOOL)animated {
  53. [super viewWillAppear:animated];
  54. _isPushed = NO;
  55. self.navigationController.navigationBar.alpha = 0;
  56. [self setPersonData];
  57. }
  58. - (void)viewWillDisappear:(BOOL)animated {
  59. [super viewWillDisappear:animated];
  60. _isPushed = YES;
  61. self.navigationController.navigationBar.alpha = 1.0;
  62. }
  63. -(void)myInit{
  64. CGFloat x,y,w,h;
  65. x = 0;
  66. y = 0;
  67. w = kSize.width;
  68. h = PersonVCTop_H;
  69. _topView = [[UIView alloc] KSetxywh];
  70. _topView.backgroundColor = defGreen;
  71. [self.view addSubview:_topView];
  72. y+=h;
  73. h=117;
  74. UIView *headView = [[UIView alloc] KSetxywh];
  75. headView.backgroundColor = KBackGroundColor;
  76. y -= PersonVCTop_H;
  77. h = 100;
  78. UIView *view = [[UIView alloc] KSetxywh];
  79. view.backgroundColor = defGreen;
  80. [headView addSubview:view];
  81. x = y = 15;
  82. w = h = 70;
  83. UIImageView *imgView = [[UIImageView alloc] KSetxywh];
  84. [imgView setModeAspectFill];
  85. imgView.layer.masksToBounds = YES;
  86. imgView.layer.cornerRadius = h/2.0;
  87. [view addSubview:imgView];
  88. _headImgV = imgView;
  89. UIButton *btn = [[UIButton alloc] KSetxywh];
  90. [btn addTarget:self action:@selector(tapClick) forControlEvents:UIControlEventTouchUpInside];
  91. [view addSubview:btn];
  92. x += w + 10;
  93. y -= 5;
  94. w = kSize.width - x;
  95. h = 40;
  96. UILabel *label = [[UILabel alloc] KSetxywh];
  97. [label setText:@"欢迎您!" Font:FontTitle TextColor:[UIColor blackColor]];
  98. [view addSubview:label];
  99. nameLabel = label;
  100. y += h;
  101. label = [[UILabel alloc] KSetxywh];
  102. [label setText:@"" Font:Font17 TextColor:[UIColor blackColor]];
  103. [view addSubview:label];
  104. schoolNamelabel = label;
  105. [self setPersonData];
  106. UITableView * tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, PersonVCTop_H, kSize.width, kSize.height-PersonVCTop_H-kTabBarHeight) style:UITableViewStyleGrouped];
  107. [tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"me_cellID"];
  108. tableview.delegate = self;
  109. tableview.dataSource = self;
  110. tableview.showsVerticalScrollIndicator = NO;
  111. tableview.rowHeight = 50;
  112. tableview.tableHeaderView = headView;
  113. view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 60)];
  114. tableview.tableFooterView = view;
  115. [self.view addSubview:tableview];
  116. [self.view insertSubview:tableview belowSubview:_topView];
  117. //客服
  118. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(registerSuccess:) name:CUSTOM_LOGIN_SUCCEED object:nil];
  119. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(registerFailure:) name:CUSTOM_LOGIN_ERROR_USER object:nil];
  120. _isConnecting = NO;
  121. _isPushed = NO;
  122. }
  123. - (void)setPersonData
  124. {
  125. if ([MYAPPDELEGATE.userDic[@"photo"] length] > 0) {
  126. [_headImgV sd_setImageWithURL:[NSURL URLWithString:MYAPPDELEGATE.userDic[@"photo"]] placeholderImage:[UIImage imageNamed:@"me_DefaultHead"]];
  127. }else {
  128. _headImgV.image = [UIImage imageNamed:@"me_DefaultHead"];
  129. }
  130. NSString *nameString = @"欢迎您!";
  131. if ([MYAPPDELEGATE.userDic[@"realName"] length] > 0) {
  132. nameString = [NSString stringWithFormat:@"%@,欢迎您!",MYAPPDELEGATE.userDic[@"realName"]];
  133. }
  134. nameLabel.text = nameString;
  135. schoolNamelabel.text = [NSString stringWithFormat:@"%@ %@",MYAPPDELEGATE.userDic[@"dqmc"],MYAPPDELEGATE.userDic[@"qxmc"]];
  136. }
  137. #pragma mark 照片选择
  138. -(void)tapClick{
  139. InputView* vi = [[InputView alloc] initWithTitle:@"请选择头像"];
  140. [vi setDelegate:self];
  141. [vi show];
  142. _inputVi = vi;
  143. }
  144. -(void)InputView:(InputView *)view didGetImage:(UIImage *)image {
  145. [self upLoadImgWithImage:image];
  146. }
  147. -(void)InputViewWillPickImage:(InputView *)view
  148. {
  149. UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
  150. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
  151. pickerImage.sourceType = view.type;
  152. // pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  153. pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];
  154. }
  155. pickerImage.delegate = self;
  156. pickerImage.allowsEditing = NO;
  157. [self presentViewController:pickerImage animated:YES completion:nil];
  158. }
  159. - (void) imagePickerController:(UIImagePickerController *)picker
  160. didFinishPickingMediaWithInfo:(NSDictionary *)info
  161. {
  162. [_inputVi cancelAction];
  163. [picker dismissViewControllerAnimated:YES completion:^{
  164. UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
  165. [self upLoadImgWithImage:originalImage];
  166. }];
  167. }
  168. #pragma mark 头像上传
  169. -(void)upLoadImgWithImage:(UIImage *)image
  170. {
  171. if (!image) {
  172. return;
  173. }
  174. NSData * data;
  175. if (UIImageJPEGRepresentation(image, .5))
  176. {
  177. //图片质量 压缩成多少
  178. data = UIImageJPEGRepresentation(image, .5);
  179. }else{
  180. data = UIImagePNGRepresentation(image);
  181. }
  182. NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
  183. NSMutableDictionary * mDic = [NSMutableDictionary new];
  184. [mDic setValue:@"1" forKey:@"type"];
  185. [mDic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"keyword"];
  186. [mDic setValue:encodedImageStr forKey:@"content"];
  187. [self getDataWithDic:mDic method:@"upload-1" block:^(NSDictionary *successDic) {
  188. [self showMsgByMBWithString:@"修改头像成功"];
  189. [_headImgV sd_setImageWithURL:[NSURL URLWithString:successDic[@"body"]] placeholderImage:[UIImage imageNamed:@"me_DefaultHead"]];
  190. [MYAPPDELEGATE.userDic setValue:successDic[@"body"] forKey:@"photo"];
  191. }];
  192. }
  193. #pragma mark tableview代理相关
  194. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  195. return _contentArr.count;
  196. }
  197. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  198. return [_contentArr[section] count];
  199. }
  200. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  201. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"me_cellID" forIndexPath:indexPath];
  202. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  203. cell.imageView.image = [UIImage imageNamed:[_imgArray[indexPath.section] objectAtIndex:indexPath.row]];
  204. cell.textLabel.text = _contentArr[indexPath.section][indexPath.row];
  205. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  206. return cell;
  207. }
  208. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  209. if (indexPath.section == 0){
  210. if (indexPath.row == 0) {
  211. //我的资料
  212. MyMessageVC *vc = [[MyMessageVC alloc]init];
  213. [self.navigationController pushViewController:vc animated:YES];
  214. return;
  215. return;
  216. }
  217. if (indexPath.row == 1) {
  218. //绑定手机
  219. [self showMsgByMBWithString:unOpenMsg];
  220. return;
  221. }
  222. if (indexPath.row == 2) {
  223. //修改密码
  224. [self fixKey];
  225. return;
  226. }
  227. }else if (indexPath.section == 1){
  228. if (indexPath.row == 0) {
  229. //使用手册
  230. [self showMsgByMBWithString:unOpenMsg];
  231. return;
  232. }
  233. if (indexPath.row == 1) {
  234. //联系客服
  235. if (_isConnecting) {
  236. return;
  237. }
  238. _isConnecting = YES;
  239. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  240. // userId 只能使用 数字 字母(包括大小写) 下划线
  241. NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
  242. NSString *name = [NSString stringWithFormat:@"%@[闽I监管_%@]",MYAPPDELEGATE.userDic[@"realName"],version];
  243. [QMConnect registerSDKWithAppKey:CUSTOMERSERVICE_APPKEY userName:name userId:[NSString stringWithFormat:@"%@",MYAPPDELEGATE.userDic[@"id"]]];
  244. return;
  245. }
  246. if (indexPath.row == 2) {
  247. AboutVC *vc = [[AboutVC alloc]init];
  248. [self.navigationController pushViewController:vc animated:YES];
  249. return;
  250. }
  251. }else if (indexPath.section == 2 && indexPath.row == 0){
  252. //退出登录
  253. [self loginAciton];
  254. }
  255. }
  256. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  257. //topview
  258. CGRect newFrame = self.topView.frame;
  259. CGFloat settingViewOffsetY = PersonVCTop_H - scrollView.contentOffset.y;
  260. newFrame.size.height = settingViewOffsetY;
  261. // NSLog(@"%f,%f",scrollView.contentOffset.y,newFrame.size.height);
  262. if (settingViewOffsetY < PersonVCTop_H) {
  263. newFrame.size.height = PersonVCTop_H;
  264. }
  265. self.topView.frame = newFrame;
  266. //navBar
  267. self.navigationController.navigationBar.alpha = PersonVCRate*scrollView.contentOffset.y;
  268. // NSLog(@"-->> %f", self.navigationController.navigationBar.alpha);
  269. }
  270. #pragma mark 修改密码
  271. -(void)fixKey
  272. {
  273. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"验证原密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
  274. [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {
  275. textField.placeholder = @"请输入原密码";
  276. }];
  277. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  278. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  279. NSString *text = [[alert.textFields firstObject] text];
  280. NSString *key = MYAPPDELEGATE.userDic[@"password"];
  281. if (![[text md5Encrypt] isEqualToString:key]) {
  282. [self showMsgByMBWithString:@"原密码错误!"];
  283. return;
  284. }
  285. [self willModifyPwd];
  286. }]];
  287. dispatch_async(dispatch_get_main_queue(), ^{
  288. [self.tabBarController presentViewController:alert animated:true completion:nil];
  289. });
  290. }
  291. -(void)willModifyPwd{
  292. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:@"修改密码" message:nil preferredStyle:UIAlertControllerStyleAlert];
  293. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  294. textField.placeholder = @"请输入新密码";
  295. textField.secureTextEntry = YES;
  296. }];
  297. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  298. textField.placeholder = @"请确认密码";
  299. textField.secureTextEntry = YES;
  300. }];
  301. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  302. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定修改" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  303. // 读取文本框的值显示出来
  304. UITextField *newtf1 = alertFind.textFields[0];
  305. UITextField *newtf = alertFind.textFields[1];
  306. if (newtf1.text.length < 6 || newtf.text.length < 6) {
  307. [self showMsgByMBWithString:@"密码长度不能少于6个字符"];
  308. return;
  309. }
  310. if (![newtf1.text isEqualToString:newtf.text])
  311. {
  312. UIAlertController *noname = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码不一致,请您核查" preferredStyle:UIAlertControllerStyleAlert];
  313. [noname addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
  314. dispatch_async(dispatch_get_main_queue(), ^{
  315. [self.tabBarController presentViewController:noname animated:true completion:nil];
  316. });
  317. return;
  318. }
  319. [self chanagePasswordWithOldStr:MYAPPDELEGATE.userDic[@"password"] newStr:[newtf.text md5Encrypt]];
  320. }]];
  321. dispatch_async(dispatch_get_main_queue(), ^{
  322. [self.tabBarController presentViewController:alertFind animated:true completion:nil];
  323. });
  324. }
  325. -(void)chanagePasswordWithOldStr:(NSString *)oldpwd newStr:(NSString *)newpwd{
  326. NSMutableDictionary * mdic = [NSMutableDictionary new];
  327. [mdic setValue:MYAPPDELEGATE.userDic[@"id"] forKey:@"id"];
  328. [mdic setValue:oldpwd forKey:@"oldPwd"];
  329. [mdic setValue:newpwd forKey:@"newPwd"];
  330. [self getDataWithDic:mdic method:@"modifyPwd" block:^(NSDictionary *successDic) {
  331. //修改成功,返回登录界面,重新登录
  332. UIAlertController * alert = [UIAlertController alertControllerWithTitle:nil message:@"修改成功,请重新登录" preferredStyle:UIAlertControllerStyleAlert];
  333. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  334. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
  335. [ud setObject:@"" forKey:@"userPassWord"];
  336. [ud synchronize];//先这样吧。如果非要清除显示占用的密码再做处理
  337. [self.tabBarController dismissViewControllerAnimated:YES completion:nil];
  338. }]];
  339. [self.tabBarController presentViewController:alert animated:YES completion:nil];
  340. }];
  341. }
  342. -(void)loginAciton{
  343. MYAPPDELEGATE.userDic = nil;
  344. [LoginVC saveAppIosImei];
  345. NSUserDefaults *defatluts = [NSUserDefaults standardUserDefaults];
  346. [defatluts removeObjectForKey:@"userPassWord"];
  347. [defatluts synchronize];
  348. [self setPersonData];
  349. LoginVC * loginvc = [[LoginVC alloc]init];
  350. MYAPPDELEGATE.window.rootViewController = loginvc;
  351. }
  352. #pragma mark 客服
  353. - (void)registerSuccess:(NSNotification *)sender {
  354. NSLog(@"注册成功");
  355. if (_isPushed) {
  356. [MBProgressHUD hideHUDForView:self.view animated:NO];
  357. _isConnecting = NO;
  358. return;
  359. }
  360. // [QMConnect sdkGetWebchatScheduleConfig:^(NSDictionary * _Nonnull scheduleDic) {
  361. // dispatch_async(dispatch_get_main_queue(), ^{
  362. // self.dictionary = scheduleDic;
  363. // if ([self.dictionary[@"scheduleEnable"] intValue] == 1) {
  364. // NSLog(@"日程管理");
  365. // [self starSchedule];
  366. // }else{
  367. // NSLog(@"技能组");
  368. // [self getPeers];
  369. // }
  370. // });
  371. // } failBlock:^{
  372. //
  373. // }];
  374. [self getPeers];
  375. }
  376. - (void)registerFailure:(NSNotification *)sender {
  377. NSLog(@"注册失败::%@", sender.object);
  378. self.isConnecting = NO;
  379. [MBProgressHUD hideHUDForView:self.view animated:NO];
  380. }
  381. #pragma mark - 技能组选择
  382. - (void)getPeers {
  383. [QMConnect sdkGetPeers:^(NSArray * _Nonnull peerArray) {
  384. dispatch_async(dispatch_get_main_queue(), ^{
  385. NSLog(@"%@", peerArray);
  386. NSArray *peers = peerArray;
  387. self.isConnecting = NO;
  388. [MBProgressHUD hideHUDForView:self.view animated:NO];
  389. if (peers.count == 1 && peers.count != 0) {
  390. [self showChatRoomViewController:[peers.firstObject objectForKey:@"id"] processType:@""];
  391. }else {
  392. [self showPeersWithAlert:peers messageStr:@"选择您咨询的类型或业务部门(对应技能组)"];
  393. }
  394. });
  395. } failureBlock:^{
  396. dispatch_async(dispatch_get_main_queue(), ^{
  397. [MBProgressHUD hideHUDForView:self.view animated:NO];
  398. self.isConnecting = NO;
  399. });
  400. }];
  401. }
  402. #pragma mark - 日程管理
  403. - (void)starSchedule {
  404. self.isConnecting = NO;
  405. [MBProgressHUD hideHUDForView:self.view animated:NO];
  406. if ([self.dictionary[@"scheduleId"] isEqual: @""] || [self.dictionary[@"processId"] isEqual: @""] || [self.dictionary objectForKey:@"entranceNode"] == nil || [self.dictionary objectForKey:@"leavemsgNodes"] == nil) {
  407. [QMAlert showMessage:@"对不起,由于在线咨询配置错误,暂时无法进行咨询"];
  408. }else{
  409. NSDictionary *entranceNode = self.dictionary[@"entranceNode"];
  410. NSArray *entrances = entranceNode[@"entrances"];
  411. NSLog(@" 获取到日程节点数组 ===== %@", entrances);
  412. // [self showPeersWithAlert: sdkEntrances];
  413. if (entrances.count == 1 && entrances.count != 0) {
  414. [self showChatRoomViewController:[entrances.firstObject objectForKey:@"processTo"] processType:[entrances.firstObject objectForKey:@"processType"]];
  415. }else{
  416. [self showPeersWithAlert:entrances messageStr:@"选择您咨询的日程管理类型"];
  417. }
  418. }
  419. }
  420. - (void)showPeersWithAlert: (NSArray *)peers messageStr: (NSString *)message {
  421. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"选择您咨询的类型或业务部门(对应技能组)" preferredStyle:UIAlertControllerStyleAlert];
  422. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  423. self.isConnecting = NO;
  424. }];
  425. [alertController addAction:cancelAction];
  426. for (NSDictionary *index in peers) {
  427. UIAlertAction *surelAction = [UIAlertAction actionWithTitle:[index objectForKey:@"name"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  428. if ([self.dictionary[@"scheduleEnable"] integerValue] == 1) {
  429. [self showChatRoomViewController:[index objectForKey:@"processTo"] processType:[index objectForKey:@"processType"]];
  430. }else{
  431. [self showChatRoomViewController:[index objectForKey:@"id"] processType:@""];
  432. }
  433. }];
  434. [alertController addAction:surelAction];
  435. }
  436. [self presentViewController:alertController animated:YES completion:nil];
  437. }
  438. #pragma mark - 跳转聊天界面
  439. - (void)showChatRoomViewController:(NSString *)peerId processType:(NSString *)processType {
  440. QMChatRoomViewController *chatRoomViewController = [[QMChatRoomViewController alloc] init];
  441. chatRoomViewController.peerId = peerId;
  442. chatRoomViewController.isPush = NO;
  443. NSString *path = MYAPPDELEGATE.userDic[@"photo"];
  444. if (!path) {
  445. path = @"";
  446. }
  447. chatRoomViewController.avaterStr = path;
  448. if ([self.dictionary[@"scheduleEnable"] intValue] == 1) {
  449. chatRoomViewController.isOpenSchedule = true;
  450. chatRoomViewController.scheduleId = self.dictionary[@"scheduleId"];
  451. chatRoomViewController.processId = self.dictionary[@"processId"];
  452. chatRoomViewController.currentNodeId = peerId;
  453. chatRoomViewController.processType = processType;
  454. }else{
  455. chatRoomViewController.isOpenSchedule = false;
  456. }
  457. [self.navigationController pushViewController:chatRoomViewController animated:YES];
  458. }
  459. - (NSMutableAttributedString *)setSpace:(CGFloat)line kern:(NSNumber *)kern font:(UIFont *)font text:(NSString *)text {
  460. NSMutableParagraphStyle * paraStyle = [NSMutableParagraphStyle new];
  461. paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
  462. paraStyle.alignment = NSTextAlignmentCenter;
  463. paraStyle.lineSpacing = line;
  464. paraStyle.hyphenationFactor = 1.0;
  465. paraStyle.firstLineHeadIndent = 0.0;
  466. paraStyle.paragraphSpacingBefore = 0.0;
  467. paraStyle.headIndent = 0;
  468. paraStyle.tailIndent = 0;
  469. NSDictionary *attributes = @{
  470. NSFontAttributeName: font,
  471. NSParagraphStyleAttributeName: paraStyle,
  472. NSKernAttributeName: kern
  473. };
  474. NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:text attributes:attributes];
  475. return attributeStr;
  476. }
  477. - (void)dealloc {
  478. [[NSNotificationCenter defaultCenter] removeObserver:self name:CUSTOM_LOGIN_SUCCEED object:nil];
  479. [[NSNotificationCenter defaultCenter] removeObserver:self name:CUSTOM_LOGIN_ERROR_USER object:nil];
  480. }
  481. - (void)didReceiveMemoryWarning {
  482. [super didReceiveMemoryWarning];
  483. // Dispose of any resources that can be recreated.
  484. }
  485. @end