Commit 3f3eafb5 cgx

完成首页轮播图数据对接

1 个父辈 dc159ebd
正在显示 35 个修改的文件 包含 221 行增加231 行删除
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECC727F2E97A003EDFE3 /* MacroFuncUtil.m */; }; D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECC727F2E97A003EDFE3 /* MacroFuncUtil.m */; };
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; }; D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; };
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; }; D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; };
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BE32E52814D42B006539BE /* HomeRequestModel.m */; };
D0C09ED728007D9100709D4C /* relax_normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED328007D9100709D4C /* relax_normal_lottie.json */; }; D0C09ED728007D9100709D4C /* relax_normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED328007D9100709D4C /* relax_normal_lottie.json */; };
D0C09ED828007D9100709D4C /* 478_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED428007D9100709D4C /* 478_lottie.json */; }; D0C09ED828007D9100709D4C /* 478_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED428007D9100709D4C /* 478_lottie.json */; };
D0C09ED928007D9100709D4C /* 478normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED528007D9100709D4C /* 478normal_lottie.json */; }; D0C09ED928007D9100709D4C /* 478normal_lottie.json in Resources */ = {isa = PBXBuildFile; fileRef = D0C09ED528007D9100709D4C /* 478normal_lottie.json */; };
...@@ -98,6 +99,7 @@ ...@@ -98,6 +99,7 @@
D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; }; D0CFD3D027FB3B920002982B /* launcher@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CD27FB3B910002982B /* launcher@3x.png */; };
D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; }; D0CFD3D127FB3B920002982B /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = D0CFD3CE27FB3B920002982B /* launcher.png */; };
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D3826628124E8A005BB219 /* FeedbackController.m */; }; D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D3826628124E8A005BB219 /* FeedbackController.m */; };
D0DF90AE2814390000FC0F64 /* BannerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DF90AD2814390000FC0F64 /* BannerModel.m */; };
D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */; }; D0E65FFA2807A654006562F2 /* NSArray+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */; };
D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */; }; D0E65FFB2807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */; };
D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */; }; D0E65FFC2807A654006562F2 /* NSSet+HYBUnicodeReadable.m in Sources */ = {isa = PBXBuildFile; fileRef = D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */; };
...@@ -262,6 +264,8 @@ ...@@ -262,6 +264,8 @@
D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AdaptationUtil.m; sourceTree = "<group>"; }; D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AdaptationUtil.m; sourceTree = "<group>"; };
D0B5ECD627F2F1B0003EDFE3 /* ServerAPIUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServerAPIUtil.h; sourceTree = "<group>"; }; D0B5ECD627F2F1B0003EDFE3 /* ServerAPIUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServerAPIUtil.h; sourceTree = "<group>"; };
D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; }; D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; };
D0BE32E42814D42B006539BE /* HomeRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRequestModel.h; sourceTree = "<group>"; };
D0BE32E52814D42B006539BE /* HomeRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRequestModel.m; sourceTree = "<group>"; };
D0C09ED328007D9100709D4C /* relax_normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = relax_normal_lottie.json; sourceTree = "<group>"; }; D0C09ED328007D9100709D4C /* relax_normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = relax_normal_lottie.json; sourceTree = "<group>"; };
D0C09ED428007D9100709D4C /* 478_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478_lottie.json; sourceTree = "<group>"; }; D0C09ED428007D9100709D4C /* 478_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478_lottie.json; sourceTree = "<group>"; };
D0C09ED528007D9100709D4C /* 478normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478normal_lottie.json; sourceTree = "<group>"; }; D0C09ED528007D9100709D4C /* 478normal_lottie.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = 478normal_lottie.json; sourceTree = "<group>"; };
...@@ -287,6 +291,9 @@ ...@@ -287,6 +291,9 @@
D0D3826628124E8A005BB219 /* FeedbackController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackController.m; sourceTree = "<group>"; }; D0D3826628124E8A005BB219 /* FeedbackController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedbackController.m; sourceTree = "<group>"; };
D0D7480328118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; }; D0D7480328118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
D0D7480428118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; }; D0D7480428118D0B00036379 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
D0DF90AB28142F1300FC0F64 /* DreamSleepDebug.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = DreamSleepDebug.entitlements; sourceTree = "<group>"; };
D0DF90AC2814390000FC0F64 /* BannerModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BannerModel.h; sourceTree = "<group>"; };
D0DF90AD2814390000FC0F64 /* BannerModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BannerModel.m; sourceTree = "<group>"; };
D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+HYBUnicodeReadable.m"; sourceTree = "<group>"; }; D0E65FF42807A654006562F2 /* NSArray+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+HYBUnicodeReadable.m"; sourceTree = "<group>"; }; D0E65FF52807A654006562F2 /* NSDictionary+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSet+HYBUnicodeReadable.m"; sourceTree = "<group>"; }; D0E65FF62807A654006562F2 /* NSSet+HYBUnicodeReadable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSet+HYBUnicodeReadable.m"; sourceTree = "<group>"; };
...@@ -301,7 +308,6 @@ ...@@ -301,7 +308,6 @@
D0E660042807D02C006562F2 /* UserRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UserRequestModel.m; sourceTree = "<group>"; }; D0E660042807D02C006562F2 /* UserRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UserRequestModel.m; sourceTree = "<group>"; };
D0E6600628080F97006562F2 /* SystemSetController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemSetController.h; sourceTree = "<group>"; }; D0E6600628080F97006562F2 /* SystemSetController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemSetController.h; sourceTree = "<group>"; };
D0E6600728080F97006562F2 /* SystemSetController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SystemSetController.m; sourceTree = "<group>"; }; D0E6600728080F97006562F2 /* SystemSetController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SystemSetController.m; sourceTree = "<group>"; };
D0F808ED2803C83A0097899F /* DreamSleepDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DreamSleepDebug.entitlements; sourceTree = "<group>"; };
D0F808F32803D4E70097899F /* Track.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Track.m; sourceTree = "<group>"; }; D0F808F32803D4E70097899F /* Track.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Track.m; sourceTree = "<group>"; };
D0F808F42803D4E70097899F /* Track.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Track.h; sourceTree = "<group>"; }; D0F808F42803D4E70097899F /* Track.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Track.h; sourceTree = "<group>"; };
D0F808FC280421C20097899F /* ThreeMinuteController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThreeMinuteController.h; sourceTree = "<group>"; }; D0F808FC280421C20097899F /* ThreeMinuteController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThreeMinuteController.h; sourceTree = "<group>"; };
...@@ -668,7 +674,7 @@ ...@@ -668,7 +674,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D091BBB82809024100487A50 /* DreamSleepBeta.entitlements */, D091BBB82809024100487A50 /* DreamSleepBeta.entitlements */,
D0F808ED2803C83A0097899F /* DreamSleepDebug.entitlements */, D0DF90AB28142F1300FC0F64 /* DreamSleepDebug.entitlements */,
D04567AA27F6D067009F0A82 /* Main */, D04567AA27F6D067009F0A82 /* Main */,
D04567AB27F6D0A5009F0A82 /* HomeModule */, D04567AB27F6D0A5009F0A82 /* HomeModule */,
D04567AC27F6D0BA009F0A82 /* AISleepCoach */, D04567AC27F6D0BA009F0A82 /* AISleepCoach */,
...@@ -845,6 +851,10 @@ ...@@ -845,6 +851,10 @@
D0506B1428051ED400229278 /* SafeSleepModel.m */, D0506B1428051ED400229278 /* SafeSleepModel.m */,
D0E660012807B5AE006562F2 /* SafeSleepRequestModel.h */, D0E660012807B5AE006562F2 /* SafeSleepRequestModel.h */,
D0E660002807B5AE006562F2 /* SafeSleepRequestModel.m */, D0E660002807B5AE006562F2 /* SafeSleepRequestModel.m */,
D0DF90AC2814390000FC0F64 /* BannerModel.h */,
D0DF90AD2814390000FC0F64 /* BannerModel.m */,
D0BE32E42814D42B006539BE /* HomeRequestModel.h */,
D0BE32E52814D42B006539BE /* HomeRequestModel.m */,
); );
path = Model; path = Model;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1021,11 +1031,13 @@ ...@@ -1021,11 +1031,13 @@
D0506B0C280503A800229278 /* UIButton+Extras.m in Sources */, D0506B0C280503A800229278 /* UIButton+Extras.m in Sources */,
D0C50B3F27FD381000DC68F0 /* UIView+Extras.m in Sources */, D0C50B3F27FD381000DC68F0 /* UIView+Extras.m in Sources */,
D07DAC902810546A0067A1BF /* DSImagePickerController.m in Sources */, D07DAC902810546A0067A1BF /* DSImagePickerController.m in Sources */,
D0DF90AE2814390000FC0F64 /* BannerModel.m in Sources */,
D0E65FFF2807AC5E006562F2 /* DSProgressHUD.m in Sources */, D0E65FFF2807AC5E006562F2 /* DSProgressHUD.m in Sources */,
D0E660022807B5AE006562F2 /* SafeSleepRequestModel.m in Sources */, D0E660022807B5AE006562F2 /* SafeSleepRequestModel.m in Sources */,
D0E6600828080F97006562F2 /* SystemSetController.m in Sources */, D0E6600828080F97006562F2 /* SystemSetController.m in Sources */,
D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */, D091BBB72808F9DA00487A50 /* BreathTextView.m in Sources */,
D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */, D04B3DBB27F6F7940022F8DF /* AISleepCoachController.m in Sources */,
D0BE32E62814D42B006539BE /* HomeRequestModel.m in Sources */,
D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */, D0D3826728124E8A005BB219 /* FeedbackController.m in Sources */,
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */, D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */,
D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */, D0C09EE028007E5F00709D4C /* BreatheController.m in Sources */,
......
//
// BannerModel.h
// DreamSleep
//
// Created by peter on 2022/4/23.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 首页barnner数据model
@interface BannerModel : NSObject
@property (nonatomic, assign) int banner_id;
// banner图名称
@property (nonatomic, copy) NSString *banner_name;
// banner图片url
@property (nonatomic, copy) NSString *banner_url;
// banner图排序权重
@property (nonatomic, assign) int order_value;
// banner图文章详情页链接
@property (nonatomic, copy) NSString *info_url;
// banner图描述
@property (nonatomic, copy) NSString *banner_desc;
@end
NS_ASSUME_NONNULL_END
//
// BannerModel.m
// DreamSleep
//
// Created by peter on 2022/4/23.
//
#import "BannerModel.h"
@implementation BannerModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"banner_id" : @"id"};
}
@end
...@@ -11,7 +11,6 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -11,7 +11,6 @@ NS_ASSUME_NONNULL_BEGIN
/// HomeHeaderView和DsMiddleView数据model /// HomeHeaderView和DsMiddleView数据model
@interface HeaderDataModel : NSObject @interface HeaderDataModel : NSObject
+ (NSArray *)getCarouselImages;
+ (NSArray *)getDsMiddleImages; + (NSArray *)getDsMiddleImages;
@end @end
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#import "HeaderDataModel.h" #import "HeaderDataModel.h"
@implementation HeaderDataModel @implementation HeaderDataModel
+ (NSArray *)getCarouselImages {
return @[@"banner1", @"banner2", @"banner3", @"banner4"];;
}
+ (NSArray *)getDsMiddleImages { + (NSArray *)getDsMiddleImages {
return @[@"btn_home_qpsleep_normal", @"btn_home_jhrelax_normal", @"btn_home_478relax_normal"];; return @[@"btn_home_qpsleep_normal", @"btn_home_jhrelax_normal", @"btn_home_478relax_normal"];;
} }
......
//
// HomeRequestModel.h
// DreamSleep
//
// Created by peter on 2022/4/24.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
@interface HomeRequestModel : DSNetworkTool
/// banner列表数据
@property (nonatomic, strong) NSArray *bannerListData;
/// 获取banner列表数据
/// @param completion completion
+ (NSURLSessionDataTask *)queryBannerListWithCompletion:(void (^)(HomeRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// HomeRequestModel.m
// DreamSleep
//
// Created by peter on 2022/4/24.
//
#import "HomeRequestModel.h"
#import "BannerModel.h"
@implementation HomeRequestModel
+ (NSURLSessionDataTask *)queryBannerListWithCompletion:(void (^)(HomeRequestModel *requestModel))completion {
HomeRequestModel * requestModel = [[HomeRequestModel alloc] init];
NSString *api = @"query_ssmian_banner_list";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"获取首页banner列表接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSArray *resultArr = apiDic[@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < resultArr.count; i++) {
BannerModel *bannerModel = [BannerModel yy_modelWithJSON:resultArr[i]];
[tmpArr addObject:bannerModel];
}
requestModel.bannerListData = [tmpArr copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = DSResCodeNetFail;
requestModel.errorInfo = failureInfo;
completion(requestModel);
}];
}
@end
...@@ -11,6 +11,11 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -11,6 +11,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 自定义首页头部 /// 自定义首页头部
@interface HomeHeaderView : UIView @interface HomeHeaderView : UIView
/// 更新banner列表数据
/// @param listData listData
- (void)updateBannerWithListData:(NSArray *)listData;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -6,16 +6,18 @@ ...@@ -6,16 +6,18 @@
// //
#import "HomeHeaderView.h" #import "HomeHeaderView.h"
#import "BannerModel.h"
#import "CWCarousel.h" #import "CWCarousel.h"
#import "CWPageControl.h" #import "CWPageControl.h"
#import "HeaderDataModel.h" #import "HeaderDataModel.h"
#import "DsMiddleView.h" #import "DsMiddleView.h"
#import "ThreeMinuteController.h" #import "ThreeMinuteController.h"
#import "PrivacyViewController.h"
@interface HomeHeaderView () <CWCarouselDatasource, CWCarouselDelegate> @interface HomeHeaderView () <CWCarouselDatasource, CWCarouselDelegate>
// 轮播图 // 轮播图
@property (nonatomic, strong) CWCarousel *barnnerView; @property (nonatomic, strong) CWCarousel *barnnerView;
@property (nonatomic, strong) NSArray *imgs; @property (nonatomic, strong) NSArray *bannerDatas;
@property (nonatomic, strong) DsMiddleView *dsMiddleView; @property (nonatomic, strong) DsMiddleView *dsMiddleView;
@end @end
...@@ -23,12 +25,8 @@ ...@@ -23,12 +25,8 @@
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
self.imgs = [HeaderDataModel getCarouselImages]; self.bannerDatas = [NSArray array];
[self addSubview:self.barnnerView]; [self addSubview:self.barnnerView];
dispatch_after(1, dispatch_get_main_queue(), ^{
[self.barnnerView freshCarousel];
});
[self addSubview:self.dsMiddleView]; [self addSubview:self.dsMiddleView];
} }
return self; return self;
...@@ -48,6 +46,68 @@ ...@@ -48,6 +46,68 @@
}]; }];
} }
#pragma mark - public
- (void)updateBannerWithListData:(NSArray *)listData {
self.bannerDatas = listData;
[self.barnnerView freshCarousel];
}
#pragma mark - CWCarouselDatasource
- (NSInteger)numbersForCarousel {
return self.bannerDatas.count;
}
#define TmpTag 666
- (UICollectionViewCell *)viewForCarousel:(CWCarousel *)carousel indexPath:(NSIndexPath *)indexPath index:(NSInteger)index {
UICollectionViewCell *cell = [carousel.carouselView dequeueReusableCellWithReuseIdentifier:@"barnnerCellID" forIndexPath:indexPath];
UIImageView *imgView = [cell.contentView viewWithTag:TmpTag];
if (!imgView) {
imgView = [[UIImageView alloc] initWithFrame:cell.contentView.bounds];
imgView.tag = TmpTag;
imgView.contentMode = UIViewContentModeScaleAspectFit;
[cell.contentView addSubview:imgView];
}
[imgView cornerRadius:16.0];
imgView.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, 1.0);
BannerModel *model = self.bannerDatas[index];
[imgView yy_setImageWithURL:[NSURL URLWithString:model.banner_url] placeholder:[UIImage imageNamed:@"bannerPlaceholder"]];
return cell;
}
#pragma mark - CWCarouselDelegate
- (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index {
// 判断是否登录成功
if ([LoginUtils getUserLoginData]) {
BannerModel *model = self.bannerDatas[index];
switch (model.banner_id) {
case 13: { // 进入失眠拯救计划页面
[self.ds_viewController.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"失眠拯救计划" link:[NSURL URLWithString:model.info_url] isDetail:YES] animated:YES];
}
break;
case 11: { // 切换到AI睡眠教练标签
self.ds_viewController.tabBarController.selectedIndex = 1;
}
break;
case 10: { // 进入三分钟即刻入睡页面
ThreeMinuteController *threeVC = [[ThreeMinuteController alloc] init];
[self.ds_viewController.navigationController pushViewController:threeVC animated:YES];
}
break;
case 8: { // 进入睡眠评测页面
[self.ds_viewController.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"睡眠评测" link:[NSURL URLWithString:model.info_url] isDetail:YES] animated:YES];
}
break;
default:
break;
}
} else {
// 跳转到登录页面
[LoginUtils jumpToLoginControllerWithTarget:self.ds_viewController];
}
}
#pragma mark - lazy
- (CWCarousel *)barnnerView { - (CWCarousel *)barnnerView {
if (!_barnnerView) { if (!_barnnerView) {
// 自定义布局 // 自定义布局
...@@ -56,7 +116,7 @@ ...@@ -56,7 +116,7 @@
flowLayout.itemSpace_H = 12; flowLayout.itemSpace_H = 12;
// 自定义pagecontrol // 自定义pagecontrol
CGFloat width = [CWPageControl widthFromNumber:self.imgs.count]; CGFloat width = [CWPageControl widthFromNumber:self.bannerDatas.count];
CWPageControl *pageC = [[CWPageControl alloc] initWithFrame:CGRectMake(0, 0, width, 20)]; CWPageControl *pageC = [[CWPageControl alloc] initWithFrame:CGRectMake(0, 0, width, 20)];
pageC.translatesAutoresizingMaskIntoConstraints = NO; pageC.translatesAutoresizingMaskIntoConstraints = NO;
[[pageC.widthAnchor constraintEqualToConstant:width] setActive:YES]; [[pageC.widthAnchor constraintEqualToConstant:width] setActive:YES];
...@@ -84,50 +144,4 @@ ...@@ -84,50 +144,4 @@
return _dsMiddleView; return _dsMiddleView;
} }
#pragma mark - CWCarouselDatasource
- (NSInteger)numbersForCarousel {
return self.imgs.count;
}
#define TmpTag 666
- (UICollectionViewCell *)viewForCarousel:(CWCarousel *)carousel indexPath:(NSIndexPath *)indexPath index:(NSInteger)index{
UICollectionViewCell *cell = [carousel.carouselView dequeueReusableCellWithReuseIdentifier:@"barnnerCellID" forIndexPath:indexPath];
UIImageView *imgView = [cell.contentView viewWithTag:TmpTag];
if (!imgView) {
imgView = [[UIImageView alloc] initWithFrame:cell.contentView.bounds];
imgView.tag = TmpTag;
imgView.contentMode = UIViewContentModeScaleAspectFit;
[cell.contentView addSubview:imgView];
}
[imgView setImage:[UIImage imageNamed:self.imgs[index]]];
// 通过alpha来控制夜间模式
// imgView.alpha = .5;
return cell;
}
#pragma mark - CWCarouselDelegate
- (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index {
DSLog(@"did selected at index %ld", index);
// 判断是否登录
// 登录成功跳转对应页面
switch (index) {
case 0:
break;
case 1: { // 进入三分钟即刻入睡页面
ThreeMinuteController *threeVC = [[ThreeMinuteController alloc] init];
[self.ds_viewController.navigationController pushViewController:threeVC animated:YES];
}
break;
case 2: { // 切换到AI睡眠教练标签
self.ds_viewController.tabBarController.selectedIndex = 1;
}
break;
case 3:
break;
default:
break;
}
}
@end @end
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "DSGifHeader.h" #import "DSGifHeader.h"
#import "HomeHeaderView.h" #import "HomeHeaderView.h"
#import "SafeSleepCell.h" #import "SafeSleepCell.h"
#import "HomeRequestModel.h"
#import "SafeSleepRequestModel.h" #import "SafeSleepRequestModel.h"
@interface HomeTableView () <UITableViewDelegate> @interface HomeTableView () <UITableViewDelegate>
...@@ -30,13 +31,20 @@ ...@@ -30,13 +31,20 @@
[self.homeDataSource addDataArray:[SafeSleepModel getDatas]]; [self.homeDataSource addDataArray:[SafeSleepModel getDatas]];
self.mj_header = [DSGifHeader headerWithRefreshingBlock:^{ self.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
[SafeSleepRequestModel getCourseListDataWithSubID:6 completion:^(SafeSleepRequestModel * _Nonnull requestModel) { [HomeRequestModel queryBannerListWithCompletion:^(HomeRequestModel * _Nonnull requestModel) {
[self.mj_header endRefreshing];
}];
[SafeSleepRequestModel getCourseListDataWithSubID:18 completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
[self.mj_header endRefreshing]; [self.mj_header endRefreshing];
if (requestModel.resCode == DSResCodeSuccess) {
[self.headerView updateBannerWithListData:requestModel.bannerListData];
}
}]; }];
// [SafeSleepRequestModel getCourseListDataWithSubID:6 completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [self.mj_header endRefreshing];
// }];
// [SafeSleepRequestModel getCourseListDataWithSubID:18 completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [self.mj_header endRefreshing];
// }];
}]; }];
[self.mj_header beginRefreshing];
} }
return self; return self;
} }
......
...@@ -120,11 +120,20 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络 ...@@ -120,11 +120,20 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络
} else { } else {
// 网络故障 // 网络故障
DSLog(@"失败错误信息:%@", error); DSLog(@"失败错误信息:%@", error);
if (error.code != -999) {
NSString *alerStr = NetworkUnableError;
if (error.code == -1011) {
alerStr = ServerError;
} else if (error.code == -1016) {
alerStr = ServerDataFormatError;
}
failure(alerStr);
if (hasFailInfo) { if (hasFailInfo) {
NSString *alertStr = [NSString stringWithFormat:@"%ld", error.code]; view ? [DSProgressHUD showDetailInfo:alerStr inView:view] : [DSProgressHUD showDetailInfo:alerStr];
view ? [DSProgressHUD showDetailInfo:alertStr inView:view] : [DSProgressHUD showDetailInfo:alertStr]; }
} else {
failure(NetworkCancel);
} }
failure(error);
} }
}]; }];
[dataTask resume]; [dataTask resume];
......
...@@ -15,6 +15,7 @@ static MBProgressHUD *hud; ...@@ -15,6 +15,7 @@ static MBProgressHUD *hud;
+ (void)showToast:(NSString *)message inView:(UIView *)view + (void)showToast:(NSString *)message inView:(UIView *)view
{ {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
[self adjustThemeWithHud:hud];
hud.mode = MBProgressHUDModeText; hud.mode = MBProgressHUDModeText;
hud.label.text = message; hud.label.text = message;
[hud hideAnimated:NO afterDelay:1.0]; [hud hideAnimated:NO afterDelay:1.0];
...@@ -23,9 +24,9 @@ static MBProgressHUD *hud; ...@@ -23,9 +24,9 @@ static MBProgressHUD *hud;
+ (void)showToast:(NSString *)message + (void)showToast:(NSString *)message
{ {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES];
[self adjustThemeWithHud:hud];
hud.mode = MBProgressHUDModeText; hud.mode = MBProgressHUDModeText;
hud.label.text = message; hud.label.text = message;
[self adjustThemeWithHud:hud];
[hud hideAnimated:NO afterDelay:1.0]; [hud hideAnimated:NO afterDelay:1.0];
} }
...@@ -42,6 +43,7 @@ static MBProgressHUD *hud; ...@@ -42,6 +43,7 @@ static MBProgressHUD *hud;
{ {
[self dissmissProgressHUD]; [self dissmissProgressHUD];
hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
[self adjustThemeWithHud:hud];
hud.label.text = NSLocalizedString(info, @""); hud.label.text = NSLocalizedString(info, @"");
return hud; return hud;
} }
...@@ -54,6 +56,7 @@ static MBProgressHUD *hud; ...@@ -54,6 +56,7 @@ static MBProgressHUD *hud;
+ (void)showDetailInfo:(NSString *)info + (void)showDetailInfo:(NSString *)info
{ {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES];
[self adjustThemeWithHud:hud];
hud.mode = MBProgressHUDModeText; hud.mode = MBProgressHUDModeText;
hud.removeFromSuperViewOnHide = YES; hud.removeFromSuperViewOnHide = YES;
hud.detailsLabel.text = info; hud.detailsLabel.text = info;
...@@ -64,6 +67,7 @@ static MBProgressHUD *hud; ...@@ -64,6 +67,7 @@ static MBProgressHUD *hud;
+ (void)showDetailInfo:(NSString *)info inView:(UIView *)view + (void)showDetailInfo:(NSString *)info inView:(UIView *)view
{ {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES];
[self adjustThemeWithHud:hud];
hud.mode = MBProgressHUDModeText; hud.mode = MBProgressHUDModeText;
hud.removeFromSuperViewOnHide = YES; hud.removeFromSuperViewOnHide = YES;
hud.detailsLabel.text = info; hud.detailsLabel.text = info;
...@@ -74,6 +78,7 @@ static MBProgressHUD *hud; ...@@ -74,6 +78,7 @@ static MBProgressHUD *hud;
+ (void)showDetailInfo:(NSString *)info delay:(NSTimeInterval)delay + (void)showDetailInfo:(NSString *)info delay:(NSTimeInterval)delay
{ {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:DSKeyWindow animated:YES];
[self adjustThemeWithHud:hud];
hud.mode = MBProgressHUDModeText; hud.mode = MBProgressHUDModeText;
hud.removeFromSuperViewOnHide = YES; hud.removeFromSuperViewOnHide = YES;
hud.detailsLabel.text = info; hud.detailsLabel.text = info;
...@@ -81,6 +86,7 @@ static MBProgressHUD *hud; ...@@ -81,6 +86,7 @@ static MBProgressHUD *hud;
[hud hideAnimated:NO afterDelay:delay]; [hud hideAnimated:NO afterDelay:delay];
} }
#pragma mark - 适配黑夜模式
+ (void)adjustThemeWithHud:(MBProgressHUD *)hud { + (void)adjustThemeWithHud:(MBProgressHUD *)hud {
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor; hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.bezelView.dk_backgroundColorPicker = DKColorPickerWithColors(DSBlack, DSWhite, DSWhite); hud.bezelView.dk_backgroundColorPicker = DKColorPickerWithColors(DSBlack, DSWhite, DSWhite);
......
//
// JWMImagePickerController.h
// Kacare_User
//
// Created by Jia Weimin on 2017/5/18.
// Copyright © 2017年 Linno. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger,ImagePickerStyle) {
ImagePickerStyleCamera,
ImagePickerStylePhotoLibrary
};
@protocol JWMImagePickerDelegate <NSObject>
@optional
- (void)jwmImagePickerImageFinished:(UIImage *)image;
@end
@interface JWMImagePickerController : UIImagePickerController
@property (nonatomic, weak) id<JWMImagePickerDelegate> JWMdelegate;
/* 初始化方法 */
- (instancetype)initWithImagePickerStyle:(ImagePickerStyle)style delegate:(id<JWMImagePickerDelegate>)delegate;
@end
//
// JWMImagePickerController.m
// Kacare_User
//
// Created by Jia Weimin on 2017/5/18.
// Copyright © 2017年 Linno. All rights reserved.
//
#import "JWMImagePickerController.h"
@interface JWMImagePickerController () <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@end
@implementation JWMImagePickerController
- (instancetype)initWithImagePickerStyle:(ImagePickerStyle)style delegate:(id<JWMImagePickerDelegate>)delegate {
if (self = [super init]) {
_JWMdelegate = delegate;
self.allowsEditing = NO;
self.delegate = self;
if (style == ImagePickerStyleCamera) {
self.sourceType = UIImagePickerControllerSourceTypeCamera;
} else if (style == ImagePickerStylePhotoLibrary) {
self.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
}
return self;
}
#pragma mark - UINavigationControllerDelegate && 解决UIImagePickerController导航透明问题
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if ([navigationController isKindOfClass:[UIImagePickerController class]]) {
self.navigationBarHidden = YES;
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
// 导航栏背景色
appearance.backgroundColor = DSBlack;
// 隐藏分割线
appearance.shadowColor = DSClearColor;
// 生效
self.navigationBar.scrollEdgeAppearance = appearance;
// 滚动视图滚动后导航栏背景色不会被影响
self.navigationBar.standardAppearance = appearance;
}
}
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
UIImage *editedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:nil];
if ([self.JWMdelegate respondsToSelector:@selector(jwmImagePickerImageFinished:)]) {
[self.JWMdelegate jwmImagePickerImageFinished:editedImage];
}
}
@end
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#import "UserInfoView.h" #import "UserInfoView.h"
#import "PhotoAlertView.h" #import "PhotoAlertView.h"
#import "UserInfoTableView.h" #import "UserInfoTableView.h"
#import <YYWebImage/YYWebImage.h>
#import "DSImagePickerController.h" #import "DSImagePickerController.h"
#import "RSKImageCropper.h" #import "RSKImageCropper.h"
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
// //
#import "UserRequestModel.h" #import "UserRequestModel.h"
#import <YYModel/YYModel.h>
@implementation UserRequestModel @implementation UserRequestModel
......
{
"images" : [
{
"filename" : "banner2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "banner2@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "banner2@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "banner3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "banner3@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "banner3@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "banner4.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "banner4@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "banner4@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{ {
"images" : [ "images" : [
{ {
"filename" : "banner1.png", "filename" : "bannerPlaceholder.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "banner1@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "banner1@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#import <DKNightVersion/DKNightVersion.h> #import <DKNightVersion/DKNightVersion.h>
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <YTKNetwork/YTKNetwork.h> #import <YTKNetwork/YTKNetwork.h>
#import <YYModel/YYModel.h>
#import <YYWebImage/YYWebImage.h>
#import "UIView+Extras.h" #import "UIView+Extras.h"
#import "UILabel+Extras.h" #import "UILabel+Extras.h"
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!