cjc 6 yıl önce
ebeveyn
işleme
e91800ac6e

+ 67 - 3
CAIPU.xcodeproj/project.pbxproj

@@ -35,6 +35,15 @@
35 35
 		49EF9184207CB21C008B7187 /* CPHealthModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF9183207CB21C008B7187 /* CPHealthModel.m */; };
36 36
 		49EF9187207CB7D7008B7187 /* CPHealthDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF9186207CB7D7008B7187 /* CPHealthDetailViewController.m */; };
37 37
 		49EF918C207DF89D008B7187 /* CPFindLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF918B207DF89D008B7187 /* CPFindLayout.m */; };
38
+		49EF918F208054C0008B7187 /* CPHomeThemeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF918E208054C0008B7187 /* CPHomeThemeModel.m */; };
39
+		49EF919220807DE4008B7187 /* CPCommonTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF919120807DE4008B7187 /* CPCommonTool.m */; };
40
+		49EF91D320808E4A008B7187 /* CPTimeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91D220808E4A008B7187 /* CPTimeViewController.m */; };
41
+		49EF91F120809E83008B7187 /* MLMSegmentHead.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91E720809E83008B7187 /* MLMSegmentHead.m */; };
42
+		49EF91F220809E83008B7187 /* MLMSegmentManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91E920809E83008B7187 /* MLMSegmentManager.m */; };
43
+		49EF91F320809E83008B7187 /* MLMSegmentScroll.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91EB20809E83008B7187 /* MLMSegmentScroll.m */; };
44
+		49EF91F420809E83008B7187 /* UIView+EasyFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91EE20809E83008B7187 /* UIView+EasyFrame.m */; };
45
+		49EF91F520809E83008B7187 /* UIView+ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91F020809E83008B7187 /* UIView+ViewController.m */; };
46
+		49EF91F82080A90B008B7187 /* CPTimeSegViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF91F72080A90B008B7187 /* CPTimeSegViewController.m */; };
38 47
 		C428739A2028081300502005 /* CPStepTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C42873992028081300502005 /* CPStepTableView.m */; };
39 48
 		C42873A02028086E00502005 /* CPStepTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C428739F2028086E00502005 /* CPStepTableViewCell.m */; };
40 49
 		C444ED522017100F0082AA5C /* CPHomeListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C444ED512017100F0082AA5C /* CPHomeListModel.m */; };
