From 8e2f0156923679a5774c17445db18c43d277ab0b Mon Sep 17 00:00:00 2001
From: tj <1378534974@qq.com>
Date: 星期三, 26 三月 2025 16:12:28 +0800
Subject: [PATCH] 1.vip续费页面-vip基础信息 2.vip续费页面-连续包月、年卡、月卡页面绘画

---
 app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt |   51 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 47 insertions(+), 4 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 ea75a47..9c128a1 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
@@ -15,6 +15,7 @@
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.content.ContextCompat
 import androidx.fragment.app.Fragment
+import androidx.lifecycle.Observer
 import androidx.lifecycle.lifecycleScope
 import androidx.navigation.fragment.findNavController
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -22,11 +23,15 @@
 import com.example.firstapp.activity.ContentDetailActivity
 import com.example.firstapp.database.service.RetrofitClient
 import com.example.firstapp.databinding.FragmentNotificationsBinding
+import com.example.firstapp.pay.PayAbility
 import com.example.firstapp.ui.reminderOther.ReminderOtherAddActivity2
 import com.example.firstapp.ui.reminderOther.ReminderSettingsFragmentOther
 import com.example.firstapp.ui.profile.EditProfileActivity
+import com.example.firstapp.utils.Log
+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
 
 class NotificationsFragment : Fragment() {
@@ -124,6 +129,41 @@
     }
 
     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 {
             findNavController().navigate(R.id.action_navigation_notifications_to_reminderSettingsFragment)
@@ -193,7 +233,10 @@
 
         // 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)
         }
     }
 
@@ -270,11 +313,11 @@
                     .load(userInfo.cover)
                     .placeholder(R.drawable.default_avatar)
                     .into(binding.ivAvatar)
-                
+
                 // 设置昵称和账号
                 binding.tvNickname.text = userInfo.name
                 binding.tvUserId.text = "个人账号:${userInfo.contactTel}"
-                
+
                 // 设置VIP信息
                 if (userInfo.showed) {
                     binding.ivVip.visibility = View.VISIBLE
@@ -295,7 +338,7 @@
 
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
-        
+
         // 加载用户信息
         lifecycleScope.launch {
             loadUserInfo()

--
Gitblit v1.9.3