RQHomePageViewController.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. //
  2. // RQHomePageViewController.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/21.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQHomePageViewController.h"
  9. #import "MapManager.h"
  10. #import "RQQRCodeViewController.h"
  11. #import "ScanVC.h"
  12. #import "ScanPageVC.h"
  13. #import "DistenceTooLongMapVC.h"
  14. @interface RQHomePageViewController () <JXCategoryViewDelegate, JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate, SDCycleScrollViewDelegate>
  15. /// viewModel
  16. @property (nonatomic, readonly, strong) RQHomePageViewModel *viewModel;
  17. @property (nonatomic, readwrite, strong) RQHomePageTitleView *homePageTitleView;
  18. @property (nonatomic, readwrite, strong) JXPagerView *pagerView;
  19. @property (nonatomic, readwrite, strong) JXCategoryTitleView *categoryView;
  20. @property (nonatomic, readwrite, copy) NSArray <NSString *> *titles;
  21. //投诉建议入口-可共用
  22. @property (nonatomic, readwrite, strong) NYFloatingSuggestViewModel *floatingSuggestViewModel;
  23. @property (nonatomic, readwrite, strong) NYFloatingSuggestView *floatingSuggestView;
  24. //集中式理论
  25. @property (nonatomic, readwrite, assign) BOOL isNeedTest;
  26. @property (nonatomic, readwrite, assign) BOOL isCloseAudio;
  27. @property (nonatomic, readwrite, assign) NSInteger maxTime;
  28. @property (nonatomic, readwrite, copy) NSString *scanType;
  29. @property (nonatomic, readwrite, copy) NSString *scanData;
  30. @property (nonatomic, readwrite, assign) CLLocationCoordinate2D myLocation;
  31. // 在头文件中定义一个属性来跟踪扫描状态
  32. @property (nonatomic, assign) BOOL isScanning;
  33. @end
  34. @implementation RQHomePageViewController
  35. @dynamic viewModel;
  36. #pragma mark - SystemMethod
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. /// 初始化
  40. [self rq_setup];
  41. // if (myDelegate.isLogin) {
  42. // //更新登录信息 如果是登录状态的时候
  43. // reLogin(self);
  44. // }
  45. }
  46. - (void)viewDidAppear:(BOOL)animated {
  47. [super viewDidAppear:animated];
  48. // if (RQ_COMMON_MANAGER.JSJP_APP_ICON_NEED_CHANGE&&
  49. // !RQ_COMMON_MANAGER.APP_SWITCH) {//非审核下
  50. // [[UIApplication sharedApplication] setAlternateIconName:@"AppIcon_NewRule" completionHandler:^(NSError * _Nullable error) {
  51. // if (error != nil) {
  52. // NSLog(@"set alternative icon error:%@", error.localizedDescription);
  53. // }
  54. // }];
  55. // } else {
  56. // [[UIApplication sharedApplication] setAlternateIconName:@"AppIcon_Old" completionHandler:^(NSError * _Nullable error) {
  57. // if (error != nil) {
  58. // NSLog(@"set alternative icon error:%@", error.localizedDescription);
  59. // }
  60. // }];
  61. // }
  62. }
  63. - (void)viewDidLayoutSubviews {
  64. [super viewDidLayoutSubviews];
  65. self.pagerView.frame = CGRectMake(0, (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT), RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT) - RQ_APPLICATION_TAB_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT);
  66. }
  67. - (void)dealloc{
  68. //移除指定的通知,不然会造成内存泄露
  69. [[NSNotificationCenter defaultCenter] removeObserver:self name:@"Tiku_Change" object:nil];
  70. }
  71. #pragma mark - PrivateMethods
  72. /// 初始化
  73. - (void)rq_setup {
  74. /// set up ...
  75. @weakify(self)
  76. [self.view addSubview:self.pagerView];
  77. [RACObserve(RQ_USER_MANAGER, currentUser) subscribeNext:^(RQUserModel *userModel) {
  78. @strongify(self)
  79. //头像
  80. CGFloat sBoader = (kNavBarHeight - 35)/2.0;
  81. UIButton *sideBtn = [[UIButton alloc] initWithFrame:CGRectMake(sBoader, kStatusHeight + sBoader, kNavBarHeight - sBoader*2, kNavBarHeight - sBoader*2)];
  82. [self.view addSubview:sideBtn];
  83. UIImageView *iv = [[UIImageView alloc] initWithFrame:sideBtn.bounds];
  84. [iv sd_setImageWithURL:[NSURL URLWithString:userModel.photo] placeholderImage:[UIImage imageNamed:@"头像"]];
  85. iv.contentMode = UIViewContentModeScaleAspectFill;
  86. [iv setBoardWid:1 Color:RQ_MAIN_COLOR CornerRadius:6];
  87. [iv setRound];
  88. [sideBtn addSubview:iv];
  89. [sideBtn addTarget:self action:@selector(showLeftViewAction) forControlEvents:UIControlEventTouchUpInside];
  90. UIBarButtonItem* bbi0 = [[UIBarButtonItem alloc] initWithCustomView:sideBtn];
  91. self.navigationItem.leftBarButtonItem = bbi0;
  92. }];
  93. if (myDelegate.isSyn) {
  94. myDelegate.isSyn = NO;
  95. if ([myDelegate.markQuestionTableData isKindOfClass:[NSMutableArray class]]) {
  96. if (myDelegate.markQuestionTableData.count == 0) {
  97. [DB_Que_Helper moveIsDoneToMarkQuestion];//移动已做题
  98. if (myDelegate.isLogin)//更新版本 先做一次同步
  99. {
  100. [self syncQuestion];
  101. }
  102. }
  103. }
  104. }
  105. //监听题库变化
  106. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationAction:) name:@"Tiku_Change" object:nil];
  107. // 注册手势驱动
  108. // __weak typeof(self)weakSelf = self;
  109. // [self cw_registerShowIntractiveWithEdgeGesture:YES transitionDirectionAutoBlock:^(CWDrawerTransitionDirection direction) {
  110. // if (direction == CWDrawerTransitionFromLeft) { // 左侧滑出
  111. // [weakSelf defaultAnimationFromLeft];
  112. // }
  113. // }];
  114. self.navigationItem.titleView = self.homePageTitleView;
  115. self.homePageTitleView.carTypeLabel.text = [RQ_YDTQuestion_Module getCarTypeCNNameWithCarType:RQ_YDTQuestion_Module.carType];
  116. if (RQ_COMMON_MANAGER.JSJP_APP_JSQ_ICON_OPEN) {//广告(福袋)-是否开启
  117. self.homePageTitleView.chad_layout_W.constant = 25;
  118. [self.homePageTitleView layoutIfNeeded];
  119. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  120. [NY_AD_MANAGER loadAdWithPosid:@"50164389" customView:self.homePageTitleView.chadView];
  121. });
  122. }
  123. [self.homePageTitleView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH / 3.f, RQ_APPLICATION_NAV_BAR_HEIGHT));
  125. }];
  126. //二维码扫描登录网页
  127. UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"erWeiMa.png"] originImageScaleToSize:CGSizeMake(22.5, 22.5)] style:UIBarButtonItemStyleDone target:self action:@selector(clickToScan)];
  128. item.tintColor = RQ_MAIN_COLOR;
  129. if (RQ_USER_MANAGER.currentUser.city && ![RQ_USER_MANAGER.currentUser.city isEqualToString:@""] && [RQ_USER_MANAGER.currentUser.city isEqualToString:@""]) {
  130. }
  131. [RACObserve(RQ_USER_MANAGER, currentUser) subscribeNext:^(RQUserModel *userModel) {
  132. @strongify(self)
  133. if ([RQ_USER_MANAGER.currentUser.isOpenScan boolValue]) {
  134. [self.navigationItem setRightBarButtonItem:item];
  135. } else {
  136. self.navigationItem.rightBarButtonItems = @[];
  137. }
  138. }];
  139. [[[[RQNotificationCenter rac_addObserverForName:RQCarTypeChangeNotification object:nil] takeUntil:self.rac_willDeallocSignal] deliverOnMainThread] subscribeNext:^(NSNotification * _Nullable x) {
  140. @strongify(self)
  141. self.pagerView.defaultSelectedIndex = 0;
  142. self.categoryView.defaultSelectedIndex = 0;
  143. [self.pagerView reloadData];
  144. [self.categoryView reloadData];
  145. self.pagerView.isListHorizontalScrollEnabled = ![RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"];
  146. self.homePageTitleView.carTypeLabel.text = [RQ_YDTQuestion_Module getCarTypeCNNameWithCarType:RQ_YDTQuestion_Module.carType];
  147. }];
  148. [[[[RACObserve(RQ_COMMON_MANAGER, APP_SWITCH) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  149. @strongify(self)
  150. // self.pagerView.defaultSelectedIndex = 0;
  151. // self.categoryView.defaultSelectedIndex = 0;
  152. [self.pagerView reloadData];
  153. [self.categoryView reloadData];
  154. }];
  155. //投诉建议
  156. [self addFloatingSuggestView];
  157. }
  158. //添加到主窗口
  159. - (void)addFloatingSuggestView {
  160. NSInteger SP_COMPLAINT_DQBH = 0;
  161. for (ParamsItem *item in RQ_USER_MANAGER.currentUser.params) {
  162. if ([item.KEY isEqualToString:@"SP_COMPLAINT_DQBH"]) {
  163. SP_COMPLAINT_DQBH = [item.VALUE integerValue];
  164. }
  165. }
  166. if(SP_COMPLAINT_DQBH>0&&(SP_COMPLAINT_DQBH == [RQ_USER_MANAGER.currentUser.city intValue])){
  167. [self.view addSubview:self.floatingSuggestView];
  168. [self.floatingSuggestView mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.right.mas_equalTo(self.view).offset(-20.f);
  170. make.bottom.mas_equalTo(self.view).offset(-60.f);
  171. make.width.mas_equalTo(116.f);
  172. make.height.mas_equalTo(89.f);
  173. }];
  174. [self.floatingSuggestView bindViewModel:self.floatingSuggestViewModel];//绑定RAC
  175. }
  176. }
  177. - (void)notificationAction:(NSNotification *)notification{
  178. self.pagerView.defaultSelectedIndex = 0;
  179. self.categoryView.defaultSelectedIndex = 0;
  180. [self.pagerView reloadData];
  181. [self.categoryView reloadData];
  182. self.pagerView.isListHorizontalScrollEnabled = ![RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"];
  183. if ([notification.userInfo[@"zhigezhengChanged"] isEqualToString:@"NO"]) {
  184. return;
  185. }
  186. }
  187. /**显示左边抽屉
  188. */
  189. - (void)showLeftViewAction {
  190. [self defaultAnimationFromLeft];
  191. }
  192. - (void)clickToScan {
  193. @weakify(self)
  194. if (RQ_USER_MANAGER.isShouldLogin) {
  195. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  196. @strongify(self)
  197. if (isSuccess) {
  198. if (activationModel.isShare) {
  199. if (activationModel.isActive == 1) {
  200. [self gotoPt];
  201. } else {
  202. [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
  203. }
  204. } else {
  205. [self gotoPt];
  206. }
  207. }
  208. }];
  209. }
  210. }
  211. - (void)gotoPt {
  212. @weakify(self)
  213. // 检查是否正在扫描,如果是,则直接返回
  214. if (self.isScanning) {
  215. return;
  216. }
  217. NSLog(@"点击了 扫码");
  218. // 设置扫描状态为正在进行
  219. self.isScanning = YES;
  220. [QMUITips showLoadingInView:DefaultTipsParentView];
  221. RQQRCodeViewController *vc = [[RQQRCodeViewController alloc] init];
  222. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  223. [vc initBlock:^(NSString * _Nonnull result, BOOL isSuccess) {
  224. if (isSuccess) {
  225. [RQ_PT_Object_Module uploadScanCodeVerifyWithQRCodeResultStr:result resultBlock:^(BOOL isSuccess) {
  226. }];
  227. } else {
  228. ShowMsg(result);
  229. }
  230. }];
  231. [LOCATION_MANAGER updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  232. @strongify(self)
  233. if (success) {
  234. if (RQ_USER_MANAGER.verifyLevel == 0) {
  235. [self presentViewController:vc animated:YES completion:^{
  236. [QMUITips hideAllTips];
  237. self.isScanning = NO;
  238. }];
  239. } else {
  240. if (bmkLocation.mockProbability <= RQ_USER_MANAGER.verifyLevel) {
  241. [self presentViewController:vc animated:YES completion:^{
  242. [QMUITips hideAllTips];
  243. self.isScanning = NO;
  244. }];
  245. } else {
  246. [RQ_SHARE_FUNCTION showAlertWithMessage:@"请勿篡改定位信息!" completion:^(NSUInteger selectedOtherButtonIndex) {
  247. [QMUITips hideAllTips];
  248. self.isScanning = NO;
  249. }];
  250. }
  251. }
  252. } else {
  253. [RQ_SHARE_FUNCTION showAlertWithMessage:@"定位失败!" completion:^(NSUInteger selectedOtherButtonIndex) {
  254. [QMUITips hideAllTips];
  255. self.isScanning = NO;
  256. }];
  257. }
  258. }];
  259. }
  260. - (void)getMyLocation {
  261. //定位功能
  262. [MBProgressHUD rq_showProgressHUD:@"正在获取当前位置..."];
  263. [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  264. [MBProgressHUD rq_hideHUD];
  265. if (success) {
  266. _myLocation = location.coordinate;
  267. [self studentQrcode];
  268. }
  269. }];
  270. }
  271. /** 扫描二维码调取接口 */
  272. - (void)studentQrcode {
  273. if (![Util connectedToNetWork]) {
  274. showMsgUnconnect();
  275. return;
  276. }
  277. if (_myLocation.longitude == 0.0) {
  278. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"位置获取失败,请重新扫描二维码!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  279. return;
  280. }
  281. NSMutableArray *arr=[NSMutableArray array];
  282. [arr addPro:@"studentOutid" Value:RQ_USER_MANAGER.currentUser.outId];
  283. [arr addPro:@"qrcode" Value:_scanData];
  284. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  285. [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",_myLocation.longitude]];
  286. [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",_myLocation.latitude]];
  287. [arr addPro:@"type" Value:_scanType];
  288. [arr addPro:@"telType" Value:@"ios"];
  289. NSString *method = @"studentQrcode";
  290. NSString *str = [_scanType isEqualToString: @"1"] ? @"签到中...":@"签退中...";
  291. [MBProgressHUD rq_showProgressHUD:str];
  292. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  293. [MBProgressHUD rq_hideHUD];
  294. if (!root) {
  295. ShowMsg(@"操作失败,请重试!");
  296. [Tools playAudioWithString:@"操作失败,请重试!"];
  297. return;
  298. }
  299. if ([root[@"code"] integerValue] == 0) {//代表操作成功
  300. if ([_scanType isEqualToString:@"1"] || [_scanType isEqualToString:@"3"]) {
  301. myDelegate.trainStateLabel.text = @"理论学习中...";
  302. }
  303. if ([_scanType isEqualToString:@"2"]) {
  304. myDelegate.trainStateLabel.text = @"";
  305. }
  306. if (_isNeedTest) {
  307. switch ([_scanType integerValue]) { //1、签到 2、签退 3、过程验证
  308. case 1://签到成功
  309. if (_maxTime > 0) {
  310. [self setNotificationWithFireTime:_maxTime];
  311. }
  312. break;
  313. case 2://签退
  314. if ([[[UIApplication sharedApplication] scheduledLocalNotifications] count] > 0) {
  315. [[UIApplication sharedApplication] cancelAllLocalNotifications];
  316. }
  317. break;
  318. case 3://验证成功
  319. if (_maxTime > 0) {
  320. [self setNotificationWithFireTime:_maxTime];
  321. }
  322. break;
  323. default:
  324. break;
  325. }
  326. }
  327. }
  328. if ([root[@"code"] integerValue] == 2) {//距离理论教室位置较远
  329. NSString *str = root[@"msg"];
  330. if (str.length < 1) {
  331. return;
  332. }
  333. NSArray *mapArray = [str componentsSeparatedByString:@";"];
  334. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:[mapArray lastObject] preferredStyle:UIAlertControllerStyleAlert];
  335. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
  336. [alert addAction:[UIAlertAction actionWithTitle:@"查看位置详情" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  337. //进入地图页面 传入两个点 一个距离 lng lat len
  338. if (mapArray.count > 3) {
  339. // lng = 123.467129,
  340. // lat = 41.813997
  341. //122.769684;41.515881;66822;您当前距离理论教室位置66822米,请到理论教室扫码!
  342. DistenceTooLongMapVC *mapVC = [[DistenceTooLongMapVC alloc] init];
  343. mapVC.lat1 = _myLocation.latitude;
  344. mapVC.lng1 = _myLocation.longitude;
  345. mapVC.lat2 = [mapArray[1] floatValue];
  346. mapVC.lng2 = [mapArray[0] floatValue];
  347. mapVC.distence = mapArray[2];
  348. mapVC.skipMspBlock = ^{
  349. _myLocation.longitude = 0.0;
  350. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"位置已重置,请重新扫描二维码!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  351. };
  352. [self navPushHideTabbarToVC:mapVC];
  353. }
  354. }]];
  355. [self presentViewController:alert animated:true completion:nil];
  356. return;
  357. }
  358. [Tools playAudioWithString:root[@"msg"]];
  359. ShowMsg(root[@"msg"]);
  360. }];
  361. }
  362. //语音播报或者推送
  363. - (void)setNotificationWithFireTime:(NSInteger)fireTime {
  364. //移除旧的通知
  365. if ([[[UIApplication sharedApplication] scheduledLocalNotifications] count] > 0) {
  366. [[UIApplication sharedApplication] cancelAllLocalNotifications];
  367. }
  368. //定义本地通知对象
  369. UILocalNotification *notification = [[UILocalNotification alloc]init];
  370. //设置调用时间
  371. notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:fireTime];
  372. //设置通知属性
  373. notification.alertBody = @"极速驾培提醒您"; //通知主体
  374. notification.applicationIconBadgeNumber = 1;//应用程序图标右上角显示的消息数
  375. notification.alertAction = @"打开应用"; //待机界面的滑动动作提示
  376. notification.soundName = @"TrainTest.mp3";//收到通知时播放的声音,默认消息声音
  377. // 通知参数
  378. NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:@"nothing",@"ShiCaoPeriodVC_reTakePhoto", nil];
  379. notification.userInfo = userDict;
  380. //调用通知
  381. [[UIApplication sharedApplication] scheduleLocalNotification:notification];
  382. }
  383. //更新第一次进入同步数据
  384. - (void)syncQuestion {
  385. if (![Util connectedToNetWork]) {
  386. return;
  387. }
  388. [self getMyQuestionType:@"" Subject:@""];
  389. }
  390. - (void)getMyQuestionType:(NSString*)type Subject:(NSString*)subject {
  391. NSMutableArray *arr = [NSMutableArray array];
  392. [arr addPro:@"user" Value:RQ_USER_MANAGER.currentUser._id];
  393. [arr addPro:@"type" Value:type];
  394. [arr addPro:@"subject" Value:subject];
  395. [arr addPro:@"carType" Value:RQ_YDTQuestion_Module.car_type];
  396. [arr addPro:@"isPage" Value:@"0"];
  397. [arr addPro:@"pageSize" Value:@"0"];
  398. [arr addPro:@"currentPage" Value:@"0"];
  399. NSString* method = @"getMyQuestionFavs";
  400. [MBProgressHUD rq_showProgressHUD:@"收藏、错题同步中,请稍后..."];
  401. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  402. //NSLog(@"同步错题收藏---->%@--->%@",arr,root);
  403. if (!root || [root[@"code"] integerValue] == 1) {
  404. [MBProgressHUD rq_hideHUD];
  405. ShowMsg(@"题库错题、收藏、排除同步失败,请在侧栏手动同步");
  406. return;
  407. }
  408. NSArray *body = [root objectForKey:@"body"];
  409. if (body.count > 0) {
  410. if ([DB_Que_Helper deleteAllMarkQuestion]) {
  411. [DB_Que_Helper setMarkQuestionWithArray:body];
  412. }
  413. }
  414. [MBProgressHUD rq_hideHUD];
  415. [MBProgressHUD rq_showTips:@"题库错题、收藏、排除已同步完毕"];
  416. }];
  417. }
  418. // 仿QQ从左侧划出
  419. - (void)defaultAnimationFromLeft {
  420. if (RQ_USER_MANAGER.isShouldLogin) {
  421. [RQ_APPDELEGATE.services pushViewModel:[[RQSettingViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil] animated:YES];
  422. }
  423. }
  424. #pragma mark - JXPagerViewDelegate
  425. - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
  426. return [UIView new];
  427. }
  428. - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
  429. return 0.f;
  430. }
  431. - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  432. return [RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"]? 0.f : 49.f;
  433. }
  434. - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  435. return self.categoryView;
  436. }
  437. - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
  438. //和categoryView的item数量一致
  439. return self.categoryView.titles.count;
  440. }
  441. - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
  442. myDelegate.subject = [NSString stringWithFormat:@"%d",(int)index + 1];
  443. NSInteger myIndex = index;
  444. RQ_YDTQuestion_Module.subject = myIndex;
  445. RQ_SHARE_FUNCTION.myErorNum = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count;
  446. RQHomePageSubjectOneOrFourViewModel *homePageSubjectFourViewModel = [[RQHomePageSubjectOneOrFourViewModel alloc] initWithServices:self.viewModel.services params:@{RQHomePageCarTypeKey : @(RQHomePageCarType_Car), RQHomePageSubjectTypeKey : @(myIndex)}];
  447. RQHomePageSubjectOneOrFourViewController *homePageSubjectFourViewController = [[RQHomePageSubjectOneOrFourViewController alloc] initWithViewModel:homePageSubjectFourViewModel];
  448. return homePageSubjectFourViewController;
  449. }
  450. #pragma mark - JXCategoryViewDelegate
  451. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  452. RQ_YDTQuestion_Module.subject = index;
  453. RQ_SHARE_FUNCTION.myErorNum = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Wrong].count;
  454. myDelegate.subject = [NSString stringWithFormat:@"%d",(int)index + 1];
  455. self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
  456. }
  457. - (void)categoryView:(JXCategoryBaseView *)categoryView didClickSelectedItemAtIndex:(NSInteger)index {
  458. }
  459. - (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
  460. }
  461. - (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio {
  462. // if (RQ_YDTQuestion_Module.subject == leftIndex) {
  463. // /// 向左滑 向右滚动
  464. // if (1.f - ratio > 0.7) {
  465. // RQ_YDTQuestion_Module.subject = rightIndex;
  466. // }
  467. // } else if (RQ_YDTQuestion_Module.subject == rightIndex) {
  468. // /// 向右滑 向左滚动
  469. // if (1.f - ratio > 0.3) {
  470. // RQ_YDTQuestion_Module.subject = leftIndex;
  471. // }
  472. // }
  473. }
  474. #pragma mark - JXPagerMainTableViewGestureDelegate
  475. - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  476. if ([self checkIsNestContentScrollView:(UIScrollView *)gestureRecognizer.view] || [self checkIsNestContentScrollView:(UIScrollView *)otherGestureRecognizer.view]) {
  477. //如果交互的是嵌套的contentScrollView,证明在左右滑动,就不允许同时响应
  478. return NO;
  479. }
  480. return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
  481. }
  482. - (BOOL)checkIsNestContentScrollView:(UIScrollView *)scrollView {
  483. for (RQHomeSubPageViewController *list in self.pagerView.validListDict.allValues) {
  484. if (list.contentScrollView == scrollView) {
  485. return YES;
  486. }
  487. }
  488. return NO;
  489. }
  490. #pragma mark - SDCycleScrollViewDelegate
  491. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
  492. }
  493. #pragma mark - LazyLoad
  494. - (JXPagerView *)pagerView {
  495. if (!_pagerView) {
  496. _pagerView = [[JXPagerView alloc] initWithDelegate:self];
  497. _pagerView.mainTableView.gestureDelegate = self;
  498. _pagerView.defaultSelectedIndex = 0;
  499. _pagerView.mainTableView.bounces = NO;
  500. _pagerView.isListHorizontalScrollEnabled = ![RQ_YDTQuestion_Module.isZhiGeZheng isEqualToString:@"YES"];
  501. }
  502. return _pagerView;
  503. }
  504. - (JXCategoryTitleView *)categoryView {
  505. if (!_categoryView) {
  506. _categoryView = [[JXCategoryTitleView alloc] init];
  507. _categoryView.titles = self.titles;
  508. _categoryView.backgroundColor = [UIColor whiteColor];
  509. _categoryView.titleSelectedColor = RQ_MAIN_TEXT_COLOR_1;
  510. _categoryView.titleColor = RQ_MAIN_TEXT_COLOR_2;
  511. _categoryView.titleFont = RQRegularFont(17);
  512. _categoryView.titleSelectedFont = RQSemiboldFont(22);
  513. _categoryView.titleColorGradientEnabled = YES;
  514. _categoryView.titleLabelZoomEnabled = YES;
  515. _categoryView.contentScrollViewClickTransitionAnimationEnabled = YES;
  516. _categoryView.titleLabelZoomSelectedVerticalOffset = 0.0f;
  517. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  518. lineView.indicatorColor = RQ_MAIN_COLOR;
  519. lineView.indicatorHeight = 4;
  520. lineView.verticalMargin = 0;
  521. _categoryView.indicators = @[lineView];
  522. _categoryView.defaultSelectedIndex = 0;
  523. _categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
  524. _categoryView.delegate = self;
  525. }
  526. return _categoryView;
  527. }
  528. - (NSArray<NSString *> *)titles {
  529. return @[@"科一", @"科二", @"科三", @"科四"];
  530. }
  531. - (RQHomePageTitleView *)homePageTitleView {
  532. if (!_homePageTitleView) {
  533. _homePageTitleView = [RQHomePageTitleView homePageTitleViewView];
  534. _homePageTitleView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH / 3.f, RQ_APPLICATION_NAV_BAR_HEIGHT);
  535. }
  536. return _homePageTitleView;
  537. }
  538. - (NYFloatingSuggestViewModel *)floatingSuggestViewModel {
  539. if(!_floatingSuggestViewModel){
  540. _floatingSuggestViewModel = [[NYFloatingSuggestViewModel alloc] init];
  541. }
  542. return _floatingSuggestViewModel;
  543. }
  544. - (NYFloatingSuggestView *)floatingSuggestView {
  545. if (!_floatingSuggestView) {
  546. _floatingSuggestView = [NYFloatingSuggestView floatingSuggestView];
  547. }
  548. return _floatingSuggestView;
  549. }
  550. @end