- 查询用户接口
This commit is contained in:
parent
6b924979f3
commit
3bfdcd753f
Binary file not shown.
|
|
@ -19,6 +19,9 @@ enum UserAPI {
|
|||
bind: String,
|
||||
data: [String: Any])
|
||||
|
||||
/// 用户信息
|
||||
case userInfo
|
||||
|
||||
/// 退出登录
|
||||
case logout
|
||||
}
|
||||
|
|
@ -29,19 +32,20 @@ extension UserAPI: MultiTargetProtocol {
|
|||
switch self {
|
||||
case .login:
|
||||
return "api/user/login"
|
||||
case .userInfo:
|
||||
return "api/user"
|
||||
case .logout:
|
||||
return "api/user/logout"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
.post
|
||||
// switch self {
|
||||
// case .:
|
||||
// return .get
|
||||
// case .login:
|
||||
// return .post
|
||||
// }
|
||||
switch self {
|
||||
case .userInfo:
|
||||
return .get
|
||||
default:
|
||||
return .post
|
||||
}
|
||||
}
|
||||
|
||||
var task: Moya.Task {
|
||||
|
|
@ -53,6 +57,9 @@ extension UserAPI: MultiTargetProtocol {
|
|||
params["data"] = data
|
||||
return .requestParameters(parameters: params, encoding: JSONEncoding())
|
||||
|
||||
case .userInfo:
|
||||
return .requestParameters(parameters: Parameters(), encoding: JSONEncoding())
|
||||
|
||||
case .logout:
|
||||
return .requestParameters(parameters: Parameters(), encoding: JSONEncoding())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ final class MainTabBarController: UITabBarController {
|
|||
NSLayoutConstraint.activate([
|
||||
customTabBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
customTabBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
customTabBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||
customTabBar.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -41),
|
||||
customTabBar.heightAnchor.constraint(equalToConstant: tabBarHeight)
|
||||
])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ class HomeViewController: BaseViewController {
|
|||
setupMap()
|
||||
setupLocation()
|
||||
loadMembers()
|
||||
|
||||
requestUserInfo()
|
||||
}
|
||||
|
||||
// MARK: - Map Setup
|
||||
|
|
@ -114,6 +116,13 @@ class HomeViewController: BaseViewController {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
private func requestUserInfo() {
|
||||
UserService.userInfo().subscribe { response in
|
||||
|
||||
}.disposed(by: disposeBag)
|
||||
}
|
||||
}
|
||||
|
||||
#if !targetEnvironment(simulator)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,14 @@ struct UserService {
|
|||
.asObservable()
|
||||
}
|
||||
|
||||
/// 用户信息
|
||||
static func userInfo() -> Observable<ResponseModel> {
|
||||
let api = UserAPI.userInfo.multiTarget
|
||||
return APIProvider.request(token: api)
|
||||
.map(ResponseModel.self)
|
||||
.asObservable()
|
||||
}
|
||||
|
||||
/// 退出登录
|
||||
static func logout() -> Observable<ResponseModel> {
|
||||
let api = UserAPI.logout.multiTarget
|
||||
|
|
|
|||
Loading…
Reference in New Issue