chore: 判断盲盒数量,确定是否进入新手引导

This commit is contained in:
Junhui Chen 2025-09-06 22:18:16 +08:00
parent 8f97b0c544
commit 8fb6d5c6b9

View File

@ -108,11 +108,6 @@ struct BlindBoxView: View {
init(mediaType: BlindBoxMediaType) { init(mediaType: BlindBoxMediaType) {
self.mediaType = mediaType self.mediaType = mediaType
// First/Second
if mediaType == BlindBoxMediaType.all {
print("获取盲盒列表")
}
} }
// //
@ -162,6 +157,39 @@ struct BlindBoxView: View {
startPolling() startPolling()
case .all: case .all:
print("Loading all content...") print("Loading all content...")
// First/Second
NetworkService.shared.get(
path: "/blind_boxs/query",
parameters: nil
) { (result: Result<APIResponse<[BlindList]>, NetworkError>) in
DispatchQueue.main.async {
switch result {
case .success(let response):
if response.data.count == 0 {
// -First
print("❌ 没有盲盒,跳转到新手引导-First盲盒页面")
// return
}
if response.data.count == 1 && response.data[0].boxType == "First" {
// -Second
print("❌ 只有First盲盒跳转到新手引导-Second盲盒页面")
// return
}
self.blindList = response.data ?? []
// none
if self.blindList.isEmpty {
self.animationPhase = .none
}
print("✅ 成功获取 \(self.blindList.count) 个盲盒")
case .failure(let error):
self.blindList = []
self.animationPhase = .none
print("❌ 获取盲盒列表失败:", error.localizedDescription)
}
}
}
// //
NetworkService.shared.get( NetworkService.shared.get(
path: "/membership/personal-center-info", path: "/membership/personal-center-info",
@ -195,27 +223,6 @@ struct BlindBoxView: View {
} }
} }
} }
//
NetworkService.shared.get(
path: "/blind_boxs/query",
parameters: nil
) { (result: Result<APIResponse<[BlindList]>, NetworkError>) in
DispatchQueue.main.async {
switch result {
case .success(let response):
self.blindList = response.data ?? []
// none
if self.blindList.isEmpty {
self.animationPhase = .none
}
print("✅ 成功获取 \(self.blindList.count) 个盲盒")
case .failure(let error):
self.blindList = []
self.animationPhase = .none
print("❌ 获取盲盒列表失败:", error.localizedDescription)
}
}
}
} }
} }
// //
@ -862,7 +869,7 @@ struct BlindBoxView: View {
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" { if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
// Preview // Preview
let previewToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJqdGkiOjczNzAwMTY5NzMzODE1NzA1NjAsImlkZW50aXR5IjoiNzM1MDQzOTY2MzExNjYxOTc3NyIsImV4cCI6MTc1Nzc1Mzc3NH0.tZ8p5sW4KX6HFoJpJN0e4VmJOAGhTrYD2yTwQwilKpufzqOAfXX4vpGYBurgBIcHj2KmXKX2PQMOeeAtvAypDA" let previewToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJqdGkiOjczNzAwMTY5NzMzODE1NzA1NjAsImlkZW50aXR5IjoiNzM1MDQzOTY2MzExNjYxOTc3NyIsImV4cCI6MTc1Nzc1Mzc3NH0.tZ8p5sW4KX6HFoJpJN0e4VmJOAGhTrYD2yTwQwilKpufzqOAfXX4vpGYBurgBIcHj2KmXKX2PQMOeeAtvAypDA"
KeychainHelper.saveAccessToken(previewToken) let _ = KeychainHelper.saveAccessToken(previewToken)
print("🔑 Preview token set for testing") print("🔑 Preview token set for testing")
} }
#endif #endif