Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit d9fb03a7
由
cgx
编写于
2022-05-10 18:21:56 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完成舒眠课程、助眠音乐模块
1 个父辈
ee637f38
显示空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
166 行增加
和
60 行删除
DreamSleep/DreamSleep/Basement/H5/ExceptionDefaultView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioDetailHeaderView.h
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioDetailHeaderView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.h
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseModel.h
DreamSleep/DreamSleep/Class/HomeModule/Home/LookAllController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepModel.h
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepModel.m
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepRequestModel.m
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.h
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeTableView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.h
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.m
DreamSleep/DreamSleep/Basement/H5/ExceptionDefaultView.m
查看文件 @
d9fb03a
...
...
@@ -53,10 +53,6 @@
return
self
;
}
-
(
void
)
dealloc
{
DSLog
(
@"deallocdeallocdealloc"
);
}
#pragma mark - Actions
-
(
void
)
dealAction
{
if
(
self
.
dealBlock
)
{
self
.
dealBlock
();
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioDetailHeaderView.h
查看文件 @
d9fb03a
...
...
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 音频详情播放列表页头部视图
@interface
AudioDetailHeaderView
:
UIView
-
(
instancetype
)
initWithModel
:(
CourseModel
*
)
model
;
-
(
instancetype
)
initWithModel
:(
CourseModel
*
)
model
courseType
:(
CourseType
)
courseType
;
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioDetailHeaderView.m
查看文件 @
d9fb03a
...
...
@@ -9,6 +9,7 @@
@interface
AudioDetailHeaderView
()
@property
(
nonatomic
,
strong
)
UIImageView
*
bgIV
;
@property
(
nonatomic
,
strong
)
UIView
*
maskView
;
@property
(
nonatomic
,
strong
)
UIImageView
*
audioIV
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioNameLab
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioDescLab
;
...
...
@@ -17,34 +18,68 @@
@implementation
AudioDetailHeaderView
-
(
instancetype
)
initWithModel
:(
CourseModel
*
)
model
{
if
(
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
25
0
)])
{
-
(
instancetype
)
initWithModel
:(
CourseModel
*
)
model
courseType
:(
CourseType
)
courseType
{
if
(
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
courseType
==
CourseTypeSafe
?
250
:
30
0
)])
{
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
self
.
clipsToBounds
=
YES
;
[
self
addSubview
:
self
.
bgIV
];
[
self
addSubview
:
self
.
audioIV
];
[
self
addSubview
:
self
.
audioNameLab
];
if
(
courseType
==
CourseTypeSafe
)
{
[
self
addSubview
:
self
.
audioIV
];
[
self
addSubview
:
self
.
audioDescLab
];
[
self
addSubview
:
self
.
cornerView
];
self
.
audioDescLab
.
text
=
model
.
audio_desc
;
// self.bgIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, .5);
// self.audioIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, .5);
}
else
{
[
self
addSubview
:
self
.
maskView
];
[
self
.
maskView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
width
.
height
.
equalTo
(
@118
);
make
.
top
.
equalTo
(
self
).
offset
(
118
);
}];
}
[
self
.
bgIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
bg_url
]
placeholder
:[
UIImage
imageNamed
:
@"bannerPlaceholder"
]];
[
self
.
audioIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
audio_img
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
self
.
audioNameLab
.
text
=
model
.
audio_name
;
self
.
audio
DescLab
.
text
=
model
.
audio_desc
;
self
.
audio
NameLab
.
font
=
courseType
==
CourseTypeSafe
?
BoldFont
(
16
.
0
)
:
BoldFont
(
18
.
0
)
;
[
self
.
bgIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
if
(
courseType
==
CourseTypeSafe
)
{
make
.
edges
.
equalTo
(
self
);
}
else
{
make
.
top
.
left
.
right
.
equalTo
(
self
);
make
.
height
.
equalTo
(
@210
);
}
}];
[
self
.
audioIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
if
(
courseType
==
CourseTypeSafe
)
{
make
.
left
.
equalTo
(
self
).
offset
(
17
);
make
.
top
.
equalTo
(
self
).
offset
(
105
);
make
.
width
.
height
.
equalTo
(
@100
);
}
else
{
[
self
.
audioIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
edges
.
equalTo
(
self
.
maskView
);
}];
}
}];
[
self
.
audioNameLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
if
(
courseType
==
CourseTypeSafe
)
{
make
.
left
.
equalTo
(
self
.
audioIV
.
mas_right
).
offset
(
30
);
make
.
top
.
equalTo
(
self
.
audioIV
);
}
else
{
make
.
centerX
.
equalTo
(
self
);
make
.
top
.
equalTo
(
self
.
audioIV
.
mas_bottom
).
offset
(
15
);
}
}];
if
(
courseType
==
CourseTypeSafe
)
{
[
self
.
audioDescLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
audioNameLab
);
make
.
top
.
equalTo
(
self
.
audioNameLab
.
mas_bottom
).
offset
(
10
);
...
...
@@ -55,6 +90,7 @@
make
.
height
.
equalTo
(
@40
);
}];
}
}
return
self
;
}
...
...
@@ -62,15 +98,25 @@
-
(
UIImageView
*
)
bgIV
{
if
(
!
_bgIV
)
{
_bgIV
=
[
UIImageView
new
];
_bgIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
_bgIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
5
,
.
5
);
}
return
_bgIV
;
}
-
(
UIView
*
)
maskView
{
if
(
!
_maskView
)
{
_maskView
=
[
UIView
new
];
_maskView
.
backgroundColor
=
DSWhite
;
[
_maskView
cornerRadius
:
15
.
0
];
[
_maskView
addSubview
:
self
.
audioIV
];
}
return
_maskView
;
}
-
(
UIImageView
*
)
audioIV
{
if
(
!
_audioIV
)
{
_audioIV
=
[
UIImageView
new
];
_audioIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
_audioIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
8
,
.
5
);
}
return
_audioIV
;
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.h
查看文件 @
d9fb03a
...
...
@@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 课程详情页(音频列表)
@interface
CourseDetailController
:
DSBaseViewController
@property
(
nonatomic
,
strong
)
CourseModel
*
courseModel
;
@property
(
nonatomic
,
assign
)
CourseType
courseType
;
@property
(
nonatomic
,
weak
)
id
<
CourseDetailControllerDelegate
>
delegate
;
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.m
查看文件 @
d9fb03a
...
...
@@ -129,7 +129,7 @@
[
self
getAudiosData
];
}
#pragma mark - UITableViewDelegate
,
UITableViewDataSource
#pragma mark - UITableViewDelegate
&&
UITableViewDataSource
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
return
self
.
subAudioArr
.
count
;
}
...
...
@@ -198,7 +198,7 @@
_audioListView
.
showsVerticalScrollIndicator
=
NO
;
_audioListView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
_audioListView
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
_audioListView
.
tableHeaderView
=
[[
AudioDetailHeaderView
alloc
]
initWithModel
:
self
.
courseModel
];
_audioListView
.
tableHeaderView
=
[[
AudioDetailHeaderView
alloc
]
initWithModel
:
self
.
courseModel
courseType
:
self
.
courseType
];
UIView
*
footView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
100
)];
_audioListView
.
tableFooterView
=
footView
;
_audioListView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseModel.h
查看文件 @
d9fb03a
...
...
@@ -7,6 +7,14 @@
#import <Foundation/Foundation.h>
/*
课程类型
*/
typedef
enum
{
CourseTypeSafe
,
// 舒眠课程
CourseTypeRelax
// 发送音乐
}
CourseType
;
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程和助眠音乐课程数据model
...
...
@@ -23,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
copy
)
NSString
*
audio_pic
;
// 背景图
@property
(
nonatomic
,
copy
)
NSString
*
bg_url
;
// 主页显示图标
@property
(
nonatomic
,
copy
)
NSString
*
home_img
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/LookAllController.m
查看文件 @
d9fb03a
...
...
@@ -56,7 +56,7 @@
}
}
-
(
void
)
switchView
c
ontrollerAction
:
(
UIButton
*
)
sender
{
-
(
void
)
switchView
C
ontrollerAction
:
(
UIButton
*
)
sender
{
_selectedIndex
=
sender
.
tag
;
[
UIView
animateWithDuration
:.
3
animations
:
^
{
self
->
_indicatorView
.
x
=
sender
.
x
;
...
...
@@ -68,18 +68,18 @@
-
(
UIButton
*
)
btnWithTitle
:
(
NSString
*
)
title
font
:
(
UIFont
*
)
font
tag
:
(
NSInteger
)
tag
sView
:
(
UIView
*
)
sView
{
UIButton
*
btn
=
[
UIButton
btnWithTitle
:
title
font
:
font
];
btn
.
tag
=
tag
;
[
btn
addTarget
:
self
action
:
@selector
(
switchView
c
ontrollerAction
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
btn
addTarget
:
self
action
:
@selector
(
switchView
C
ontrollerAction
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
sView
addSubview
:
btn
];
return
btn
;
}
-
(
void
)
addSubControllerView
{
SafeSleepListController
*
safeVC
=
[[
SafeSleepListController
alloc
]
initWith
SubID
:
6
];
SafeSleepListController
*
safeVC
=
[[
SafeSleepListController
alloc
]
initWith
CourseType
:
CourseTypeSafe
];
safeVC
.
view
.
frame
=
CGRectMake
(
0
,
0
,
kScreenWidth
,
self
.
bodyView
.
height
);
[
self
.
bodyView
addSubview
:
safeVC
.
view
];
[
self
addChildViewController
:
safeVC
];
SafeSleepListController
*
relaxVC
=
[[
SafeSleepListController
alloc
]
initWith
SubID
:
18
];
SafeSleepListController
*
relaxVC
=
[[
SafeSleepListController
alloc
]
initWith
CourseType
:
CourseTypeRelax
];
relaxVC
.
view
.
frame
=
CGRectMake
(
kScreenWidth
,
0
,
kScreenWidth
,
self
.
bodyView
.
height
);
[
self
.
bodyView
addSubview
:
relaxVC
.
view
];
[
self
addChildViewController
:
relaxVC
];
...
...
@@ -140,6 +140,7 @@
_bodyView
.
pagingEnabled
=
YES
;
_bodyView
.
showsHorizontalScrollIndicator
=
NO
;
_bodyView
.
delegate
=
self
;
[
_bodyView
setContentOffset
:
CGPointMake
(
_selectedIndex
*
_bodyView
.
width
,
0
)];
[
self
addSubControllerView
];
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepModel.h
查看文件 @
d9fb03a
...
...
@@ -11,7 +11,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程、助眠音乐、好眠声音数据 model
@interface
SafeSleepModel
:
NSObject
/// cell标题
@property
(
nonatomic
,
copy
)
NSString
*
title
;
/// 课程列表数据
@property
(
nonatomic
,
copy
)
NSArray
*
courseListDatas
;
+
(
NSArray
*
)
getDatas
;
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepModel.m
查看文件 @
d9fb03a
...
...
@@ -15,6 +15,7 @@
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
SafeSleepModel
*
m
=
[
SafeSleepModel
new
];
m
.
title
=
titles
[
i
];
m
.
courseListDatas
=
@[];
[
tmpDatas
addObject
:
m
];
}
return
[
tmpDatas
copy
];
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Model/SafeSleepRequestModel.m
查看文件 @
d9fb03a
...
...
@@ -30,7 +30,7 @@
NSString
*
api
=
@"query_relax_meditation_type"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"query{%@(sub_id:%d,is_home:%@)}"
,
api
,
subID
,
isHome
?
@"true"
:
@"false"
];
SafeSleepRequestModel
*
requestModel
=
[[
SafeSleepRequestModel
alloc
]
init
];
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
YES
success
:^
(
NSDictionary
*
apiDic
)
{
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
apiDic
)
{
requestModel
.
resCode
=
DSResCodeSuccess
;
DSLog
(
@"获取舒眠课程、助眠音乐列表数据接口dataDic:%@"
,
apiDic
);
NSArray
*
resultArr
=
apiDic
[
@"result"
];
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.h
查看文件 @
d9fb03a
...
...
@@ -6,13 +6,14 @@
//
#import <UIKit/UIKit.h>
#import "CourseModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 舒眠课程和助眠音乐列表控制器
@interface
SafeSleepListController
:
UIViewController
-
(
instancetype
)
initWith
SubID
:(
int
)
subID
;
-
(
instancetype
)
initWith
CourseType
:(
CourseType
)
type
;
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/SafeSleepListController.m
查看文件 @
d9fb03a
...
...
@@ -8,21 +8,21 @@
#import "SafeSleepListController.h"
#import "SafeSleepRequestModel.h"
#import "CourseCollectionCell.h"
#import "CourseModel.h"
#import "CourseDetailController.h"
@interface
SafeSleepListController
()
<
UICollectionViewDataSource
,
UICollectionViewDelegate
>
@property
(
nonatomic
,
strong
)
UICollectionView
*
courseListView
;
@property
(
nonatomic
,
strong
)
NSArray
*
listArr
;
@property
(
nonatomic
,
strong
)
ExceptionDefaultView
*
exceptionView
;
@end
@implementation
SafeSleepListController
{
int
_sub_id
;
CourseType
_type
;
}
-
(
instancetype
)
initWith
SubID
:
(
int
)
subID
{
-
(
instancetype
)
initWith
CourseType
:
(
CourseType
)
type
{
if
(
self
=
[
super
init
])
{
_
sub_id
=
subID
;
_
type
=
type
;
_listArr
=
@[];
}
return
self
;
...
...
@@ -34,41 +34,22 @@
self
.
view
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
.
view
addSubview
:
self
.
courseListView
];
self
.
courseListView
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
[
self
getCourseDataRequest
];
}];
[
self
.
courseListView
.
mj_header
beginRefreshing
];
}
-
(
void
)
getCourseDataRequest
{
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
self
->
_sub_id
isHome
:
NO
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
(
_type
==
CourseTypeSafe
?
6
:
18
)
isHome
:
NO
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
courseListView
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
self
.
exceptionView
.
hidden
=
YES
;
self
.
listArr
=
requestModel
.
courseListData
;
[
self
.
courseListView
reloadData
];
}
else
{
self
.
exceptionView
.
hidden
=
NO
;
}
}];
}
#pragma mark - lazy
-
(
UICollectionView
*
)
courseListView
{
if
(
!
_courseListView
)
{
UICollectionViewFlowLayout
*
layout
=
[[
UICollectionViewFlowLayout
alloc
]
init
];
layout
.
sectionFootersPinToVisibleBounds
=
YES
;
layout
.
scrollDirection
=
UICollectionViewScrollDirectionVertical
;
CGFloat
width
=
(
kScreenWidth
-
60
)
/
3
;
layout
.
itemSize
=
CGSizeMake
(
width
,
130
);
layout
.
minimumInteritemSpacing
=
15
;
_courseListView
=
[[
UICollectionView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
self
.
view
.
height
-
Bottom_SafeArea_Height
-
kTopHeight
(
0
)
-
40
)
collectionViewLayout
:
layout
];
_courseListView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
_courseListView
.
showsVerticalScrollIndicator
=
NO
;
_courseListView
.
delegate
=
self
;
_courseListView
.
dataSource
=
self
;
[
_courseListView
registerClass
:[
CourseCollectionCell
class
]
forCellWithReuseIdentifier
:
@"CourseCollectionCellID"
];
}
return
_courseListView
;
}
#pragma mark - UICollectionViewDataSource && UICollectionViewDelegate
-
(
NSInteger
)
collectionView
:
(
UICollectionView
*
)
collectionView
numberOfItemsInSection
:
(
NSInteger
)
section
{
return
self
.
listArr
.
count
;
...
...
@@ -92,8 +73,39 @@
CourseModel
*
model
=
[
self
.
listArr
objectAtIndex
:
indexPath
.
row
];
CourseDetailController
*
coureDetailVC
=
[[
CourseDetailController
alloc
]
init
];
coureDetailVC
.
courseModel
=
model
;
coureDetailVC
.
courseType
=
_type
;
[
self
.
navigationController
pushViewController
:
coureDetailVC
animated
:
YES
];
}
}
#pragma mark - lazy
-
(
UICollectionView
*
)
courseListView
{
if
(
!
_courseListView
)
{
UICollectionViewFlowLayout
*
layout
=
[[
UICollectionViewFlowLayout
alloc
]
init
];
layout
.
sectionFootersPinToVisibleBounds
=
YES
;
layout
.
scrollDirection
=
UICollectionViewScrollDirectionVertical
;
CGFloat
width
=
(
kScreenWidth
-
60
)
/
3
;
layout
.
itemSize
=
CGSizeMake
(
width
,
130
);
layout
.
minimumInteritemSpacing
=
15
;
_courseListView
=
[[
UICollectionView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
self
.
view
.
height
-
Bottom_SafeArea_Height
-
kTopHeight
(
0
)
-
40
)
collectionViewLayout
:
layout
];
_courseListView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
_courseListView
.
showsVerticalScrollIndicator
=
NO
;
_courseListView
.
delegate
=
self
;
_courseListView
.
dataSource
=
self
;
[
_courseListView
registerClass
:[
CourseCollectionCell
class
]
forCellWithReuseIdentifier
:
@"CourseCollectionCellID"
];
}
return
_courseListView
;
}
-
(
ExceptionDefaultView
*
)
exceptionView
{
if
(
!
_exceptionView
)
{
WS
(
weakSelf
);
_exceptionView
=
[[
ExceptionDefaultView
alloc
]
initWithType
:
ExceptionTypeNet
block
:
^
{
weakSelf
.
exceptionView
.
hidden
=
YES
;
[
weakSelf
getCourseDataRequest
];
}
superView
:
self
.
view
];
}
return
_exceptionView
;
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/HomeTableView.m
查看文件 @
d9fb03a
...
...
@@ -14,37 +14,56 @@
@interface
HomeTableView
()
<
UITableViewDelegate
>
@property
(
nonatomic
,
strong
)
HomeHeaderView
*
headerView
;
@property
(
nonatomic
,
strong
)
DSDataSource
*
homeDataSource
;
@property
(
nonatomic
,
strong
)
NSArray
*
dataArr
;
@end
@implementation
HomeTableView
@implementation
HomeTableView
{
// 舒眠课程数据
NSArray
*
_courseSafeArr
;
// 助眠音乐数据
NSArray
*
_courseHelpArr
;
}
-
(
instancetype
)
init
{
if
(
self
=
[
super
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
)
style
:
UITableViewStylePlain
])
{
_courseSafeArr
=
@[];
_courseHelpArr
=
@[];
self
.
dataArr
=
[
SafeSleepModel
getDatas
];
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
self
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
self
.
showsVerticalScrollIndicator
=
NO
;
[
self
.
homeDataSource
addDataArray
:
[
SafeSleepModel
getDatas
]
];
[
self
.
homeDataSource
addDataArray
:
self
.
dataArr
];
self
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
// 获取首页banner数据
[
HomeRequestModel
queryBannerListWithCompletion
:
^
(
HomeRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
headerView
updateBannerWithListData
:
requestModel
.
bannerListData
];
}
}];
// [SafeSleepRequestModel getCourseListDataWithSubID:6 isHome:YES completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [self.mj_header endRefreshing];
// }];
// [SafeSleepRequestModel getCourseListDataWithSubID:18 isHome:Yes completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
// [self.mj_header endRefreshing];
// }];
// 获取首页舒眠课程数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
6
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
self
->
_courseSafeArr
=
requestModel
.
courseListData
;
}
}];
// 获取首页助眠音乐数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
18
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
self
->
_courseHelpArr
=
requestModel
.
courseListData
;
}
}];
}];
[
self
.
mj_header
beginRefreshing
];
}
return
self
;
}
#pragma mark - lazy
-
(
DSDataSource
*
)
homeDataSource
{
if
(
!
_homeDataSource
)
{
CellConfigureBlock
cellBlock
=
^
(
SafeSleepCell
*
cell
,
SafeSleepModel
*
model
,
NSIndexPath
*
indexPath
)
{
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.h
查看文件 @
d9fb03a
...
...
@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
-
(
instancetype
)
initCollectionViewWithIndexPath
:(
NSIndexPath
*
)
indexPath
;
-
(
instancetype
)
initWithIndexPath
:(
NSIndexPath
*
)
indexPath
courseListDatas
:(
NSArray
*
)
courseListDatas
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionView.m
查看文件 @
d9fb03a
...
...
@@ -10,11 +10,14 @@
@interface
SafeHelperCollectionView
()
<
UICollectionViewDelegate
,
UICollectionViewDataSource
>
@property
(
nonatomic
,
strong
)
NSIndexPath
*
cellIndexPath
;
/// 首页舒眠课程和助眠音乐课程列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
courseListData
;
@end
@implementation
SafeHelperCollectionView
-
(
instancetype
)
initCollectionViewWithIndexPath
:(
NSIndexPath
*
)
indexPath
{
-
(
instancetype
)
initWithIndexPath
:(
NSIndexPath
*
)
indexPath
courseListDatas
:(
NSArray
*
)
courseListDatas
{
self
.
courseListData
=
courseListDatas
;
self
.
cellIndexPath
=
indexPath
;
CGFloat
width
=
indexPath
.
row
==
0
?
100
:
90
;
CGFloat
height
=
indexPath
.
row
==
0
?
130
:
120
;
...
...
@@ -36,18 +39,17 @@
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
-
(
NSInteger
)
collectionView
:(
UICollectionView
*
)
collectionView
numberOfItemsInSection
:(
NSInteger
)
section
{
return
8
;
return
self
.
courseListData
.
count
;
}
-
(
UICollectionViewCell
*
)
collectionView
:(
UICollectionView
*
)
collectionView
cellForItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
SafeHelperCollectionViewCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"shCollectionViewCell"
forIndexPath
:
indexPath
];
[
cell
mockDatas
:
self
.
cellIndexPath
];
cell
.
courseModel
=
self
.
courseListData
[
indexPath
.
row
];
return
cell
;
}
-
(
void
)
collectionView
:(
UICollectionView
*
)
collectionView
didSelectItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
N
SLog
(
@"row:%ld"
,
indexPath
.
row
);
D
SLog
(
@"row:%ld"
,
indexPath
.
row
);
}
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.h
查看文件 @
d9fb03a
...
...
@@ -6,11 +6,14 @@
//
#import <UIKit/UIKit.h>
#import "CourseModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface
SafeHelperCollectionViewCell
:
UICollectionViewCell
@property
(
nonatomic
,
strong
)
CourseModel
*
courseModel
;
-
(
void
)
mockDatas
:(
NSIndexPath
*
)
cellIndexPath
;
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeHelperCollectionViewCell.m
查看文件 @
d9fb03a
...
...
@@ -30,6 +30,12 @@
return
self
;
}
-
(
void
)
setCourseModel
:(
CourseModel
*
)
courseModel
{
_courseModel
=
courseModel
;
[
self
.
homeIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
courseModel
.
home_img
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
}
-
(
void
)
mockDatas
:(
NSIndexPath
*
)
cellIndexPath
{
self
.
homeIV
.
image
=
[
UIImage
imageNamed
:
cellIndexPath
.
row
==
0
?
@"test0"
:
@"test1"
];
self
.
audioTypeLab
.
text
=
@"都会浪漫"
;
...
...
@@ -72,6 +78,7 @@
}];
}
#pragma mark - lazy
-
(
UIView
*
)
roundedView
{
if
(
!
_roundedView
)
{
_roundedView
=
[
UIView
new
];
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/View/SafeSleepCell.m
查看文件 @
d9fb03a
...
...
@@ -81,6 +81,7 @@
}
}
#pragma mark - lazy
-
(
UIView
*
)
leftIV
{
if
(
!
_leftIV
)
{
_leftIV
=
[
UIView
new
];
...
...
@@ -119,7 +120,7 @@
-
(
SafeHelperCollectionView
*
)
shCollectionView
{
if
(
!
_shCollectionView
)
{
_shCollectionView
=
[[
SafeHelperCollectionView
alloc
]
init
CollectionViewWithIndexPath
:
self
.
indexPath
];
_shCollectionView
=
[[
SafeHelperCollectionView
alloc
]
init
WithIndexPath
:
self
.
indexPath
courseListDatas
:@[]
];
}
return
_shCollectionView
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论