@@ -160,6 +169,25 @@
160 169
 		49EF9186207CB7D7008B7187 /* CPHealthDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPHealthDetailViewController.m; sourceTree = "<group>"; };
161 170
 		49EF918A207DF89D008B7187 /* CPFindLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPFindLayout.h; sourceTree = "<group>"; };
162 171
 		49EF918B207DF89D008B7187 /* CPFindLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPFindLayout.m; sourceTree = "<group>"; };
172
+		49EF918D208054C0008B7187 /* CPHomeThemeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPHomeThemeModel.h; sourceTree = "<group>"; };
173
+		49EF918E208054C0008B7187 /* CPHomeThemeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPHomeThemeModel.m; sourceTree = "<group>"; };
174
+		49EF919020807DE4008B7187 /* CPCommonTool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPCommonTool.h; sourceTree = "<group>"; };
175
+		49EF919120807DE4008B7187 /* CPCommonTool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPCommonTool.m; sourceTree = "<group>"; };
176
+		49EF91D120808E4A008B7187 /* CPTimeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPTimeViewController.h; sourceTree = "<group>"; };
177
+		49EF91D220808E4A008B7187 /* CPTimeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPTimeViewController.m; sourceTree = "<group>"; };
178
+		49EF91E620809E83008B7187 /* MLMSegmentHead.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MLMSegmentHead.h; sourceTree = "<group>"; };
179
+		49EF91E720809E83008B7187 /* MLMSegmentHead.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLMSegmentHead.m; sourceTree = "<group>"; };
180
+		49EF91E820809E83008B7187 /* MLMSegmentManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MLMSegmentManager.h; sourceTree = "<group>"; };
181
+		49EF91E920809E83008B7187 /* MLMSegmentManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLMSegmentManager.m; sourceTree = "<group>"; };
182
+		49EF91EA20809E83008B7187 /* MLMSegmentScroll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MLMSegmentScroll.h; sourceTree = "<group>"; };
183
+		49EF91EB20809E83008B7187 /* MLMSegmentScroll.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLMSegmentScroll.m; sourceTree = "<group>"; };
184
+		49EF91EC20809E83008B7187 /* SegmentPageHead.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegmentPageHead.h; sourceTree = "<group>"; };
185
+		49EF91ED20809E83008B7187 /* UIView+EasyFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+EasyFrame.h"; sourceTree = "<group>"; };
186
+		49EF91EE20809E83008B7187 /* UIView+EasyFrame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+EasyFrame.m"; sourceTree = "<group>"; };
187
+		49EF91EF20809E83008B7187 /* UIView+ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+ViewController.h"; sourceTree = "<group>"; };
188
+		49EF91F020809E83008B7187 /* UIView+ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ViewController.m"; sourceTree = "<group>"; };
189
+		49EF91F62080A90B008B7187 /* CPTimeSegViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPTimeSegViewController.h; sourceTree = "<group>"; };
190
+		49EF91F72080A90B008B7187 /* CPTimeSegViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPTimeSegViewController.m; sourceTree = "<group>"; };
163 191
 		5D7DDE3161671277618A2624 /* Pods-CAIPU.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CAIPU.release.xcconfig"; path = "Pods/Target Support Files/Pods-CAIPU/Pods-CAIPU.release.xcconfig"; sourceTree = "<group>"; };
164 192
 		83372F69E447D8645B21F903 /* Pods-CAIPU.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CAIPU.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CAIPU/Pods-CAIPU.debug.xcconfig"; sourceTree = "<group>"; };
165 193
 		C42873982028081300502005 /* CPStepTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPStepTableView.h; sourceTree = "<group>"; };
@@ -426,6 +454,25 @@
426 454
 			path = Source;
427 455
 			sourceTree = "<group>";
428 456
 		};
457
+		49EF91E520809E83008B7187 /* MLMSegmentPageView */ = {
458
+			isa = PBXGroup;
459
+			children = (
460
+				49EF91E620809E83008B7187 /* MLMSegmentHead.h */,
461
+				49EF91E720809E83008B7187 /* MLMSegmentHead.m */,
462
+				49EF91E820809E83008B7187 /* MLMSegmentManager.h */,
463
+				49EF91E920809E83008B7187 /* MLMSegmentManager.m */,
464
+				49EF91EA20809E83008B7187 /* MLMSegmentScroll.h */,
465
+				49EF91EB20809E83008B7187 /* MLMSegmentScroll.m */,
466
+				49EF91EC20809E83008B7187 /* SegmentPageHead.h */,
467
+				49EF91ED20809E83008B7187 /* UIView+EasyFrame.h */,
468
+				49EF91EE20809E83008B7187 /* UIView+EasyFrame.m */,
469
+				49EF91EF20809E83008B7187 /* UIView+ViewController.h */,
470
+				49EF91F020809E83008B7187 /* UIView+ViewController.m */,
471
+			);
472
+			name = MLMSegmentPageView;
473
+			path = "../../../../../../../../Downloads/MLMSegmentPage-master/MLMSegmentPageView";
474
+			sourceTree = "<group>";
475
+		};
429 476
 		C47D02702011EF5D00E5C025 /* NewPagedFlowView */ = {
430 477
 			isa = PBXGroup;
431 478
 			children = (
@@ -459,6 +506,7 @@
459 506
 		C4B7E2992011D1D00046C0EC /* Third(第三方) */ = {
460 507
 			isa = PBXGroup;
461 508
 			children = (
509
+				49EF91E520809E83008B7187 /* MLMSegmentPageView */,
462 510
 				49EF914A2073787C008B7187 /* SDCycleScrollView */,
463 511
 				C47D02902013198900E5C025 /* CPSegmentControl.h */,
464 512
 				C47D02912013198900E5C025 /* CPSegmentControl.m */,
@@ -622,6 +670,10 @@
622 670
 				C4B4106E202077A300C95284 /* CPDetailViewController.m */,
623 671
 				49EF9164207466CF008B7187 /* CPThemeDetailController.h */,
624 672
 				49EF9165207466CF008B7187 /* CPThemeDetailController.m */,
673
+				49EF91D120808E4A008B7187 /* CPTimeViewController.h */,
674
+				49EF91D220808E4A008B7187 /* CPTimeViewController.m */,
675
+				49EF91F62080A90B008B7187 /* CPTimeSegViewController.h */,
676
+				49EF91F72080A90B008B7187 /* CPTimeSegViewController.m */,
625 677
 			);
626 678
 			path = Controllers;
627 679
 			sourceTree = "<group>";
@@ -643,6 +695,8 @@
643 695
 				C4B4225E2021638700C95284 /* CPStepModel.m */,
644 696
 				C4B422602021653100C95284 /* CPIngredientModel.h */,
645 697
 				C4B422612021653100C95284 /* CPIngredientModel.m */,
698
+				49EF918D208054C0008B7187 /* CPHomeThemeModel.h */,
699
+				49EF918E208054C0008B7187 /* CPHomeThemeModel.m */,
646 700
 			);
647 701
 			path = Models;
648 702
 			sourceTree = "<group>";
@@ -719,6 +773,8 @@
719 773
 			children = (
720 774
 				497B1C2F2056503E00EBB024 /* SortDictManager.h */,
721 775
 				497B1C2E2056503D00EBB024 /* SortDictManager.m */,
776
+				49EF919020807DE4008B7187 /* CPCommonTool.h */,
777
+				49EF919120807DE4008B7187 /* CPCommonTool.m */,
722 778
 				C4F5116820106F8D0012111E /* CPHTTP.h */,
723 779
 				C4F5116920106F8D0012111E /* CPHTTP.m */,
724 780
 			);
@@ -886,7 +942,7 @@
886 942
 /* Begin PBXShellScriptBuildPhase section */
887 943
 		71393BF3FFF1783FF67A3610 /* [CP] Check Pods Manifest.lock */ = {
888 944
 			isa = PBXShellScriptBuildPhase;
889
-			buildActionMask = 2147483647;
945
+			buildActionMask = 8;
890 946
 			files = (
891 947
 			);
892 948
 			inputPaths = (
@@ -897,10 +953,9 @@
897 953
 			outputPaths = (
898 954
 				"$(DERIVED_FILE_DIR)/Pods-CAIPU-checkManifestLockResult.txt",
899 955
 			);
900
-			runOnlyForDeploymentPostprocessing = 0;
956
+			runOnlyForDeploymentPostprocessing = 1;
901 957
 			shellPath = /bin/sh;
902 958
 			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
903
-			showEnvVarsInLog = 0;
904 959
 		};
905 960
 		9377BA666AA34D731D8222DC /* [CP] Copy Pods Resources */ = {
906 961
 			isa = PBXShellScriptBuildPhase;
@@ -956,9 +1011,11 @@
956 1011
 				C4B4225F2021638700C95284 /* CPStepModel.m in Sources */,
957 1012
 				C47D02952013265300E5C025 /* CPRequestViewModel.m in Sources */,
958 1013
 				49EF9103207318A4008B7187 /* CPVideoCell.m in Sources */,
1014
+				49EF919220807DE4008B7187 /* CPCommonTool.m in Sources */,
959 1015
 				497B1BDD205138AC00EBB024 /* CPHistoryCell.m in Sources */,
960 1016
 				497B1BE720523E2500EBB024 /* CPFeedBackController.m in Sources */,
961 1017
 				C47D02982013296500E5C025 /* CPCategoryModel.m in Sources */,
1018
+				49EF91F520809E83008B7187 /* UIView+ViewController.m in Sources */,
962 1019
 				C4B4225C2021634700C95284 /* CPDetailModel.m in Sources */,
963 1020
 				C4B422652021661E00C95284 /* CPDetailHeaderView.m in Sources */,
964 1021
 				C4F5115B201034B10012111E /* CPTabBarController.m in Sources */,
@@ -975,12 +1032,14 @@
975 1032
 				49EF90CE2071F8A5008B7187 /* CPHealthViewController.m in Sources */,
976 1033
 				C47D02792011F2C000E5C025 /* CPHomeHeaderView.m in Sources */,
977 1034
 				49EF9184207CB21C008B7187 /* CPHealthModel.m in Sources */,
1035
+				49EF91F220809E83008B7187 /* MLMSegmentManager.m in Sources */,
978 1036
 				C444ED522017100F0082AA5C /* CPHomeListModel.m in Sources */,
979 1037
 				49EF90C32071CADC008B7187 /* CPThemeCollectionCell.m in Sources */,
980 1038
 				497B1BE420523E0100EBB024 /* PlaceholderTextView.m in Sources */,
981 1039
 				49EF915E2073787C008B7187 /* SDCollectionViewCell.m in Sources */,
982 1040
 				C47D027C2011F64800E5C025 /* CPHotButton.m in Sources */,
983 1041
 				C4B422622021653100C95284 /* CPIngredientModel.m in Sources */,
1042
+				49EF91F420809E83008B7187 /* UIView+EasyFrame.m in Sources */,
984 1043
 				C4F5116720106F0D0012111E /* MBProgressHUD+Extension.m in Sources */,
985 1044
 				C4B4106F202077A300C95284 /* CPDetailViewController.m in Sources */,
986 1045
 				C4F51152201033180012111E /* CPHomeViewController.m in Sources */,
@@ -990,16 +1049,20 @@
990 1049
 				C4E30ECB202023B300B61788 /* CPSearchResultView.m in Sources */,
991 1050
 				49EF91602073787C008B7187 /* UIView+SDExtension.m in Sources */,
992 1051
 				C457079C2015827500F60FEE /* CPSearchManager.m in Sources */,
1052
+				49EF918F208054C0008B7187 /* CPHomeThemeModel.m in Sources */,
993 1053
 				497B1BE02051458700EBB024 /* CPCollectionModel.m in Sources */,
994 1054
 				49EF916320737A6E008B7187 /* CPHealthCell.m in Sources */,
995 1055
 				49EF915D2073787C008B7187 /* TAPageControl.m in Sources */,
1056
+				49EF91F82080A90B008B7187 /* CPTimeSegViewController.m in Sources */,
996 1057
 				C4B4226B2022BCFD00C95284 /* CPDetailTableView.m in Sources */,
997 1058
 				C4F51155201033290012111E /* CPMoreViewController.m in Sources */,
998 1059
 				C4B422682022A6FD00C95284 /* CPPerceptionView.m in Sources */,
999 1060
 				49EF9187207CB7D7008B7187 /* CPHealthDetailViewController.m in Sources */,
1000 1061
 				C47ACA7D20108984005DA04C /* CPClassifyRightCollectionViewCell.m in Sources */,
1001 1062
 				497B1BD720512E6300EBB024 /* CPMyHistoryController.m in Sources */,
1063
+				49EF91F120809E83008B7187 /* MLMSegmentHead.m in Sources */,
1002 1064
 				49EF90D42071FD59008B7187 /* CPPhotoCell.m in Sources */,
1065
+				49EF91D320808E4A008B7187 /* CPTimeViewController.m in Sources */,
1003 1066
 				C4F5116A20106F8D0012111E /* CPHTTP.m in Sources */,
1004 1067
 				C42873A02028086E00502005 /* CPStepTableViewCell.m in Sources */,
1005 1068
 				C47D02762011EF5D00E5C025 /* PGIndexBannerSubiew.m in Sources */,
@@ -1009,6 +1072,7 @@
1009 1072
 				49EF915A2073787C008B7187 /* TAAbstractDotView.m in Sources */,
1010 1073
 				49EF90D12071FA62008B7187 /* CPFindViewController.m in Sources */,
1011 1074
 				497B1BEB205259B400EBB024 /* CPAboutViewController.m in Sources */,
1075
+				49EF91F320809E83008B7187 /* MLMSegmentScroll.m in Sources */,
1012 1076
 				C4B7E2952011A1820046C0EC /* CPSearchViewController.m in Sources */,
1013 1077
 				C4F5116D2010726D0012111E /* CPClassifyLeftView.m in Sources */,
1014 1078
 				C4F5116120103B350012111E /* CPDismissViewController.m in Sources */,

+ 1 - 0
CAIPU/Main/Classification(分类)/Models/CPHomeListModel.h

@@ -15,5 +15,6 @@
15 15
 @property (nonatomic,strong)NSNumber *views;
16 16
 @property (nonatomic,copy)  NSString *title;
17 17
 @property (nonatomic,copy)  NSString *url;
18
+@property (nonatomic,copy)  NSString *intro;
18 19
 
19 20
 @end

+ 2 - 2
CAIPU/Main/Classification(分类)/Models/CPRequestViewModel.m

@@ -29,7 +29,7 @@
29 29
 }
30 30
 
31 31
 + (void)requestBannerData:(void (^)(NSArray *data))success{
32
-    NSString *urlString = [NSString stringWithFormat:@"%@/features/getBannerRecommend",URL];
32
+    NSString *urlString = [NSString stringWithFormat:@"%@/features/earlyMiddleAndLateTheme",URL];
33 33
     [CPHTTP post:urlString params:nil success:^(id json) {
34 34
         success(json);
35 35
     } failure:^(NSError *error) {
@@ -47,7 +47,7 @@
47 47
 }
48 48
 
49 49
 + (void)requestHomeTime:(NSNumber *)page Data:(void (^)(NSArray *data))success{
50
-    NSString *urlString = [NSString stringWithFormat:@"%@/features/getRecommend",URL];
50
+    NSString *urlString = [NSString stringWithFormat:@"%@/features/theLastRecipes",URL];
51 51
     [CPHTTP post:urlString params:@{@"page":page} success:^(id json) {
52 52
         success(json);
53 53
     } failure:^(NSError *error) {

+ 0 - 1
CAIPU/Main/Find(发现)/View/CPPhotoCell.h

@@ -14,7 +14,6 @@ static NSString *KCPPhotoCellIdTwo = @"CPPhotoCellTypeTwoPic";
14 14
 static NSString *KCPPhotoCellIdThree = @"CPPhotoCellTypeThreePic";
15 15
 
16 16
 @interface CPPhotoCell : UITableViewCell
17
-+ (instancetype)cellWithTableView:(UITableView *)tableView;
18 17
 
19 18
 @property (nonatomic, strong) NSArray *photos;
20 19
 @property (nonatomic, strong) CPFindModel *model;

+ 2 - 1
CAIPU/Main/Find(发现)/View/CPPhotoCell.m

@@ -10,6 +10,7 @@
10 10
 #import "PYPhotosView.h"
11 11
 #import "PYPhotoBrowseView.h"
12 12
 #import "CPFindIconView.h"
13
+#import "CPCommonTool.h"
13 14
 
14 15
 @interface CPPhotoCell ()
15 16
 @property (nonatomic, strong) UIView *content;
@@ -111,7 +112,7 @@
111 112
 - (void)setModel:(CPFindModel *)model {
112 113
     _model = model;
113 114
     self.nickLabel.text = model.vest_name;
114
-    self.timeLabel.text = model.publish_time;
115
+    self.timeLabel.text = [CPCommonTool getDateWith:model.publish_time];
115 116
     
116 117
     [self.iconView configViewWithIcons:model.thumb_up_imgs upCount:model.thumb_up_num];
117 118
     

+ 3 - 1
CAIPU/Main/Find(发现)/View/CPVideoCell.m

@@ -8,6 +8,7 @@
8 8
 
9 9
 #import "CPVideoCell.h"
10 10
 #import "CPFindIconView.h"
11
+#import "CPCommonTool.h"
11 12
 
12 13
 @interface CPVideoCell ()
13 14
 @property (nonatomic, strong) UIView *content;
@@ -118,7 +119,8 @@
118 119
 - (void)setModel:(CPFindModel *)model {
119 120
     _model = model;
120 121
     self.nickLabel.text = model.vest_name;
121
-    self.timeLabel.text = model.publish_time;
122
+    self.timeLabel.text = [CPCommonTool getDateWith:model.publish_time];
123
+  
122 124
     [self.videoImage sd_setImageWithURL:[NSURL URLWithString:model.publish_info.firstObject]];
123 125
     
124 126
     [self.iconView configViewWithIcons:model.thumb_up_imgs upCount:model.thumb_up_num];

+ 6 - 0
CAIPU/Main/Health(健康)/Controller/CPHealthViewController.m

@@ -21,6 +21,12 @@
21 21
 
22 22
 @implementation CPHealthViewController
23 23
 
24
+
25
+- (void)viewWillAppear:(BOOL)animated {
26
+    [super viewWillAppear:animated];
27
+    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
28
+}
29
+
24 30
 - (void)viewDidLoad {
25 31
     [super viewDidLoad];
26 32
     

+ 55 - 5
CAIPU/Main/Home(菜谱大全)/Controllers/CPHomeViewController.m

@@ -13,11 +13,14 @@
13 13
 #import "CPHomeListModel.h"
14 14
 #import "CPDetailViewController.h"
15 15
 #import "CPThemeCollectionCell.h"
16
+#import "CPHomeThemeModel.h"
17
+#import "CPThemeDetailController.h"
18
+#import "CPTimeViewController.h"
16 19
 
17 20
 static NSString *const homeIdentifier = @"homeIdentifier";
18 21
 static NSString *const themeIdentifier = @"themeIdentifier";
19 22
 
20
-@interface CPHomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,CPHomeHeaderViewDelegate>{
23
+@interface CPHomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,CPHomeHeaderViewDelegate,CPThemeCollectionCellDelegate>{
21 24
     NSInteger _page;
22 25
 }
23 26
 
@@ -29,6 +32,7 @@ static NSString *const themeIdentifier = @"themeIdentifier";
29 32
 
30 33
 @property (nonatomic, strong) UICollectionReusableView *headerView;
31 34
 @property (nonatomic, strong) UICollectionReusableView *sectionHeader;
35
+@property (nonatomic, strong) NSMutableArray *themeList;
32 36
 @end
33 37
 
34 38
 @implementation CPHomeViewController
@@ -42,6 +46,7 @@ static NSString *const themeIdentifier = @"themeIdentifier";
42 46
     [self createNav];
43 47
     [self createView];
44 48
     [self requestData:@(_page)];
49
+    [self requestThemeData];
45 50
 }
46 51
 
47 52
 - (void)viewWillAppear:(BOOL)animated{
@@ -73,9 +78,6 @@ static NSString *const themeIdentifier = @"themeIdentifier";
73 78
 - (void)createView{
74 79
     
75 80
     UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
76
-//    flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 30) / 2, 220*SCREEN_MUTI);
77
-//    flowLayout.minimumLineSpacing = 10;
78
-//    flowLayout.minimumInteritemSpacing = 5;
79 81
     UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NavHeight - TabbarHeight) collectionViewLayout:flowLayout];
80 82
     self.collectionView = collectionView;
81 83
     collectionView.backgroundColor = [UIColor backgroudColor];
@@ -125,6 +127,26 @@ static NSString *const themeIdentifier = @"themeIdentifier";
125 127
     }];
126 128
 }
127 129
 
130
+
131
+/**
132
+ 加载主题的数据
133
+ */
134
+- (void)requestThemeData {
135
+    
136
+    NSString *urlString = [NSString stringWithFormat:@"%@/features/otherTheme",URL];
137
+    [CPHTTP post:urlString params:nil success:^(id json) {
138
+        
139
+        NSArray *list = [NSArray yy_modelArrayWithClass:[CPHomeThemeModel class] json:json];
140
+        [self.themeList addObjectsFromArray:list];
141
+        
142
+        [self.collectionView reloadData];
143
+    } failure:^(NSError *error) {
144
+        
145
+    }];
146
+    
147
+}
148
+
149
+
128 150
 - (void)searchAction{
129 151
    
130 152
     CPSearchViewController *search = [[CPSearchViewController alloc]init];
@@ -142,7 +164,7 @@ static NSString *const themeIdentifier = @"themeIdentifier";
142 164
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
143 165
 {
144 166
     if (section == 0) {
145
-        return 3;
167
+        return self.themeList.count;
146 168
     }
147 169
     return self.dataSource.count;
148 170
 }
@@ -177,6 +199,7 @@ static NSString *const themeIdentifier = @"themeIdentifier";
177 199
     
178 200
     if (indexPath.section == 0) {
179 201
         CPThemeCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:themeIdentifier forIndexPath:indexPath];
202
+        cell.delegate = self;
180 203
         return cell;
181 204
     }
182 205
     
@@ -259,6 +282,24 @@ static NSString *const themeIdentifier = @"themeIdentifier";
259 282
  热门推荐 查看全部
260 283
  */
261 284
 - (void)allAction {
285
+    CPTimeViewController *time = [[CPTimeViewController alloc] init];
286
+    [self.navigationController pushViewController:time animated:YES];
287
+}
288
+
289
+#pragma mark ------------- CPThemeCollectionCellDelegate-----
290
+
291
+/**
292
+ 主题查看全部
293
+*/
294
+- (void)CPThemeCollectionCellClickAll:(CPHomeThemeModel *)model {
295
+    CPThemeDetailController *detail = [[CPThemeDetailController alloc] init];
296
+    [self.navigationController pushViewController:detail animated:YES];
297
+}
298
+
299
+/**
300
+ 点击主题里的商品
301
+ */
302
+- (void)CPThemeCollectionCellDidClickItemAtIndex:(NSInteger)index model:(CPHomeListModel *)model {
262 303
     
263 304
 }
264 305
 
@@ -283,6 +324,13 @@ static NSString *const themeIdentifier = @"themeIdentifier";
283 324
     return _dataSource;
284 325
 }
285 326
 
327
+- (NSMutableArray *)themeList {
328
+    if (!_themeList) {
329
+        _themeList = [NSMutableArray array];
330
+    }
331
+    return _themeList;
332
+}
333
+
286 334
 - (void)didReceiveMemoryWarning {
287 335
     [super didReceiveMemoryWarning];
288 336
     // Dispose of any resources that can be recreated.
@@ -298,4 +346,6 @@ static NSString *const themeIdentifier = @"themeIdentifier";
298 346
 }
299 347
 */
300 348
 
349
+
350
+
301 351
 @end

+ 2 - 1
CAIPU/Main/Home(菜谱大全)/Controllers/CPThemeDetailController.h

@@ -8,7 +8,8 @@
8 8
 
9 9
 #import <UIKit/UIKit.h>
10 10
 #import "CPBaseViewController.h"
11
+#import "CPHomeThemeModel.h"
11 12
 
12 13
 @interface CPThemeDetailController : CPBaseViewController
13
-
14
+@property (nonatomic, strong) CPHomeThemeModel *themeModel;
14 15
 @end

+ 3 - 2
CAIPU/Main/Home(菜谱大全)/Controllers/CPThemeDetailController.m

@@ -109,7 +109,7 @@ static NSString *const homeIdentifier = @"homeIdentifier";
109 109
 
110 110
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
111 111
 {
112
-    return 10;
112
+    return self.themeModel.menuList.count;
113 113
 }
114 114
 
115 115
 
@@ -118,7 +118,9 @@ static NSString *const homeIdentifier = @"homeIdentifier";
118 118
 - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
119 119
 {
120 120
     
121
+    CPHomeListModel *model = self.themeModel.menuList[indexPath.row];
121 122
     CPChoiceCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:homeIdentifier forIndexPath:indexPath];
123
+    cell.listModel = model;
122 124
     return cell;
123 125
 }
124 126
 
@@ -132,7 +134,6 @@ static NSString *const homeIdentifier = @"homeIdentifier";
132 134
 }
133 135
 
134 136
 - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
135
-    NSLog(@"333");
136 137
 }
137 138
 - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(8_0) {
138 139
     self.collectionView.height = self.collectionView.contentSize.height;

+ 15 - 0
CAIPU/Main/Home(菜谱大全)/Controllers/CPTimeSegViewController.h

@@ -0,0 +1,15 @@
1
+//
2
+//  CPTimeSegViewController.h
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+#import "CPBaseViewController.h"
11
+@interface CPTimeSegViewController : CPBaseViewController
12
+
13
+@property (nonatomic, copy) NSString *themeId;
14
+
15
+@end

+ 184 - 0
CAIPU/Main/Home(菜谱大全)/Controllers/CPTimeSegViewController.m

@@ -0,0 +1,184 @@
1
+//
2
+//  CPTimeSegViewController.m
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import "CPTimeSegViewController.h"
10
+#import "CPChoiceCollectionViewCell.h"
11
+#import "CPDetailViewController.h"
12
+#import "CPHomeListModel.h"
13
+static NSString *timeCellID = @"timeCellID";
14
+static NSString *reusableHeader = @"reusableHeader";
15
+
16
+@interface CPTimeSegViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
17
+@property (nonatomic, strong) UICollectionView *collectionView;
18
+@property (nonatomic, strong) NSMutableArray *dataArr;
19
+@property (nonatomic, strong) UICollectionReusableView *header;
20
+@property (nonatomic, strong) CPHomeListModel *topModel;
21
+@end
22
+
23
+@implementation CPTimeSegViewController
24
+
25
+- (void)viewDidLoad {
26
+    [super viewDidLoad];
27
+    
28
+    [self requestData];
29
+    [self createView];
30
+   
31
+}
32
+
33
+- (void)createView{
34
+    
35
+    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
36
+    UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NavHeight) collectionViewLayout:flowLayout];
37
+    self.collectionView = collectionView;
38
+    flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 20 -5) / 2, 220*SCREEN_MUTI);
39
+    collectionView.backgroundColor = [UIColor backgroudColor];
40
+    [collectionView registerClass:[CPChoiceCollectionViewCell class] forCellWithReuseIdentifier:timeCellID];
41
+    
42
+    [collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
43
+    [collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"sectionHeader"];
44
+    collectionView.delegate = self;
45
+    collectionView.dataSource = self;
46
+     [collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:reusableHeader];
47
+    
48
+    //上拉加载
49
+    MJRefreshAutoNormalFooter *footer=[[MJRefreshAutoNormalFooter alloc]init];
50
+    [footer setRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
51
+    collectionView.mj_footer = footer;
52
+    [self.view addSubview:collectionView];
53
+}
54
+
55
+- (void)requestData {
56
+    
57
+    NSString *urlString = [NSString stringWithFormat:@"%@/features/menuList",URL];
58
+    NSDictionary *param = @{@"id":@""};
59
+    [CPHTTP post:urlString params:param success:^(id json) {
60
+        
61
+        NSArray *list = [NSArray yy_modelArrayWithClass:[CPHomeListModel class] json:json];
62
+        self.topModel = list.firstObject;
63
+        [self.dataArr addObjectsFromArray:list];
64
+        [self.dataArr removeObjectAtIndex:0];
65
+        
66
+        [self.collectionView reloadData];
67
+        
68
+    } failure:^(NSError *error) {
69
+        
70
+    }];
71
+}
72
+
73
+
74
+- (void)loadMoreData {
75
+    
76
+}
77
+
78
+
79
+#pragma mark ------------------ collectionView delegete -----------
80
+- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
81
+    return 1;
82
+}
83
+
84
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
85
+{
86
+    return self.dataArr.count;
87
+}
88
+
89
+
90
+- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
91
+   
92
+    return 10;
93
+}
94
+
95
+- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
96
+    return 5;
97
+}
98
+
99
+
100
+- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
101
+{
102
+    
103
+    CPHomeListModel *model = self.dataArr[indexPath.row];
104
+    CPChoiceCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:timeCellID forIndexPath:indexPath];
105
+    cell.listModel = model;
106
+    return cell;
107
+}
108
+
109
+- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
110
+{
111
+    
112
+    self.header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:reusableHeader forIndexPath:indexPath];
113
+    
114
+    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH-20, (SCREEN_WIDTH-20)*9/16)];
115
+    imgView.userInteractionEnabled = YES;
116
+    [imgView sd_setImageWithURL:[NSURL URLWithString:self.topModel.url] placeholderImage:Placehold_Img];
117
+    [self.header addSubview:imgView];
118
+    
119
+    UILabel *label = [[UILabel alloc] initWithFrame:imgView.bounds];
120
+    NSMutableParagraphStyle  *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
121
+    [paragraphStyle  setLineSpacing:8];
122
+    
123
+    NSString  *testString = @"设置Label的行间距设置Label的行间距设置Label的行间距设置Label的行间距设置Label的行间距设置Label的行间距设置";
124
+    NSMutableAttributedString  *setString = [[NSMutableAttributedString alloc] initWithString:testString];
125
+    [setString  addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [testString length])];
126
+    [label  setAttributedText:setString];
127
+    label.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
128
+    label.textAlignment = NSTextAlignmentCenter;
129
+    label.font = [UIFont boldSystemFontOfSize:16];
130
+    label.textColor = [UIColor whiteColor];
131
+    label.numberOfLines = 0;
132
+    [imgView addSubview:label];
133
+    [self.header addSubview:imgView];
134
+    
135
+    UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imgView.frame), SCREEN_WIDTH, 60)];
136
+    titleLb.text = @"—————— 往期精选 —————— ";
137
+    titleLb.textAlignment = NSTextAlignmentCenter;
138
+    titleLb.font = [UIFont systemFontOfSize:15];
139
+    titleLb.textColor = [UIColor middleTitleColor];
140
+    [self.header addSubview:titleLb];
141
+    
142
+    
143
+    
144
+    
145
+    return self.header;
146
+    
147
+}
148
+
149
+- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
150
+{
151
+    return CGSizeMake(SCREEN_WIDTH, (SCREEN_WIDTH-20)*9/16+10+60);
152
+    
153
+}
154
+
155
+- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
156
+    CPHomeListModel *model = self.dataArr[indexPath.row];
157
+    CPDetailViewController *detail = [[CPDetailViewController alloc]init];
158
+    detail.menu_id = model.Id;
159
+    [self.navigationController pushViewController:detail animated:YES];
160
+}
161
+
162
+-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
163
+{
164
+    return UIEdgeInsetsMake(0, 10, 0, 10);
165
+    
166
+}
167
+
168
+
169
+- (void)didReceiveMemoryWarning {
170
+    [super didReceiveMemoryWarning];
171
+    // Dispose of any resources that can be recreated.
172
+}
173
+
174
+/*
175
+#pragma mark - Navigation
176
+
177
+// In a storyboard-based application, you will often want to do a little preparation before navigation
178
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
179
+    // Get the new view controller using [segue destinationViewController].
180
+    // Pass the selected object to the new view controller.
181
+}
182
+*/
183
+
184
+@end

