Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b8cc029b
由
cgx
编写于
2022-06-17 11:36:22 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
首页请求接口合并处理
1 个父辈
c572879d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
72 行增加
和
12 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Basement/Network/DSNetworkTool.m
DreamSleep/DreamSleep/Class/HomeModule/Home/Controller/HomeViewController.m
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
b8cc029
...
@@ -2276,7 +2276,7 @@
...
@@ -2276,7 +2276,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements;
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION =
8
;
CURRENT_PROJECT_VERSION =
9
;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO;
ENABLE_BITCODE = NO;
...
@@ -2347,7 +2347,7 @@
...
@@ -2347,7 +2347,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements;
CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION =
8
;
CURRENT_PROJECT_VERSION =
9
;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
FRAMEWORK_SEARCH_PATHS = (
...
@@ -2478,7 +2478,7 @@
...
@@ -2478,7 +2478,7 @@
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements;
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION =
8
;
CURRENT_PROJECT_VERSION =
9
;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO;
ENABLE_BITCODE = NO;
...
...
DreamSleep/DreamSleep/Basement/Network/DSNetworkTool.m
查看文件 @
b8cc029
...
@@ -66,7 +66,9 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络
...
@@ -66,7 +66,9 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络
success
:
(
void
(
^
)(
NSDictionary
*
apiDic
))
success
success
:
(
void
(
^
)(
NSDictionary
*
apiDic
))
success
failure
:
(
void
(
^
)(
id
failure
))
failure
failure
:
(
void
(
^
)(
id
failure
))
failure
{
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
hasNetActivity
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
hasNetActivity
];
});
if
(
loadingInfo
)
{
if
(
loadingInfo
)
{
view
?
[
DSProgressHUD
showProgressHUDWithInfo
:
loadingInfo
inView
:
view
]
:
[
DSProgressHUD
showProgressHUDWithInfo
:
loadingInfo
];
view
?
[
DSProgressHUD
showProgressHUDWithInfo
:
loadingInfo
inView
:
view
]
:
[
DSProgressHUD
showProgressHUDWithInfo
:
loadingInfo
];
}
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Controller/HomeViewController.m
查看文件 @
b8cc029
...
@@ -22,6 +22,14 @@
...
@@ -22,6 +22,14 @@
@property
(
nonatomic
,
strong
)
DSHomeView
*
homeTV
;
@property
(
nonatomic
,
strong
)
DSHomeView
*
homeTV
;
@property
(
nonatomic
,
strong
)
RescuePlanView
*
rescuePlanView
;
@property
(
nonatomic
,
strong
)
RescuePlanView
*
rescuePlanView
;
@property
(
nonatomic
,
strong
)
NoisePlayBar
*
noisePlayBar
;
@property
(
nonatomic
,
strong
)
NoisePlayBar
*
noisePlayBar
;
/// banner列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
bannerListData
;
/// 舒眠课程列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
safeListData
;
/// 助眠音乐列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
helpListData
;
/// 所有白噪音类型数据
@property
(
nonatomic
,
strong
)
NSArray
*
noiseTypeArr
;
@end
@end
@implementation
HomeViewController
@implementation
HomeViewController
...
@@ -108,37 +116,87 @@
...
@@ -108,37 +116,87 @@
#pragma mark - banner、舒眠课程、助眠音乐数据获取
#pragma mark - banner、舒眠课程、助眠音乐数据获取
-
(
void
)
requestHomeData
{
-
(
void
)
requestHomeData
{
WS
(
weakSelf
);
self
.
homeTV
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
self
.
homeTV
.
mj_header
=
[
DSGifHeader
headerWithRefreshingBlock
:
^
{
[
weakSelf
muiltiRequest
];
}];
[
self
.
homeTV
.
mj_header
beginRefreshing
];
}
-
(
void
)
muiltiRequest
{
// 创建信号量
dispatch_semaphore_t
semaphore
=
dispatch_semaphore_create
(
0
);
// 创建全局并行
dispatch_queue_t
queue
=
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
);
dispatch_group_t
group
=
dispatch_group_create
();
dispatch_group_async
(
group
,
queue
,
^
{
// 获取首页banner数据
// 获取首页banner数据
[
HomeRequestModel
queryBannerListWithCompletion
:
^
(
HomeRequestModel
*
_Nonnull
requestModel
)
{
[
HomeRequestModel
queryBannerListWithCompletion
:
^
(
HomeRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
refreshBarnner
:
requestModel
.
bannerListData
];
DSLog
(
@"获取首页banner数据成功..."
);
dispatch_semaphore_signal
(
semaphore
);
self
.
bannerListData
=
requestModel
.
bannerListData
;
}
else
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
}
}
}];
}];
});
dispatch_group_async
(
group
,
queue
,
^
{
// 获取首页舒眠课程数据
// 获取首页舒眠课程数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
6
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
6
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
updateCourseMusicCell
:
CellTypeCourse
data
:
requestModel
.
courseListData
];
DSLog
(
@"获取首页舒眠课程数据成功..."
);
dispatch_semaphore_signal
(
semaphore
);
self
.
safeListData
=
requestModel
.
courseListData
;
}
else
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
}
}
}];
}];
});
dispatch_group_async
(
group
,
queue
,
^
{
// 获取首页助眠音乐数据
// 获取首页助眠音乐数据
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
18
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
SafeSleepRequestModel
getCourseListDataWithSubID
:
18
isHome
:
YES
completion
:^
(
SafeSleepRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
updateCourseMusicCell
:
CellTypeMusic
data
:
requestModel
.
courseListData
];
NSLog
(
@"获取首页助眠音乐数据成功..."
);
dispatch_semaphore_signal
(
semaphore
);
self
.
helpListData
=
requestModel
.
courseListData
;
}
else
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
}
}
}];
}];
});
dispatch_group_async
(
group
,
queue
,
^
{
// 获取白噪音类型请求
// 获取白噪音类型请求
[
WhiteNoiseRequestModel
queryRelaxWhiteNoiseTypeWithCompletion
:
^
(
WhiteNoiseRequestModel
*
_Nonnull
requestModel
)
{
[
WhiteNoiseRequestModel
queryRelaxWhiteNoiseTypeWithCompletion
:
^
(
WhiteNoiseRequestModel
*
_Nonnull
requestModel
)
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
[
self
.
homeTV
.
mj_header
endRefreshing
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
homeTV
updateNoiseAllTypeData
:
requestModel
.
noiseTypeArr
];
NSLog
(
@"获取白噪音类型请求成功..."
);
dispatch_semaphore_signal
(
semaphore
);
self
.
noiseTypeArr
=
requestModel
.
noiseTypeArr
;
}
else
{
[
self
.
homeTV
.
mj_header
endRefreshing
];
}
}
}];
}];
}];
});
[
self
.
homeTV
.
mj_header
beginRefreshing
];
dispatch_group_notify
(
group
,
queue
,
^
{
// 四个请求对应四次信号等待
dispatch_semaphore_wait
(
semaphore
,
DISPATCH_TIME_FOREVER
);
dispatch_semaphore_wait
(
semaphore
,
DISPATCH_TIME_FOREVER
);
dispatch_semaphore_wait
(
semaphore
,
DISPATCH_TIME_FOREVER
);
dispatch_semaphore_wait
(
semaphore
,
DISPATCH_TIME_FOREVER
);
// 在这里进行请求后的方法,回到主线程
dispatch_async
(
dispatch_get_main_queue
(),
^
{
// 更新UI操作
[
self
.
homeTV
refreshBarnner
:
self
.
bannerListData
];
[
self
.
homeTV
updateCourseMusicCell
:
CellTypeCourse
data
:
self
.
safeListData
];
[
self
.
homeTV
updateCourseMusicCell
:
CellTypeMusic
data
:
self
.
helpListData
];
[
self
.
homeTV
updateNoiseAllTypeData
:
self
.
noiseTypeArr
];
});
});
}
}
#pragma mark - APP首次启动弹框
#pragma mark - APP首次启动弹框
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论