diff --git a/wake/Utils/Router.swift b/wake/Utils/Router.swift index 528df05..a30bd05 100644 --- a/wake/Utils/Router.swift +++ b/wake/Utils/Router.swift @@ -10,6 +10,7 @@ enum AppRoute: Hashable { case blindBox(mediaType: BlindBoxView.BlindBoxMediaType) case blindOutcome(media: MediaType) case memories + case subscribe @ViewBuilder var view: some View { @@ -30,6 +31,8 @@ enum AppRoute: Hashable { BlindOutcomeView(media: media) case .memories: MemoriesView() + case .subscribe: + SubscribeView() } } } diff --git a/wake/View/Components/UserProfileModal.swift b/wake/View/Components/UserProfileModal.swift index 289640d..936d30a 100644 --- a/wake/View/Components/UserProfileModal.swift +++ b/wake/View/Components/UserProfileModal.swift @@ -17,6 +17,22 @@ struct UserProfile: Codable { } } +struct MemberProfile: Codable { + let userId: String + let nickname: String + let avatarUrl: String? + let account: String + let email: String + + enum CodingKeys: String, CodingKey { + case userId = "user_id" + case nickname + case avatarUrl = "avatar_file_url" + case account + case email + } +} + // API Response wrapper struct APIResponse: Codable { let code: Int @@ -126,39 +142,43 @@ struct UserProfileModal: View { ) .padding(.horizontal) + Button(action: { + Router.shared.navigate(to: .subscribe) + }) { ZStack(alignment: .center) { - // SVG背景 - 确保铺满整个区域 - SVGImage(svgName: "Pioneer") - .scaledToFill() - .frame(maxWidth: .infinity, maxHeight: .infinity) - - // 内容区域 - VStack(alignment: .leading, spacing: 6) { - Text("Pioneer") - .font(Typography.font(for: .title3)) - .fontWeight(.bold) - .foregroundColor(.themeTextMessageMain) - .padding(.top, 6) - - Text("Expires on :") - .font(.system(size: 12)) - .foregroundColor(.themeTextMessageMain) - .padding(.top, 2) - - Text("March 15, 2025") - .font(.system(size: 12)) - .fontWeight(.bold) - .foregroundColor(.themeTextMessageMain) - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding(.leading, 32) - // 可以添加内边距使内容不紧贴边缘 - .padding(.vertical, 12) + // SVG背景 - 确保铺满整个区域 + SVGImage(svgName: "Pioneer") + .scaledToFill() + .frame(maxWidth: .infinity, maxHeight: .infinity) + + // 内容区域 + VStack(alignment: .leading, spacing: 6) { + Text("Pioneer") + .font(Typography.font(for: .title3)) + .fontWeight(.bold) + .foregroundColor(.themeTextMessageMain) + .padding(.top, 6) + + Text("Expires on :") + .font(.system(size: 12)) + .foregroundColor(.themeTextMessageMain) + .padding(.top, 2) + + Text("March 15, 2025") + .font(.system(size: 12)) + .fontWeight(.bold) + .foregroundColor(.themeTextMessageMain) + } + .frame(maxWidth: .infinity, alignment: .leading) + .padding(.leading, 32) + // 可以添加内边距使内容不紧贴边缘 + .padding(.vertical, 12) + } + .frame(height: 112) + .frame(maxWidth: .infinity) + .cornerRadius(16) + .clipped() // 确保内容不会超出边界 } - .frame(height: 112) - .frame(maxWidth: .infinity) - .cornerRadius(16) - .clipped() // 确保内容不会超出边界 VStack(spacing: 12) { // upload @@ -281,6 +301,24 @@ struct UserProfileModal: View { DispatchQueue.main.async { isLoading = false + switch result { + case .success(let response): + self.userProfile = response.data + print("✅ Successfully fetched user info:", response.data) + case .failure(let error): + self.errorMessage = error.localizedDescription + print("❌ Failed to fetch user info:", error) + } + } + } + // 会员信息 + NetworkService.shared.get( + path: "/membership/personal-center-info", + parameters: nil + ) { (result: Result, NetworkError>) in + DispatchQueue.main.async { + isLoading = false + switch result { case .success(let response): self.userProfile = response.data