+ 14 - 0
CAIPU/Main/Home(菜谱大全)/Controllers/CPTimeViewController.h

@@ -0,0 +1,14 @@
1
+//
2
+//  CPTimeViewController.h
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+#import "CPBaseViewController.h"
11
+
12
+@interface CPTimeViewController : CPBaseViewController
13
+
14
+@end

+ 99 - 0
CAIPU/Main/Home(菜谱大全)/Controllers/CPTimeViewController.m

@@ -0,0 +1,99 @@
1
+//
2
+//  CPTimeViewController.m
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import "CPTimeViewController.h"
10
+#import "MLMSegmentHead.h"
11
+#import "MLMSegmentManager.h"
12
+#import "CPThemeDetailController.h"
13
+#import "CPTimeSegViewController.h"
14
+
15
+@interface CPTimeViewController ()<MLMSegmentHeadDelegate>
16
+@property (nonatomic, strong) MLMSegmentHead *titleView;
17
+@property (nonatomic, strong) MLMSegmentScroll *segScroll;
18
+@end
19
+
20
+@implementation CPTimeViewController
21
+
22
+- (void)viewDidLoad {
23
+    [super viewDidLoad];
24
+    
25
+    [self createNav];
26
+    [self configNavigationBar];
27
+}
28
+
29
+-(void)createNav{
30
+    
31
+    [self addLeftBarButtonItemWithImageName:@"home_back" title:nil target:self selector:@selector(backAction)];
32
+    if (@available(iOS 11.0, *)) {
33
+        self.segScroll.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
34
+    }else {
35
+        self.automaticallyAdjustsScrollViewInsets = NO;
36
+    }
37
+}
38
+
39
+-(void)backAction{
40
+    
41
+    [self.navigationController popViewControllerAnimated:YES];
42
+}
43
+
44
+- (void)configNavigationBar {
45
+    self.view.backgroundColor = [UIColor whiteColor];
46
+    
47
+    
48
+    NSArray *titles = @[@"早餐",@"午餐",@"晚餐"];
49
+    
50
+    NSMutableArray *list = [NSMutableArray array];
51
+    for (int i = 0; i < titles.count; i++) {
52
+        CPTimeSegViewController *seg = [[CPTimeSegViewController alloc] init];
53
+        
54
+        [list addObject:seg];
55
+    }
56
+    self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeight) vcOrViews:list];
57
+    self.segScroll.loadAll = YES;
58
+    self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-100, 44) titles:titles headStyle:SegmentHeadStyleArrow layoutStyle:MLMSegmentLayoutCenter];
59
+    self.titleView.headColor = [UIColor clearColor];
60
+    self.titleView.fontScale = 1.2;
61
+    self.titleView.fontSize = 14;
62
+    self.titleView.lineScale = .8;
63
+    self.titleView.arrowColor = [UIColor CPColorWithHex:0xff442a];
64
+    self.titleView.equalSize = YES;
65
+    self.titleView.bottomLineHeight = 0;
66
+    self.titleView.lineColor = [UIColor CPColorWithHex:0xff442a];
67
+    self.titleView.selectColor = [UIColor CPColorWithHex:0xff442a];
68
+    self.titleView.deSelectColor = [UIColor CPColorWithHex:0x666666];
69
+    [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
70
+        self.navigationItem.titleView = self.titleView;
71
+        [self.view addSubview:self.segScroll];
72
+    }];
73
+    
74
+    
75
+}
76
+
77
+#pragma mark --------------------- MLMSegmentHeadDelegate ---------
78
+
79
+- (void)didSelectedIndex:(NSInteger)index {
80
+    
81
+}
82
+
83
+
84
+- (void)didReceiveMemoryWarning {
85
+    [super didReceiveMemoryWarning];
86
+    // Dispose of any resources that can be recreated.
87
+}
88
+
89
+/*
90
+#pragma mark - Navigation
91
+
92
+// In a storyboard-based application, you will often want to do a little preparation before navigation
93
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
94
+    // Get the new view controller using [segue destinationViewController].
95
+    // Pass the selected object to the new view controller.
96
+}
97
+*/
98
+
99
+@end

