From 1e6d955d13346ce89eb2819c86485eb6b122a8bb Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期三, 02 四月 2025 11:22:24 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
app/src/main/java/com/example/firstapp/activity/VipActivity.kt | 72 ++++++++++++++++++++++++++++--------
1 files changed, 56 insertions(+), 16 deletions(-)
diff --git a/app/src/main/java/com/example/firstapp/activity/VipActivity.kt b/app/src/main/java/com/example/firstapp/activity/VipActivity.kt
index 1199c1b..9cf1f11 100644
--- a/app/src/main/java/com/example/firstapp/activity/VipActivity.kt
+++ b/app/src/main/java/com/example/firstapp/activity/VipActivity.kt
@@ -1,6 +1,7 @@
package com.example.firstapp.activity
import android.app.AlertDialog
+import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.TypedValue
@@ -18,6 +19,7 @@
import androidx.cardview.widget.CardView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
+import androidx.core.content.ContentProviderCompat.requireContext
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
@@ -96,6 +98,10 @@
// 勾选协议点击事件
handlePrototalClick()
+
+ // VIP会员服务协议
+ handleVipProtocolClick()
+
}
@@ -105,11 +111,11 @@
// 监听 RadioButton 选中状态
protocol.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
isPaymentSelected = isChecked // 更新全局变量
- if(isChecked){
- protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round_selected)
- }else{
- protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round)
- }
+// if(isChecked){
+// protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round_selected)
+// }else{
+// protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round)
+// }
})
}
@@ -322,14 +328,17 @@
val alipayAmount:TextView = findViewById(R.id.alipay_amount);
val wechatAmount:TextView = findViewById(R.id.wechat_amount);
+ val protocolDescLayout:TextView = findViewById(R.id.protocol_desc_layout);
+
alipayAmount.text=currentPrice.toString()
wechatAmount.text=currentPrice.toString()
+ protocolDescLayout.text="自动续费可随时取消,开通后每月按${currentPrice.toString()}元自动续费,可随时取消自动续费"
}catch (e: Exception) {
Toast.makeText(this@VipActivity, e.message, Toast.LENGTH_LONG).show()
- Log.d("AliPayHelper","xuan: ${e.message}")
+ Log.d("AliPayHelper","支付失败: ${e.message}")
}
val adapter = CardAdapter(cardList) { cardViewList, cardData, cardView ->
@@ -359,7 +368,16 @@
layoutParams = ConstraintLayout.LayoutParams(
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, resources.displayMetrics).toInt(),
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, resources.displayMetrics).toInt()
- )
+ ).apply {
+ // 设置 margin
+ setMargins(
+ TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20f, resources.displayMetrics).toInt(), // left
+ TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, resources.displayMetrics).toInt(), // top
+ TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20f, resources.displayMetrics).toInt(), // right
+ TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, resources.displayMetrics).toInt() // bottom
+ )
+ }
+
}
val textView = TextView(this).apply {
@@ -371,7 +389,8 @@
val checkView = ImageView(this).apply {
id = View.generateViewId()
- setImageResource(R.drawable.ic_check)
+// setImageResource(R.drawable.ic_check)
+ setImageResource(R.mipmap.vip_right)
layoutParams = ConstraintLayout.LayoutParams(
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, resources.displayMetrics).toInt(),
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, resources.displayMetrics).toInt()
@@ -391,14 +410,14 @@
ConstraintSet.TOP,
previousViewId,
if (index == 0) ConstraintSet.TOP else ConstraintSet.BOTTOM,
- 16
+ 32
)
constraintSet.connect(
iconView.id,
ConstraintSet.START,
ConstraintSet.PARENT_ID,
ConstraintSet.START,
- 16
+ 32
)
// Text 位置
@@ -408,7 +427,7 @@
ConstraintSet.START,
iconView.id,
ConstraintSet.END,
- 8
+ 32
)
// Check 位置
@@ -418,7 +437,7 @@
ConstraintSet.END,
ConstraintSet.PARENT_ID,
ConstraintSet.END,
- 16
+ 32
)
constraintSet.applyTo(container)
@@ -462,7 +481,14 @@
alipayAmount.text=currentPrice.toString()
wechatAmount.text=currentPrice.toString()
// 处理点击事件,这里我们只是简单地展示一个 Toast
- Toast.makeText(this, "点击了: ${title}", Toast.LENGTH_SHORT).show()
+// Toast.makeText(this, "点击了: ${title}", Toast.LENGTH_SHORT).show()
+ // 只有连续包月才展示
+ val xieyiLayout:LinearLayout = findViewById(R.id.xieyi_layout);
+ if (title == "连续包月") {
+ xieyiLayout.visibility = View.VISIBLE
+ }else{
+ xieyiLayout.visibility = View.GONE
+ }
orderName = title
orderType=title
@@ -472,9 +498,6 @@
private fun loadUserInfo() {
// 获取Fragment实例
val memberInfoCardFragment = supportFragmentManager.findFragmentById(R.id.memberInfoCardFragment) as MemberInfoCardFragment?
-
-
-
lifecycleScope.launch {
try {
// 从本地获取保存的手机号
@@ -501,4 +524,21 @@
}
+ // VIP会员服务协议
+ private fun handleVipProtocolClick(){
+
+ binding.protocolVip.setOnClickListener{
+ startContentActivity("VIP会员服务协议", "VIP会员服务协议")
+ }
+
+ }
+
+ private fun startContentActivity(type: String, title: String) {
+ val intent = Intent(this, ContentDetailActivity::class.java).apply {
+ putExtra(ContentDetailActivity.ID, type)
+ putExtra(ContentDetailActivity.EXTRA_TITLE, title)
+ }
+ startActivity(intent)
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.3