From 85d11d6cd12abdd1e1f5f7516a7fb53a4826633f Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期二, 15 四月 2025 09:17:18 +0800 Subject: [PATCH] add: 消息提醒 --- app/src/main/java/com/example/firstapp/activity/VipActivity.kt | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 47 insertions(+), 9 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 a25ef54..34a255c 100644 --- a/app/src/main/java/com/example/firstapp/activity/VipActivity.kt +++ b/app/src/main/java/com/example/firstapp/activity/VipActivity.kt @@ -252,8 +252,9 @@ Toast.makeText(this@VipActivity, "请勾选协议", Toast.LENGTH_LONG).show() return@launch // 直接 return,不往下执行 } - Toast.makeText(this@VipActivity, "功能暂未开放", Toast.LENGTH_LONG).show() - return@launch +// Toast.makeText(this@VipActivity, "功能暂未开放", Toast.LENGTH_LONG).show() +// return@launch + doWechatPay() } catch (e: Exception) { @@ -266,6 +267,23 @@ } + private fun doWechatPay() { + val map=HashMap<String,String>() + map["appId"]="wxb4ba3c02aa476ea1" + map["partnerid"]="1900006771" + map["package"]="Sign=WXPay" + map["noncestr"]="2ac6c60ebfe7e549fbbc922ac54269bb" + map["timeStamp"]="1606317975" + map["prepayid"]="wx25232614962974fb29d1227819cc3e000g" + map["sign"]="wx25232614962974fb29d1227819cc3e000g" + PayAbility.wxPay(this, map, Observer { success -> + if (success == 0) { + Toast.makeText(this@VipActivity, "支付失败", Toast.LENGTH_LONG).show() + } else { + Toast.makeText(this@VipActivity, "支付成功", Toast.LENGTH_LONG).show() + } + }) + } private fun vipCardInit() { val recyclerView = findViewById<RecyclerView>(R.id.recycler_view) @@ -328,14 +346,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 -> @@ -365,7 +386,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 { @@ -377,7 +407,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() @@ -397,14 +428,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 位置 @@ -414,7 +445,7 @@ ConstraintSet.START, iconView.id, ConstraintSet.END, - 8 + 32 ) // Check 位置 @@ -424,7 +455,7 @@ ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END, - 16 + 32 ) constraintSet.applyTo(container) @@ -469,6 +500,13 @@ wechatAmount.text=currentPrice.toString() // 处理点击事件,这里我们只是简单地展示一个 Toast // 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 -- Gitblit v1.9.3