+ 2 - 2
CAIPU/Main/Home(菜谱大全)/Models/CPBannerModel.h

@@ -13,6 +13,6 @@
13 13
 @property (nonatomic, strong) NSNumber *Id;
14 14
 @property (nonatomic, copy)   NSString *title;             //轮播用
15 15
 @property (nonatomic, copy)   NSString *url;
16
-@property (nonatomic, copy)   NSString *name;              //热门用
17
-
16
+@property (nonatomic, copy)   NSString *name;
17
+@property (nonatomic, copy)   NSString *display_position;//1、2、3 对应 早、午、晚
18 18
 @end

+ 20 - 0
CAIPU/Main/Home(菜谱大全)/Models/CPHomeThemeModel.h

@@ -0,0 +1,20 @@
1
+//
2
+//  CPHomeThemeModel.h
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+#import "CPHomeListModel.h"
11
+
12
+@interface CPHomeThemeModel : NSObject
13
+
14
+@property (nonatomic, strong) NSString *Id;
15
+@property (nonatomic, strong) NSString *title;
16
+@property (nonatomic, strong) NSString *url;
17
+@property (nonatomic, strong) NSString *intro;
18
+@property (nonatomic, strong) NSArray <CPHomeListModel *>*menuList;
19
+
20
+@end

