MineViewController.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. //
  2. // MineViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/17.
  6. //
  7. #import "MineViewController.h"
  8. #import "MineNavView.h"
  9. #import "SettingViewController.h"
  10. #import "KSBaseWKWebViewController.h"
  11. #import "NetworkingCheckController.h"
  12. #import "DeviceCheckView.h"
  13. #import "UserInfoManager.h"
  14. #import "TeacherInfo.h"
  15. #import "VideoCourseViewController.h"
  16. #import "LiveListViewController.h"
  17. #import "MinePageViewController.h"
  18. #import "MyLiveCourseViewController.h"
  19. #import "MyStyleViewController.h"
  20. #import "MyBankCardViewController.h"
  21. #import "MyCourseViewController.h"
  22. #import "UserSettingViewController.h"
  23. #import "FeedbackViewController.h"
  24. #import "KSScanViewController.h"
  25. #import "KSPremissionAlert.h"
  26. #import "RecordCheckManager.h"
  27. #import "MyIncomeViewController.h"
  28. #import "MineHeadView.h"
  29. #import "MineFunctionView.h"
  30. #import "MineTeachToolView.h"
  31. #import "MineBottomView.h"
  32. #import "MyMusicViewController.h"
  33. #import "HomeworkListViewController.h"
  34. #import "EvaluateCourseListViewController.h"
  35. #import "BadgeIntroduceView.h"
  36. @interface MineViewController ()<UIScrollViewDelegate>
  37. @property (nonatomic, strong) MineNavView *navView;
  38. @property (nonatomic, strong) MineHeadView *headView;
  39. @property (nonatomic, strong) MineFunctionView *normalFunctionView;
  40. @property (nonatomic, strong) MineTeachToolView *teachToolView;
  41. @property (nonatomic, strong) MineBottomView *bottomView;
  42. @property (nonatomic, strong) DeviceCheckView *checkView;
  43. @property (nonatomic, strong) TeacherInfo *mineInfo;
  44. @property (nonatomic, strong) BadgeIntroduceView *intruduceAlert;
  45. @end
  46. @implementation MineViewController
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. // Do any additional setup after loading the view.
  50. self.ks_prefersNavigationBarHidden = YES;
  51. [self configUI];
  52. }
  53. - (void)viewWillAppear:(BOOL)animated {
  54. [super viewWillAppear:animated];
  55. if ([self checkIsLoginToLoginView:YES]) {
  56. [self requsetUserMessage];
  57. [self requestUserMemo];
  58. [self queryAmountDetail];
  59. }
  60. }
  61. - (void)queryAmountDetail {
  62. [KSNetworkingManager teacherAccountDetail:KS_GET success:^(NSDictionary * _Nonnull dic) {
  63. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  64. double amount = [[dic dictionaryValueForKey:@"data"] doubleValueForKey:@"amountShare"];
  65. [self evaluateAmount:amount];
  66. }
  67. else {
  68. [self MBPShow:MESSAGEKEY];
  69. }
  70. } faliure:^(NSError * _Nonnull error) {
  71. }];
  72. }
  73. - (void)evaluateAmount:(double)amount {
  74. NSString *valueString = [NSString formatMoneyDoubleNum:amount];
  75. NSString *amountString = [NSString stringWithFormat:@"累计收益%@元",valueString];
  76. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:amountString attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:HexRGB(0x999999)}];
  77. [attr addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13.0f weight:UIFontWeightMedium], NSForegroundColorAttributeName:HexRGB(0xff4e19)} range:[amountString rangeOfString:valueString]];
  78. self.bottomView.shareAmountLabel.attributedText = attr;
  79. }
  80. - (void)requestUserMemo {
  81. [[UserInfoManager shareInstance] requsetconfigCallback:^(BOOL success) {
  82. [self refreshBodyView:success];
  83. }];
  84. }
  85. - (void)refreshBodyView:(BOOL)isMember {
  86. self.headView.isMember = isMember;
  87. CGFloat height = [self.headView getViewHeight];
  88. [self.headView mas_updateConstraints:^(MASConstraintMaker *make) {
  89. make.height.mas_equalTo(height);
  90. }];
  91. self.normalFunctionView.isMember = isMember;
  92. [self.normalFunctionView configView];
  93. CGFloat functionHeight = [self.normalFunctionView getViewHeight];
  94. [self.normalFunctionView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.top.mas_equalTo(self.headView.mas_bottom).offset(12);
  96. make.left.right.mas_equalTo(self.view);
  97. make.height.mas_equalTo(functionHeight);
  98. }];
  99. self.teachToolView.isMember = isMember;
  100. [self.teachToolView configView];
  101. CGFloat toolViewHeight = [self.teachToolView getViewHeight];
  102. [self.teachToolView mas_updateConstraints:^(MASConstraintMaker *make) {
  103. make.height.mas_equalTo(toolViewHeight);
  104. }];
  105. self.bottomView.isMember = isMember;
  106. CGFloat bottomViewHeight = [self.bottomView getViewHeight];
  107. [self.bottomView mas_updateConstraints:^(MASConstraintMaker *make) {
  108. make.height.mas_equalTo(bottomViewHeight);
  109. }];
  110. }
  111. - (void)requsetUserMessage {
  112. [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  113. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  114. self.mineInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  115. NSString *rongToken = UserDefault(RongTokenKey);
  116. if ([NSString isEmptyString:rongToken]) {
  117. [USER_MANAGER queryUserInfoConnectRongCloud:YES];
  118. }
  119. [self refreshView];
  120. }
  121. else {
  122. [self MBPShow:MESSAGEKEY];
  123. }
  124. } faliure:^(NSError * _Nonnull error) {
  125. }];
  126. }
  127. - (void)refreshView {
  128. [self.headView configMessage:self.mineInfo];
  129. if ([NSString isEmptyString:self.mineInfo.username]) {
  130. self.navView.headTitle.text = [NSString stringWithFormat:@"游客%@",self.mineInfo.userId];;
  131. }
  132. else {
  133. self.navView.headTitle.text = self.mineInfo.username;
  134. }
  135. }
  136. - (void)configUI {
  137. self.scrollView.delegate = self;
  138. [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  139. make.left.right.mas_equalTo(self.view);
  140. make.top.mas_equalTo(self.view.mas_top);
  141. make.bottom.mas_equalTo(self.view.mas_bottom);
  142. }];
  143. UIImage *bgImage = [UIImage imageNamed:@"mine_header"];
  144. UIImageView *imageView = [[UIImageView alloc] initWithImage:bgImage];
  145. imageView.frame = CGRectMake(KPortraitWidth - bgImage.size.width, 0, bgImage.size.width, bgImage.size.height);
  146. [self.view addSubview:imageView];
  147. [self.view addSubview:self.navView];
  148. [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.width.mas_equalTo(KPortraitWidth);
  150. make.right.top.mas_equalTo(self.view);
  151. make.height.mas_equalTo(kNaviBarHeight);
  152. }];
  153. [self.view bringSubviewToFront:self.scrollView];
  154. [self.view bringSubviewToFront:self.navView];
  155. [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  156. make.top.mas_equalTo(self.view.mas_top);
  157. make.left.right.mas_equalTo(self.view);
  158. make.bottom.mas_equalTo(self.view.mas_bottom);
  159. }];
  160. self.scrollView.backgroundColor = [UIColor clearColor];
  161. UIView *headView = [[UIView alloc] init];
  162. headView.backgroundColor = [UIColor clearColor];
  163. [self.scrollView addSubview:headView];
  164. [headView mas_makeConstraints:^(MASConstraintMaker *make) {
  165. make.top.mas_equalTo(self.scrollView.mas_top);
  166. make.left.right.mas_equalTo(self.view);
  167. make.height.mas_equalTo(kNaviBarHeight);
  168. }];
  169. [self.scrollView addSubview:self.headView];
  170. CGFloat headHeight = [self.headView getViewHeight];
  171. [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.top.mas_equalTo(headView.mas_bottom);
  173. make.left.right.mas_equalTo(self.view);
  174. make.height.mas_equalTo(headHeight);
  175. }];
  176. [self.scrollView addSubview:self.normalFunctionView];
  177. CGFloat functionHeight = [self.normalFunctionView getViewHeight];
  178. [self.normalFunctionView mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.top.mas_equalTo(self.headView.mas_bottom).offset(12);
  180. make.left.right.mas_equalTo(self.view);
  181. make.height.mas_equalTo(functionHeight);
  182. }];
  183. [self.scrollView addSubview:self.teachToolView];
  184. CGFloat toolViewHeight = [self.teachToolView getViewHeight];
  185. [self.teachToolView mas_makeConstraints:^(MASConstraintMaker *make) {
  186. make.top.mas_equalTo(self.normalFunctionView.mas_bottom);
  187. make.left.right.mas_equalTo(self.view);
  188. make.height.mas_equalTo(toolViewHeight);
  189. }];
  190. [self.scrollView addSubview:self.bottomView];
  191. CGFloat bottomHeight = [self.bottomView getViewHeight];
  192. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  193. make.top.mas_equalTo(self.teachToolView.mas_bottom);
  194. make.left.right.mas_equalTo(self.view);
  195. make.height.mas_equalTo(bottomHeight);
  196. make.bottom.mas_equalTo(self.scrollView.mas_bottom);
  197. }];
  198. }
  199. - (void)operationAction:(MINEVIEWTYPE)type {
  200. switch (type) {
  201. case MINEVIEWTYPE_AUTH: // 达人认证
  202. {
  203. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  204. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  205. [self.navigationController pushViewController:webCtrl animated:YES];
  206. }
  207. break;
  208. case MINEVIEWTYPE_HOMEPAGE: // 我的主页
  209. {
  210. if (![self.mineInfo.entryStatus isEqualToString:@"PASS"]) { // 跳转达人认证
  211. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  212. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  213. [self.navigationController pushViewController:webCtrl animated:YES];
  214. }
  215. else {
  216. MinePageViewController *pageCtrl = [[MinePageViewController alloc] init];
  217. [self.navigationController pushViewController:pageCtrl animated:YES];
  218. }
  219. }
  220. break;
  221. case MINEVIEWTYPE_INCOME:
  222. {
  223. MyIncomeViewController *incomeCtrl = [[MyIncomeViewController alloc] init];
  224. [self.navigationController pushViewController:incomeCtrl animated:YES];
  225. }
  226. break;
  227. case MINEVIEWTYPE_MIEN: // 个人风采
  228. {
  229. if (![self.mineInfo.entryStatus isEqualToString:@"PASS"]) { // 跳转达人认证
  230. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  231. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  232. [self.navigationController pushViewController:webCtrl animated:YES];
  233. }
  234. else { // 风采
  235. MyStyleViewController *styleCtrl = [[MyStyleViewController alloc] init];
  236. [self.navigationController pushViewController:styleCtrl animated:YES];
  237. }
  238. }
  239. break;
  240. case MINEVIEWTYPE_STARTBOARDCAST: // 开启直播
  241. {
  242. if ([self.mineInfo.liveFlag isEqualToString:@"1"]) {
  243. LiveListViewController *ctrl = [[LiveListViewController alloc] init];
  244. [self.navigationController pushViewController:ctrl animated:YES];
  245. }
  246. else { // 开通直播审核
  247. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  248. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/openLive"];
  249. [self.navigationController pushViewController:webCtrl animated:YES];
  250. }
  251. }
  252. break;
  253. case MINEVIEWTYPE_ORDER: // 商品订单
  254. {
  255. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  256. ctrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST,@"/#/goodsOrder"];
  257. [self.navigationController pushViewController:ctrl animated:YES];
  258. }
  259. break;
  260. case MINEVIEWTYPE_ACCOMPANY: // 陪练课设置
  261. {
  262. if (![self.mineInfo.entryStatus isEqualToString:@"PASS"]) { // 跳转达人认证
  263. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  264. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  265. [self.navigationController pushViewController:webCtrl animated:YES];
  266. }
  267. else { // 设置页面
  268. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  269. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/practiceSetting"];
  270. [self.navigationController pushViewController:webCtrl animated:YES];
  271. }
  272. }
  273. break;
  274. case MINEVIEWTYPE_BOARDCASTCOURSE: // 直播课程
  275. {
  276. MyLiveCourseViewController *ctrl = [[MyLiveCourseViewController alloc] init];
  277. [self.navigationController pushViewController:ctrl animated:YES];
  278. }
  279. break;
  280. case MINEVIEWTYPE_VIDEOCOURSE: // 视频课
  281. {
  282. VideoCourseViewController *ctrl = [[VideoCourseViewController alloc] init];
  283. [self.navigationController pushViewController:ctrl animated:YES];
  284. }
  285. break;
  286. case MINEVIEWTYPE_EXTENDPLAN: // 推广计划
  287. {
  288. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  289. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/extendPlan"];
  290. [self.navigationController pushViewController:webCtrl animated:YES];
  291. }
  292. break;
  293. case MINEVIEWTYPE_CARD: // 我的银行卡
  294. {
  295. MyBankCardViewController *ctrl = [[MyBankCardViewController alloc] init];
  296. [self.navigationController pushViewController:ctrl animated:YES];
  297. }
  298. break;
  299. case MINEVIEWTYPE_NETWORKING: // 网络检测
  300. {
  301. NetworkingCheckController *checkVC = [[NetworkingCheckController alloc] init];
  302. [self.navigationController pushViewController:checkVC animated:YES];
  303. }
  304. break;
  305. case MINEVIEWTYPE_DEVICE: // 设备检测
  306. {
  307. [self.checkView showAlert];
  308. }
  309. break;
  310. case MINEVIEWTYPE_HELP: // 帮助
  311. {
  312. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  313. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/helpCenter"];
  314. [self.navigationController pushViewController:webCtrl animated:YES];
  315. }
  316. break;
  317. case MINEVIEWTYPE_FANS: // 我的粉丝
  318. {
  319. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  320. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/myFans"];
  321. [self.navigationController pushViewController:webCtrl animated:YES];
  322. }
  323. break;
  324. case MINEVIEWTYPE_FINISHCOURSE: // 我的课程
  325. {
  326. MyCourseViewController *ctrl = [[MyCourseViewController alloc] init];
  327. [self.navigationController pushViewController:ctrl animated:YES];
  328. }
  329. break;
  330. case MINEVIEWTYPE_UNFINISHCOURSE: // 我的课程
  331. {
  332. MyCourseViewController *ctrl = [[MyCourseViewController alloc] init];
  333. [self.navigationController pushViewController:ctrl animated:YES];
  334. }
  335. break;
  336. case MINEVIEWTYPE_USERSETTING: // 用户设置
  337. {
  338. UserSettingViewController *ctrl = [[UserSettingViewController alloc] init];
  339. [self.navigationController pushViewController:ctrl animated:YES];
  340. }
  341. break;
  342. case MINEVIEWTYPE_FEEDBACK: // 反馈
  343. {
  344. FeedbackViewController *ctrl = [[FeedbackViewController alloc] init];
  345. [self.navigationController pushViewController:ctrl animated:YES];
  346. }
  347. break;
  348. case MINEVIEWTYPE_MEMERCENTER:
  349. {
  350. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  351. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/memberCenter"];
  352. [self.navigationController pushViewController:webCtrl animated:YES];
  353. }
  354. break;
  355. case MINEVIEWTYPE_TRADERECORD:
  356. {
  357. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  358. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/rechargeRecord"];
  359. [self.navigationController pushViewController:webCtrl animated:YES];
  360. }
  361. break;
  362. case MINEVIEWTYPE_MUSIC: // 我的曲谱
  363. {
  364. MyMusicViewController *musicCtrl = [[MyMusicViewController alloc] init];
  365. [self.navigationController pushViewController:musicCtrl animated:YES];
  366. }
  367. break;
  368. case MINEVIEWTYPE_MUSICROOM: // 云酷琴房
  369. {
  370. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  371. ctrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST,@"/#/pianoRoom"];
  372. [self.navigationController pushViewController:ctrl animated:YES];
  373. }
  374. break;
  375. case MINEVIEWTYPE_HOMEWORK: // 作业
  376. {
  377. HomeworkListViewController *ctrl = [[HomeworkListViewController alloc] init];
  378. [self.navigationController pushViewController:ctrl animated:YES];
  379. }
  380. break;
  381. case MINEVIEWTYPE_EVALUATE: // 评价
  382. {
  383. EvaluateCourseListViewController *ctrl = [[EvaluateCourseListViewController alloc] init];
  384. [self.navigationController pushViewController:ctrl animated:YES];
  385. }
  386. break;
  387. case MINEVIEWTYPE_SHOWDESC: // 介绍弹窗
  388. {
  389. [self showDescAlert];
  390. }
  391. break;
  392. case MINEVIEWTYPE_TICKET:
  393. {
  394. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  395. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/coupons"];
  396. [self.navigationController pushViewController:webCtrl animated:YES];
  397. }
  398. break;
  399. default:
  400. break;
  401. }
  402. }
  403. - (BadgeIntroduceView *)intruduceAlert {
  404. if (!_intruduceAlert) {
  405. _intruduceAlert = [BadgeIntroduceView shareInstance];
  406. _intruduceAlert.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
  407. }
  408. return _intruduceAlert;
  409. }
  410. - (void)showDescAlert {
  411. [self.intruduceAlert showAlertInView:[NSObject getKeyWindow]];
  412. }
  413. #pragma mark --- lazying
  414. - (MineNavView *)navView {
  415. if (!_navView) {
  416. _navView = [MineNavView shareInstance];
  417. MJWeakSelf;
  418. [_navView mineNavAction:^(MINENAVATYPE actionType) {
  419. if (actionType == MINENAVATYPE_SETTING) {
  420. [weakSelf settingAction];
  421. }
  422. else {
  423. [weakSelf scanAction];
  424. }
  425. }];
  426. }
  427. return _navView;
  428. }
  429. - (void)scanAction {
  430. // 判断是否有权限
  431. PREMISSIONTYPE albumEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
  432. if (albumEnable == PREMISSIONTYPE_YES) { // 如果有权限
  433. KSScanViewController *ctrl = [[KSScanViewController alloc] init];
  434. [self.navigationController pushViewController:ctrl animated:YES];
  435. }
  436. else {
  437. if (albumEnable == PREMISSIONTYPE_NO) {
  438. [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
  439. }
  440. }
  441. }
  442. - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
  443. [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
  444. } confirm:^{
  445. [self openSettingView];
  446. }];
  447. }
  448. - (void)openSettingView {
  449. if (@available(iOS 10, *)) {
  450. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  451. } else {
  452. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  453. }
  454. }
  455. - (DeviceCheckView *)checkView {
  456. if (!_checkView) {
  457. _checkView = [DeviceCheckView shareInstance];
  458. }
  459. return _checkView;
  460. }
  461. - (void)settingAction {
  462. SettingViewController *ctrl = [[SettingViewController alloc] init];
  463. [self.navigationController pushViewController:ctrl animated:YES];
  464. }
  465. - (void)dealloc {
  466. [[NSNotificationCenter defaultCenter] removeObserver:self];
  467. }
  468. - (MineHeadView *)headView {
  469. if (!_headView) {
  470. _headView = [MineHeadView shareInstance];
  471. MJWeakSelf;
  472. [_headView operationCallback:^(MINEVIEWTYPE type) {
  473. [weakSelf operationAction:type];
  474. }];
  475. }
  476. return _headView;
  477. }
  478. - (MineFunctionView *)normalFunctionView {
  479. if (!_normalFunctionView) {
  480. _normalFunctionView = [MineFunctionView shareInstance];
  481. // [_normalFunctionView configView];
  482. MJWeakSelf;
  483. [_normalFunctionView functionViewAction:^(MINEVIEWTYPE type) {
  484. [weakSelf operationAction:type];
  485. }];
  486. }
  487. return _normalFunctionView;
  488. }
  489. - (MineTeachToolView *)teachToolView {
  490. if (!_teachToolView) {
  491. _teachToolView = [MineTeachToolView shareInstance];
  492. // [_teachToolView configView];
  493. MJWeakSelf;
  494. [_teachToolView functionViewAction:^(MINEVIEWTYPE type) {
  495. [weakSelf operationAction:type];
  496. }];
  497. }
  498. return _teachToolView;
  499. }
  500. - (MineBottomView *)bottomView {
  501. if (!_bottomView) {
  502. _bottomView = [MineBottomView shareInstance];
  503. MJWeakSelf;
  504. [_bottomView operationCallback:^(MINEVIEWTYPE type) {
  505. [weakSelf operationAction:type];
  506. }];
  507. }
  508. return _bottomView;
  509. }
  510. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  511. CGFloat space = scrollView.contentOffset.y;
  512. if (space >= kNaviBarHeight) {
  513. self.navView.backgroundColor = [UIColor whiteColor];
  514. self.navView.headTitle.hidden = NO;
  515. self.navView.lineView.hidden = NO;
  516. }
  517. else {
  518. self.navView.headTitle.hidden = YES;
  519. self.navView.lineView.hidden = YES;
  520. CGFloat rate = space / kNaviBarHeight < 0 ? 0 : space / kNaviBarHeight;
  521. self.navView.backgroundColor = HexRGBAlpha(0xffffff, rate);
  522. }
  523. }
  524. /*
  525. #pragma mark - Navigation
  526. // In a storyboard-based application, you will often want to do a little preparation before navigation
  527. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  528. // Get the new view controller using [segue destinationViewController].
  529. // Pass the selected object to the new view controller.
  530. }
  531. */
  532. @end