personVC.m 23 KB

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