+ 15 - 0
CAIPU/Main/Home(菜谱大全)/Models/CPHomeThemeModel.m

@@ -0,0 +1,15 @@
1
+//
2
+//  CPHomeThemeModel.m
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import "CPHomeThemeModel.h"
10
+
11
+@implementation CPHomeThemeModel
12
++ (NSDictionary *)modelCustomPropertyMapper {
13
+    return @{@"Id" : @"id"};
14
+}
15
+@end

+ 2 - 2
CAIPU/Main/Home(菜谱大全)/Views/CPHomeHeaderView.m

@@ -88,8 +88,8 @@
88 88
         for (CPBannerModel *model in array) {
89 89
             [self.bannerArray addObject:model];
90 90
         }
91
-        CPBannerModel *model = self.bannerArray[0];
92
-        [self.titleButton setTitle:model.title forState:UIControlStateNormal];
91
+//        CPBannerModel *model = self.bannerArray[0];
92
+//        [self.titleButton setTitle:model.title forState:UIControlStateNormal];
93 93
         [self.bannerView reloadData];
94 94
     }];
95 95
 }

+ 13 - 2
CAIPU/Main/Home(菜谱大全)/Views/CPThemeCollectionCell.h

@@ -7,16 +7,27 @@
7 7
 //
8 8
 
