MineViewController.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 "MineBodyView.h"
  10. #import "SettingViewController.h"
  11. #import "KSBaseWKWebViewController.h"
  12. #import "NetworkingCheckController.h"
  13. #import "DeviceCheckView.h"
  14. #import "UserInfoManager.h"
  15. #import "TeacherInfo.h"
  16. #import "VideoCourseViewController.h"
  17. #import "CreateLiveViewController.h"
  18. @interface MineViewController ()
  19. @property (nonatomic, strong) MineNavView *navView;
  20. @property (nonatomic, strong) MineBodyView *bodyView;
  21. @property (nonatomic, strong) DeviceCheckView *checkView;
  22. @property (nonatomic, strong) TeacherInfo *mineInfo;
  23. @end
  24. @implementation MineViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. self.ks_prefersNavigationBarHidden = YES;
  29. [self configUI];
  30. }
  31. - (void)viewWillAppear:(BOOL)animated {
  32. [super viewWillAppear:animated];
  33. if ([self checkIsLoginToLoginView:YES]) {
  34. [self requsetUserMessage];
  35. }
  36. }
  37. - (void)requsetUserMessage {
  38. [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  39. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  40. self.mineInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  41. NSString *rongToken = UserDefault(RongTokenKey);
  42. if ([NSString isEmptyString:rongToken]) {
  43. [USER_MANAGER queryUserInfoConnectRongCloud:YES];
  44. }
  45. [self refreshView];
  46. }
  47. else {
  48. [self MBPShow:MESSAGEKEY];
  49. }
  50. } faliure:^(NSError * _Nonnull error) {
  51. }];
  52. }
  53. - (void)refreshView {
  54. [self.bodyView configMessage:self.mineInfo];
  55. }
  56. - (void)configUI {
  57. UIImage *bgImage = [UIImage imageNamed:@"login_head"];
  58. CGFloat height = bgImage.size.height / bgImage.size.width * kScreenWidth;
  59. UIImageView *imageView = [[UIImageView alloc] initWithImage:bgImage];
  60. imageView.frame = CGRectMake(0, 0, kScreenWidth, height);
  61. [self.view addSubview:imageView];
  62. [self.view addSubview:self.navView];
  63. CGFloat navHeight = CGRectGetHeight(self.navView.frame);
  64. [self.view bringSubviewToFront:self.scrollView];
  65. [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  66. make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
  67. make.left.right.mas_equalTo(self.view);
  68. make.bottom.mas_equalTo(self.view.mas_bottom);
  69. }];
  70. // bodyView;
  71. _bodyView = [MineBodyView shareInstance];
  72. [self.scrollView addSubview:_bodyView];
  73. CGFloat contentMinHeight = [_bodyView getViewHeight];
  74. CGFloat contentHeight = kScreenHeight - kTabBarHeight - navHeight;
  75. CGFloat viewHeight = contentMinHeight > contentHeight ? contentMinHeight : contentHeight;
  76. [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.top.mas_equalTo(self.scrollView.mas_top);
  78. make.left.right.mas_equalTo(self.view);
  79. make.height.mas_equalTo(viewHeight);
  80. }];
  81. MJWeakSelf;
  82. [_bodyView operationCallback:^(MINEVIEWTYPE type) {
  83. [weakSelf operationAction:type];
  84. }];
  85. [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
  86. if (viewHeight + navHeight > kScreenHeight - kNaviBarHeight) {
  87. self.scrollView.scrollEnabled = YES;
  88. }
  89. }
  90. - (void)operationAction:(MINEVIEWTYPE)type {
  91. switch (type) {
  92. case MINEVIEWTYPE_AUTH: // 老师认证
  93. {
  94. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  95. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  96. [self.navigationController pushViewController:webCtrl animated:YES];
  97. }
  98. break;
  99. case MINEVIEWTYPE_HOMEPAGE: // 我的主页
  100. {
  101. }
  102. break;
  103. case MINEVIEWTYPE_MIEN: // 个人风采
  104. {
  105. }
  106. break;
  107. case MINEVIEWTYPE_STARTBOARDCAST: // 开启直播
  108. {
  109. // if (self.mineInfo.liveFlag == 1) {
  110. CreateLiveViewController *ctrl = [[CreateLiveViewController alloc] init];
  111. [self.navigationController pushViewController:ctrl animated:YES];
  112. // }
  113. // else { // 开通直播审核
  114. // KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  115. // webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/openLive"];
  116. // [self.navigationController pushViewController:webCtrl animated:YES];
  117. // }
  118. }
  119. break;
  120. case MINEVIEWTYPE_ORDER: // 商品订单
  121. {
  122. }
  123. break;
  124. case MINEVIEWTYPE_ACCOMPANY: // 陪练课设置
  125. {
  126. if (self.mineInfo.entryStatus != 2) { // 跳转老师认证
  127. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  128. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  129. [self.navigationController pushViewController:webCtrl animated:YES];
  130. }
  131. else {
  132. }
  133. }
  134. break;
  135. case MINEVIEWTYPE_BOARDCASTCOURSE: // 直播课
  136. {
  137. }
  138. break;
  139. case MINEVIEWTYPE_VIDEOCOURSE: // 视频课
  140. {
  141. VideoCourseViewController *ctrl = [[VideoCourseViewController alloc] init];
  142. [self.navigationController pushViewController:ctrl animated:YES];
  143. }
  144. break;
  145. case MINEVIEWTYPE_MUSICIANAUTH: // 音乐人认证
  146. {
  147. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  148. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/musicCert"];
  149. [self.navigationController pushViewController:webCtrl animated:YES];
  150. }
  151. break;
  152. case MINEVIEWTYPE_CARD: // 我的银行卡
  153. {
  154. }
  155. break;
  156. case MINEVIEWTYPE_NETWORKING: // 网络检测
  157. {
  158. NetworkingCheckController *checkVC = [[NetworkingCheckController alloc] init];
  159. [self.navigationController pushViewController:checkVC animated:YES];
  160. }
  161. break;
  162. case MINEVIEWTYPE_DEVICE: // 设备检测
  163. {
  164. [self.checkView showAlert];
  165. }
  166. break;
  167. case MINEVIEWTYPE_HELP: // 帮助
  168. {
  169. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  170. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/helpCenter"];
  171. [self.navigationController pushViewController:webCtrl animated:YES];
  172. }
  173. break;
  174. default:
  175. break;
  176. }
  177. }
  178. #pragma mark --- lazying
  179. - (MineNavView *)navView {
  180. if (!_navView) {
  181. _navView = [MineNavView shareInstance];
  182. MJWeakSelf;
  183. [_navView mineNavAction:^{
  184. [weakSelf settingAction];
  185. }];
  186. }
  187. return _navView;
  188. }
  189. - (DeviceCheckView *)checkView {
  190. if (!_checkView) {
  191. _checkView = [DeviceCheckView shareInstance];
  192. }
  193. return _checkView;
  194. }
  195. - (void)settingAction {
  196. SettingViewController *ctrl = [[SettingViewController alloc] init];
  197. [self.navigationController pushViewController:ctrl animated:YES];
  198. }
  199. - (void)dealloc {
  200. [[NSNotificationCenter defaultCenter] removeObserver:self];
  201. }
  202. /*
  203. #pragma mark - Navigation
  204. // In a storyboard-based application, you will often want to do a little preparation before navigation
  205. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  206. // Get the new view controller using [segue destinationViewController].
  207. // Pass the selected object to the new view controller.
  208. }
  209. */
  210. @end