Browse Source

首页最近课程

Steven 7 months ago
parent
commit
1e070f5167

+ 2 - 1
KulexiuForStudent/KulexiuForStudent/Module/Home/Model/RecentCourseModel.h

@@ -21,7 +21,8 @@
 @property (nonatomic, strong) NSString *courseStartTime;
 @property (nonatomic, strong) NSString *teacherId;
 @property (nonatomic, strong) NSString *courseGroupName;
-@property (nonatomic, strong) NSString *courseName;
+@property (nonatomic, strong) NSString *courseEndTime;
+
 
 + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict;
 - (instancetype)initWithDictionary:(NSDictionary *)dict;

+ 8 - 7
KulexiuForStudent/KulexiuForStudent/Module/Home/Model/RecentCourseModel.m

@@ -18,7 +18,7 @@ NSString *const kRecentCourseModelTeacherName = @"teacherName";
 NSString *const kRecentCourseModelCourseStartTime = @"courseStartTime";
 NSString *const kRecentCourseModelTeacherId = @"teacherId";
 NSString *const kRecentCourseModelCourseGroupName = @"courseGroupName";
-NSString *const kRecentCourseModelCourseName = @"courseName";
+NSString *const kRecentCourseModelCourseEndTime = @"courseEndTime";
 
 
 @interface RecentCourseModel ()
@@ -39,7 +39,8 @@ NSString *const kRecentCourseModelCourseName = @"courseName";
 @synthesize courseStartTime = _courseStartTime;
 @synthesize teacherId = _teacherId;
 @synthesize courseGroupName = _courseGroupName;
-@synthesize courseName = _courseName;
+@synthesize courseEndTime = _courseEndTime;
+
 
 + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
 {
@@ -63,7 +64,7 @@ NSString *const kRecentCourseModelCourseName = @"courseName";
             self.courseStartTime = [self objectOrNilForKey:kRecentCourseModelCourseStartTime fromDictionary:dict];
             self.teacherId = [self objectOrNilForKey:kRecentCourseModelTeacherId fromDictionary:dict];
             self.courseGroupName = [self objectOrNilForKey:kRecentCourseModelCourseGroupName fromDictionary:dict];
-            self.courseName = [self objectOrNilForKey:kRecentCourseModelCourseName fromDictionary:dict];
+        self.courseEndTime = [self objectOrNilForKey:kRecentCourseModelCourseEndTime fromDictionary:dict];
     }
     
     return self;
@@ -83,7 +84,7 @@ NSString *const kRecentCourseModelCourseName = @"courseName";
     [mutableDict setValue:self.courseStartTime forKey:kRecentCourseModelCourseStartTime];
     [mutableDict setValue:self.teacherId forKey:kRecentCourseModelTeacherId];
     [mutableDict setValue:self.courseGroupName forKey:kRecentCourseModelCourseGroupName];
-    [mutableDict setValue:self.courseName forKey:kRecentCourseModelCourseName];
+    [mutableDict setValue:self.courseEndTime forKey:kRecentCourseModelCourseEndTime];
     return [NSDictionary dictionaryWithDictionary:mutableDict];
 }
 
@@ -120,7 +121,7 @@ NSString *const kRecentCourseModelCourseName = @"courseName";
     self.courseStartTime = [aDecoder decodeObjectForKey:kRecentCourseModelCourseStartTime];
     self.teacherId = [aDecoder decodeObjectForKey:kRecentCourseModelTeacherId];
     self.courseGroupName = [aDecoder decodeObjectForKey:kRecentCourseModelCourseGroupName];
-    self.courseName = [aDecoder decodeObjectForKey:kRecentCourseModelCourseName];
+    self.courseEndTime = [aDecoder decodeObjectForKey:kRecentCourseModelCourseEndTime];
     return self;
 }
 
@@ -137,7 +138,7 @@ NSString *const kRecentCourseModelCourseName = @"courseName";
     [aCoder encodeObject:_courseStartTime forKey:kRecentCourseModelCourseStartTime];
     [aCoder encodeObject:_teacherId forKey:kRecentCourseModelTeacherId];
     [aCoder encodeObject:_courseGroupName forKey:kRecentCourseModelCourseGroupName];
-    [aCoder encodeObject:_courseName forKey:kRecentCourseModelCourseName];
+    [aCoder encodeObject:_courseEndTime forKey:kRecentCourseModelCourseEndTime];
 }
 
 - (id)copyWithZone:(NSZone *)zone
@@ -156,7 +157,7 @@ NSString *const kRecentCourseModelCourseName = @"courseName";
         copy.courseStartTime = [self.courseStartTime copyWithZone:zone];
         copy.teacherId = [self.teacherId copyWithZone:zone];
         copy.courseGroupName = [self.courseGroupName copyWithZone:zone];
-        copy.courseName = [self.courseName copyWithZone:zone];
+        copy.courseEndTime = [self.courseEndTime copyWithZone:zone];
     }
     
     return copy;

+ 9 - 2
KulexiuForStudent/KulexiuForStudent/Module/Home/View/RecentCourse/HomeRecentCourseView.m

@@ -41,17 +41,24 @@
     NSDateFormatter *formatter = [NSObject getDateformatter];
     [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
     NSDate *beginDate = [formatter dateFromString:model.courseStartTime];
+    NSDate *endDate = [formatter dateFromString:model.courseEndTime];
+    
     NSDate *currentDate = [NSDate date];
     [formatter setDateFormat:@"yyyy-MM-dd"];
     NSString *currentDay = [formatter stringFromDate:currentDate];
     NSString *courseDay = [formatter stringFromDate:beginDate];
     if ([currentDay isEqualToString:courseDay]) {
         [formatter setDateFormat:@"HH:mm"];
-        self.timeLabel.text = [NSString stringWithFormat:@"今日 %@", [NSString returnNoNullStringWithString:[formatter stringFromDate:beginDate]]];
+        NSString *beginTime = [NSString returnNoNullStringWithString:[formatter stringFromDate:beginDate]];
+        NSString *endTime = [NSString returnNoNullStringWithString:[formatter stringFromDate:endDate]];
+        self.timeLabel.text = [NSString stringWithFormat:@"今日 %@-%@", beginTime, endTime];
     }
     else {
         [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
-        self.timeLabel.text = [NSString returnNoNullStringWithString:[formatter stringFromDate:beginDate]];
+        NSString *beginTime = [NSString returnNoNullStringWithString:[formatter stringFromDate:beginDate]];
+        [formatter setDateFormat:@"HH:mm"];
+        NSString *endTime = [NSString returnNoNullStringWithString:[formatter stringFromDate:endDate]];
+        self.timeLabel.text = [NSString stringWithFormat:@"%@-%@", beginTime, endTime];
     }
     
     if ([model.status isEqualToString:@"ING"]) { // 进行中