9 9
 #import <UIKit/UIKit.h>
10
+#import "CPHomeThemeModel.h"
11
+#import "CPHomeListModel.h"
12
+
13
+@protocol CPThemeCollectionCellDelegate<NSObject>
14
+
15
+- (void)CPThemeCollectionCellClickAll:(CPHomeThemeModel *)model;
16
+- (void)CPThemeCollectionCellDidClickItemAtIndex:(NSInteger)index model:(CPHomeListModel *)model;
10 17
 
11
-@interface CPThemeCollectionCell : UICollectionViewCell
12 18
 
13 19
 @end
14 20
 
21
+@interface CPThemeCollectionCell : UICollectionViewCell
22
+@property (nonatomic, strong) CPHomeThemeModel *themeModel;
23
+@property (nonatomic, weak) id <CPThemeCollectionCellDelegate> delegate;
24
+@end
25
+
15 26
 
16 27
 
17 28
 #pragma mark --============cell=========
18 29
 
19 30
 @interface CPThemeItem : UICollectionViewCell
20
-
31
+@property (nonatomic, strong) CPHomeListModel *listModel;
21 32
 
22 33
 @end

+ 22 - 3
CAIPU/Main/Home(菜谱大全)/Views/CPThemeCollectionCell.m

@@ -13,6 +13,7 @@
13 13
 @property (nonatomic, strong) UILabel *titleLabel;
