LeftViewController.m 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. #import "LeftViewController.h"
  2. #import "AppDelegate.h"
  3. #import "MyUINavigationController.h"
  4. #import "StuDetailVC.h"
  5. #import "LoginViewController.h"
  6. #import "SchoolInfoVC.h"
  7. #import "FavTopicsVC.h"
  8. #import "CoachDetailInfoVC.h"
  9. #import "ChooseExLibVC.h"
  10. #import "TrainInfoVC.h"
  11. #import "HeadCell.h"
  12. #import "AboutVC.h"
  13. #import "CLButton.h"
  14. #import "CoachPlanVC.h"
  15. #import "CLCell.h"
  16. #import "MyMsgVC.h"
  17. #import "RecordVC_New.h"
  18. #import "mySuggestVC.h"
  19. #import "SelfAppointmentVC.h"
  20. #import "HelpQuestionVC.h"
  21. #import "SelectSchoolVC.h"
  22. #import "TrainInfoVC.h"
  23. #import "ThirdLoginBindYunGuanVC.h"// 第三方登录绑定imei以及学员账号
  24. #import "BindVC.h" //证件号登录绑定imei
  25. //客服
  26. #import "QMChatRoomViewController.h"
  27. #import <QMLineSDK/QMLineSDK.h>
  28. #import "QMAlert.h"
  29. typedef enum {
  30. AlertTypeStopTiming = 1,
  31. AlertTypeGotoLogin
  32. }AlertType;
  33. @interface LeftViewController ()
  34. {
  35. /**用于在列表显示.需要从defUser里面取值
  36. */
  37. NSDictionary *queLibNameDict;
  38. UIView *syncView;
  39. UILabel *bgLabel;
  40. UIButton *allBtn;
  41. NSArray *wrongArray;
  42. NSArray *collectArray;
  43. NSArray *exceptArray;
  44. NSArray *wrongFourArray;
  45. NSArray *collectFourArray;
  46. NSArray *exceptFourArray;
  47. NSMutableArray<UIButton *> *btns;
  48. NSArray<NSArray *> *allQuestionArray;
  49. NSMutableArray<NSString *> *selectedArray;
  50. }
  51. //客服
  52. @property (nonatomic, assign) BOOL isPushed; // 控制跳转
  53. @property (nonatomic, assign) BOOL isConnecting; // 控制多次注册
  54. @property (nonatomic, copy) NSDictionary * dictionary; //客服一些配置
  55. @end
  56. @implementation LeftViewController
  57. {
  58. UITableView *myTableView;
  59. NSArray* titles;
  60. NSArray* images;
  61. /**夜间模式按钮
  62. */
  63. UIButton* nightBtn;
  64. int seconds;
  65. //NSTimer* timer;
  66. NSDateFormatter* formatter;
  67. }
  68. - (void)viewDidLoad
  69. {
  70. [super viewDidLoad];
  71. [self myInit];
  72. }
  73. - (void)didReceiveMemoryWarning
  74. {
  75. [super didReceiveMemoryWarning];
  76. }
  77. -(void)viewWillAppear:(BOOL)animated
  78. {
  79. [super viewWillAppear:animated];
  80. self.navigationController.navigationBarHidden = YES;
  81. [myTableView reloadData];
  82. _isPushed = NO;
  83. // self.navigationController.navigationBar.barTintColor = defGreen;
  84. }
  85. -(void)viewWillDisappear:(BOOL)animated {
  86. [super viewWillDisappear:animated];
  87. _isPushed = YES;
  88. }
  89. -(void)myInit
  90. {
  91. self.navigationController.navigationBar.translucent = YES;
  92. btns = [NSMutableArray array];
  93. selectedArray = [NSMutableArray array];
  94. /**
  95. 与数据库一致 如果摩托车有变动 要改 --danson
  96. @"C1",@"A2",@"A1",@"D",@"4",@"1",@"2",@"3",@"5"
  97. */
  98. queLibNameDict = @{@"C1" : @"小车",
  99. @"C2" : @"小车",
  100. @"C3" : @"小车",
  101. @"A2" : @"货车",
  102. @"B2" : @"货车",
  103. @"A1" : @"客车",
  104. @"A3" : @"客车",
  105. @"B1" : @"客车",
  106. @"D" : @"摩托车",
  107. @"E" : @"摩托车",
  108. @"F" : @"摩托车",
  109. @"1" : @"客运",
  110. @"2" : @"货运",
  111. @"3" : @"危险品",
  112. @"4" : @"教练员",
  113. @"5" : @"出租车",
  114. @"6" : @"网约车",
  115. };
  116. titles = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN?
  117. @[
  118. @"立即登录",
  119. @"我的题库",
  120. ]
  121. :@[@"立即登录",
  122. @"我的驾校",
  123. @"我的教练",
  124. @"绑定账号",
  125. @"我的题库",
  126. @"同步题库",
  127. @"我的学时",
  128. @"培训记录",
  129. @"投诉评价",
  130. @"线上咨询",
  131. /*@"给我们评价",*/
  132. @"帮助",
  133. @"退出登录"];
  134. images = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN?
  135. @[
  136. @"drawer_head.png",
  137. @"leftvc_icon14.png",
  138. ]
  139. :@[@"drawer_head.png",
  140. @"leftvc_icon3.png",
  141. @"leftvc_icon6.png",
  142. @"function02_s",//绑定账号
  143. @"leftvc_icon4.png",
  144. @"leftvc_icon14.png",//同步题库
  145. @"function06_s",//我的学时
  146. @"leftvc_record.png",
  147. @"drawer_img06.png",
  148. @"qm_default_agent.png",
  149. /*@"leftvc_icon8.png",*/
  150. @"drawer_img02.png",
  151. @"drawer_img12.png",
  152. @"001.png",
  153. @"001.png",
  154. @"001.png",
  155. @"001.png"];
  156. //高度 titles.count*[CLCell cellHeight] + 60
  157. myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kLeftViewWid, kSize.height - 35)];
  158. [myTableView setDataSource:self];
  159. [myTableView setDelegate:self];
  160. [myTableView setShowsVerticalScrollIndicator:NO];
  161. [self.view addSubview:myTableView];
  162. [myTableView setScrollEnabled:(myTableView.bottom > kSize.height - 40)];
  163. UIView* vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, myTableView.bottom - kSize.height - 40)];
  164. [myTableView setTableFooterView:vi];
  165. CGFloat btnWid = 100;
  166. CGFloat btnHei = 35;
  167. CGFloat y = kSize.height - btnHei -kSafeAreaBottomHeight;
  168. vi = [[UIView alloc] initWithFrame:CGRectMake(0, y,kLeftViewWid , btnHei)];
  169. [self.view addSubview:vi];
  170. [vi setBackgroundColor:[UIColor whiteColor]];
  171. CLButton* btn = [[CLButton alloc] initWithFrame:CGRectMake(0, 0, btnWid, btnHei)];
  172. [btn setTitle:@"关于" forState:UIControlStateNormal];
  173. [btn setImage:[UIImage imageNamed:@"leftvc_about"] forState:UIControlStateNormal];
  174. btn.titleLabel.font = [UIFont scaleSize:NormalFont];
  175. [btn setTitleColor:kTitleColor forState:UIControlStateNormal];
  176. [btn setStyle:1];
  177. [vi addSubview:btn];
  178. [btn setBackgroundColor:[UIColor clearColor]];
  179. [btn addTarget:self action:@selector(gotoAboutVC) forControlEvents:UIControlEventTouchUpInside];
  180. btn = [[CLButton alloc] initWithFrame:CGRectMake(kLeftViewWid - btnWid,0, btnWid, btnHei)];
  181. //可以对页面内改变昼夜模式做出正确反映
  182. btn.selected = myDelegate.isNightMode;
  183. [btn setTitle:@"夜间" forState:UIControlStateNormal];
  184. [btn setTitle:@"日间" forState:UIControlStateSelected];
  185. [btn setImage:[UIImage imageNamed:@"leftvc_night.png"] forState:UIControlStateNormal];
  186. [btn setImage:[UIImage imageNamed:@"leftvc_mid.png"] forState:UIControlStateSelected];
  187. btn.titleLabel.font = [UIFont scaleSize:NormalFont];
  188. [btn setTitleColor:kTitleColor forState:UIControlStateNormal];
  189. [btn setStyle:1];
  190. [vi addSubview:btn];
  191. [btn setBackgroundColor:[UIColor clearColor]];
  192. nightBtn = btn;
  193. [btn addTarget:self action:@selector(nightModeClick:) forControlEvents:UIControlEventTouchUpInside];
  194. //客服
  195. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(registerSuccess:) name:CUSTOM_LOGIN_SUCCEED object:nil];
  196. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(registerFailure:) name:CUSTOM_LOGIN_ERROR_USER object:nil];
  197. _isConnecting = NO;
  198. _isPushed = NO;
  199. }
  200. #pragma mark -
  201. -(void)nightModeClick:(UIButton*)sender
  202. {
  203. [sender setSelected:!sender.selected];
  204. [myDelegate setIsNightMode:sender.selected];
  205. if (sender.selected) {
  206. [MBProgressHUD showSuccess:@"已关闭夜间练习模式" ToView:self.view];
  207. }else{
  208. [MBProgressHUD showSuccess:@"已关闭夜间练习模式" ToView:self.view];
  209. }
  210. }
  211. -(void)userLoginAction{
  212. LoginViewController* vc = [[LoginViewController alloc] init];
  213. [self cw_presentViewController:vc];
  214. }
  215. -(void)gotoStuDetaiVC{
  216. StuDetailVC* vc = [[StuDetailVC alloc] init];
  217. vc.tag = 1;
  218. [self cw_pushViewController:vc];
  219. }
  220. -(void)gotoSchoolVC{
  221. if (defUser.userSchoolId && [defUser.userSchoolId length] < 1) {
  222. //还未绑定驾校 选择驾校按钮 绑定成功后 重调登录接口 然后刷新UI(因为驾校相关信息较多 故不直接添加至本地信息)
  223. SelectSchoolVC *selectVC = [[SelectSchoolVC alloc] init];
  224. selectVC.skipType = @"1";
  225. [selectVC finishBlock:^{
  226. [myTableView reloadData];
  227. }];
  228. [self cw_pushViewController:selectVC];
  229. }else{
  230. SchoolInfoVC *vc = [[SchoolInfoVC alloc] init];
  231. [self cw_pushViewController:vc];
  232. }
  233. }
  234. /**可以把这些跳转做成用class来跳转。传参就用用字典了。
  235. */
  236. -(void)gotoCoachDetailInfoVC{
  237. CoachDetailInfoVC* vc = [[CoachDetailInfoVC alloc] init];
  238. [self cw_pushViewController:vc];
  239. }
  240. -(void)gotoChooseExLibVC{
  241. ChooseExLibVC* vc = [[ChooseExLibVC alloc] init];
  242. [self cw_pushViewController:vc];
  243. }
  244. -(void)gotoAboutVC{
  245. AboutVC* vc = [[AboutVC alloc] init];
  246. [self cw_pushViewController:vc];
  247. }
  248. -(void)gotoVC:(NSString*)name
  249. {
  250. UIViewController* vc = [NSClassFromString(name) new];
  251. [self cw_pushViewController:vc];
  252. }
  253. -(void)gotoTrafficVC
  254. {
  255. HelpQuestionVC* vc = [[HelpQuestionVC alloc] init];
  256. vc.source = @"left";
  257. [self cw_pushViewController:vc];
  258. }
  259. -(void)showAlert:(NSString*)str{
  260. UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
  261. alert.delegate = self;
  262. [alert show];
  263. }
  264. -(void)showAlertGotoLogin{
  265. UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您还未登录,不能使用该功能" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
  266. [alert setTag:AlertTypeGotoLogin];
  267. [alert show];
  268. }
  269. -(void)cellBtnClick:(UIButton*)sender{
  270. int tag = (int)sender.tag;
  271. if (!myDelegate.isLogin) {
  272. [self userLoginAction];
  273. return;
  274. }
  275. if( 0 == tag){
  276. MyMsgVC* vc = [[MyMsgVC alloc] init];
  277. [self cw_pushViewController:vc];
  278. }
  279. if ( 1 == sender.tag) {
  280. FavTopicsVC* vc = [[FavTopicsVC alloc] init];
  281. [self cw_pushViewController:vc];
  282. }
  283. }
  284. -(void)btnClick:(UIButton *)sender
  285. {
  286. if (sender.tag == 1) {//全选是否
  287. sender.selected = !sender.selected;
  288. if (sender.selected) {
  289. [selectedArray removeAllObjects];
  290. NSArray *array = @[@"2",@"3",@"4",@"5",@"6",@"7"];
  291. [selectedArray addObjectsFromArray:array];
  292. for (UIButton *btn in btns) {
  293. btn.selected = YES;
  294. }
  295. }else{
  296. [selectedArray removeAllObjects];
  297. for (UIButton *btn in btns) {
  298. btn.selected = NO;
  299. }
  300. }
  301. }
  302. if (sender.tag > 1 && sender.tag < 8) {
  303. sender.selected = !sender.selected;
  304. if (sender.selected) {
  305. if (![selectedArray containsObject:[NSString stringWithFormat:@"%d",(int)sender.tag]]) {
  306. [selectedArray addObject:[NSString stringWithFormat:@"%d",(int)sender.tag]];
  307. if (selectedArray.count == 6) {
  308. allBtn.selected = YES;
  309. }
  310. }
  311. }else{
  312. if ([selectedArray containsObject:[NSString stringWithFormat:@"%d",(int)sender.tag]]) {
  313. if (selectedArray.count == 6) {
  314. allBtn.selected = NO;
  315. }
  316. [selectedArray removeObject:[NSString stringWithFormat:@"%d",(int)sender.tag]];
  317. }
  318. }
  319. }
  320. if (sender.tag == 8) {//取消
  321. [self removeSyncView];
  322. }
  323. if (sender.tag == 9) {//同步按钮
  324. if (wrongArray.count > 0 || collectArray.count > 0 || exceptArray.count > 0 || wrongFourArray.count > 0 || collectFourArray.count > 0 || exceptFourArray.count > 0) {
  325. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"同步题库(错题、收藏、排错题)将覆盖本地的题目记录,您尚有题目未上传,建议上传完在同步,是否继续同步?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"同步", nil];
  326. [alert show];
  327. }else{
  328. [self syncQuestion];
  329. }
  330. }
  331. if (sender.tag == 10) {//上传
  332. if (selectedArray.count == 0) {
  333. ShowMsg(@"请选择需要上传的题目");
  334. return;
  335. }
  336. [self saveBetchFavQuestion];
  337. }
  338. }
  339. #pragma mark - 侧栏功能
  340. - (void)initSyncView {
  341. 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];//错题
  342. 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];//收藏
  343. 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];//排错
  344. 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];//错题
  345. 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];//收藏
  346. 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];//排错
  347. allQuestionArray = @[wrongArray,collectArray,exceptArray,wrongFourArray,collectFourArray,exceptFourArray];
  348. NSArray<NSString *> *titleArray = @[@"科一错误题",@"科一收藏题",@"科一排错题",@"科四错误题",@"科四收藏题",@"科四排错题"];
  349. 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]];
  350. syncView = [[UIView alloc] initWithFrame:kFrame];
  351. syncView.backgroundColor = windowBlockColor;
  352. [[UIApplication sharedApplication].keyWindow addSubview:syncView];
  353. UIView *selectView = [[UIView alloc] initWithFrame:CGRectMake(20, (kSize.height - 370)/2.0, kSize.width - 40, 350)];
  354. selectView.backgroundColor = [UIColor whiteColor];
  355. [selectView borderColor:[UIColor whiteColor] width:.1 cornorRadios:5];
  356. [syncView addSubview:selectView];
  357. CGFloat x,y,w,h;
  358. y = 0;
  359. w = 200;
  360. h = 50;
  361. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, y, w, h)];
  362. [titleLabel setText:@"未上传的题目" Font:FontLarger TextColor:kTitleColor];
  363. [selectView addSubview:titleLabel];
  364. x = kSize.width - 130;
  365. w = 80;
  366. allBtn = [[UIButton alloc] setxywh];//paySelected.png
  367. [allBtn setImage:[UIImage imageNamed:@"paySelect.png"] withTitle:@"全选" Font:FontTitle forState:UIControlStateNormal];
  368. [allBtn setImage:[UIImage imageNamed:@"paySelected.png"] forState:UIControlStateSelected];
  369. allBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  370. [allBtn setImageEdgeInsets:UIEdgeInsetsMake(10, allBtn.titleLabel.width, 10, -allBtn.titleLabel.width)];
  371. [allBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -allBtn.imageView.width, 0, allBtn.imageView.width)];
  372. [allBtn target:self tag:1];
  373. [selectView addSubview:allBtn];
  374. [allBtn addViewWithRect:CGRectMake(0, 48.5, kSize.width - 40, 1.5)];
  375. y += h;
  376. h = 40;
  377. [btns removeAllObjects];
  378. for (int i = 0; i < 6; i ++) {
  379. x = 10;
  380. w = [[titleArray firstObject] sizeForFont:FontTitle].width + 10;
  381. UILabel *label = [[UILabel alloc] setxywh];
  382. [label setText:titleArray[i] Font:FontTitle TextColor:contentTextColor];
  383. [selectView addSubview:label];
  384. x += w + 10;
  385. w = 100;
  386. label = [[UILabel alloc] setxywh];
  387. [label setText:countArray[i] Font:FontTitle TextColor:defGreen];
  388. [selectView addSubview:label];
  389. x = 0;
  390. w = kSize.width - 40;
  391. UIImage *selectImage = [[UIImage imageNamed:@"paySelect.png"] scaledToSize:CGSizeMake(30, 30)];
  392. UIImage *selectHImage = [[UIImage imageNamed:@"paySelected.png"] scaledToSize:CGSizeMake(30, 30)];
  393. UIButton *selectBtn = [[UIButton alloc] setxywh];
  394. [selectBtn setImage:selectImage forState:UIControlStateNormal];
  395. [selectBtn setImage:selectHImage forState:UIControlStateSelected];
  396. selectBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  397. [selectBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -15, 0, 15)];
  398. [selectBtn target:self tag:i + 2];//234567
  399. [selectView addSubview:selectBtn];
  400. [btns addObject:selectBtn];
  401. [selectBtn addViewWithRect:CGRectMake(0, y + h - 1, kSize.width - 40, 1)];
  402. y += h;
  403. }
  404. y += 10;
  405. w = (kSize.width - 60)/3.0 - 20;
  406. h = 35;
  407. NSArray *titArray = @[@"取消",@"同步题目",@"上传题目"];
  408. for (int i = 0; i < 3; i ++) {
  409. x = 20 + i*(w + 20);
  410. UIButton *button = [[UIButton alloc] setxywh];
  411. [button setTitle:titArray[i] forState:UIControlStateNormal];
  412. [button setTitle:titArray[i] textColor:[UIColor whiteColor] font:FontTitle fotState:UIControlStateNormal];
  413. button.backgroundColor = defGreen;
  414. [button borderColor:defGreen width:1.5 cornorRadios:3];
  415. [button target:self tag:i + 8];
  416. [selectView addSubview:button];
  417. }
  418. }
  419. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  420. {
  421. if (buttonIndex != alertView.cancelButtonIndex) {
  422. if (alertView.tag == 100) {
  423. [self logOutAction];
  424. }else{
  425. [self syncQuestion];
  426. }
  427. }
  428. }
  429. -(void)removeSyncView
  430. {
  431. if (syncView) {
  432. [syncView removeFromSuperview];
  433. syncView = nil;
  434. }
  435. }
  436. //同步题库
  437. -(void)syncQuestion
  438. {
  439. [syncView setUserInteractionEnabled:NO];
  440. bgLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, (kSize.height - 80)/2.0, kSize.width - 60, 70)];
  441. bgLabel.backgroundColor = backGroundColor;
  442. [bgLabel setBoardWid:5 Color:contentTextColor];
  443. [bgLabel setText:@"收藏、错题同步中,请稍后..." Font:24 TextColor:kTitleColor Alignment:NSTextAlignmentCenter];
  444. [[UIApplication sharedApplication].keyWindow addSubview:bgLabel];
  445. [self getMyQuestionType:@"" Subject:@""];
  446. }
  447. -(void)getMyQuestionType:(NSString*)type Subject:(NSString*)subject;
  448. {
  449. if (myDelegate.isLogin == NO || ![Util connectedToNetWork]) {
  450. [self removebgLabel];
  451. return ;
  452. }
  453. NSMutableArray *arr = [NSMutableArray array];
  454. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  455. [arr addPro:@"outId" Value:defUser.userStuId];
  456. [arr addPro:@"type" Value:type];
  457. [arr addPro:@"subject" Value:subject];
  458. [arr addPro:@"carType" Value:defUser.car_type];
  459. [arr addPro:@"isPage" Value:@"0"];
  460. [arr addPro:@"pageSize" Value:@"0"];
  461. [arr addPro:@"currentPage" Value:@"0"];
  462. NSString* method = @"getMyQuestionFavs";
  463. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  464. //NSLog(@"同步错题收藏---->%@--->%@",arr,root);
  465. if (!root || [root[@"code"] isEqualToString:@"1"]) {
  466. [self removebgLabel];
  467. return ;
  468. }
  469. NSArray* body = [root objectForKey:@"body"];
  470. if (body.count < 1) {
  471. [self removebgLabel];
  472. //说明错题为零 那如果一个人一直没联网 没同步错题 现在同步到为零了 怎么办 所以还是获取本地吧
  473. return;
  474. }
  475. //每次同步前要清空数据库
  476. if ([defUser.car_type isEqualToString:@"2"]) {
  477. if ([DB_Que_Helper deleteGZPZ_EXAM_CYRYAllMarkQuestion]) {
  478. [DB_Que_Helper setGZPZ_EXAM_CYRYMarkQuestionWithArray:body];
  479. RQ_SHARE_FUNCTION.myErorNum = [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithMarkType:@"1"];
  480. }
  481. } else {
  482. if ([body isKindOfClass:[NSArray class]]) {
  483. NSArray *arr = body;
  484. [RQ_YDT_USER_Question_Module deleteAllRemoveRecord];
  485. [RQ_YDT_USER_Question_Module deleteAllCollectRecord];
  486. [RQ_YDT_USER_Question_Module deleteAllDoRecord];
  487. [arr.rac_sequence.signal subscribeNext:^(NSDictionary *dic) {
  488. if ([dic[@"TYPE"] isEqualToString:@"1"]) {
  489. /// 收藏
  490. [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];
  491. } else if ([dic[@"TYPE"] isEqualToString:@"2"]) {
  492. /// 错题
  493. [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];
  494. } else if ([dic[@"TYPE"] isEqualToString:@"3"]) {
  495. /// 排除
  496. [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];
  497. }
  498. }];
  499. }
  500. RQ_SHARE_FUNCTION.myErorNum = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count;
  501. }
  502. [self removebgLabel];
  503. if (syncView) {
  504. [syncView removeFromSuperview];
  505. syncView = nil;
  506. }
  507. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"题库错题、收藏、排除已同步完毕" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  508. [alert show];
  509. }];
  510. }
  511. -(void)removebgLabel
  512. {
  513. if (bgLabel) {
  514. [bgLabel removeFromSuperview];
  515. bgLabel = nil;
  516. }
  517. //myDelegate.isSyn = NO;
  518. [syncView setUserInteractionEnabled:YES];
  519. }
  520. //预约查询
  521. -(void)appointmentAction
  522. {
  523. SelfAppointmentVC *vc = [[SelfAppointmentVC alloc] init];
  524. // MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  525. // [nav.view setBackgroundColor:[UIColor whiteColor]];
  526. // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  527. // nav.modalPresentationStyle = UIModalPresentationFullScreen;
  528. // [self.parentViewController presentViewController:nav animated:YES completion:nil];
  529. [self cw_pushViewController:vc];
  530. }
  531. //意见反馈
  532. -(void)suggestAction
  533. {
  534. UIActionSheet* sheet = [[UIActionSheet alloc] initWithTitle:@"意见反馈" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:
  535. @"向驾校建议",@"向教练建议",@"向系统建议",@"我的建议", nil];
  536. [sheet showInView:self.view];
  537. }
  538. //我的日记
  539. -(void)myRecoedAction
  540. {
  541. RecordVC_New *vc = [[RecordVC_New alloc] init];
  542. [self cw_pushViewController:vc];
  543. }
  544. -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  545. {
  546. // NSLog(@"sheet %ld",(int)buttonIndex);
  547. if ( 4 == buttonIndex) {
  548. //取消
  549. return;
  550. }
  551. if ( 3 == buttonIndex) {
  552. //历史建议
  553. mySuggestVC *vc = [[mySuggestVC alloc] init];
  554. // MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  555. // [nav.view setBackgroundColor:[UIColor whiteColor]];
  556. // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  557. // nav.modalPresentationStyle = UIModalPresentationFullScreen;
  558. // [self.parentViewController presentViewController:nav animated:YES completion:nil];
  559. [self cw_pushViewController:vc];
  560. return;
  561. }
  562. //驾校/教练
  563. if (buttonIndex == 1 || buttonIndex == 0) {
  564. if ([defUser.userDict[@"outId"] isEqualToString:@""]) {
  565. ShowMsg(@"您还未绑定学员账号");
  566. return;
  567. }
  568. }
  569. SuggestVC* vc = [[SuggestVC alloc] init];
  570. [vc setType:(int)buttonIndex + 1];
  571. // MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  572. // [nav.view setBackgroundColor:[UIColor whiteColor]];
  573. // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  574. // nav.modalPresentationStyle = UIModalPresentationFullScreen;
  575. // [self.parentViewController presentViewController:nav animated:YES completion:nil];
  576. [self cw_pushViewController:vc];
  577. }
  578. - (void)logOutAction
  579. {
  580. if (!myDelegate.isLogin) {
  581. ShowMsg(@"还未登录无法退出登录");
  582. return;
  583. }
  584. if (myDelegate.mnPeriodVC || myDelegate.dcPeriodVC) {
  585. ShowMsg(@"检测到您正在计学时,请先结束计时");
  586. return;
  587. }
  588. myDelegate.isLogin = NO;
  589. if ([defUser.car_type isEqualToString:@"2"]) {
  590. defUser.car_type = @"C1";
  591. defUser.isZhiGeZheng = @"NO";
  592. myDelegate.subject = @"1";
  593. }
  594. [defUser removeUserInfo];
  595. ShowMsgSuc();
  596. [myTableView reloadData];
  597. }
  598. //-(void)gotoEvaluate
  599. //{
  600. // NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=1225178346"];
  601. // if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)){
  602. // str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id1225178346"];
  603. // }
  604. // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
  605. //}
  606. #pragma mark 上传错题
  607. - (void)saveBetchFavQuestion {
  608. if (myDelegate.isLogin == NO) {
  609. ShowMsg(@"未登录无法上传错题");
  610. return ;
  611. }
  612. if (![Util connectedToNetWork]) {
  613. showMsgUnconnect();
  614. return;
  615. }
  616. NSString *wrongString = @"";
  617. NSString *favString = @"";
  618. NSString *pcString = @"";
  619. //25 36 47
  620. for (NSString *tagStr in selectedArray) {
  621. NSInteger tag = [tagStr integerValue];
  622. NSArray *qids = allQuestionArray[tag - 2];
  623. NSString *sub = @"1";
  624. if (tag > 4) {
  625. sub = @"4";
  626. }
  627. if ([defUser.car_type isEqualToString:@"2"]) {
  628. for (NSString *qid in qids) {
  629. NSString *pinStr = [NSString stringWithFormat:@"%@,%@;",qid,sub];
  630. if (tag == 2 || tag == 5) {//错题
  631. wrongString = [wrongString stringByAppendingString:pinStr];
  632. }
  633. if (tag == 3 || tag == 6) {//收藏
  634. favString = [favString stringByAppendingString:pinStr];
  635. }
  636. if (tag == 4 || tag == 7) {//排除
  637. pcString = [pcString stringByAppendingString:pinStr];
  638. }
  639. }
  640. } else {
  641. for (RQYDTQuestionModel *ydtQuestionModel in qids) {
  642. NSString *pinStr = [NSString stringWithFormat:@"%ld,%@;",ydtQuestionModel.ID,sub];
  643. if (tag == 2 || tag == 5) {//错题
  644. wrongString = [wrongString stringByAppendingString:pinStr];
  645. }
  646. if (tag == 3 || tag == 6) {//收藏
  647. favString = [favString stringByAppendingString:pinStr];
  648. }
  649. if (tag == 4 || tag == 7) {//排除
  650. pcString = [pcString stringByAppendingString:pinStr];
  651. }
  652. }
  653. }
  654. }
  655. if (wrongString.length == 0 && favString.length == 0 && pcString.length == 0) {
  656. ShowMsg(@"当前选择上传的题目数量为0");
  657. return;
  658. }
  659. NSArray<NSString *> *questionArray = @[wrongString,favString,pcString];
  660. [syncView setUserInteractionEnabled:NO];
  661. bgLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, (kSize.height - 80)/2.0, kSize.width - 60, 70)];
  662. bgLabel.backgroundColor = backGroundColor;
  663. [bgLabel setBoardWid:5 Color:contentTextColor];
  664. [bgLabel setText:@"上传中,请稍后..." Font:24 TextColor:kTitleColor Alignment:NSTextAlignmentCenter];
  665. [[UIApplication sharedApplication].keyWindow addSubview:bgLabel];
  666. [self saveBetchFavQuestionWithArray:questionArray];
  667. }
  668. - (void)saveBetchFavQuestionWithArray:(NSArray<NSString *> *)array {
  669. NSMutableArray *arr = [NSMutableArray array];
  670. [arr addPro:@"favArr" Value:array[1]];
  671. [arr addPro:@"wrongArr" Value:[array firstObject]];
  672. [arr addPro:@"pcArr" Value:[array lastObject]];
  673. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  674. [arr addPro:@"outId" Value:defUser.userStuId];
  675. [arr addPro:@"carType" Value:defUser.car_type];
  676. NSString* method = @"saveBetchFavQuestion";
  677. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  678. //NSLog(@"上传错题---->%@--->%@",arr,root);
  679. if (!root) {
  680. ShowMsg(@"上传失败,请重试");
  681. [self removebgLabel];
  682. return ;
  683. }
  684. if ([root[@"code"] isEqualToString:@"1"]) {
  685. ShowMsg(root[@"body"]);
  686. [self removebgLabel];
  687. return;
  688. }
  689. ShowMsg(root[@"body"]);
  690. [self removebgLabel];
  691. if (syncView) {
  692. [syncView removeFromSuperview];
  693. syncView = nil;
  694. }
  695. if ([defUser.car_type isEqualToString:@"2"]) {
  696. [DB_Que_Helper setGZPZ_EXAM_CYRYIsUpdateWithArray:selectedArray];
  697. } else {
  698. // [DB_Que_Helper setIsUpdateWithArray:selectedArray];
  699. [collectArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
  700. [RQ_YDT_USER_Question_Module collectQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectOne isUploadFlag:YES];
  701. }];
  702. [collectFourArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
  703. [RQ_YDT_USER_Question_Module collectQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectFour isUploadFlag:YES];
  704. }];
  705. [exceptArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
  706. [RQ_YDT_USER_Question_Module removeQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectOne isUploadFlag:YES];
  707. }];
  708. [exceptFourArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
  709. [RQ_YDT_USER_Question_Module removeQuestionWithID:ydtQuestionModel.ID carType:RQ_YDTQuestion_Module.carType subject:RQHomePageSubjectType_SubjectFour isUploadFlag:YES];
  710. }];
  711. [wrongArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
  712. [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];
  713. }];
  714. [wrongFourArray.rac_sequence.signal subscribeNext:^(RQYDTQuestionModel *ydtQuestionModel) {
  715. [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];
  716. }];
  717. }
  718. RQ_UPDATE_LOCALDATA_MANAGER.count = 600;
  719. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"题库错题、收藏、排除已上传成功" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  720. [alert show];
  721. }];
  722. }
  723. #pragma mark - tableView
  724. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  725. {
  726. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  727. switch (indexPath.row) {
  728. case 0:
  729. {
  730. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  731. } else {
  732. if (myDelegate.isLogin) {
  733. [self gotoStuDetaiVC];
  734. }else{
  735. [self userLoginAction];
  736. }
  737. }
  738. }
  739. break;
  740. case 1: //我的驾校
  741. {
  742. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  743. [self gotoChooseExLibVC];
  744. } else {
  745. if (myDelegate.isLogin) {
  746. [self gotoSchoolVC];
  747. }else{
  748. ShowMsg(@"请登录后再操作!");
  749. [self userLoginAction];
  750. }
  751. }
  752. }
  753. break;
  754. case 2: //我的教练
  755. if (myDelegate.isLogin) {
  756. if (!defUser.userDict[@"outId"]) {
  757. ShowMsg(@"查询不到您的教练");
  758. return;
  759. }
  760. if ([defUser.userDict[@"outId"] isEqualToString:@""]) {
  761. ShowMsg(@"查询不到您的教练");
  762. return;
  763. }
  764. [self gotoCoachDetailInfoVC];
  765. }else{
  766. ShowMsg(@"请登录后再操作!");
  767. [self userLoginAction];
  768. }
  769. break;
  770. case 3: //绑定账号
  771. if (myDelegate.isLogin) {
  772. if(defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0){
  773. NSString *IMEI = defUser.userDict[@"imei"];
  774. if (IMEI.length > 0) {
  775. if ([Tools getIDFAWithType:GetIDFAType_Default]) {
  776. if (![IMEI isEqualToString:[Tools getIDFAWithType:GetIDFAType_Default]]) {
  777. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"当前账号已经与其它手机绑定" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  778. [alert show];
  779. }else {
  780. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"账号与手机已绑定" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  781. [alert show];
  782. }
  783. }
  784. }else {
  785. // BindVC* vc = [[BindVC alloc] init];
  786. // [vc bindSuccessWithBlock:^{
  787. // [LoginViewController reLoginFromViewController:self finishBlock:nil];
  788. // }];
  789. // MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  790. // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  791. // nav.modalPresentationStyle = UIModalPresentationFullScreen;
  792. // [self.parentViewController presentViewController:nav animated:YES completion:^{
  793. // }];
  794. [self uploadBindStuImeiBlock:^(BOOL isSuccess) {
  795. if (isSuccess) {
  796. [LoginViewController reLoginFromViewController:self finishBlock:nil];
  797. }
  798. }];
  799. break;
  800. }
  801. }else{
  802. ThirdLoginBindYunGuanVC *vc = [[ThirdLoginBindYunGuanVC alloc] init];
  803. vc.skipType = 1;
  804. MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  805. nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  806. nav.modalPresentationStyle = UIModalPresentationFullScreen;
  807. [self.parentViewController presentViewController:nav animated:YES completion:nil];
  808. }
  809. }else{
  810. ShowMsg(@"请登录后再操作!");
  811. [self userLoginAction];
  812. }
  813. break;
  814. case 4: //我的题库
  815. [self gotoChooseExLibVC];
  816. break;
  817. case 5: //同步题库
  818. if (myDelegate.isLogin) {
  819. [self initSyncView];
  820. }else{
  821. ShowMsg(@"请登录后再操作!");
  822. [self userLoginAction];
  823. }
  824. break;
  825. case 6: //我的学时
  826. {
  827. if (myDelegate.isLogin) {
  828. if(defUser.userDict[@"outId"] && [defUser.userDict[@"outId"] length] > 0){
  829. TrainInfoVC *vc = [[TrainInfoVC alloc] init];
  830. vc.skipType = 1;
  831. MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  832. nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  833. nav.modalPresentationStyle = UIModalPresentationFullScreen;
  834. [self cw_pushViewController:vc];
  835. // [self.parentViewController presentViewController:nav animated:YES completion:nil];
  836. }else{
  837. ShowMsg(@"未绑定学员账号,无法进行此操作");
  838. }
  839. }else{
  840. ShowMsg(@"请登录后再操作!");
  841. [self userLoginAction];
  842. }
  843. }
  844. break;
  845. case 7: //培训记录
  846. if (myDelegate.isLogin) {
  847. if ([defUser.userDict[@"outId"] length] < 1) {
  848. ShowMsg(@"未绑定学员账号,无法进行此操作");
  849. return;
  850. }
  851. [self myRecoedAction];
  852. }else{
  853. ShowMsg(@"请登录后再操作!");
  854. [self userLoginAction];
  855. }
  856. break;
  857. case 8: //意见反馈
  858. if (myDelegate.isLogin) {
  859. [self suggestAction];
  860. }else{
  861. ShowMsg(@"请登录后再操作!");
  862. [self userLoginAction];
  863. }
  864. break;
  865. case 9: //客服-联系我们
  866. {
  867. if (!myDelegate.isLogin) {
  868. ShowMsg(@"请登录后再操作!");
  869. [self userLoginAction];
  870. break;
  871. }
  872. if (_isConnecting) {
  873. return;
  874. }
  875. _isConnecting = YES;
  876. [MBProgressHUD showLoadToView:self.view];
  877. // userId 只能使用 数字 字母(包括大小写) 下划线
  878. NSString *name = defUser.userDict[@"userName"];
  879. if ([defUser.userDict[@"userName"] length] < 1) {
  880. name = defUser.userDict[@"nickName"];
  881. }
  882. [QMConnect registerSDKWithAppKey:CUSTOMERSERVICE_APPKEY userName:[NSString stringWithFormat:@"%@[iOS学员]",name] userId:[NSString stringWithFormat:@"%@",defUser.userDict[@"id"]]];
  883. }
  884. break;
  885. // case 10: //给我们的评价
  886. // [self gotoEvaluate];
  887. break;
  888. case 10: //帮助
  889. [myDelegate setUrl:@"帮助;help"];
  890. [self gotoTrafficVC];
  891. break;
  892. case 11: //退出登录
  893. {
  894. UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"确定要退出登录吗" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
  895. alert.tag = 100;
  896. [alert show];
  897. break;
  898. }
  899. default:
  900. break;
  901. }
  902. }
  903. - (void)uploadBindStuImeiBlock:(void (^)(BOOL isSuccess))bindBlock {
  904. NSMutableArray *arr=[NSMutableArray array];
  905. [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
  906. [arr addPro:@"sfzhm" Value:defUser.sfzmhm];
  907. [arr addPro:@"tel" Value:defUser.userTel];
  908. if ([Tools getIDFAWithType:GetIDFAType_Default]) {
  909. [arr addPro:@"imei" Value:[Tools getIDFAWithType:GetIDFAType_Default]];
  910. }
  911. [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  912. NSString* method = @"bindImei";
  913. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  914. [MBProgressHUD hideHUDForView:self.view];
  915. if (!root) {
  916. ShowMsg(@"绑定失败,请重试");
  917. bindBlock(false);
  918. return;
  919. }
  920. if ([root[@"code"] isEqualToString:@"0"]) {
  921. showMsgByAlertWithSureBlock(self, @"绑定成功", ^{
  922. bindBlock(true);
  923. });
  924. }else{
  925. showMsgByAlert(self, root[@"msg"]);
  926. bindBlock(false);
  927. }
  928. }];
  929. }
  930. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  931. {
  932. return RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? titles.count : myDelegate.isLogin ? titles.count : titles.count-1;
  933. }
  934. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  935. switch (indexPath.row) {
  936. case 0:
  937. return RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? 80 : 110;
  938. break;
  939. default:
  940. return [CLCell cellHeight];
  941. break;
  942. }
  943. }
  944. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  945. return [UIView new];
  946. }
  947. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  948. {
  949. return .1;
  950. }
  951. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  952. {
  953. if (0 == indexPath.row) {
  954. return [self headCellWithTableView:tableView];
  955. }
  956. UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"clCell"];;
  957. if (!cell) {
  958. cell = [[CLCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"clCell"];
  959. }
  960. NSString* str;
  961. switch (indexPath.row)
  962. {
  963. case 1:
  964. {
  965. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  966. str = [queLibNameDict objectForKey:defUser.car_type];
  967. [cell.detailTextLabel setText:str];
  968. [cell.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
  969. } else {
  970. NSString *jxjcString = @"请选择驾校";
  971. if ([defUser.userDict[@"schoolName"] length] > 0) {
  972. jxjcString = defUser.userDict[@"schoolName"];
  973. }
  974. if ([defUser.userSchDict[@"shortName"] length] > 0) {
  975. jxjcString = defUser.userSchDict[@"shortName"];
  976. }
  977. [cell.detailTextLabel setText:jxjcString];
  978. [cell.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
  979. }
  980. }
  981. break;
  982. case 4:
  983. str = [queLibNameDict objectForKey:defUser.car_type];
  984. [cell.detailTextLabel setText:str];
  985. [cell.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
  986. break;
  987. default:
  988. //这里需要将detail设置为空 去重用
  989. [cell.detailTextLabel setText:@""];
  990. break;
  991. }
  992. [cell.textLabel setFont:[UIFont scaleSize:15]];
  993. cell.textLabel.textColor = kTitleColor;
  994. cell.textLabel.text = titles[indexPath.row];
  995. cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
  996. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  997. [cell.detailTextLabel setTextColor:defGreen];
  998. return cell;
  999. }
  1000. -(UITableViewCell* )headCellWithTableView:(UITableView*)tableView{
  1001. HeadCell* cell = [tableView dequeueReusableCellWithIdentifier:@"headCell"];;
  1002. if (!cell) {
  1003. cell = [[HeadCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"headCell"];
  1004. [cell createBtns];
  1005. UIButton* btn;
  1006. btn = cell.leftBtn;
  1007. [btn setTag:0];
  1008. [cell addSubview:btn];
  1009. [btn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  1010. btn = cell.rightBrn;
  1011. [btn setTag:1];
  1012. [cell addSubview:btn];
  1013. [btn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  1014. }
  1015. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  1016. cell.textLabel.text = @"驾考学员";
  1017. cell.detailTextLabel.text = @"欢迎您!";
  1018. cell.accessoryType = UITableViewCellAccessoryNone;
  1019. } else {
  1020. if (myDelegate.isLogin) {
  1021. NSString *nameString = defUser.userDict[@"userName"];
  1022. if (nameString.length < 1) {
  1023. nameString = defUser.userDict[@"nickName"];
  1024. }
  1025. if (nameString.length < 1) {
  1026. nameString = defUser.userDict[@"loginCode"];
  1027. }
  1028. cell.textLabel.text = nameString;
  1029. cell.detailTextLabel.text = @"欢迎您!";
  1030. } else {
  1031. cell.textLabel.text = titles[0];
  1032. cell.detailTextLabel.text = @"登录后可查看学习进度!";
  1033. }
  1034. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  1035. }
  1036. cell.detailTextLabel.textColor = defGreen;
  1037. cell.detailTextLabel.numberOfLines = 0;
  1038. cell.textLabel.textColor = kTitleColor;
  1039. NSString *path = defUser.userDict[@"photo"];
  1040. if ( path && ![path isEqualToString:@""] && [Util connectedToNetWork] && myDelegate.isLogin) {
  1041. if (path && ![path hasPrefix:@"http"]){
  1042. path = [imgPreFix stringByAppendingString:path];
  1043. }
  1044. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:images[0]]];
  1045. }else{
  1046. cell.imageView.image = [UIImage imageNamed:images[0]];
  1047. }
  1048. return cell;
  1049. }
  1050. #pragma mark 客服
  1051. - (void)registerSuccess:(NSNotification *)sender {
  1052. NSLog(@"注册成功");
  1053. if (_isPushed) {
  1054. [MBProgressHUD hideHUDForView:self.view];
  1055. _isConnecting = NO;
  1056. return;
  1057. }
  1058. [QMConnect sdkGetWebchatScheduleConfig:^(NSDictionary * _Nonnull scheduleDic) {
  1059. dispatch_async(dispatch_get_main_queue(), ^{
  1060. self.dictionary = scheduleDic;
  1061. if ([self.dictionary[@"scheduleEnable"] intValue] == 1) {
  1062. NSLog(@"日程管理");
  1063. [self starSchedule];
  1064. }else{
  1065. NSLog(@"技能组");
  1066. [self getPeers];
  1067. }
  1068. });
  1069. } failBlock:^{
  1070. }];
  1071. }
  1072. - (void)registerFailure:(NSNotification *)sender {
  1073. NSLog(@"注册失败::%@", sender.object);
  1074. self.isConnecting = NO;
  1075. [MBProgressHUD hideHUDForView:self.view];
  1076. }
  1077. #pragma mark - 技能组选择
  1078. - (void)getPeers {
  1079. [QMConnect sdkGetPeers:^(NSArray * _Nonnull peerArray) {
  1080. dispatch_async(dispatch_get_main_queue(), ^{
  1081. NSLog(@"%@", peerArray);
  1082. NSArray *peers = peerArray;
  1083. self.isConnecting = NO;
  1084. [MBProgressHUD hideHUDForView:self.view];
  1085. if (peers.count == 1 && peers.count != 0) {
  1086. [self showChatRoomViewController:[peers.firstObject objectForKey:@"id"] processType:@""];
  1087. }else {
  1088. [self showPeersWithAlert:peers messageStr:@"选择您咨询的类型或业务部门(对应技能组)"];
  1089. }
  1090. });
  1091. } failureBlock:^{
  1092. dispatch_async(dispatch_get_main_queue(), ^{
  1093. [MBProgressHUD hideHUDForView:self.view];
  1094. self.isConnecting = NO;
  1095. });
  1096. }];
  1097. }
  1098. #pragma mark - 日程管理
  1099. - (void)starSchedule {
  1100. self.isConnecting = NO;
  1101. [MBProgressHUD hideHUDForView:self.view];
  1102. if ([self.dictionary[@"scheduleId"] isEqual: @""] || [self.dictionary[@"processId"] isEqual: @""] || [self.dictionary objectForKey:@"entranceNode"] == nil || [self.dictionary objectForKey:@"leavemsgNodes"] == nil) {
  1103. [QMAlert showMessage:@"对不起,由于在线咨询配置错误,暂时无法进行咨询"];
  1104. }else{
  1105. NSDictionary *entranceNode = self.dictionary[@"entranceNode"];
  1106. NSArray *entrances = entranceNode[@"entrances"];
  1107. NSLog(@" 获取到日程节点数组 ===== %@", entrances);
  1108. // [self showPeersWithAlert: sdkEntrances];
  1109. if (entrances.count == 1 && entrances.count != 0) {
  1110. [self showChatRoomViewController:[entrances.firstObject objectForKey:@"processTo"] processType:[entrances.firstObject objectForKey:@"processType"]];
  1111. }else{
  1112. [self showPeersWithAlert:entrances messageStr:@"选择您咨询的日程管理类型"];
  1113. }
  1114. }
  1115. }
  1116. - (void)showPeersWithAlert: (NSArray *)peers messageStr: (NSString *)message {
  1117. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"选择您咨询的类型或业务部门(对应技能组)" preferredStyle:UIAlertControllerStyleAlert];
  1118. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1119. self.isConnecting = NO;
  1120. }];
  1121. [alertController addAction:cancelAction];
  1122. for (NSDictionary *index in peers) {
  1123. UIAlertAction *surelAction = [UIAlertAction actionWithTitle:[index objectForKey:@"name"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1124. if ([self.dictionary[@"scheduleEnable"] integerValue] == 1) {
  1125. [self showChatRoomViewController:[index objectForKey:@"processTo"] processType:[index objectForKey:@"processType"]];
  1126. }else{
  1127. [self showChatRoomViewController:[index objectForKey:@"id"] processType:@""];
  1128. }
  1129. }];
  1130. [alertController addAction:surelAction];
  1131. }
  1132. [self presentViewController:alertController animated:YES completion:nil];
  1133. }
  1134. #pragma mark - 跳转聊天界面
  1135. - (void)showChatRoomViewController:(NSString *)peerId processType:(NSString *)processType {
  1136. QMChatRoomViewController *chatRoomViewController = [[QMChatRoomViewController alloc] init];
  1137. chatRoomViewController.peerId = peerId;
  1138. chatRoomViewController.isPush = NO;
  1139. NSString *path = defUser.userDict[@"photo"];
  1140. if (!path) {
  1141. path = @"";
  1142. }
  1143. chatRoomViewController.avaterStr = path;
  1144. if ([self.dictionary[@"scheduleEnable"] intValue] == 1) {
  1145. chatRoomViewController.isOpenSchedule = true;
  1146. chatRoomViewController.scheduleId = self.dictionary[@"scheduleId"];
  1147. chatRoomViewController.processId = self.dictionary[@"processId"];
  1148. chatRoomViewController.currentNodeId = peerId;
  1149. chatRoomViewController.processType = processType;
  1150. }else{
  1151. chatRoomViewController.isOpenSchedule = false;
  1152. }
  1153. MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:chatRoomViewController];
  1154. [nav.view setBackgroundColor:[UIColor whiteColor]];
  1155. nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  1156. nav.navigationBar.translucent = NO;
  1157. nav.modalPresentationStyle = UIModalPresentationFullScreen;
  1158. // [self.parentViewController presentViewController:nav animated:YES completion:nil];
  1159. [self cw_presentViewController:nav];
  1160. }
  1161. - (NSMutableAttributedString *)setSpace:(CGFloat)line kern:(NSNumber *)kern font:(UIFont *)font text:(NSString *)text {
  1162. NSMutableParagraphStyle * paraStyle = [NSMutableParagraphStyle new];
  1163. paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
  1164. paraStyle.alignment = NSTextAlignmentCenter;
  1165. paraStyle.lineSpacing = line;
  1166. paraStyle.hyphenationFactor = 1.0;
  1167. paraStyle.firstLineHeadIndent = 0.0;
  1168. paraStyle.paragraphSpacingBefore = 0.0;
  1169. paraStyle.headIndent = 0;
  1170. paraStyle.tailIndent = 0;
  1171. NSDictionary *attributes = @{
  1172. NSFontAttributeName: font,
  1173. NSParagraphStyleAttributeName: paraStyle,
  1174. NSKernAttributeName: kern
  1175. };
  1176. NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:text attributes:attributes];
  1177. return attributeStr;
  1178. }
  1179. - (void)dealloc {
  1180. [[NSNotificationCenter defaultCenter] removeObserver:self name:CUSTOM_LOGIN_SUCCEED object:nil];
  1181. [[NSNotificationCenter defaultCenter] removeObserver:self name:CUSTOM_LOGIN_ERROR_USER object:nil];
  1182. }
  1183. - (void)cw_pushViewController:(UIViewController *)vc drewerHiddenDuration:(NSTimeInterval)duration {
  1184. CWLateralSlideAnimator *animator = (CWLateralSlideAnimator *)self.transitioningDelegate;
  1185. animator.configuration.HiddenAnimDuration = duration > 0 ? duration : animator.configuration.HiddenAnimDuration;
  1186. UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
  1187. RQBaseNavigationController *nav;
  1188. NSString *TransitionType = kCATransitionPush;
  1189. if ([rootVC isKindOfClass:[RQMainTabBarViewController class]]) {
  1190. RQMainTabBarViewController *mainTabBarViewController = (RQMainTabBarViewController *)rootVC;
  1191. NSInteger index = mainTabBarViewController.tabBarController.selectedIndex;
  1192. nav = mainTabBarViewController.tabBarController.childViewControllers[index];
  1193. }else if ([rootVC isKindOfClass:[RQBaseNavigationController class]]) {
  1194. if (animator.animationType == CWDrawerAnimationTypeDefault) TransitionType = kCATransitionFade;
  1195. nav = (RQBaseNavigationController *)rootVC;
  1196. }else {
  1197. NSLog(@"This no UINavigationController...");
  1198. return;
  1199. }
  1200. NSNumber *direction = objc_getAssociatedObject(self, &CWLateralSlideDirectionKey);
  1201. NSString *subType = direction.integerValue ? kCATransitionFromLeft : kCATransitionFromRight;
  1202. CATransition *transition = [CATransition animation];
  1203. transition.duration = 0.20f;
  1204. transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
  1205. transition.type = TransitionType;
  1206. transition.subtype = subType;
  1207. [nav.view.layer addAnimation:transition forKey:nil];
  1208. [self dismissViewControllerAnimated:YES completion:nil];
  1209. [nav pushViewController:vc animated:NO];
  1210. }
  1211. @end