feat: 控制第一个盲盒生成
This commit is contained in:
parent
5b9413699f
commit
3dc171aefe
@ -11,7 +11,7 @@ enum AppRoute: Hashable {
|
|||||||
case blindOutcome(media: MediaType, title: String? = nil, description: String? = nil, isMember: Bool, goToFeedback: Bool = false)
|
case blindOutcome(media: MediaType, title: String? = nil, description: String? = nil, isMember: Bool, goToFeedback: Bool = false)
|
||||||
case memories
|
case memories
|
||||||
case subscribe
|
case subscribe
|
||||||
case userInfo
|
case userInfo(createFirstBlindBox: Bool = false)
|
||||||
case account
|
case account
|
||||||
case about
|
case about
|
||||||
case permissionManagement
|
case permissionManagement
|
||||||
@ -51,8 +51,8 @@ enum AppRoute: Hashable {
|
|||||||
MemoriesView()
|
MemoriesView()
|
||||||
case .subscribe:
|
case .subscribe:
|
||||||
SubscribeView()
|
SubscribeView()
|
||||||
case .userInfo:
|
case .userInfo(let createFirstBlindBox):
|
||||||
UserInfo()
|
UserInfo(createFirstBlindBox: createFirstBlindBox)
|
||||||
case .account:
|
case .account:
|
||||||
AccountView()
|
AccountView()
|
||||||
case .about:
|
case .about:
|
||||||
|
|||||||
@ -98,7 +98,7 @@ struct UserProfileModal: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
Router.shared.navigate(to: .userInfo)
|
Router.shared.navigate(to: .userInfo(createFirstBlindBox: false))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Image(systemName: "person.circle.fill")
|
Image(systemName: "person.circle.fill")
|
||||||
|
|||||||
@ -264,7 +264,7 @@ struct LoginView: View {
|
|||||||
self.showError = true
|
self.showError = true
|
||||||
}
|
}
|
||||||
// 跳转到userinfo
|
// 跳转到userinfo
|
||||||
Router.shared.navigate(to: .userInfo)
|
Router.shared.navigate(to: .userInfo(createFirstBlindBox: true))
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
print("❌ [15] 后端认证失败")
|
print("❌ [15] 后端认证失败")
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct UserInfo: View {
|
struct UserInfo: View {
|
||||||
|
let createFirstBlindBox: Bool
|
||||||
|
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@StateObject private var router = Router.shared
|
@StateObject private var router = Router.shared
|
||||||
|
|
||||||
@ -44,9 +46,10 @@ struct UserInfo: View {
|
|||||||
.map { _ in false })
|
.map { _ in false })
|
||||||
.receive(on: RunLoop.main)
|
.receive(on: RunLoop.main)
|
||||||
|
|
||||||
init() {
|
init(createFirstBlindBox: Bool) {
|
||||||
// 在初始化时预加载键盘
|
// 在初始化时预加载键盘
|
||||||
_ = UserInfo.keyboardPreloader
|
_ = UserInfo.keyboardPreloader
|
||||||
|
self.createFirstBlindBox = createFirstBlindBox
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -182,31 +185,35 @@ struct UserInfo: View {
|
|||||||
self.userName = userData.username
|
self.userName = userData.username
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传头像为素材
|
if createFirstBlindBox {
|
||||||
MaterialUpload.shared.addMaterial(
|
// 上传头像为素材
|
||||||
fileId: uploadedFileId ?? "",
|
MaterialUpload.shared.addMaterial(
|
||||||
previewFileId: uploadedFileId ?? ""
|
fileId: uploadedFileId ?? "",
|
||||||
) { result in
|
previewFileId: uploadedFileId ?? ""
|
||||||
switch result {
|
) { result in
|
||||||
case .success(let data):
|
switch result {
|
||||||
print("素材添加成功,返回ID: \(data ?? [])")
|
case .success(let data):
|
||||||
// 触发盲盒生成
|
print("素材添加成功,返回ID: \(data ?? [])")
|
||||||
BlindBoxApi.shared.generateBlindBox(
|
// 触发盲盒生成
|
||||||
boxType: "First",
|
BlindBoxApi.shared.generateBlindBox(
|
||||||
materialIds: data ?? []
|
boxType: "First",
|
||||||
) { result in
|
materialIds: data ?? []
|
||||||
switch result {
|
) { result in
|
||||||
case .success(let blindBoxData):
|
switch result {
|
||||||
print("✅ 盲盒生成成功: \(blindBoxData?.id ?? "0")")
|
case .success(let blindBoxData):
|
||||||
// 导航到首页盲盒等待用户开启第一个盲盒
|
print("✅ 盲盒生成成功: \(blindBoxData?.id ?? "0")")
|
||||||
Router.shared.navigate(to: .blindBox(mediaType: .image, blindBoxId: blindBoxData?.id ?? "0"))
|
// 导航到首页盲盒等待用户开启第一个盲盒
|
||||||
case .failure(let error):
|
Router.shared.navigate(to: .blindBox(mediaType: .image, blindBoxId: blindBoxData?.id ?? "0"))
|
||||||
print("❌ 盲盒生成失败: \(error.localizedDescription)")
|
case .failure(let error):
|
||||||
|
print("❌ 盲盒生成失败: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
case .failure(let error):
|
||||||
|
print("素材添加失败: \(error.localizedDescription)")
|
||||||
}
|
}
|
||||||
case .failure(let error):
|
|
||||||
print("素材添加失败: \(error.localizedDescription)")
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Router.shared.navigate(to: .blindBox(mediaType: .all))
|
||||||
}
|
}
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
print("❌ 用户信息更新失败: \(error.localizedDescription)")
|
print("❌ 用户信息更新失败: \(error.localizedDescription)")
|
||||||
@ -327,6 +334,6 @@ struct SettingsRow: View {
|
|||||||
// MARK: - Preview
|
// MARK: - Preview
|
||||||
struct UserInfo_Previews: PreviewProvider {
|
struct UserInfo_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
UserInfo()
|
UserInfo(createFirstBlindBox: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user