14 14
 @property (nonatomic, strong) UICollectionView *collectionView;
15 15
 @property (nonatomic, strong) UILabel *allButton;
16
+@property (nonatomic, strong) NSArray *dataArr;
16 17
 
17 18
 @end
18 19
 
@@ -62,22 +63,34 @@
62 63
 }
63 64
 
64 65
 
66
+- (void)setThemeModel:(CPHomeThemeModel *)themeModel {
67
+    _themeModel = themeModel;
68
+    self.titleLabel.text = themeModel.title;
69
+    self.dataArr = themeModel.menuList.mutableCopy;
70
+    [self.collectionView reloadData];
71
+}
72
+
73
+
65 74
 #pragma mark -----------------
66 75
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
67 76
 {
68
-    return 10;
77
+    return self.dataArr.count;
69 78
 }
70 79
 
71 80
 - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
72 81
 {
73 82
     CPThemeItem *item = [collectionView dequeueReusableCellWithReuseIdentifier:@"CPThemeItem" forIndexPath:indexPath];
74
-    
83
+    CPHomeListModel *listModel = self.dataArr[indexPath.row];
84
+    item.listModel = listModel;
75 85
     return item;
76 86
 }
77 87
 
78 88
 
79 89
 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
80
-   
90
+    if (self.delegate && [self.delegate respondsToSelector:@selector(CPThemeCollectionCellDidClickItemAtIndex:model:)]) {
91
+        CPHomeListModel *model = self.dataArr[indexPath.row];
92
+        [self.delegate CPThemeCollectionCellDidClickItemAtIndex:indexPath.row model:model];
93
+    }
81 94
 }
