|
@@ -111,6 +111,8 @@
|
|
|
|
|
|
@property (nonatomic, assign) NSInteger courseCount;
|
|
|
|
|
|
+@property (nonatomic, assign) BOOL isFirstLoad;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation HomeViewController
|
|
@@ -120,15 +122,56 @@
|
|
|
// Do any additional setup after loading the view.
|
|
|
self.ks_prefersNavigationBarHidden = YES;
|
|
|
self.isChooseLive = YES;
|
|
|
+ self.isFirstLoad = YES;
|
|
|
[self configNavView];
|
|
|
[self configUI];
|
|
|
- [self requestUserInfo]; // 获取声部
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
[super viewWillAppear:animated];
|
|
|
+ if (self.isFirstLoad == YES) {
|
|
|
+ [self requestUserInfo:YES]; // 获取声部
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self requestUserInfo:NO];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self requestUnreadCount];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)requestUnreadCount {
|
|
|
+ [KSNetworkingManager queryCountOfUnreadRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ NSArray *countArray = [dic arrayValueForKey:@"data"];
|
|
|
+ NSInteger courseCount = 0;
|
|
|
+ NSInteger sysCount = 0;
|
|
|
+ NSInteger noticeCount = 0;
|
|
|
+ for (NSDictionary *parm in countArray) {
|
|
|
+ if ([[parm stringValueForKey:@"key"] isEqualToString:@"COURSE"]) {
|
|
|
+ courseCount = [parm integerValueForKey:@"value"];
|
|
|
+ }
|
|
|
+ if ([[parm stringValueForKey:@"key"] isEqualToString:@"SYSTEM"]) {
|
|
|
+ sysCount = [parm integerValueForKey:@"value"];
|
|
|
+ }
|
|
|
+ if ([[parm stringValueForKey:@"key"] isEqualToString:@"NOTICE"]) {
|
|
|
+ noticeCount = [parm integerValueForKey:@"value"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (courseCount != 0 || sysCount != 0 || noticeCount != 0) {
|
|
|
+ self.navView.dotView.hidden = NO;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.navView.dotView.hidden = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
- (void)configNavView {
|
|
@@ -185,25 +228,6 @@
|
|
|
}];
|
|
|
tableHeaderHeight += self.buttonViewHeight;
|
|
|
|
|
|
-// NSMutableArray *buttonInfoArray = [NSMutableArray array];
|
|
|
-// NSArray *titleArray = @[@"陪练课",@"直播课",@"视频课",@"乐谱库",@"老师风采"];
|
|
|
-// NSArray *imageArray = @[@"home_accompany",@"home_live",@"home_video",@"home_music",@"home_style"];
|
|
|
-// NSString *accompanyUrl = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/practiceClass"];
|
|
|
-// NSString *liveUrl = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveClass"];
|
|
|
-// NSString *videoUrl = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/videoClass"];
|
|
|
-// NSString *musicUrl = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-songbook"];
|
|
|
-// NSString *teacherUrl = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherElegant"];
|
|
|
-// NSArray *linkUrlArray = @[accompanyUrl,liveUrl,videoUrl,musicUrl,teacherUrl];
|
|
|
-// for (NSInteger i = 0; i < titleArray.count; i++) {
|
|
|
-// HomeMessageModel *model = [[HomeMessageModel alloc] init];
|
|
|
-// model.title = titleArray[i];
|
|
|
-// model.coverImage = imageArray[i];
|
|
|
-// model.linkUrl = linkUrlArray[i];
|
|
|
-// [buttonInfoArray addObject:model];
|
|
|
-// }
|
|
|
-// self.buttonArray = [NSMutableArray arrayWithArray:buttonInfoArray];
|
|
|
-// [self showButtonMessage];
|
|
|
-
|
|
|
// 课程提醒
|
|
|
[self.tableHeaderView addSubview:self.tipsCourseView];
|
|
|
self.tipsViewHeight = CGFLOAT_MIN;
|
|
@@ -450,7 +474,8 @@
|
|
|
[self refreshTableHeadHeight];
|
|
|
}
|
|
|
|
|
|
-- (void)requestUserInfo {
|
|
|
+- (void)requestUserInfo:(BOOL)checkSubject {
|
|
|
+ self.isFirstLoad = NO;
|
|
|
[KSNetworkingManager queryStudentInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
self.mineInfo = [[StudentInfoModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
|
|
@@ -458,7 +483,7 @@
|
|
|
if ([NSString isEmptyString:rongToken]) {
|
|
|
[USER_MANAGER queryUserInfoConnectRongCloud:YES];
|
|
|
}
|
|
|
- [self refreshNavView];
|
|
|
+ [self refreshNavView:checkSubject];
|
|
|
}
|
|
|
else {
|
|
|
[self MBPShow:MESSAGEKEY];
|
|
@@ -507,13 +532,16 @@
|
|
|
[self refreshTableHeadHeight];
|
|
|
}
|
|
|
|
|
|
-- (void)refreshNavView {
|
|
|
- if ([NSString isEmptyString:self.mineInfo.subjectName]) {
|
|
|
- [self showInstrumentView:YES];
|
|
|
- }
|
|
|
- else {
|
|
|
- [self requestData];
|
|
|
+- (void)refreshNavView:(BOOL)checkSubject {
|
|
|
+ if (checkSubject) {
|
|
|
+ if ([NSString isEmptyString:self.mineInfo.subjectName]) {
|
|
|
+ [self showInstrumentView:YES];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self requestData];
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
[self.navView.userAvatal sd_setImageWithURL:[NSURL URLWithString:[self.mineInfo.heardUrl getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
|
|
|
NSString *userName = @"";
|
|
|
if ([NSString isEmptyString:self.mineInfo.username]) {
|
|
@@ -1147,7 +1175,7 @@
|
|
|
SubjectChooseViewController *ctrl = [[SubjectChooseViewController alloc] init];
|
|
|
MJWeakSelf;
|
|
|
[ctrl chooseSubjectCallback:^{
|
|
|
- [weakSelf requestUserInfo];
|
|
|
+ [weakSelf requestUserInfo:NO];
|
|
|
[weakSelf requestData];
|
|
|
}];
|
|
|
if (hideBackButton) {
|