123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940 |
- //
- // FunctionVC.m
- // jiaPei
- //
- // Created by apple on 16/7/27.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "FunctionVC.h"
- #import "StuDetailVC.h"
- #import "FenceSiteVC.h"
- #import "AllCoachPlanVC.h"
- #import "SelectSchoolVC.h"
- #import "MyReserveVC.h"
- #import "MyOrderVC.h"
- #import "MyAccountVC.h"//我的账户
- #import "MyAccountDetailVC.h"//详情
- #import "TopUpMoneyVC.h"//充值
- #import "BindVC.h"
- #import "ThirdLoginBindYunGuanVC.h"
- #import "ButtonView.h"
- #import "Tools.h"
- #import "MNQtTrainVC.h"
- #import "BigTruckVC.h"
- #import "ScanVC.h"
- //客服
- #import "QMChatRoomViewController.h"
- #import <QMLineSDK/QMLineSDK.h>
- #import "QMAlert.h"
- #import "MyUINavigationController.h"
- /// 转校记录
- #import "ChangeSchoolListViewController.h"
- #import "RQWebViewViewController.h"
- @interface FunctionVC ()<UIScrollViewDelegate,UIAlertViewDelegate>
- {
- UIScrollView *mainScroll;
- UIImageView *headImg;
- UILabel *nameLabel;
- UILabel *phoneLabel;
- UILabel *identLabel;
- }
- //客服
- @property (nonatomic, assign) BOOL isPushed; // 控制跳转
- @property (nonatomic, assign) BOOL isConnecting; // 控制多次注册
- @property (nonatomic, copy) NSDictionary * dictionary; //客服一些配置
- @end
- @implementation FunctionVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = backGroundColor;
- //self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1];
- self.navigationController.navigationBar.translucent = NO;
-
- self.navigationItem.title = @"快捷功能";
-
- [self myInit];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- [self setHeaderView];
- }
- -(void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- self.tabBarController.tabBar.hidden = NO;
- }
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- self.hidesBottomBarWhenPushed = NO;
- }
-
- [super viewWillDisappear:animated];
-
- }
- -(void)viewDidDisappear:(BOOL)animated
- {
- [super viewDidDisappear:animated];
- self.navigationController.navigationBar.barTintColor = nil;
- }
- -(void)myInit
- {
- mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet)];
- mainScroll.delegate = self;
- [self.view addSubview:mainScroll];
-
- CGFloat x,y,w,h;
- x = y = 0;
- w = kSize.width;
- h = kSize.width*0.35;
- UIView *headView = [[UIView alloc] setxywh];
- headView.backgroundColor = [UIColor whiteColor];
- //[UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1]
- [mainScroll addSubview:headView];
-
- //----------------------顶部头像所在视图-----------------------
- w = 0.7*h;
- headImg = [[UIImageView alloc] initWithFrame:CGRectMake(20, 0.15*h, w, w)];
- [headImg setBoardWid:1 Color:defGreen];
- [headImg setRound];
- [headView addSubview:headImg];
-
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = headImg.frame;
- [btn target:self tag:1];
- [headView addSubview:btn];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30 + w, 0.15*h, kSize.width - 30 - w -10, 0.28*h)];
- [label setText:@"" Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
- [headView addSubview:label];
- nameLabel = label;
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(30 + w, 0.43*h, kSize.width - 30 - w -10, 0.21*h)];
- [label setText:@"" Font:NormalFont TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
- [headView addSubview:label];
- phoneLabel = label;
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(30 + w, 0.64*h, kSize.width - 30 - w -10, 0.21*h)];
- [label setText:@"" Font:NormalFont TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
- [headView addSubview:label];
- identLabel = label;
-
- [self setHeaderView];
-
- //-------------------账户信息------------------
- y += h;
- w = kSize.width/3.0;
- //h = 45;
- /// RQ-MARK:待开发功能 苹果审核无法通过 暂时隐藏
- h = 0;
- NSArray *titAndImgArray = @[@"account01.png",
- @"account02.png",
- @"account03.png",
- @"我的账户",
- @"我要充值",
- @"资金明细"];
- for (int i = 0; i < 3; i ++) {
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(i*w, y, w, h);
- [btn setBoardWid:1 Color:KlineColor];
- btn.backgroundColor = [UIColor clearColor];
- [btn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:.4 alpha:.3]] forState:UIControlStateHighlighted];
- [btn setTitle:@"" textColor:kTitleColor font:Font17 fotState:UIControlStateNormal];
- [btn target:self tag:i - 3];//-3 -2 -1
- ButtonView *view = [[ButtonView alloc] initWithFrame:btn.frame Image:titAndImgArray[i] Title:titAndImgArray[i + 3] Detail:@"" type:2];
- [mainScroll addSubview:view];
- [mainScroll addSubview:btn];
- }
-
- //-------------------预约相关------------------
- x = 20;
- y += h + 10;
- w = kSize.width - 40;
- h = 30;
- label = [[UILabel alloc] setxywh];
- [label setText:@"预约相关" Font:NormalFont TextColor:contentTextColor];
- [mainScroll addSubview:label];
-
- [label addViewWithRect:CGRectMake(0, y - 10, kSize.width, 10)];
-
-
- y += h;
- w = kSize.width/2.0;
- h = 60;
-
- // NSArray *titleArray = @[@"教练计划", @"我的预约",@"我的订单",@"我的学时",
- // @"模拟计时",@"大客/货车计时",@"转校查询",
- // @"线上咨询"];//@"绑定申请",
- // NSArray *detailArray = @[@"先学后付,计时收费",
- // @"我和教练的约会,点我",
- // @"交易过程管理,由我掌控",
- // @"计时结果查询,点我进入",
- //
- // @"轻松模拟课时",
- // @"大客/货车计时服务",
- // @"转校查询",
- //
- // @"您有什么问题吗,欢迎咨询",];//@"绑定后才能实操计时哦",
- // NSArray *imageArray = @[@"function01.png",//@"function02.png",
- // @"function03.png",
- // @"function04.png",
- // @"function06.png",
- //
- // @"function09.png",
- // @"function10.png",
- // @"changeSchool.png",
- //
- // @"qm_default_agent.png"];
-
- NSArray *moduleOneTitleArray = @[@"教练计划", @"我的预约",@"我的订单",@"我的学时"];
- NSArray *moduleOneDetailArray = @[@"先学后付,计时收费",@"我和教练的约会,点我",@"交易过程管理,由我掌控",@"计时结果查询,点我进入",];
- NSArray *moduleOneImageArray = @[@"function01.png",@"function03.png",@"function04.png",@"function06.png"];
-
- for (int i = 0; i < moduleOneTitleArray.count; i ++) {
-
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake((i%2)*w, y + 60*(i/2), w, h);
- [btn setBoardWid:1 Color:KlineColor];
- btn.backgroundColor = [UIColor clearColor];
- [btn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:.4 alpha:.3]] forState:UIControlStateHighlighted];
- [btn setTitle:@"" textColor:kTitleColor font:Font17 fotState:UIControlStateNormal];
- [btn target:self tag:i + 2];//2345
-
-
- ButtonView *view = [[ButtonView alloc] initWithFrame:btn.frame Image:moduleOneImageArray[i] Title:moduleOneTitleArray[i] Detail:moduleOneDetailArray[i] type:1];
- [mainScroll addSubview:view];
- [mainScroll addSubview:btn];
- }
-
- //-----------学时相关-----------------
- NSArray *moduleTwoTitleArray = @[ @"模拟计时",@"大客/货车计时",@"转校查询",@"查看合同"];
- NSArray *moduleTwoDetailArray = @[@"轻松模拟课时",@"大客/货车计时服务",@"转校查询",@"查看报名合同"];
- NSArray *moduleTwoImageArray = @[ @"function09.png",@"function10.png",@"changeSchool.png",@"stuProtocol.png"];
- x = 20;
- y += 2*h + 10;
- w = kSize.width - 40;
- h = 30;
- label = [[UILabel alloc] setxywh];
- [label setText:@"学车计时" Font:NormalFont TextColor:contentTextColor];
- [mainScroll addSubview:label];
-
- [label addViewWithRect:CGRectMake(0, y - 10, kSize.width, 10)];
-
- label = [[UILabel alloc] setxywh];
- [label setText:@"" Font:FontTitle TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentRight];
- [mainScroll addSubview:label];
- myDelegate.trainStateLabel = label;
-
- y += h;
- w = kSize.width/2.0;
- h = 60;
- for (int i = 0; i < moduleTwoTitleArray.count; i ++) {
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake((i%2)*w, y + 60*(i/2), w, h);
- [btn setBoardWid:1 Color:KlineColor];
- btn.backgroundColor = [UIColor clearColor];
- [btn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:.4 alpha:.3]] forState:UIControlStateHighlighted];
- [btn setTitle:@"" textColor:kTitleColor font:Font17 fotState:UIControlStateNormal];
- [btn target:self tag:i + 2 + moduleOneTitleArray.count];//678
-
-
- ButtonView *view = [[ButtonView alloc] initWithFrame:btn.frame Image:moduleTwoImageArray[i] Title:moduleTwoTitleArray[i] Detail:moduleTwoDetailArray[i] type:1];
- [mainScroll addSubview:view];
- [mainScroll addSubview:btn];
- }
-
-
- //-----------咨询相关-----------------
- NSArray *moduleThreeTitleArray = @[@"线上咨询"];
- NSArray *moduleThreeDetailArray = @[@"您有什么问题吗,欢迎咨询"];
- NSArray *moduleThreeImageArray = @[@"qm_default_agent.png"];
- x = 20;
- y += h * 2 + 10;
- w = kSize.width - 40;
- h = 30;
- label = [[UILabel alloc] setxywh];
- [label setText:@"咨询相关" Font:NormalFont TextColor:contentTextColor];
- [mainScroll addSubview:label];
-
- [label addViewWithRect:CGRectMake(0, y - 10, kSize.width, 10)];
-
-
- y += h;
- w = kSize.width;
- h = 60;
- for (int i = 0; i < moduleThreeTitleArray.count; i ++) {
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake((i%2)*w, y + 60*(i/2), w, h);
- [btn setBoardWid:1 Color:KlineColor];
- btn.backgroundColor = [UIColor clearColor];
- [btn setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:.4 alpha:.3]] forState:UIControlStateHighlighted];
- [btn setTitle:@"" textColor:kTitleColor font:Font17 fotState:UIControlStateNormal];
- [btn target:self tag:i + 2 + moduleOneTitleArray.count + moduleTwoTitleArray.count];
-
-
- ButtonView *view = [[ButtonView alloc] initWithFrame:btn.frame Image:moduleThreeImageArray[i] Title:moduleThreeTitleArray[i] Detail:moduleThreeDetailArray[i] type:1];
- [mainScroll addSubview:view];
- [mainScroll addSubview:btn];
- }
-
- [mainScroll setContentSize:CGSizeMake(kSize.width, y + h + 30)];
-
- //客服
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(registerSuccess:) name:CUSTOM_LOGIN_SUCCEED object:nil];
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(registerFailure:) name:CUSTOM_LOGIN_ERROR_USER object:nil];
-
- _isConnecting = NO;
- _isPushed = NO;
- }
- -(void)setHeaderView
- {
- NSString *str = defUser.userDict[@"photo"];
- if (str && ![str hasPrefix:@"http"]){
- str = [imgPreFix stringByAppendingString:str];
- }
- if (str == nil) {
- str = @"";
- }
- [headImg sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"drawer_head.png"]];
-
-
- //NSLog(@"%@",defUser.userDict);
- NSString *nameString = defUser.userDict[@"userName"];
- if (nameString.length < 1) {
- nameString = defUser.userDict[@"nickName"];
- }
- if (nameString.length < 1) {
- nameString = defUser.userDict[@"loginCode"];
- }
- if (nameString.length < 1) {
- nameString = @"暂未登录";
- }
- nameLabel.text = nameString;
-
- NSString *telString = @"";
- //NSLog(@"%@",defUser.userDict);
- if ([defUser.userTel length] > 0) {
- telString = defUser.userTel;
- if (telString.length > 10) {
- NSMutableString *mutTel = [NSMutableString stringWithString:telString];
- [mutTel replaceCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
- telString = (NSString *)mutTel;
- }
- }
- phoneLabel.text = telString;
-
- NSMutableString *sfzhmString = nil;
- if ([defUser.userDict[@"sfzmhm"] length] > 0) {
- sfzhmString = [NSMutableString stringWithString:defUser.userDict[@"sfzmhm"]];
- [sfzhmString replaceCharactersInRange:NSMakeRange(sfzhmString.length - 8, 6) withString:@"******"];
- }else{
- sfzhmString = [NSMutableString stringWithString:@""];
- }
- identLabel.text = sfzhmString;
- }
- -(void)btnClick:(UIButton *)sender
- {
- // if (sender.tag == -1 || sender.tag == -2 || sender.tag == -3) {
- // UIAlertController * alertC = [UIAlertController alertControllerWithTitle:@"" message:@"建设中,暂未开放" preferredStyle:UIAlertControllerStyleAlert];
- // [alertC addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
- // [self presentViewController:alertC animated:YES completion:nil];
- // return;
- // }
-
- switch (sender.tag) {
-
- case -3://我的账户
- if (myDelegate.isLogin) {
- [self gotoVC:@"MyAccountVC"];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case -2://我要充值
- if (myDelegate.isLogin) {
- TopUpMoneyVC* vc = [[TopUpMoneyVC alloc] init];
- vc.type = 1;
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case -1://资金明细
- if (myDelegate.isLogin) {
- [self gotoVC:@"MyAccountDetailVC"];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
-
- case 1://个人中心
- if (myDelegate.isLogin) {
- [self gotoStuDetaiVC];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case 2://@"教练计划"
- if (myDelegate.isLogin) {
- //如果是驾校学员
- if (defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0) {
- [self getSchPlaces];//跳转选择训练场地或者选择教练页面
- }else{
- SelectSchoolVC *selectVC = [[SelectSchoolVC alloc] init];
- selectVC.skipType = @"2";
- [self navPushHideTabbarToVC:selectVC];
- }
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case 3://@"我的预约"
- if (myDelegate.isLogin) {
- if (defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0) {
- [self gotoVC:@"MyReserveVC"];
- }else{
- [self judgeLoginType];
- }
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case 4://@"我的订单"
- {
- if (myDelegate.isLogin) {
- if (defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0) {
- [self gotoVC:@"MyOrderVC"];
- }else{
- [self judgeLoginType];
- }
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- }
- break;
- case 5://@"我的学时"
- {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- break;
- }
-
- if(defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0){
- [self gotoVC:@"TrainInfoVC"];
- }else{
- [self judgeLoginType];
- }
- }
- break;
- case 6://@"模拟器训练"
- {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- break;
- }
- /// RQ-MARk
- [Tools confirmImeiWithLogType:@"3" successBlock:^{
- [self gotoMNTrain];
- }];
- }
- break;
- case 7://@"大车"
- {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- break;
- }
- [Tools confirmImeiWithLogType:@"4" successBlock:^{
- [self gotoBigCar];
- }];
- }
- break;
- case 8: {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- break;
- }
- [Tools confirmImeiWithLogType:@"3" successBlock:^{
- ChangeSchoolListViewController *vc = [[ChangeSchoolListViewController alloc] init];
- [self navPushHideTabbarToVC:vc];
- }];
- break;
- }
- case 9: {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- break;
- }
- [Tools confirmImeiWithLogType:@"3" successBlock:^{
- [self getStuProtocolResult:^(BOOL isSuccess, NSString *urlStr) {
- if (isSuccess) {
- RQWebViewViewController *vc = [[RQWebViewViewController alloc] init];
- vc.webType = WebTypeStuProtocol;
- vc.url = urlStr;
- [self navPushHideTabbarToVC:vc];
- } else {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"该学员查询暂无报名合同!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil preferredActionTitle:nil completion:nil];
- }
- }];
- }];
- break;
- }
- case 10://@"线上咨询"
- {
- if (!myDelegate.isLogin)
- if (_isConnecting) {
- return;
- }
- _isConnecting = YES;
- [MBProgressHUD showLoadToView:self.view];
-
- // userId 只能使用 数字 字母(包括大小写) 下划线
- NSString *name = defUser.userDict[@"userName"];
- if ([defUser.userDict[@"userName"] length] < 1) {
- name = defUser.userDict[@"nickName"];
- }
- NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
- name = [NSString stringWithFormat:@"%@[辽I学员_%@]",name,version];
- [QMConnect registerSDKWithAppKey:CUSTOMERSERVICE_APPKEY userName:name userId:[NSString stringWithFormat:@"%@",defUser.userDict[@"id"]]];
- }
- break;
-
- default:
- ShowMsg(@"暂未开通,敬请期待");
- break;
- }
- }
- - (void)judgeLoginType
- {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- NSDictionary *udDic = [ud objectForKey:@"jiaPeiLoginTest"];
- if ([udDic[@"loginType"] isEqualToString:@"1"]){
- ShowMsg(@"您的账号暂未在计时系统受理");
- }else{
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"您的账号还未绑定学员账号" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"绑定", nil];
- [alert show];
- }
- }
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (buttonIndex != alertView.cancelButtonIndex) {
- //第三方登录 提示到绑定学员账号页面
- ThirdLoginBindYunGuanVC *vc = [[ThirdLoginBindYunGuanVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- }
- -(void)userLoginAction{
- LoginViewController* vc = [[LoginViewController alloc] init];
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.parentViewController presentViewController:vc animated:YES completion:nil];
- }
- -(void)gotoVC:(NSString*)name
- {
- UIViewController* vc = [NSClassFromString(name) new];
-
- [self navPushHideTabbarToVC:vc];
- }
- -(void)gotoStuDetaiVC{
- StuDetailVC* vc = [[StuDetailVC alloc] init];
- vc.tag = 2;
- [self navPushHideTabbarToVC:vc];
- }
- - (void)getSchPlaces
- {
- if (![Util connectedToNetWork]) {
- ShowMsg(@"无网络连接");
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- [arr addPro:@"jxbh" Value:defUser.userSchoolId];
-
- NSString* method = @"getSchPlaces";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!root) {
- [self goAllCoachPlanVC];
- return;
- }
-
- if ([root[@"code"] intValue] == 0) {
- if ([root[@"body"] count] < 1) {
- [self goAllCoachPlanVC];
- }else {
- FenceSiteVC *vc = [[FenceSiteVC alloc] init];
- vc.dataArray = root[@"body"];
- vc.dqbh = defUser.userDict[@"city"];
- [self navPushHideTabbarToVC:vc];
- }
- }else {
- [self goAllCoachPlanVC];
- }
- }];
- }
- // 获取学员合同
- - (void)getStuProtocolResult:(void (^)(BOOL isSuccess, NSString *urlStr))result {
- if (![Util connectedToNetWork]) {
- ShowMsg(@"无网络连接");
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"stuid" Value:defUser.userDict[@"outId"]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
-
- NSString* method = @"getStuProtocol";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!root) {
- ShowMsgFailed();
- return;
- }
-
- if ([root[@"code"] intValue] == 0) {
- if (root[@"data"] && ![root[@"data"] isEqualToString:@""]) {
- result(true, root[@"data"]);
- } else {
- result(false, @"");
- }
- }else {
- if (root[@"body"] && ![root[@"body"] isEqualToString:@""]) {
- ShowMsg(root[@"body"]);
- } else if (root[@"msg"] && ![root[@"msg"] isEqualToString:@""]) {
- ShowMsg(root[@"msg"]);
- } else {
- ShowMsg(@"数据异常");
- }
- result(false, @"");
- }
- }];
- }
- #pragma mark - gotoxxxx计时
- -(void)gotoMNTrain{
-
- if (myDelegate.mnTrainType == nil) {
- [self getCurrentState];
- return;
- }
-
- if ([myDelegate.dcTrainType isEqualToString:@"0"]) {
- showMsgByAlert(self, @"当前正在进行大客/货车计时");
- return;
- }
- NSString *kemu = [NSString stringWithFormat:@"%@",defUser.userDict[@"pxjd"]];
- if ([kemu isEqualToString:@"1"] || [kemu isEqualToString:@"4"]) {
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"当前培训阶段无法进行模拟计时" preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:alertFind animated:true completion:nil];
- return;
- }
- if (myDelegate.mnPeriodVC) {
- [self navPushHideTabbarToVC:myDelegate.mnPeriodVC];
- }else{
- switch ([myDelegate.mnTrainType integerValue]) {
- case 1:
-
- {
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"请扫描模拟设备登录二维码" preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }]];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- [self openScan];
- }]];
- [self presentViewController:alertFind animated:true completion:nil];
- }
-
- break;
- default:
- [self gotoVC:@"MNQtTrainVC"];
- break;
- }
-
- }
- }
- #pragma mark 打开相机扫描二维码
- -(void)openScan{
- ScanVC *scan = [[ScanVC alloc] init];
- scan.type = @"2";
- [scan scanBlock:^(NSString *dataString) {
- if ([dataString isEqualToString:@"success"]) {
- myDelegate.mnTrainType = @"2";
- [self gotoVC:@"MNQtTrainVC"];
- }
- }];
- [self navPushHideTabbarToVC:scan];
- }
- -(void)gotoBigCar{
- if ([myDelegate.mnTrainType isEqualToString:@"0"]) {
- showMsgByAlert(self, @"当前正在进行模拟计时");
- return;
- }
- //判断培训类型
- NSArray *arr = @[@"A1",@"A2",@"A3",@"B1",@"B2"];
- if (![arr containsObject:defUser.userDict[@"carType"]]) {
-
- showMsgByAlert(self, [NSString stringWithFormat:@"您当前培训车型为%@,不允许进行大客/货车计时",defUser.userDict[@"carType"]]);
- return;
- }
-
- NSString *kemu = [NSString stringWithFormat:@"%@",defUser.userDict[@"pxjd"]];
- if ([kemu isEqualToString:@"1"] || [kemu isEqualToString:@"4"]) {
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"当前培训阶段不允许进行大客/货车计时" preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:alertFind animated:true completion:nil];
- return;
- }
- if (myDelegate.dcPeriodVC) {
- [self navPushHideTabbarToVC:myDelegate.dcPeriodVC];
- }else{
- [self gotoVC:@"BigTruckVC"];
- }
- }
- - (void)goAllCoachPlanVC{
- AllCoachPlanVC* vc = [[AllCoachPlanVC alloc] init];
- vc.searchJXBH = defUser.userSchoolId;
- [self navPushHideTabbarToVC:vc];
- }
- #pragma mark 网络请求
- //获取当前训练状态
- -(void)getCurrentState
- {
- [MBProgressHUD showMessage:@"正在获取当前训练状态" toView:self.view];
- //这个主要目的是为了更新本地学时编号等数据
- [LoginViewController getCurrentStateWithCompleteBlock:^(NSDictionary *root) {
- [MBProgressHUD hideHUDForView:self.view animated:NO];
- if (!root) {
- ShowMsg(@"请求失败");
- return;
- }
- if ([root[@"code"] isEqualToString:@"0"]) {
- [self gotoMNTrain];
- }else{
- ShowMsg(root[@"msg"]);
- }
-
- }];
-
- }
- #pragma mark 客服
- - (void)registerSuccess:(NSNotification *)sender {
- NSLog(@"注册成功");
- if (_isPushed) {
- [MBProgressHUD hideHUDForView:self.view];
- _isConnecting = NO;
- return;
- }
- [QMConnect sdkGetWebchatScheduleConfig:^(NSDictionary * _Nonnull scheduleDic) {
- dispatch_async(dispatch_get_main_queue(), ^{
- self.dictionary = scheduleDic;
- if ([self.dictionary[@"scheduleEnable"] intValue] == 1) {
- NSLog(@"日程管理");
- [self starSchedule];
- }else{
- NSLog(@"技能组");
- [self getPeers];
- }
- });
- } failBlock:^{
-
- }];
- }
- - (void)registerFailure:(NSNotification *)sender {
- NSLog(@"注册失败::%@", sender.object);
- self.isConnecting = NO;
- [MBProgressHUD hideHUDForView:self.view];
- }
- #pragma mark - 技能组选择
- - (void)getPeers {
- [QMConnect sdkGetPeers:^(NSArray * _Nonnull peerArray) {
- dispatch_async(dispatch_get_main_queue(), ^{
- NSLog(@"%@", peerArray);
- NSArray *peers = peerArray;
- self.isConnecting = NO;
- [MBProgressHUD hideHUDForView:self.view];
- if (peers.count == 1 && peers.count != 0) {
- [self showChatRoomViewController:[peers.firstObject objectForKey:@"id"] processType:@""];
- }else {
- [self showPeersWithAlert:peers messageStr:@"选择您咨询的类型或业务部门(对应技能组)"];
- }
- });
- } failureBlock:^{
- dispatch_async(dispatch_get_main_queue(), ^{
- [MBProgressHUD hideHUDForView:self.view];
- self.isConnecting = NO;
- });
- }];
- }
- #pragma mark - 日程管理
- - (void)starSchedule {
- self.isConnecting = NO;
- [MBProgressHUD hideHUDForView:self.view];
- if ([self.dictionary[@"scheduleId"] isEqual: @""] || [self.dictionary[@"processId"] isEqual: @""] || [self.dictionary objectForKey:@"entranceNode"] == nil || [self.dictionary objectForKey:@"leavemsgNodes"] == nil) {
- [QMAlert showMessage:@"对不起,由于在线咨询配置错误,暂时无法进行咨询"];
- }else{
-
- NSDictionary *entranceNode = self.dictionary[@"entranceNode"];
- NSArray *entrances = entranceNode[@"entrances"];
- NSLog(@" 获取到日程节点数组 ===== %@", entrances);
- // [self showPeersWithAlert: sdkEntrances];
- if (entrances.count == 1 && entrances.count != 0) {
- [self showChatRoomViewController:[entrances.firstObject objectForKey:@"processTo"] processType:[entrances.firstObject objectForKey:@"processType"]];
- }else{
- [self showPeersWithAlert:entrances messageStr:@"选择您咨询的日程管理类型"];
- }
- }
- }
- - (void)showPeersWithAlert: (NSArray *)peers messageStr: (NSString *)message {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"选择您咨询的类型或业务部门(对应技能组)" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- self.isConnecting = NO;
- }];
- [alertController addAction:cancelAction];
- for (NSDictionary *index in peers) {
- UIAlertAction *surelAction = [UIAlertAction actionWithTitle:[index objectForKey:@"name"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- if ([self.dictionary[@"scheduleEnable"] integerValue] == 1) {
- [self showChatRoomViewController:[index objectForKey:@"processTo"] processType:[index objectForKey:@"processType"]];
- }else{
- [self showChatRoomViewController:[index objectForKey:@"id"] processType:@""];
- }
- }];
- [alertController addAction:surelAction];
- }
- [self presentViewController:alertController animated:YES completion:nil];
- }
- #pragma mark - 跳转聊天界面
- - (void)showChatRoomViewController:(NSString *)peerId processType:(NSString *)processType {
- QMChatRoomViewController *chatRoomViewController = [[QMChatRoomViewController alloc] init];
- chatRoomViewController.peerId = peerId;
- chatRoomViewController.isPush = NO;
- NSString *path = defUser.userDict[@"photo"];
- if (!path) {
- path = @"";
- }
- chatRoomViewController.avaterStr = path;
- if ([self.dictionary[@"scheduleEnable"] intValue] == 1) {
- chatRoomViewController.isOpenSchedule = true;
- chatRoomViewController.scheduleId = self.dictionary[@"scheduleId"];
- chatRoomViewController.processId = self.dictionary[@"processId"];
- chatRoomViewController.currentNodeId = peerId;
- chatRoomViewController.processType = processType;
- }else{
- chatRoomViewController.isOpenSchedule = false;
- }
- MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:chatRoomViewController];
- [nav.view setBackgroundColor:[UIColor whiteColor]];
- nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- nav.navigationBar.translucent = NO;
- nav.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.parentViewController presentViewController:nav animated:YES completion:nil];
- // 此处为了统一“退出登录”返回方式 就选择了present进去
- }
- - (NSMutableAttributedString *)setSpace:(CGFloat)line kern:(NSNumber *)kern font:(UIFont *)font text:(NSString *)text {
- NSMutableParagraphStyle * paraStyle = [NSMutableParagraphStyle new];
- paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
- paraStyle.alignment = NSTextAlignmentCenter;
- paraStyle.lineSpacing = line;
- paraStyle.hyphenationFactor = 1.0;
- paraStyle.firstLineHeadIndent = 0.0;
- paraStyle.paragraphSpacingBefore = 0.0;
- paraStyle.headIndent = 0;
- paraStyle.tailIndent = 0;
- NSDictionary *attributes = @{
- NSFontAttributeName: font,
- NSParagraphStyleAttributeName: paraStyle,
- NSKernAttributeName: kern
- };
- NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:text attributes:attributes];
- return attributeStr;
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self name:CUSTOM_LOGIN_SUCCEED object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:CUSTOM_LOGIN_ERROR_USER object:nil];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|