123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- //
- // MineViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/17.
- //
- #import "MineViewController.h"
- #import "MineNavView.h"
- #import "MineBodyView.h"
- #import "SettingViewController.h"
- #import "KSBaseWKWebViewController.h"
- #import "NetworkingCheckController.h"
- #import "DeviceCheckView.h"
- #import "UserInfoManager.h"
- #import "TeacherInfo.h"
- #import "VideoCourseViewController.h"
- #import "CreateLiveViewController.h"
- @interface MineViewController ()
- @property (nonatomic, strong) MineNavView *navView;
- @property (nonatomic, strong) MineBodyView *bodyView;
- @property (nonatomic, strong) DeviceCheckView *checkView;
- @property (nonatomic, strong) TeacherInfo *mineInfo;
- @end
- @implementation MineViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if ([self checkIsLoginToLoginView:YES]) {
- [self requsetUserMessage];
- }
- }
- - (void)requsetUserMessage {
- [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.mineInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- NSString *rongToken = UserDefault(RongTokenKey);
- if ([NSString isEmptyString:rongToken]) {
- [USER_MANAGER queryUserInfoConnectRongCloud:YES];
- }
- [self refreshView];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshView {
- [self.bodyView configMessage:self.mineInfo];
- }
- - (void)configUI {
- UIImage *bgImage = [UIImage imageNamed:@"login_head"];
- CGFloat height = bgImage.size.height / bgImage.size.width * kScreenWidth;
- UIImageView *imageView = [[UIImageView alloc] initWithImage:bgImage];
- imageView.frame = CGRectMake(0, 0, kScreenWidth, height);
- [self.view addSubview:imageView];
-
- [self.view addSubview:self.navView];
- CGFloat navHeight = CGRectGetHeight(self.navView.frame);
- [self.view bringSubviewToFront:self.scrollView];
- [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
- make.left.right.mas_equalTo(self.view);
- make.bottom.mas_equalTo(self.view.mas_bottom);
- }];
-
- // bodyView;
- _bodyView = [MineBodyView shareInstance];
- [self.scrollView addSubview:_bodyView];
- CGFloat contentMinHeight = [_bodyView getViewHeight];
- CGFloat contentHeight = kScreenHeight - kTabBarHeight - navHeight;
- CGFloat viewHeight = contentMinHeight > contentHeight ? contentMinHeight : contentHeight;
- [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.left.right.mas_equalTo(self.view);
- make.height.mas_equalTo(viewHeight);
- }];
- MJWeakSelf;
- [_bodyView operationCallback:^(MINEVIEWTYPE type) {
- [weakSelf operationAction:type];
- }];
-
- [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
- if (viewHeight + navHeight > kScreenHeight - kNaviBarHeight) {
- self.scrollView.scrollEnabled = YES;
- }
- }
- - (void)operationAction:(MINEVIEWTYPE)type {
- switch (type) {
- case MINEVIEWTYPE_AUTH: // 老师认证
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- break;
- case MINEVIEWTYPE_HOMEPAGE: // 我的主页
- {
-
- }
- break;
- case MINEVIEWTYPE_MIEN: // 个人风采
- {
-
- }
- break;
- case MINEVIEWTYPE_STARTBOARDCAST: // 开启直播
- {
- // if (self.mineInfo.liveFlag == 1) {
- CreateLiveViewController *ctrl = [[CreateLiveViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- // }
- // else { // 开通直播审核
- // KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- // webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/openLive"];
- // [self.navigationController pushViewController:webCtrl animated:YES];
- // }
- }
- break;
- case MINEVIEWTYPE_ORDER: // 商品订单
- {
-
- }
- break;
- case MINEVIEWTYPE_ACCOMPANY: // 陪练课设置
- {
- if (self.mineInfo.entryStatus != 2) { // 跳转老师认证
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- else {
-
- }
- }
- break;
- case MINEVIEWTYPE_BOARDCASTCOURSE: // 直播课
- {
-
- }
- break;
- case MINEVIEWTYPE_VIDEOCOURSE: // 视频课
- {
- VideoCourseViewController *ctrl = [[VideoCourseViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- break;
- case MINEVIEWTYPE_MUSICIANAUTH: // 音乐人认证
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/musicCert"];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- break;
- case MINEVIEWTYPE_CARD: // 我的银行卡
- {
-
- }
- break;
- case MINEVIEWTYPE_NETWORKING: // 网络检测
- {
- NetworkingCheckController *checkVC = [[NetworkingCheckController alloc] init];
- [self.navigationController pushViewController:checkVC animated:YES];
- }
- break;
- case MINEVIEWTYPE_DEVICE: // 设备检测
- {
- [self.checkView showAlert];
- }
- break;
- case MINEVIEWTYPE_HELP: // 帮助
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/helpCenter"];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- break;
- default:
- break;
- }
- }
- #pragma mark --- lazying
- - (MineNavView *)navView {
- if (!_navView) {
- _navView = [MineNavView shareInstance];
- MJWeakSelf;
- [_navView mineNavAction:^{
- [weakSelf settingAction];
- }];
- }
- return _navView;
- }
- - (DeviceCheckView *)checkView {
- if (!_checkView) {
- _checkView = [DeviceCheckView shareInstance];
- }
- return _checkView;
- }
- - (void)settingAction {
- SettingViewController *ctrl = [[SettingViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|