From 8f218a39e45c8fffcba2247af011a779cb9ecce7 Mon Sep 17 00:00:00 2001
From: tj <1378534974@qq.com>
Date: 星期三, 02 四月 2025 11:09:38 +0800
Subject: [PATCH] 1.vip续费页面-样式修改

---
 app/src/main/java/com/example/firstapp/ui/vip/MemberInfoCardViewModel.kt |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 1 deletions(-)

diff --git a/app/src/main/java/com/example/firstapp/ui/vip/MemberInfoCardViewModel.kt b/app/src/main/java/com/example/firstapp/ui/vip/MemberInfoCardViewModel.kt
index 1530b32..fa18bcf 100644
--- a/app/src/main/java/com/example/firstapp/ui/vip/MemberInfoCardViewModel.kt
+++ b/app/src/main/java/com/example/firstapp/ui/vip/MemberInfoCardViewModel.kt
@@ -2,17 +2,38 @@
 
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
+import com.example.firstapp.R
+import com.example.firstapp.database.response.UserInfo
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.StateFlow
 import kotlinx.coroutines.launch
 
 class MemberInfoCardViewModel : ViewModel() {
-    // TODO: Implement the ViewModel
+
+    // 联系方式
     private val _phoneNumber = MutableStateFlow("18099999999")
     val phoneNumber: StateFlow<String> = _phoneNumber
 
+    // 开通状态
     private val _memberStatus = MutableStateFlow("未开通")
     val memberStatus: StateFlow<String> = _memberStatus
+
+    // 头像
+    private val _cover = MutableStateFlow("http://192.168.1.201:9000/sms/avatar/avatar_default.png")
+    val cover: StateFlow<String> = _cover
+
+    // vip头像
+    private val _vipCover = MutableStateFlow("")
+    val vipCover: StateFlow<String> = _vipCover
+
+    // 背景色
+    private val _background = MutableStateFlow(R.drawable.dialog_background)
+    val background: StateFlow<Int> = _background
+
+    // 背景色
+    private val _color = MutableStateFlow("#E8EAEE")
+    val color: StateFlow<String> = _color
+
 
     // 更新数据的方法
     fun updatePhoneNumber(phoneNumber: String) {
@@ -20,4 +41,52 @@
             _phoneNumber.value = phoneNumber
         }
     }
+
+    fun updateMemberStatus(userInfo: UserInfo) {
+        viewModelScope.launch {
+
+            // 电话号码
+            _phoneNumber.value=userInfo.contactTel
+
+            // 开通状态
+            if(userInfo.isMember){
+                // 判断userInfo.memberOvertime是否为空,如果不为空,则截取字符串到年月日
+//                if(userInfo.memberOvertime.isNotEmpty()){
+//                    _memberStatus.value = userInfo.memberOvertime.substring(0,10)+" 到期"
+//                }
+
+                _memberStatus.value = " 到期"
+                userInfo.memberOvertime?.let {
+                    if (it.isNotEmpty()) {
+                        _memberStatus.value = it.substring(0, 10) + " 到期"
+                    }
+                }
+                // vip头像
+                _vipCover.value ="http://192.168.1.201:9000/sms/member/vip.png"
+                _background.value = R.drawable.vip_black_background
+                _color.value ="#A9A9AB"
+
+            }else{
+                _memberStatus.value = "未开通"
+                _vipCover.value ="http://192.168.1.201:9000/sms/member/vip_no.png"
+                _background.value =R.drawable.vip_white_background
+                _color.value ="#A4A4A4"
+            }
+
+            // 头像
+            // 如果头像不为空的话,则更新头像
+//            if(userInfo.cover.isNotEmpty()){
+//                _cover.value = userInfo.cover
+//            }
+            userInfo.cover?.let {
+                if (it.isNotEmpty()) {
+                    _cover.value = it
+                }
+            }
+
+
+        }
+    }
+
+
 }
\ No newline at end of file

--
Gitblit v1.9.3