From 0bf7ddf03d457908a4ff2f2373f4fd8ee00275e3 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期一, 31 三月 2025 15:46:56 +0800
Subject: [PATCH] fix 我的
---
app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt | 66 +++++++++++++-------------------
1 files changed, 27 insertions(+), 39 deletions(-)
diff --git a/app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt b/app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt
index d7494f4..f87eb83 100644
--- a/app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt
+++ b/app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt
@@ -31,7 +31,9 @@
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.launch
import com.bumptech.glide.Glide
+import com.example.firstapp.activity.VipActivity
import com.example.firstapp.database.response.UserInfo
+import com.example.firstapp.utils.PreferencesManager
class NotificationsFragment : Fragment() {
@@ -129,39 +131,6 @@
private fun setupClickListeners() {
- // 支付插件
- binding.payPlugin.setOnClickListener {
- // 跳转到支付插件页面
- lifecycleScope.launch {
- try {
- val response = RetrofitClient.apiService.getPayOrderInfo()
- var orderInfo=response.data
- Log.d("AliPayHelper","获取订单信息时: ${response}")
- // 这里调用支付宝
- PayAbility.aliPay(requireActivity(), orderInfo, Observer {
- when (it.resultStatus) {
- "9000" -> {
-// Snackbar.make(binding.root, "支付成功", Snackbar.LENGTH_LONG).show()
- requireActivity().runOnUiThread {
- Toast.makeText(requireContext(), "支付成功", Toast.LENGTH_LONG).show()
- }
- }
- else -> {
-// Snackbar.make(binding.root, "支付失败", Snackbar.LENGTH_LONG).show()
- requireActivity().runOnUiThread {
- Toast.makeText(requireContext(), "支付失败", Toast.LENGTH_LONG).show()
- }
-
- }
- }
- })
-
- } catch (e: Exception) {
- Log.d("AliPayHelper","获取订单信息时发生错误: ${e.message}")
- }
- }
- }
-
// 设置提醒
binding.layoutReminder.setOnClickListener {
@@ -210,7 +179,6 @@
// 隐私协议
binding.layoutPrivacy.setOnClickListener {
startContentActivity("privacy_policy", "隐私协议")
- startActivity(intent)
}
// 使用教程
@@ -233,8 +201,20 @@
// VIP续费
binding.btnRenew.setOnClickListener {
- Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show()
+// Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show()
+ // 跳转到vipActivity
+ val intent = Intent(requireContext(), VipActivity::class.java)
+ startActivity(intent)
}
+
+ binding.cardVip.setOnClickListener {
+// Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show()
+ // 跳转到vipActivity
+ val intent = Intent(requireContext(), VipActivity::class.java)
+ startActivity(intent)
+ }
+
+
}
private fun showEmailDialog() {
@@ -299,7 +279,14 @@
private suspend fun loadUserInfo() {
try {
- val response = RetrofitClient.apiService.getUserInfo("17586582287")
+ // 从本地获取保存的手机号
+ val savedPhone = PreferencesManager.getPhone()
+ if (savedPhone.isNullOrEmpty()) {
+ Toast.makeText(context, "用户未登录", Toast.LENGTH_SHORT).show()
+ return
+ }
+
+ val response = RetrofitClient.apiService.getUserInfo(savedPhone)
if (response.code == "0" && response.data != null) {
// 保存用户信息
currentUserInfo = response.data
@@ -316,15 +303,16 @@
binding.tvUserId.text = "个人账号:${userInfo.contactTel}"
// 设置VIP信息
- if (userInfo.showed) {
+ if (userInfo.isMember) {
binding.ivVip.visibility = View.VISIBLE
binding.cardVip.visibility = View.VISIBLE
- binding.tvVipExpire.text = "${userInfo.overTime} 到期"
+ binding.tvVipExpire.text = "${userInfo.memberOverDate} 到期"
} else {
//非会员信息
+ binding.ivVip.visibility = View.GONE
+ binding.cardVip.visibility = View.VISIBLE
binding.btnRenew.text = "立即开通"
binding.linearVipContainer.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.gray))
- binding.cardVip.visibility = View.GONE
}
}
} catch (e: Exception) {
--
Gitblit v1.9.3