123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419 |
- #import "LeftViewController.h"
- #import "AppDelegate.h"
- #import "MyUINavigationController.h"
- #import "StuDetailVC.h"
- #import "LoginViewController.h"
- #import "SchoolInfoVC.h"
- #import "FavTopicsVC.h"
- #import "CoachDetailInfoVC.h"
- #import "ChooseExLibVC.h"
- #import "TrainInfoVC.h"
- #import "HeadCell.h"
- #import "AboutVC.h"
- #import "CLButton.h"
- #import "CoachPlanVC.h"
- #import "CLCell.h"
- #import "MyMsgVC.h"
- #import "RecordVC_New.h"
- #import "mySuggestVC.h"
- #import "SelfAppointmentVC.h"
- #import "HelpQuestionVC.h"
- #import "SelectSchoolVC.h"
- #import "TrainInfoVC.h"
- #import "ThirdLoginBindYunGuanVC.h"// 第三方登录绑定imei以及学员账号
- #import "BindVC.h" //证件号登录绑定imei
- //客服
- #import "QMChatRoomViewController.h"
- #import <QMLineSDK/QMLineSDK.h>
- #import "QMAlert.h"
- typedef enum {
- AlertTypeStopTiming = 1,
- AlertTypeGotoLogin
- }AlertType;
- @interface LeftViewController ()
- {
- /**用于在列表显示.需要从defUser里面取值
- */
- NSDictionary *queLibNameDict;
-
- UIView *syncView;
- UILabel *bgLabel;
- UIButton *allBtn;
-
- NSArray *wrongArray;
- NSArray *collectArray;
- NSArray *exceptArray;
- NSArray *wrongFourArray;
- NSArray *collectFourArray;
- NSArray *exceptFourArray;
-
- NSMutableArray<UIButton *> *btns;
- NSArray<NSArray *> *allQuestionArray;
- NSMutableArray<NSString *> *selectedArray;
- }
- //客服
- @property (nonatomic, assign) BOOL isPushed; // 控制跳转
- @property (nonatomic, assign) BOOL isConnecting; // 控制多次注册
- @property (nonatomic, copy) NSDictionary * dictionary; //客服一些配置
- @end
- @implementation LeftViewController
- {
- UITableView *myTableView;
- NSArray* titles;
- NSArray* images;
-
- /**夜间模式按钮
- */
- UIButton* nightBtn;
-
- int seconds;
- //NSTimer* timer;
- NSDateFormatter* formatter;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- [self myInit];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = YES;
- [myTableView reloadData];
-
- _isPushed = NO;
- // self.navigationController.navigationBar.barTintColor = defGreen;
-
- }
- -(void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- _isPushed = YES;
- }
- -(void)myInit
- {
- self.navigationController.navigationBar.translucent = YES;
-
- btns = [NSMutableArray array];
- selectedArray = [NSMutableArray array];
-
- /**
- 与数据库一致 如果摩托车有变动 要改 --danson
- @"C1",@"A2",@"A1",@"D",@"4",@"1",@"2",@"3",@"5"
- */
- queLibNameDict = @{@"C1" : @"小车",
- @"C2" : @"小车",
- @"C3" : @"小车",
- @"A2" : @"货车",
- @"B2" : @"货车",
- @"A1" : @"客车",
- @"A3" : @"客车",
- @"B1" : @"客车",
- @"D" : @"摩托车",
- @"E" : @"摩托车",
- @"F" : @"摩托车",
- @"1" : @"客运",
- @"2" : @"货运",
- @"3" : @"危险品",
- @"4" : @"教练员",
- @"5" : @"出租车",
- @"6" : @"网约车",
- };
-
- titles = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN?
- @[
- @"立即登录",
- @"我的题库",
- ]
- :@[@"立即登录",
- @"我的驾校",
- @"我的教练",
- @"绑定账号",
- @"我的题库",
- @"同步题库",
- @"我的学时",
- @"培训记录",
- @"投诉评价",
- @"线上咨询",
- /*@"给我们评价",*/
- @"帮助",
- @"退出登录"];
- images = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN?
- @[
- @"drawer_head.png",
- @"leftvc_icon14.png",
- ]
- :@[@"drawer_head.png",
- @"leftvc_icon3.png",
- @"leftvc_icon6.png",
- @"function02_s",//绑定账号
- @"leftvc_icon4.png",
- @"leftvc_icon14.png",//同步题库
- @"function06_s",//我的学时
- @"leftvc_record.png",
- @"drawer_img06.png",
- @"qm_default_agent.png",
- /*@"leftvc_icon8.png",*/
- @"drawer_img02.png",
- @"drawer_img12.png",
- @"001.png",
- @"001.png",
- @"001.png",
- @"001.png"];
- //高度 titles.count*[CLCell cellHeight] + 60
- myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kLeftViewWid, kSize.height - 35)];
- [myTableView setDataSource:self];
- [myTableView setDelegate:self];
- [myTableView setShowsVerticalScrollIndicator:NO];
- [self.view addSubview:myTableView];
-
- [myTableView setScrollEnabled:(myTableView.bottom > kSize.height - 40)];
-
- UIView* vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, myTableView.bottom - kSize.height - 40)];
- [myTableView setTableFooterView:vi];
-
-
- CGFloat btnWid = 100;
- CGFloat btnHei = 35;
- CGFloat y = kSize.height - btnHei -kSafeAreaBottomHeight;
- vi = [[UIView alloc] initWithFrame:CGRectMake(0, y,kLeftViewWid , btnHei)];
- [self.view addSubview:vi];
- [vi setBackgroundColor:[UIColor whiteColor]];
-
- CLButton* btn = [[CLButton alloc] initWithFrame:CGRectMake(0, 0, btnWid, btnHei)];
- [btn setTitle:@"关于" forState:UIControlStateNormal];
- [btn setImage:[UIImage imageNamed:@"leftvc_about"] forState:UIControlStateNormal];
- btn.titleLabel.font = [UIFont scaleSize:NormalFont];
- [btn setTitleColor:kTitleColor forState:UIControlStateNormal];
- [btn setStyle:1];
- [vi addSubview:btn];
- [btn setBackgroundColor:[UIColor clearColor]];
- [btn addTarget:self action:@selector(gotoAboutVC) forControlEvents:UIControlEventTouchUpInside];
-
- btn = [[CLButton alloc] initWithFrame:CGRectMake(kLeftViewWid - btnWid,0, btnWid, btnHei)];
- //可以对页面内改变昼夜模式做出正确反映
- btn.selected = myDelegate.isNightMode;
- [btn setTitle:@"夜间" forState:UIControlStateNormal];
- [btn setTitle:@"日间" forState:UIControlStateSelected];
- [btn setImage:[UIImage imageNamed:@"leftvc_night.png"] forState:UIControlStateNormal];
- [btn setImage:[UIImage imageNamed:@"leftvc_mid.png"] forState:UIControlStateSelected];
- btn.titleLabel.font = [UIFont scaleSize:NormalFont];
- [btn setTitleColor:kTitleColor forState:UIControlStateNormal];
- [btn setStyle:1];
- [vi addSubview:btn];
- [btn setBackgroundColor:[UIColor clearColor]];
- nightBtn = btn;
- [btn addTarget:self action:@selector(nightModeClick:) forControlEvents:UIControlEventTouchUpInside];
-
-
- //客服
- [[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;
- }
- #pragma mark -
- -(void)nightModeClick:(UIButton*)sender
- {
- [sender setSelected:!sender.selected];
- [myDelegate setIsNightMode:sender.selected];
-
- if (sender.selected) {
- [MBProgressHUD showSuccess:@"已关闭夜间练习模式" ToView:self.view];
- }else{
- [MBProgressHUD showSuccess:@"已关闭夜间练习模式" ToView:self.view];
- }
- }
- -(void)userLoginAction{
- LoginViewController* vc = [[LoginViewController alloc] init];
- [self cw_presentViewController:vc];
-
- }
- -(void)gotoStuDetaiVC{
- StuDetailVC* vc = [[StuDetailVC alloc] init];
- vc.tag = 1;
- [self cw_pushViewController:vc];
- }
- -(void)gotoSchoolVC{
- if (defUser.userSchoolId && [defUser.userSchoolId length] < 1) {
- //还未绑定驾校 选择驾校按钮 绑定成功后 重调登录接口 然后刷新UI(因为驾校相关信息较多 故不直接添加至本地信息)
- SelectSchoolVC *selectVC = [[SelectSchoolVC alloc] init];
- selectVC.skipType = @"1";
- [selectVC finishBlock:^{
- [myTableView reloadData];
- }];
- [self cw_pushViewController:selectVC];
- }else{
- SchoolInfoVC *vc = [[SchoolInfoVC alloc] init];
- [self cw_pushViewController:vc];
- }
- }
- /**可以把这些跳转做成用class来跳转。传参就用用字典了。
- */
- -(void)gotoCoachDetailInfoVC{
- CoachDetailInfoVC* vc = [[CoachDetailInfoVC alloc] init];
- [self cw_pushViewController:vc];
- }
- -(void)gotoChooseExLibVC{
- ChooseExLibVC* vc = [[ChooseExLibVC alloc] init];
- [self cw_pushViewController:vc];
- }
- -(void)gotoAboutVC{
- AboutVC* vc = [[AboutVC alloc] init];
- [self cw_pushViewController:vc];
- }
- -(void)gotoVC:(NSString*)name
- {
- UIViewController* vc = [NSClassFromString(name) new];
- [self cw_pushViewController:vc];
- }
- -(void)gotoTrafficVC
- {
- HelpQuestionVC* vc = [[HelpQuestionVC alloc] init];
- vc.source = @"left";
- [self cw_pushViewController:vc];
- }
- -(void)showAlert:(NSString*)str{
- UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
- alert.delegate = self;
- [alert show];
- }
- -(void)showAlertGotoLogin{
- UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您还未登录,不能使用该功能" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
- [alert setTag:AlertTypeGotoLogin];
- [alert show];
- }
- -(void)cellBtnClick:(UIButton*)sender{
- int tag = (int)sender.tag;
- if (!myDelegate.isLogin) {
- [self userLoginAction];
- return;
- }
- if( 0 == tag){
- MyMsgVC* vc = [[MyMsgVC alloc] init];
- [self cw_pushViewController:vc];
- }
-
- if ( 1 == sender.tag) {
- FavTopicsVC* vc = [[FavTopicsVC alloc] init];
- [self cw_pushViewController:vc];
- }
- }
- -(void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 1) {//全选是否
- sender.selected = !sender.selected;
- if (sender.selected) {
- [selectedArray removeAllObjects];
- NSArray *array = @[@"2",@"3",@"4",@"5",@"6",@"7"];
- [selectedArray addObjectsFromArray:array];
-
- for (UIButton *btn in btns) {
- btn.selected = YES;
- }
- }else{
- [selectedArray removeAllObjects];
- for (UIButton *btn in btns) {
- btn.selected = NO;
- }
- }
-
- }
- if (sender.tag > 1 && sender.tag < 8) {
- sender.selected = !sender.selected;
- if (sender.selected) {
- if (![selectedArray containsObject:[NSString stringWithFormat:@"%d",(int)sender.tag]]) {
- [selectedArray addObject:[NSString stringWithFormat:@"%d",(int)sender.tag]];
- if (selectedArray.count == 6) {
- allBtn.selected = YES;
- }
- }
- }else{
- if ([selectedArray containsObject:[NSString stringWithFormat:@"%d",(int)sender.tag]]) {
- if (selectedArray.count == 6) {
- allBtn.selected = NO;
- }
- [selectedArray removeObject:[NSString stringWithFormat:@"%d",(int)sender.tag]];
- }
- }
- }
- if (sender.tag == 8) {//取消
-
- [self removeSyncView];
- }
- if (sender.tag == 9) {//同步按钮
-
- if (wrongArray.count > 0 || collectArray.count > 0 || exceptArray.count > 0 || wrongFourArray.count > 0 || collectFourArray.count > 0 || exceptFourArray.count > 0) {
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"同步题库(错题、收藏、排错题)将覆盖本地的题目记录,您尚有题目未上传,建议上传完在同步,是否继续同步?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"同步", nil];
- [alert show];
- }else{
- [self syncQuestion];
- }
- }
- if (sender.tag == 10) {//上传
-
- if (selectedArray.count == 0) {
- ShowMsg(@"请选择需要上传的题目");
- return;
- }
- [self saveBetchFavQuestion];
- }
- }
- #pragma mark - 侧栏功能
- - (void)initSyncView {
-
- wrongArray = [defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithUpData:0 MarkType:@"1" Subject:@"1"] : [RQ_YDTQuestion_Module getQuestionWithSubject:RQHomePageSubjectType_SubjectOne exerciseType:RQExerciseType_Wrong_NotUpload];//错题
- collectArray = [defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithUpData:0 MarkType:@"2" Subject:@"1"] : [RQ_YDTQuestion_Module getQuestionWithSubject:RQHomePageSubjectType_SubjectOne exerciseType:RQExerciseType_Collect_NotUpload];//收藏
- exceptArray = [defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithUpData:0 MarkType:@"3" Subject:@"1"] : [RQ_YDTQuestion_Module getQuestionWithSubject:RQHomePageSubjectType_SubjectOne exerciseType:RQExerciseType_Remove_NotUpload];//排错
-
- wrongFourArray = [defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithUpData:0 MarkType:@"1" Subject:@"4"] : [RQ_YDTQuestion_Module getQuestionWithSubject:RQHomePageSubjectType_SubjectFour exerciseType:RQExerciseType_Wrong_NotUpload];//错题
- collectFourArray = [defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithUpData:0 MarkType:@"2" Subject:@"4"] : [RQ_YDTQuestion_Module getQuestionWithSubject:RQHomePageSubjectType_SubjectFour exerciseType:RQExerciseType_Collect_NotUpload];//收藏
- exceptFourArray = [defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithUpData:0 MarkType:@"3" Subject:@"4"] : [RQ_YDTQuestion_Module getQuestionWithSubject:RQHomePageSubjectType_SubjectFour exerciseType:RQExerciseType_Remove_NotUpload];//排错
-
- allQuestionArray = @[wrongArray,collectArray,exceptArray,wrongFourArray,collectFourArray,exceptFourArray];
-
-
- NSArray<NSString *> *titleArray = @[@"科一错误题",@"科一收藏题",@"科一排错题",@"科四错误题",@"科四收藏题",@"科四排错题"];
- NSArray<NSString *> *countArray = @[[NSString stringWithFormat:@"共%d题",(int)wrongArray.count],[NSString stringWithFormat:@"共%d题",(int)collectArray.count],[NSString stringWithFormat:@"共%d题",(int)exceptArray.count],[NSString stringWithFormat:@"共%d题",(int)wrongFourArray.count],[NSString stringWithFormat:@"共%d题",(int)collectFourArray.count],[NSString stringWithFormat:@"共%d题",(int)exceptFourArray.count]];
-
-
- syncView = [[UIView alloc] initWithFrame:kFrame];
- syncView.backgroundColor = windowBlockColor;
- [[UIApplication sharedApplication].keyWindow addSubview:syncView];
-
- UIView *selectView = [[UIView alloc] initWithFrame:CGRectMake(20, (kSize.height - 370)/2.0, kSize.width - 40, 350)];
- selectView.backgroundColor = [UIColor whiteColor];
- [selectView borderColor:[UIColor whiteColor] width:.1 cornorRadios:5];
- [syncView addSubview:selectView];
-
-
- CGFloat x,y,w,h;
- y = 0;
- w = 200;
- h = 50;
- UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, y, w, h)];
- [titleLabel setText:@"未上传的题目" Font:FontLarger TextColor:kTitleColor];
- [selectView addSubview:titleLabel];
-
- x = kSize.width - 130;
- w = 80;
- allBtn = [[UIButton alloc] setxywh];//paySelected.png
- [allBtn setImage:[UIImage imageNamed:@"paySelect.png"] withTitle:@"全选" Font:FontTitle forState:UIControlStateNormal];
- [allBtn setImage:[UIImage imageNamed:@"paySelected.png"] forState:UIControlStateSelected];
- allBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- [allBtn setImageEdgeInsets:UIEdgeInsetsMake(10, allBtn.titleLabel.width, 10, -allBtn.titleLabel.width)];
- [allBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -allBtn.imageView.width, 0, allBtn.imageView.width)];
- [allBtn target:self tag:1];
- [selectView addSubview:allBtn];
- [allBtn addViewWithRect:CGRectMake(0, 48.5, kSize.width - 40, 1.5)];
-
- y += h;
- h = 40;
- [btns removeAllObjects];
- for (int i = 0; i < 6; i ++) {
- x = 10;
- w = [[titleArray firstObject] sizeForFont:FontTitle].width + 10;
- UILabel *label = [[UILabel alloc] setxywh];
- [label setText:titleArray[i] Font:FontTitle TextColor:contentTextColor];
- [selectView addSubview:label];
-
- x += w + 10;
- w = 100;
- label = [[UILabel alloc] setxywh];
- [label setText:countArray[i] Font:FontTitle TextColor:defGreen];
- [selectView addSubview:label];
-
- x = 0;
- w = kSize.width - 40;
-
- UIImage *selectImage = [[UIImage imageNamed:@"paySelect.png"] scaledToSize:CGSizeMake(30, 30)];
- UIImage *selectHImage = [[UIImage imageNamed:@"paySelected.png"] scaledToSize:CGSizeMake(30, 30)];
-
- UIButton *selectBtn = [[UIButton alloc] setxywh];
- [selectBtn setImage:selectImage forState:UIControlStateNormal];
- [selectBtn setImage:selectHImage forState:UIControlStateSelected];
- selectBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- [selectBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -15, 0, 15)];
- [selectBtn target:self tag:i + 2];//234567
- [selectView addSubview:selectBtn];
-
- [btns addObject:selectBtn];
-
- [selectBtn addViewWithRect:CGRectMake(0, y + h - 1, kSize.width - 40, 1)];
- y += h;
- }
-
- y += 10;
- w = (kSize.width - 60)/3.0 - 20;
- h = 35;
- NSArray *titArray = @[@"取消",@"同步题目",@"上传题目"];
- for (int i = 0; i < 3; i ++) {
- x = 20 + i*(w + 20);
- UIButton *button = [[UIButton alloc] setxywh];
- [button setTitle:titArray[i] forState:UIControlStateNormal];
- [button setTitle:titArray[i] textColor:[UIColor whiteColor] font:FontTitle fotState:UIControlStateNormal];
- button.backgroundColor = defGreen;
- [button borderColor:defGreen width:1.5 cornorRadios:3];
- [button target:self tag:i + 8];
- [selectView addSubview:button];
- }
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (buttonIndex != alertView.cancelButtonIndex) {
- if (alertView.tag == 100) {
- [self logOutAction];
- }else{
- [self syncQuestion];
- }
- }
- }
- -(void)removeSyncView
- {
- if (syncView) {
- [syncView removeFromSuperview];
- syncView = nil;
- }
- }
- //同步题库
- -(void)syncQuestion
- {
- [syncView setUserInteractionEnabled:NO];
-
- bgLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, (kSize.height - 80)/2.0, kSize.width - 60, 70)];
- bgLabel.backgroundColor = backGroundColor;
- [bgLabel setBoardWid:5 Color:contentTextColor];
- [bgLabel setText:@"收藏、错题同步中,请稍后..." Font:24 TextColor:kTitleColor Alignment:NSTextAlignmentCenter];
- [[UIApplication sharedApplication].keyWindow addSubview:bgLabel];
-
- [self getMyQuestionType:@"" Subject:@""];
- }
- -(void)getMyQuestionType:(NSString*)type Subject:(NSString*)subject;
- {
- if (myDelegate.isLogin == NO || ![Util connectedToNetWork]) {
- [self removebgLabel];
- return ;
- }
-
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"outId" Value:defUser.userStuId];
- [arr addPro:@"type" Value:type];
- [arr addPro:@"subject" Value:subject];
- [arr addPro:@"carType" Value:defUser.car_type];
- [arr addPro:@"isPage" Value:@"0"];
- [arr addPro:@"pageSize" Value:@"0"];
- [arr addPro:@"currentPage" Value:@"0"];
-
- NSString* method = @"getMyQuestionFavs";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- //NSLog(@"同步错题收藏---->%@--->%@",arr,root);
- if (!root || [root[@"code"] isEqualToString:@"1"]) {
-
- [self removebgLabel];
- return ;
- }
-
- NSArray* body = [root objectForKey:@"body"];
- if (body.count < 1) {
-
- [self removebgLabel];
- //说明错题为零 那如果一个人一直没联网 没同步错题 现在同步到为零了 怎么办 所以还是获取本地吧
- return;
- }
- //每次同步前要清空数据库
- if ([defUser.car_type isEqualToString:@"2"]) {
- if ([DB_Que_Helper deleteGZPZ_EXAM_CYRYAllMarkQuestion]) {
- [DB_Que_Helper setGZPZ_EXAM_CYRYMarkQuestionWithArray:body];
- RQ_SHARE_FUNCTION.myErorNum = [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithMarkType:@"1"];
- }
- } else {
- if ([body isKindOfClass:[NSArray class]]) {
- NSArray *arr = body;
- [RQ_YDT_USER_Question_Module deleteAllRemoveRecord];
- [RQ_YDT_USER_Question_Module deleteAllCollectRecord];
- [RQ_YDT_USER_Question_Module deleteAllDoRecord];
- [arr.rac_sequence.signal subscribeNext:^(NSDictionary *dic) {
- if ([dic[@"TYPE"] isEqualToString:@"1"]) {
- /// 收藏
- [RQ_YDT_USER_Question_Module collectQuestionWithID:[dic[@"QID"] integerValue] carType:[RQ_YDTQuestion_Module getCarTypeWithCarTypeName:dic[@"CARTYPE"]] subject:[RQ_YDTQuestion_Module getSubjectWithSubjectName:dic[@"SUBJECT"]] isUploadFlag:YES];
- } else if ([dic[@"TYPE"] isEqualToString:@"2"]) {
- /// 错题
- [RQ_YDT_USER_Question_Module doQuestionWithID:[dic[@"QID"] integerValue] myAnswer:0 trueAnswer:0 carType:[RQ_YDTQuestion_Module getCarTypeWithCarTypeName:dic[@"CARTYPE"]] subject:[RQ_YDTQuestion_Module getSubjectWithSubjectName:dic[@"SUBJECT"]] exerciseType:RQExerciseType_Wrong isUploadFlag:YES];
-
- } else if ([dic[@"TYPE"] isEqualToString:@"3"]) {
- /// 排除
- [RQ_YDT_USER_Question_Module removeQuestionWithID:[dic[@"QID"] integerValue] carType:[RQ_YDTQuestion_Module getCarTypeWithCarTypeName:dic[@"CARTYPE"]] subject:[RQ_YDTQuestion_Module getSubjectWithSubjectName:dic[@"SUBJECT"]] isUploadFlag:YES];
- }
- }];
- }
- RQ_SHARE_FUNCTION.myErorNum = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count;
- }
-
-
-
- [self removebgLabel];
- if (syncView) {
- [syncView removeFromSuperview];
- syncView = nil;
- }
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"题库错题、收藏、排除已同步完毕" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- }];
- }
- -(void)removebgLabel
- {
- if (bgLabel) {
- [bgLabel removeFromSuperview];
- bgLabel = nil;
- }
-
- //myDelegate.isSyn = NO;
- [syncView setUserInteractionEnabled:YES];
- }
- //预约查询
- -(void)appointmentAction
- {
- SelfAppointmentVC *vc = [[SelfAppointmentVC alloc] init];
- // MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- // [nav.view setBackgroundColor:[UIColor whiteColor]];
- // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- // nav.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self.parentViewController presentViewController:nav animated:YES completion:nil];
- [self cw_pushViewController:vc];
- }
- //意见反馈
- -(void)suggestAction
- {
- UIActionSheet* sheet = [[UIActionSheet alloc] initWithTitle:@"意见反馈" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:
- @"向驾校建议",@"向教练建议",@"向系统建议",@"我的建议", nil];
- [sheet showInView:self.view];
- }
- //我的日记
- -(void)myRecoedAction
- {
- RecordVC_New *vc = [[RecordVC_New alloc] init];
- [self cw_pushViewController:vc];
- }
- -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- // NSLog(@"sheet %ld",(int)buttonIndex);
- if ( 4 == buttonIndex) {
- //取消
- return;
- }
-
- if ( 3 == buttonIndex) {
- //历史建议
- mySuggestVC *vc = [[mySuggestVC alloc] init];
- // MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- // [nav.view setBackgroundColor:[UIColor whiteColor]];
- // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- // nav.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self.parentViewController presentViewController:nav animated:YES completion:nil];
- [self cw_pushViewController:vc];
-
- return;
- }
- //驾校/教练
- if (buttonIndex == 1 || buttonIndex == 0) {
- if ([defUser.userDict[@"outId"] isEqualToString:@""]) {
- ShowMsg(@"您还未绑定学员账号");
- return;
- }
- }
-
- SuggestVC* vc = [[SuggestVC alloc] init];
- [vc setType:(int)buttonIndex + 1];
- // MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- // [nav.view setBackgroundColor:[UIColor whiteColor]];
- // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- // nav.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self.parentViewController presentViewController:nav animated:YES completion:nil];
- [self cw_pushViewController:vc];
- }
- - (void)logOutAction
- {
- if (!myDelegate.isLogin) {
- ShowMsg(@"还未登录无法退出登录");
- return;
- }
-
- if (myDelegate.mnPeriodVC || myDelegate.dcPeriodVC) {
- ShowMsg(@"检测到您正在计学时,请先结束计时");
- return;
- }
-
- myDelegate.isLogin = NO;
- if ([defUser.car_type isEqualToString:@"2"]) {
- defUser.car_type = @"C1";
- defUser.isZhiGeZheng = @"NO";
- myDelegate.subject = @"1";
- }
- [defUser removeUserInfo];
- ShowMsgSuc();
- [myTableView reloadData];
- }
- //-(void)gotoEvaluate
- //{
- // NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=1225178346"];
- // if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)){
- // str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id1225178346"];
- // }
- // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
- //}
- #pragma mark 上传错题
- - (void)saveBetchFavQuestion {
- if (myDelegate.isLogin == NO) {
- ShowMsg(@"未登录无法上传错题");
- return ;
- }
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSString *wrongString = @"";
- NSString *favString = @"";
- NSString *pcString = @"";
- //25 36 47
-
- for (NSString *tagStr in selectedArray) {
-
- NSInteger tag = [tagStr integerValue];
- NSArray *qids = allQuestionArray[tag - 2];
- NSString *sub = @"1";
- if (tag > 4) {
- sub = @"4";
- }
-
- if ([defUser.car_type isEqualToString:@"2"]) {
- for (NSString *qid in qids) {
-
- NSString *pinStr = [NSString stringWithFormat:@"%@,%@;",qid,sub];
-
- if (tag == 2 || tag == 5) {//错题
- wrongString = [wrongString stringByAppendingString:pinStr];
- }
- if (tag == 3 || tag == 6) {//收藏
- favString = [favString stringByAppendingString:pinStr];
- }
- if (tag == 4 || tag == 7) {//排除
- pcString = [pcString stringByAppendingString:pinStr];
- }
- }
- } else {
- for (RQYDTQuestionModel *ydtQuestionModel in qids) {
- NSString *pinStr = [NSString stringWithFormat:@"%ld,%@;",ydtQuestionModel.ID,sub];
- if (tag == 2 || tag == 5) {//错题
- wrongString = [wrongString stringByAppendingString:pinStr];
- }
- if (tag == 3 || tag == 6) {//收藏
- favString = [favString stringByAppendingString:pinStr];
- }
- if (tag == 4 || tag == 7) {//排除
- pcString = [pcString stringByAppendingString:pinStr];
- }
- }
- }
-
-
- }
-
- if (wrongString.length == 0 && favString.length == 0 && pcString.length == 0) {
- ShowMsg(@"当前选择上传的题目数量为0");
- return;
- }
-
- NSArray<NSString *> *questionArray = @[wrongString,favString,pcString];
-
- [syncView setUserInteractionEnabled:NO];
- bgLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, (kSize.height - 80)/2.0, kSize.width - 60, 70)];
- bgLabel.backgroundColor = backGroundColor;
- [bgLabel setBoardWid:5 Color:contentTextColor];
- [bgLabel setText:@"上传中,请稍后..." Font:24 TextColor:kTitleColor Alignment:NSTextAlignmentCenter];
- [[UIApplication sharedApplication].keyWindow addSubview:bgLabel];
-
- [self saveBetchFavQuestionWithArray:questionArray];
- }
- - (void)saveBetchFavQuestionWithArray:(NSArray<NSString *> *)array {
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"favArr" Value:array[1]];
- [arr addPro:@"wrongArr" Value:[array firstObject]];
- [arr addPro:@"pcArr" Value:[array lastObject]];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"outId" Value:defUser.userStuId];
- [arr addPro:@"carType" Value:defUser.car_type];
-
- NSString* method = @"saveBetchFavQuestion";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- //NSLog(@"上传错题---->%@--->%@",arr,root);
- if (!root) {
- ShowMsg(@"上传失败,请重试");
- [self removebgLabel];
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- [self removebgLabel];
- return;
- }
-
- ShowMsg(root[@"body"]);
-
- [self removebgLabel];
- if (syncView) {
- [syncView removeFromSuperview];
- syncView = nil;
- }
- if ([defUser.car_type isEqualToString:@"2"]) {
- [DB_Que_Helper setGZPZ_EXAM_CYRYIsUpdateWithArray:selectedArray];
- } else {
- // [DB_Que_Helper setIsUpdateWithArray:selectedArray];
- [collectArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
- [RQ_YDT_USER_Question_Module collectQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectOne isUploadFlag:YES];
- }];
- [collectFourArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
- [RQ_YDT_USER_Question_Module collectQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectFour isUploadFlag:YES];
- }];
-
- [exceptArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
- [RQ_YDT_USER_Question_Module removeQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectOne isUploadFlag:YES];
- }];
- [exceptFourArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
- [RQ_YDT_USER_Question_Module removeQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectFour isUploadFlag:YES];
- }];
-
- [wrongArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
- [RQ_YDT_USER_Question_Module doQuestionWithID:ydtQuestionModel.ID myAnswer:0 trueAnswer:0 carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectOne exerciseType:RQExerciseType_Wrong isUploadFlag:YES];
- }];
- [wrongFourArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
- [RQ_YDT_USER_Question_Module doQuestionWithID:ydtQuestionModel.ID myAnswer:0 trueAnswer:0 carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectFour exerciseType:RQExerciseType_Wrong isUploadFlag:YES];
- }];
- }
-
- RQ_UPDATE_LOCALDATA_MANAGER.count = 600;
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"题库错题、收藏、排除已上传成功" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- }];
- }
- #pragma mark - tableView
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- switch (indexPath.row) {
- case 0:
- {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- if (myDelegate.isLogin) {
- [self gotoStuDetaiVC];
- }else{
- [self userLoginAction];
- }
- }
- }
- break;
- case 1: //我的驾校
- {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- [self gotoChooseExLibVC];
- } else {
- if (myDelegate.isLogin) {
- [self gotoSchoolVC];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- }
-
- }
- break;
-
- case 2: //我的教练
- if (myDelegate.isLogin) {
- if (!defUser.userDict[@"outId"]) {
- ShowMsg(@"查询不到您的教练");
- return;
- }
- if ([defUser.userDict[@"outId"] isEqualToString:@""]) {
- ShowMsg(@"查询不到您的教练");
- return;
- }
- [self gotoCoachDetailInfoVC];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
-
- case 3: //绑定账号
- if (myDelegate.isLogin) {
- if(defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0){
- NSString *IMEI = defUser.userDict[@"imei"];
- if (IMEI.length > 0) {
- if ([Tools getIDFAWithType:GetIDFAType_Default]) {
- if (![IMEI isEqualToString:[Tools getIDFAWithType:GetIDFAType_Default]]) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"当前账号已经与其它手机绑定" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- }else {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"账号与手机已绑定" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- }
- }
- }else {
-
- // BindVC* vc = [[BindVC alloc] init];
- // [vc bindSuccessWithBlock:^{
- // [LoginViewController reLoginFromViewController:self finishBlock:nil];
- // }];
- // MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- // nav.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self.parentViewController presentViewController:nav animated:YES completion:^{
- // }];
- [self uploadBindStuImeiBlock:^(BOOL isSuccess) {
- if (isSuccess) {
- [LoginViewController reLoginFromViewController:self finishBlock:nil];
- }
- }];
- break;
- }
- }else{
- ThirdLoginBindYunGuanVC *vc = [[ThirdLoginBindYunGuanVC alloc] init];
- vc.skipType = 1;
- MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- nav.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.parentViewController presentViewController:nav animated:YES completion:nil];
- }
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
-
- case 4: //我的题库
- [self gotoChooseExLibVC];
- break;
- case 5: //同步题库
- if (myDelegate.isLogin) {
- [self initSyncView];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case 6: //我的学时
- {
- if (myDelegate.isLogin) {
- if(defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0){
- TrainInfoVC *vc = [[TrainInfoVC alloc] init];
- vc.skipType = 1;
- MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- nav.modalPresentationStyle = UIModalPresentationFullScreen;
- [self cw_pushViewController:vc];
- // [self.parentViewController presentViewController:nav animated:YES completion:nil];
- }else{
- ShowMsg(@"未绑定学员账号,无法进行此操作");
- }
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- }
- break;
- case 7: //培训记录
- if (myDelegate.isLogin) {
-
- if ([defUser.userDict[@"outId"] length] < 1) {
- ShowMsg(@"未绑定学员账号,无法进行此操作");
- return;
- }
- [self myRecoedAction];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
- case 8: //意见反馈
- if (myDelegate.isLogin) {
- [self suggestAction];
- }else{
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }
- break;
-
- case 9: //客服-联系我们
- {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- break;
- }
-
- 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"];
- }
- [QMConnect registerSDKWithAppKey:CUSTOMERSERVICE_APPKEY userName:[NSString stringWithFormat:@"%@[iOS学员]",name] userId:[NSString stringWithFormat:@"%@",defUser.userDict[@"id"]]];
- }
- break;
- // case 10: //给我们的评价
- // [self gotoEvaluate];
- break;
- case 10: //帮助
- [myDelegate setUrl:@"帮助;help"];
- [self gotoTrafficVC];
- break;
- case 11: //退出登录
- {
- UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"确定要退出登录吗" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
- alert.tag = 100;
- [alert show];
- break;
- }
- default:
- break;
- }
- }
- - (void)uploadBindStuImeiBlock:(void (^)(BOOL isSuccess))bindBlock {
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
- [arr addPro:@"sfzhm" Value:defUser.sfzmhm];
- [arr addPro:@"tel" Value:defUser.userTel];
- if ([Tools getIDFAWithType:GetIDFAType_Default]) {
- [arr addPro:@"imei" Value:[Tools getIDFAWithType:GetIDFAType_Default]];
- }
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
-
- NSString* method = @"bindImei";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
- if (!root) {
- ShowMsg(@"绑定失败,请重试");
- bindBlock(false);
- return;
- }
-
- if ([root[@"code"] isEqualToString:@"0"]) {
- showMsgByAlertWithSureBlock(self, @"绑定成功", ^{
- bindBlock(true);
- });
- }else{
- showMsgByAlert(self, root[@"msg"]);
- bindBlock(false);
- }
- }];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? titles.count : myDelegate.isLogin ? titles.count : titles.count-1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- switch (indexPath.row) {
- case 0:
- return RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? 80 : 110;
- break;
- default:
- return [CLCell cellHeight];
- break;
- }
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- return [UIView new];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (0 == indexPath.row) {
- return [self headCellWithTableView:tableView];
- }
- UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"clCell"];;
- if (!cell) {
- cell = [[CLCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"clCell"];
- }
- NSString* str;
- switch (indexPath.row)
- {
- case 1:
- {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- str = [queLibNameDict objectForKey:defUser.car_type];
- [cell.detailTextLabel setText:str];
- [cell.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
- } else {
- NSString *jxjcString = @"请选择驾校";
- if ([defUser.userDict[@"schoolName"] length] > 0) {
- jxjcString = defUser.userDict[@"schoolName"];
- }
- if ([defUser.userSchDict[@"shortName"] length] > 0) {
- jxjcString = defUser.userSchDict[@"shortName"];
- }
- [cell.detailTextLabel setText:jxjcString];
- [cell.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
- }
- }
- break;
- case 4:
- str = [queLibNameDict objectForKey:defUser.car_type];
- [cell.detailTextLabel setText:str];
- [cell.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
- break;
- default:
- //这里需要将detail设置为空 去重用
- [cell.detailTextLabel setText:@""];
- break;
- }
- [cell.textLabel setFont:[UIFont scaleSize:15]];
- cell.textLabel.textColor = kTitleColor;
- cell.textLabel.text = titles[indexPath.row];
- cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- [cell.detailTextLabel setTextColor:defGreen];
- return cell;
- }
- -(UITableViewCell* )headCellWithTableView:(UITableView*)tableView{
- HeadCell* cell = [tableView dequeueReusableCellWithIdentifier:@"headCell"];;
- if (!cell) {
- cell = [[HeadCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"headCell"];
-
- [cell createBtns];
- UIButton* btn;
- btn = cell.leftBtn;
- [btn setTag:0];
- [cell addSubview:btn];
- [btn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- btn = cell.rightBrn;
- [btn setTag:1];
- [cell addSubview:btn];
- [btn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- }
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- cell.textLabel.text = @"驾考学员";
- cell.detailTextLabel.text = @"欢迎您!";
- cell.accessoryType = UITableViewCellAccessoryNone;
- } else {
- if (myDelegate.isLogin) {
- NSString *nameString = defUser.userDict[@"userName"];
- if (nameString.length < 1) {
- nameString = defUser.userDict[@"nickName"];
- }
- if (nameString.length < 1) {
- nameString = defUser.userDict[@"loginCode"];
- }
- cell.textLabel.text = nameString;
- cell.detailTextLabel.text = @"欢迎您!";
- } else {
- cell.textLabel.text = titles[0];
- cell.detailTextLabel.text = @"登录后可查看学习进度!";
- }
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
- cell.detailTextLabel.textColor = defGreen;
- cell.detailTextLabel.numberOfLines = 0;
- cell.textLabel.textColor = kTitleColor;
-
- NSString *path = defUser.userDict[@"photo"];
- if ( path && ![path isEqualToString:@""] && [Util connectedToNetWork] && myDelegate.isLogin) {
-
- if (path && ![path hasPrefix:@"http"]){
- path = [imgPreFix stringByAppendingString:path];
- }
- [cell.imageView sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:images[0]]];
- }else{
- cell.imageView.image = [UIImage imageNamed:images[0]];
- }
-
-
- return cell;
- }
- #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];
- [self cw_presentViewController:nav];
- }
- - (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)cw_pushViewController:(UIViewController *)vc drewerHiddenDuration:(NSTimeInterval)duration {
-
- CWLateralSlideAnimator *animator = (CWLateralSlideAnimator *)self.transitioningDelegate;
- animator.configuration.HiddenAnimDuration = duration > 0 ? duration : animator.configuration.HiddenAnimDuration;
- UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
- RQBaseNavigationController *nav;
- NSString *TransitionType = kCATransitionPush;
- if ([rootVC isKindOfClass:[RQMainTabBarViewController class]]) {
- RQMainTabBarViewController *mainTabBarViewController = (RQMainTabBarViewController *)rootVC;
- NSInteger index = mainTabBarViewController.tabBarController.selectedIndex;
- nav = mainTabBarViewController.tabBarController.childViewControllers[index];
- }else if ([rootVC isKindOfClass:[RQBaseNavigationController class]]) {
- if (animator.animationType == CWDrawerAnimationTypeDefault) TransitionType = kCATransitionFade;
- nav = (RQBaseNavigationController *)rootVC;
- }else {
- NSLog(@"This no UINavigationController...");
- return;
- }
-
- NSNumber *direction = objc_getAssociatedObject(self, &CWLateralSlideDirectionKey);
- NSString *subType = direction.integerValue ? kCATransitionFromLeft : kCATransitionFromRight;
- CATransition *transition = [CATransition animation];
- transition.duration = 0.20f;
- transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
- transition.type = TransitionType;
- transition.subtype = subType;
- [nav.view.layer addAnimation:transition forKey:nil];
-
- [self dismissViewControllerAnimated:YES completion:nil];
- [nav pushViewController:vc animated:NO];
- }
- @end
|