From cece79bf75a9b672b33b772acffca209eecfc8f2 Mon Sep 17 00:00:00 2001
From: zuoxiao <lf_zuo@163.com>
Date: 星期四, 26 六月 2025 08:27:25 +0800
Subject: [PATCH] refactor(generallibrary):优化补卡界面布局和样式- 调整了卡片信息展示区域的样式,包括背景色、文字颜色等 - 优化了输入区域的布局结构,减小了控件间距和尺寸- 更新了确认补卡按钮的样式 - 统一了文字大小和颜色,提高了可读性
---
generallibrary/src/main/java/com/dayu/general/activity/NewCard2Activity.kt | 59 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/generallibrary/src/main/java/com/dayu/general/activity/NewCard2Activity.kt b/generallibrary/src/main/java/com/dayu/general/activity/NewCard2Activity.kt
index 2eb3f4c..3f6fcb8 100644
--- a/generallibrary/src/main/java/com/dayu/general/activity/NewCard2Activity.kt
+++ b/generallibrary/src/main/java/com/dayu/general/activity/NewCard2Activity.kt
@@ -24,6 +24,7 @@
import com.dayu.general.databinding.ActivityNewCardGeBinding
import com.dayu.general.net.ApiManager
import com.dayu.general.net.BaseResponse
+import com.dayu.general.tool.BaseCommon.Companion.protocol
import com.dayu.general.tool.CardCommon.Companion.USER_CARD_TYPE_1
import com.dayu.general.tool.CardOperationType
import com.dayu.general.tool.NfcReadHelper
@@ -46,7 +47,7 @@
private var paymentMethod: String = "鐜伴噾"
// 鏀粯鏂瑰紡ID
- private var paymentId: Long = 0
+ private var paymentId: String = ""
// 鏀粯鏂瑰紡鍒楄〃
private var paymentMethodList: List<PaymentMethod> = listOf()
@@ -170,18 +171,49 @@
private fun getPaymentMethods() {
ApiManager.getInstance().requestGetLoading(
this,
- "sell/paymentmethod/get",
- PaymentMethodResponse::class.java,
+ "terminal/paymentmethod/get",
+ Any::class.java,
null,
- object : SubscriberListener<BaseResponse<PaymentMethodResponse>>() {
- override fun onNext(response: BaseResponse<PaymentMethodResponse>) {
+ object : SubscriberListener<BaseResponse<Any>>() {
+ override fun onNext(response: BaseResponse<Any>) {
if (response.success) {
- // 鑾峰彇鏀粯鏂瑰紡鍒楄〃
- val paymentMethods = response.content?.obj ?: listOf()
- if (paymentMethods.isNotEmpty()) {
- paymentMethodList = paymentMethods
- // 鏇存柊鏀粯鏂瑰紡鏄剧ず
- updatePaymentMethodRadioGroup()
+ try {
+ // 瀹夊叏鍦板鐞嗚繑鍥炵殑content锛屾湇鍔″櫒杩斿洖鐨勬槸ArrayList<LinkedHashMap>
+ val paymentMethods = mutableListOf<PaymentMethod>()
+ val content = response.content
+
+ if (content is List<*>) {
+ content.forEach { item ->
+ if (item is Map<*, *>) {
+ val id = item["id"]?.toString() ?: ""
+ val name = item["name"]?.toString() ?: ""
+ if (id.isNotEmpty() && name.isNotEmpty()) {
+ paymentMethods.add(PaymentMethod(id, name))
+ }
+ }
+ }
+ }
+
+ if (paymentMethods.isNotEmpty()) {
+ paymentMethodList = paymentMethods
+ // 鏇存柊鏀粯鏂瑰紡鏄剧ず
+ updatePaymentMethodRadioGroup()
+ } else {
+ Toast.makeText(
+ this@NewCard2Activity,
+ "鑾峰彇鏀粯鏂瑰紡澶辫触锛氳繑鍥炴暟鎹负绌�",
+ Toast.LENGTH_SHORT
+ ).show()
+ }
+ } catch (e: Exception) {
+ android.util.Log.e("NewCard2Activity", "瑙f瀽鏀粯鏂瑰紡鏁版嵁澶辫触", e)
+ android.util.Log.e("NewCard2Activity", "鍘熷鏁版嵁绫诲瀷: ${response.content?.javaClass?.name}")
+ android.util.Log.e("NewCard2Activity", "鍘熷鏁版嵁鍐呭: ${response.content}")
+ Toast.makeText(
+ this@NewCard2Activity,
+ "瑙f瀽鏀粯鏂瑰紡鏁版嵁澶辫触: ${e.message}",
+ Toast.LENGTH_SHORT
+ ).show()
}
} else {
Toast.makeText(
@@ -194,6 +226,7 @@
override fun onError(e: Throwable?) {
super.onError(e)
+ android.util.Log.e("NewCard2Activity", "缃戠粶璇锋眰澶辫触", e)
Toast.makeText(
this@NewCard2Activity,
"鑾峰彇鏀粯鏂瑰紡澶辫触: ${e?.message ?: "缃戠粶寮傚父"}",
@@ -323,7 +356,7 @@
params["amount"] = rechargeAmount // 鍏呭�奸噾棰�(鍏�)
params["paymentId"] = paymentId // 鏀粯鏂瑰紡ID
params["remarks"] = remark // 澶囨敞
- params["protocol"] = "p206V1_0_1" // 鍗忚
+ params["protocol"] = protocol // 鍗忚
params["operator"] = BaseApplication.userId // 鎿嶄綔浜篒D
// 鎵ц鍗$墖婵�娲籄PI璇锋眰
@@ -344,7 +377,7 @@
clientId = clientId,
cardFee = cardFee,
remark = binding.newCardRemark.text.toString(),
- paymentMethod = paymentId.toInt(),
+ paymentMethod = paymentId.toLongOrNull()?.toInt() ?: 0,
isReported = true,
isCardWritten = false, // 鍒濆璁剧疆涓篺alse锛屽啓鍗℃垚鍔熷悗鍐嶆洿鏂颁负true
operatorId = orderId,
--
Gitblit v1.8.0