82 95
 
83 96
 @end
@@ -119,6 +132,12 @@
119 132
     }];
120 133
 }
121 134
 
135
+- (void)setListModel:(CPHomeListModel *)listModel {
136
+    _listModel = listModel;
137
+    [self.imageView sd_setImageWithURL:[NSURL URLWithString:listModel.url] placeholderImage:Placehold_Img];
138
+    self.titleLabel.text = listModel.title;
139
+}
140
+
122 141
 - (UIImageView *)imageView {
123 142
     if (!_imageView) {
124 143
         _imageView = [[UIImageView alloc] init];

+ 15 - 0
CAIPU/Main/Tools(工具)/CPCommonTool.h

@@ -0,0 +1,15 @@
1
+//
2
+//  CPCommonTool.h
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+
11
+@interface CPCommonTool : NSObject
12
+//时间戳转多久前
13
++ (NSString *)getDateWith:(NSString *)ctime;
14
+
15
+@end

+ 115 - 0
CAIPU/Main/Tools(工具)/CPCommonTool.m

@@ -0,0 +1,115 @@
1
+//
2
+//  CPCommonTool.m
3
+//  CAIPU
4
+//
5
+//  Created by 小花 on 2018/4/13.
6
+//  Copyright © 2018年 kuxuan. All rights reserved.
7
+//
8
+
9
+#import "CPCommonTool.h"
10
+
11
+@implementation CPCommonTool
12
+
13
++ (NSString *)getDateWith:(NSString *)ctime {
14
+    
15
+    
16
+    
17
+    NSTimeInterval time=[ctime doubleValue];
18
+    
19
+    
20
+    NSDate * detaildate=[NSDate dateWithTimeIntervalSince1970:time];
21
+    
22
+    
23
+    NSString *currentDateStr = [self dateToNSString:detaildate];
24
+    
25
+    
26
+    return currentDateStr;
27
+    
28
+}
29
+
30
++(NSString*)dateToNSString:(NSDate*)date
31
+
32
+{
33
+
34
+    NSTimeInterval late = [date timeIntervalSince1970]*1;
35
+    
36
+    NSString * timeString = nil;
37
+    
38
+    NSDate * dat = [NSDate dateWithTimeIntervalSinceNow:0];
39
+    
40
+    NSTimeInterval now = [dat timeIntervalSince1970]*1;
41
+    
42
+    NSTimeInterval cha = now - late;
43
+    if (cha/3600 < 1) {
44
+        
45
+        timeString = [NSString stringWithFormat:@"%f", cha/60];
46
+        
47
+        timeString = [timeString substringToIndex:timeString.length-7];
48
+        
49
+        int num= [timeString intValue];
50
+        
51
+        if (num <= 1) {
52
+            
53
+            timeString = [NSString stringWithFormat:@"刚刚"];
54
+            
55
+        }else{
56
+            
57
+            timeString = [NSString stringWithFormat:@"%@分钟前", timeString];
58
+            
59
+        }
60
+        
61
+    }
62
+    
63
+    if (cha/3600 > 1 && cha/86400 < 1) {
64
+        
65
+        timeString = [NSString stringWithFormat:@"%f", cha/3600];
66
+        
67
+        timeString = [timeString substringToIndex:timeString.length-7];
68
+        
69
+        timeString = [NSString stringWithFormat:@"%@小时前", timeString];
70
+        
71
+    }
72
+    
73
+    if (cha/86400 > 1)
74
+        
75
+    {
76
+        
77
+        timeString = [NSString stringWithFormat:@"%f", cha/86400];
78
+        
79
+        timeString = [timeString substringToIndex:timeString.length-7];
80
+        
81
+        int num = [timeString intValue];
82
+        
83
+        if (num < 2) {
84
+            
85
+            timeString = [NSString stringWithFormat:@"昨天"];
86
+            
87
+        }else if(num == 2){
88
+            
89
+            timeString = [NSString stringWithFormat:@"前天"];
90
+            
91
+        }else if (num > 2 && num <7){
92
+            
93
+            timeString = [NSString stringWithFormat:@"%@天前", timeString];
94
+            
95
+        }
96
+        else if (num >= 7 && num <= 10) {
97
+        
98
+            timeString = [NSString stringWithFormat:@"1周前"];
99
+        
100
+        }
101
+        else if(num >= 7){
102
+            
103
+            timeString = [NSString stringWithFormat:@"%@天前", timeString];
104
+            
105
+        }
106
+        
107
+    }
108
+    
109
+    
110
+    
111
+    return timeString;
112
+}
113
+
114
+
115
+@end