From f980c833f832c42094cf78005aab5d0eb014c8ec Mon Sep 17 00:00:00 2001
From: zhujie <leon.zhu@cloudroam.com.cn>
Date: 星期五, 18 四月 2025 15:23:58 +0800
Subject: [PATCH] 邀请有礼

---
 app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt |   50 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 43 insertions(+), 7 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 f87eb83..1d26709 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
@@ -21,6 +21,7 @@
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
 import com.example.firstapp.R
 import com.example.firstapp.activity.ContentDetailActivity
+import com.example.firstapp.activity.ReminderSettingsActivity
 import com.example.firstapp.database.service.RetrofitClient
 import com.example.firstapp.databinding.FragmentNotificationsBinding
 import com.example.firstapp.pay.PayAbility
@@ -31,8 +32,10 @@
 import com.google.android.material.snackbar.Snackbar
 import kotlinx.coroutines.launch
 import com.bumptech.glide.Glide
+import com.example.firstapp.activity.SettingActivity
 import com.example.firstapp.activity.VipActivity
 import com.example.firstapp.database.response.UserInfo
+import com.example.firstapp.ui.invitation.InvitationActivity
 import com.example.firstapp.utils.PreferencesManager
 
 class NotificationsFragment : Fragment() {
@@ -96,6 +99,14 @@
         return binding.root
     }
 
+    override fun onResume() {
+        super.onResume()
+        // 加载用户信息
+        lifecycleScope.launch {
+            loadUserInfo()
+        }
+    }
+
     private suspend fun loadConfigurations() {
         try {
             // 获取小红书链接
@@ -131,10 +142,24 @@
 
     private fun setupClickListeners() {
 
-
         // 设置提醒
         binding.layoutReminder.setOnClickListener {
-            findNavController().navigate(R.id.action_navigation_notifications_to_reminderSettingsFragment)
+            // 判断是否是会员
+            currentUserInfo?.let { user ->
+                if (user.isMember) {
+                    // 是会员,跳转到提醒设置页面
+                    val intent = Intent(requireContext(), ReminderSettingsActivity::class.java)
+                    startActivity(intent)
+                } else {
+                    // 不是会员,跳转到VIP页面
+                    val intent = Intent(requireContext(), VipActivity::class.java)
+                    intent.putExtra("source", "reminder")
+                    startActivity(intent)
+                    Toast.makeText(context, "开通会员后可使用提醒功能", Toast.LENGTH_SHORT).show()
+                }
+            } ?: run {
+                Toast.makeText(context, "正在加载用户信息,请稍后再试", Toast.LENGTH_SHORT).show()
+            }
         }
 
         // 待办
@@ -145,7 +170,9 @@
 
         // 好友邀请
         binding.layoutInvite.setOnClickListener {
-            shareToWechat()
+            // 跳转到邀请活动页面
+            val intent = Intent(requireActivity(), InvitationActivity::class.java)
+            startActivity(intent)
         }
 
         // AI助手
@@ -178,12 +205,12 @@
 
         // 隐私协议
         binding.layoutPrivacy.setOnClickListener {
-            startContentActivity("privacy_policy", "隐私协议")
+            startContentActivity("隐私协议", "隐私协议")
         }
 
         // 使用教程
         binding.layoutTutorial.setOnClickListener {
-            startContentActivity("user_guide", "使用教程")
+            startContentActivity("使用教程", "使用教程")
         }
 
         // 头像点击老的处理逻辑
@@ -211,6 +238,13 @@
 //            Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show()
             // 跳转到vipActivity
             val intent = Intent(requireContext(), VipActivity::class.java)
+            startActivity(intent)
+        }
+
+        // 设置按钮点击
+        binding.ivSetting.setOnClickListener {
+            // 跳转到
+            val intent = Intent(requireContext(), SettingActivity::class.java)
             startActivity(intent)
         }
 
@@ -269,9 +303,9 @@
         }
     }
 
-    private fun startContentActivity(type: String, title: String) {
+    private fun startContentActivity(id: String, title: String) {
         val intent = Intent(requireContext(), ContentDetailActivity::class.java).apply {
-            putExtra(ContentDetailActivity.EXTRA_CONTENT_TYPE, type)
+            putExtra(ContentDetailActivity.ID, id)
             putExtra(ContentDetailActivity.EXTRA_TITLE, title)
         }
         startActivity(intent)
@@ -292,6 +326,8 @@
                 currentUserInfo = response.data
                 val userInfo = response.data
 
+                // 本地保存我的邀请码
+                PreferencesManager.setInviteCode(userInfo.intervialcode);
                 // 设置头像
                 Glide.with(this)
                     .load(userInfo.cover)

--
Gitblit v1.9.3