初始化傻瓜比价正式版 iOS 客户端
对标安卓正式版、对接 app-server(8770)的 SwiftUI 客户端。iOS 无障碍受限、无比价核心,做自成一体:美团 CPS 导购 + 福利(签到/任务/金币)+ 查看(比价记录/省钱战绩)。 功能完整 M0-M5:脚手架、短信登录(JWT+Keychain+401 自动刷新)、首页券 feed 导购、比价记录+省钱战绩、福利、我的(资料/反馈/设置/注销)。 单 target、0 三方依赖、XcodeGen 生成工程;Debug/Release 双 plist 分流 ATS。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import Foundation
|
||||
|
||||
/// 用户资料,对齐后端 app/api/v1/user.py(需登录)。
|
||||
struct UserService {
|
||||
private var api: APIClient { .shared }
|
||||
|
||||
/// 改昵称,返回更新后的 user。
|
||||
func updateNickname(_ nickname: String) async throws -> UserDTO {
|
||||
try await api.patch("api/v1/user/profile", body: ProfileUpdateRequest(nickname: nickname))
|
||||
}
|
||||
|
||||
/// 上传头像(字段名 file),返回更新后的 user(含新 avatar_url)。
|
||||
func uploadAvatar(jpeg: Data) async throws -> UserDTO {
|
||||
try await api.postMultipart(
|
||||
"api/v1/user/avatar",
|
||||
files: [MultipartFile(name: "file", filename: "avatar.jpg", mimeType: "image/jpeg", data: jpeg)]
|
||||
)
|
||||
}
|
||||
|
||||
/// 注销账号(软删除 + 匿名化)。
|
||||
func deleteAccount() async throws -> OkResponse {
|
||||
try await api.delete("api/v1/user")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user