From 2fece6551faab0402e7ed53658a60d2256e7a5be Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期四, 12 六月 2025 14:58:56 +0800 Subject: [PATCH] feat(generallibrary): 新增挂失功能并优化相关界面- 新增 LossCardActivity 和 CardWriteSuccessActivity - 实现卡片挂失功能和写卡成功页面 - 优化充值界面布局- 调整卡片信息显示逻辑 - 修复部分 UI样式问题 --- generallibrary/src/main/java/com/dayu/general/view/CardRefundDialog.kt | 78 + generallibrary/src/main/java/com/dayu/general/activity/LossCardActivity.kt | 306 +++++++++ generallibrary/src/main/java/com/dayu/general/activity/BSCardFragment.kt | 4 generallibrary/src/main/java/com/dayu/general/activity/RechargeFragment.kt | 84 +- generallibrary/src/main/res/drawable/edit_text_bg.xml | 29 generallibrary/src/main/res/layout/activity_recharge_detail.xml | 407 +++++++++++ README.md | 374 ++++++++++ generallibrary/src/main/res/layout/activity_card_list.xml | 4 generallibrary/src/main/res/layout/fragment_recharge.xml | 328 --------- generallibrary/src/main/java/com/dayu/general/activity/SearchUserListActivity.kt | 52 + generallibrary/src/main/res/layout/activity_card_write_success.xml | 88 ++ generallibrary/src/main/java/com/dayu/general/activity/RechargeDetailActivity.kt | 254 +++++++ generallibrary/src/main/AndroidManifest.xml | 3 generallibrary/src/main/java/com/dayu/general/bean/net/CardInfoResult.kt | 6 14 files changed, 1,616 insertions(+), 401 deletions(-) diff --git a/README.md b/README.md index f276ded..10c21e2 100644 --- a/README.md +++ b/README.md @@ -317,8 +317,17 @@ 2. 鐐瑰嚮浜嬩欢鐩戝惉 ```kotlin // 鏂瑰紡1锛氫娇鐢ㄧ被鍨嬪父閲忥紙鎺ㄨ崘锛� -titleBar.setOnItemclickListner(TitleBar.ClickType_LEFT_IMAGE) { finish() } -titleBar.setOnItemclickListner(TitleBar.ClickType_RIGHT_TEXT) { showMenu() } +titleBar.setOnItemclickListner(TitleBar.ClickType_LEFT_IMAGE) { + finish() +} +titleBar.setOnItemclickListner(TitleBar.ClickType_RIGHT_TEXT) { + showMenu() +} + +// 鎴栬�呬娇鐢ㄥ畬鏁寸殑OnClickListener +titleBar.setOnItemclickListner(TitleBar.ClickType_LEFT_IMAGE, View.OnClickListener { + finish() +}) // 鏂瑰紡2锛氫娇鐢ㄤ綅缃拰绫诲瀷甯搁噺锛堝凡搴熷純锛� titleBar.setOnItemclickListner(TitleBar.IMAGE, TitleBar.LEFT) { finish() } @@ -352,6 +361,173 @@ 2. 璁剧疆鏂囨湰鎴栧浘鐗囨椂锛屽鏋滀紶鍏ull鎴�0锛屽搴旂殑瑙嗗浘灏嗚闅愯棌 3. 缁勪欢榛樿浣跨敤鍨傜洿绾挎�у竷灞�锛岀‘淇濆湪甯冨眬鏂囦欢涓缃悎閫傜殑楂樺害 +#### 甯歌浣跨敤绀轰緥 +```kotlin +// 鍦ˋctivity鐨刬nitView鏂规硶涓缃� +private fun initView() { + // 璁剧疆杩斿洖鎸夐挳鐐瑰嚮浜嬩欢 + binding.titleBar.setOnItemclickListner(TitleBar.ClickType_LEFT_IMAGE) { + finish() + } + + // 璁剧疆鍙充晶鏂囨湰鎸夐挳鐐瑰嚮浜嬩欢 + binding.titleBar.setOnItemclickListner(TitleBar.ClickType_RIGHT_TEXT) { + // 澶勭悊鍙充晶鎸夐挳鐐瑰嚮閫昏緫 + handleRightButtonClick() + } +} +``` + +## 鏀粯鏂瑰紡鍔ㄦ�佽幏鍙栧姛鑳� + +椤圭洰涓疄鐜颁簡鏀粯鏂瑰紡鐨勫姩鎬佽幏鍙栧拰鏄剧ず鍔熻兘锛屾敮鎸佷粠鏈嶅姟鍣ㄨ幏鍙栨敮浠樻柟寮忓垪琛ㄥ苟鍔ㄦ�佸垱寤篟adioButton銆� + +### 鏁版嵁缁撴瀯 + +```kotlin +// 鏀粯鏂瑰紡鏁版嵁绫� +data class PaymentMethod( + val id: Long, + val name: String, + val remarks: String, + val deleted: Int +) + +// 鏀粯鏂瑰紡鎺ュ彛杩斿洖鏁版嵁绫� +data class PaymentMethodResponse( + val itemTotal: Any?, + val obj: List<PaymentMethod>, + val pageCurr: Any?, + val pageSize: Any?, + val pageTotal: Any? +) +``` + +### 浣跨敤鏂瑰紡 + +#### 1. 鍦ˋctivity涓坊鍔犳敮浠樻柟寮忕浉鍏冲睘鎬� + +```kotlin +class YourActivity : AppCompatActivity() { + // 鏀粯鏂瑰紡鐩稿叧灞炴�� + private var paymentMethod: String = "鐜伴噾" + private var paymentId: Long = 0 + private var paymentMethodList: List<PaymentMethod> = listOf() + + // ... 鍏朵粬浠g爜 +} +``` + +#### 2. 鑾峰彇鏀粯鏂瑰紡鍒楄〃 + +```kotlin +/** + * 鑾峰彇鏀粯鏂瑰紡鍒楄〃 + */ +private fun getPaymentMethods() { + ApiManager.getInstance().requestGetLoading( + this, + "sell/paymentmethod/get", + PaymentMethodResponse::class.java, + null, + object : SubscriberListener<BaseResponse<PaymentMethodResponse>>() { + override fun onNext(response: BaseResponse<PaymentMethodResponse>) { + if (response.success) { + val paymentMethods = response.content?.obj ?: listOf() + if (paymentMethods.isNotEmpty()) { + paymentMethodList = paymentMethods + updatePaymentMethodRadioGroup() + } + } else { + Toast.makeText(this@YourActivity, "鑾峰彇鏀粯鏂瑰紡澶辫触: ${response.msg}", Toast.LENGTH_SHORT).show() + } + } + + override fun onError(e: Throwable?) { + super.onError(e) + Toast.makeText(this@YourActivity, "鑾峰彇鏀粯鏂瑰紡澶辫触: ${e?.message ?: "缃戠粶寮傚父"}", Toast.LENGTH_SHORT).show() + } + } + ) +} +``` + +#### 3. 鍔ㄦ�佸垱寤篟adioButton + +```kotlin +/** + * 鏇存柊鏀粯鏂瑰紡RadioGroup + */ +private fun updatePaymentMethodRadioGroup() { + // 娓呯┖鍘熸湁RadioButton + binding.paymentMethodRadioGroup.removeAllViews() + + // 鍔ㄦ�佹坊鍔燫adioButton + paymentMethodList.forEachIndexed { index, method -> + val radioButton = RadioButton(this) + radioButton.id = View.generateViewId() + radioButton.layoutParams = LinearLayout.LayoutParams(0, resources.getDimensionPixelSize(R.dimen.dimen_40), 1.0f) + + // 璁剧疆鏍峰紡 + radioButton.text = method.name + radioButton.background = resources.getDrawable(R.drawable.radio_selector) + radioButton.buttonDrawable = null + radioButton.gravity = Gravity.CENTER + radioButton.setTextColor(resources.getColorStateList(R.color.radio_button_text_color)) + radioButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f) + + // 娣诲姞鍒癛adioGroup + binding.paymentMethodRadioGroup.addView(radioButton) + + // 榛樿閫変腑绗竴涓� + if (index == 0) { + radioButton.isChecked = true + paymentMethod = method.name + paymentId = method.id + } + } + + // 璁剧疆閫夋嫨鐩戝惉 + binding.paymentMethodRadioGroup.setOnCheckedChangeListener { group, checkedId -> + for (i in 0 until group.childCount) { + val radioButton = group.getChildAt(i) as RadioButton + if (radioButton.id == checkedId) { + paymentMethod = radioButton.text.toString() + paymentId = paymentMethodList[i].id + break + } + } + } +} +``` + +#### 4. 甯冨眬鏂囦欢閰嶇疆 + +```xml +<RadioGroup + android:id="@+id/paymentMethodRadioGroup" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <!-- 鍔ㄦ�佹坊鍔燫adioButton锛屼笉闇�瑕侀瀹氫箟 --> +</RadioGroup> +``` + +### 鍔熻兘鐗圭偣 + +1. **鍔ㄦ�佽幏鍙�**: 浠庢湇鍔″櫒鍔ㄦ�佽幏鍙栨敮浠樻柟寮忓垪琛紝鏀寔鍚庡彴閰嶇疆 +2. **鑷姩甯冨眬**: 鏍规嵁鏀粯鏂瑰紡鏁伴噺鑷姩璋冩暣RadioButton甯冨眬 +3. **鏍峰紡缁熶竴**: 鎵�鏈夊姩鎬佸垱寤虹殑RadioButton浣跨敤缁熶竴鐨勬牱寮� +4. **榛樿閫夋嫨**: 鑷姩閫変腑绗竴涓敮浠樻柟寮忎綔涓洪粯璁ら�夐」 +5. **浜嬩欢澶勭悊**: 鏀寔閫夋嫨鍙樺寲鐩戝惉锛屽疄鏃舵洿鏂板綋鍓嶉�変腑鐨勬敮浠樻柟寮� + +### 娉ㄦ剰浜嬮」 + +1. 纭繚鍦ㄨ皟鐢╜getPaymentMethods()`鍓嶅凡缁忓垵濮嬪寲浜嗙浉鍏崇殑UI缁勪欢 +2. 鍔ㄦ�佸垱寤虹殑RadioButton闇�瑕佽缃敮涓�鐨処D锛屼娇鐢╜View.generateViewId()` +3. 鍦ˋctivity閿�姣佹椂娉ㄦ剰娓呯悊鐩稿叧璧勬簮锛岄伩鍏嶅唴瀛樻硠婕� +4. 缃戠粶璇锋眰澶辫触鏃惰鏈夌浉搴旂殑閿欒澶勭悊鏈哄埗 + ## 娉ㄦ剰浜嬮」 1. 鏁版嵁搴撹縼绉� @@ -371,6 +547,200 @@ - 纭繚寮傚父淇℃伅琚纭褰曞拰涓婃姤 - 閬垮厤寮傚父淇℃伅娉勯湶鏁忔劅鏁版嵁 +5. API寮傚父澶勭悊鏈�浣冲疄璺� + - 閽堝鐗瑰畾閿欒鐮佹彁渚涘弸濂界殑鐢ㄦ埛鎻愮ず + - 鍖哄垎缃戠粶寮傚父銆佷笟鍔″紓甯稿拰绯荤粺寮傚父 + - 寮傚父鍙戠敓鍚庡強鏃堕噸缃甎I鐘舵�侊紝鍏佽鐢ㄦ埛閲嶈瘯 + - 鎻愪緵鏄庣‘鐨勬搷浣滄寚寮曪紝濡�"璇峰厛杩涜寮�鍗℃搷浣�" + +### API寮傚父澶勭悊绀轰緥 + +```kotlin +// 鍦ˋPI鍥炶皟涓鐞嗕笉鍚岀被鍨嬬殑寮傚父 +object : SubscriberListener<BaseResponse<YourDataType>>() { + override fun onNext(response: BaseResponse<YourDataType>) { + if (response.success) { + // 澶勭悊鎴愬姛鎯呭喌 + handleSuccess(response.content) + } else { + // 澶勭悊涓氬姟寮傚父 + handleBusinessError(response.code, response.msg) + } + } + + override fun onError(e: Throwable?) { + super.onError(e) + // 澶勭悊缃戠粶寮傚父 + handleNetworkError(e) + // 閲嶇疆UI鐘舵�� + resetViewState() + } +} + +// 涓氬姟寮傚父澶勭悊鏂规硶 +private fun handleBusinessError(code: String?, msg: String?) { + when (code) { + "1081" -> ToastUtil.show("璇ュ崱鐗囨湭鍦ㄧ郴缁熶腑娉ㄥ唽锛岃鍏堣繘琛屽紑鍗℃搷浣�") + "1001" -> ToastUtil.show("鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊鍛�") + "1002" -> ToastUtil.show("璐︽埛浣欓涓嶈冻") + else -> { + val errorMsg = when { + msg.isNullOrBlank() -> "鎿嶄綔澶辫触锛岃閲嶈瘯" + msg.contains("鏁版嵁涓嶅瓨鍦�") -> "鏁版嵁涓嶅瓨鍦紝璇锋鏌ヨ緭鍏ヤ俊鎭�" + msg.contains("缃戠粶") -> "缃戠粶杩炴帴寮傚父锛岃妫�鏌ョ綉缁滃悗閲嶈瘯" + msg.contains("瓒呮椂") -> "璇锋眰瓒呮椂锛岃閲嶈瘯" + else -> "鎿嶄綔澶辫触: $msg" + } + ToastUtil.show(errorMsg) + } + } + // 閲嶇疆鐣岄潰鐘舵�� + resetViewState() +} + +// 缃戠粶寮傚父澶勭悊鏂规硶 +private fun handleNetworkError(e: Throwable?) { + val errorMsg = when { + e?.message?.contains("timeout") == true -> "缃戠粶璇锋眰瓒呮椂锛岃妫�鏌ョ綉缁滆繛鎺�" + e?.message?.contains("network") == true -> "缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃�" + e?.message?.contains("host") == true -> "鏈嶅姟鍣ㄨ繛鎺ュけ璐ワ紝璇风◢鍚庨噸璇�" + else -> "缃戠粶寮傚父: ${e?.message ?: "鏈煡閿欒"}" + } + ToastUtil.show(errorMsg) +} + +### Dialog寮圭獥浣跨敤鏈�浣冲疄璺� + +椤圭洰涓彁渚涗簡澶氱Dialog缁勪欢锛岀敤浜庝笉鍚岀殑浜や簰鍦烘櫙銆傛帹鑽愪娇鐢ㄩ」鐩凡鏈夌殑Dialog缁勪欢鏉ヤ繚鎸乁I椋庢牸鐨勪竴鑷存�с�� + +#### 甯哥敤Dialog缁勪欢 + +1. **ConfirmDialog**: 纭瀵硅瘽妗嗭紝鐢ㄤ簬閲嶈鎿嶄綔鐨勪簩娆$‘璁� +2. **TipDialog**: 鎻愮ず瀵硅瘽妗嗭紝鐢ㄤ簬鏄剧ず鎻愮ず淇℃伅 +3. **EdtDialog**: 杈撳叆瀵硅瘽妗嗭紝鐢ㄤ簬鑾峰彇鐢ㄦ埛杈撳叆 +4. **鑷畾涔塂ialog**: 缁ф壙Dialog绫诲疄鐜扮壒瀹氬姛鑳� + +#### ConfirmDialog浣跨敤绀轰緥 + +```kotlin +// 鍩烘湰鐢ㄦ硶 - 鍙樉绀烘秷鎭� +val dialog = ConfirmDialog(context, "鎿嶄綔鎴愬姛") +dialog.show() + +// 甯︽爣棰樼殑鐢ㄦ硶 +val dialog = ConfirmDialog(context, "鎻愮ず", "纭瑕佸垹闄よ繖鏉¤褰曞悧锛�") { + // 鐐瑰嚮纭鎸夐挳鐨勫洖璋� + deleteRecord() + dialog.dismiss() +} +dialog.show() + +// 鍦ㄥ紓甯稿鐞嗕腑浣跨敤 +private fun handleError(title: String, message: String) { + activity?.let { activity -> + val confirmDialog = ConfirmDialog(activity, title, message) { + // 鐐瑰嚮纭鍚庣殑鎿嶄綔 + resetViewState() + } + confirmDialog.show() + } +} +``` + +#### TipDialog浣跨敤绀轰緥 + +```kotlin +// 绠�鍗曟彁绀� +val tipDialog = TipDialog(context, "鎿嶄綔瀹屾垚") +tipDialog.show() + +// 甯﹀洖璋冪殑鎻愮ず +val tipDialog = TipDialog(context, "纭閫�鍑哄簲鐢紵", object : TipUtil.TipListener { + override fun onCancle() { + // 鍙栨秷鎿嶄綔 + } +}) +tipDialog.show() +``` + +#### 鑷畾涔塂ialog鏈�浣冲疄璺� + +```kotlin +class CustomDialog(context: Context) : Dialog(context, R.style.ws_pay_showSelfDialog) { + + private lateinit var binding: DialogCustomBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DialogCustomBinding.inflate(layoutInflater) + setContentView(binding.root) + + // 璁剧疆瀵硅瘽妗嗗睘鎬� + setupDialog() + + // 鍒濆鍖栬鍥� + initViews() + } + + private fun setupDialog() { + // 璁剧疆瀵硅瘽妗嗗搴︿负灞忓箷瀹藉害鐨�85% + window?.apply { + val params = attributes + params.width = (context.resources.displayMetrics.widthPixels * 0.85).toInt() + params.height = ViewGroup.LayoutParams.WRAP_CONTENT + params.gravity = Gravity.CENTER + attributes = params + setBackgroundDrawableResource(android.R.color.transparent) + } + + // 璁剧疆鐐瑰嚮澶栭儴涓嶅彇娑� + setCanceledOnTouchOutside(false) + } + + private fun initViews() { + binding.btnConfirm.setOnClickListener { + // 澶勭悊纭閫昏緫 + dismiss() + } + + binding.btnCancel.setOnClickListener { + dismiss() + } + } +} +``` + +#### Dialog浣跨敤娉ㄦ剰浜嬮」 + +1. **鍐呭瓨娉勬紡闃叉姢**: 纭繚鍦ˋctivity閿�姣佹椂鍏抽棴Dialog +```kotlin +override fun onDestroy() { + super.onDestroy() + dialog?.dismiss() +} +``` + +2. **鐢熷懡鍛ㄦ湡绠$悊**: 鍦‵ragment涓娇鐢―ialog鏃舵敞鎰忕敓鍛藉懆鏈� +```kotlin +// 鍦‵ragment涓畨鍏ㄦ樉绀篋ialog +activity?.let { activity -> + if (!activity.isFinishing && !activity.isDestroyed) { + dialog.show() + } +} +``` + +3. **鏍峰紡涓�鑷存��**: 浣跨敤椤圭洰缁熶竴鐨凞ialog鏍峰紡 +```kotlin +// 浣跨敤椤圭洰瀹氫箟鐨凞ialog鏍峰紡 +super(context, R.style.ws_pay_showSelfDialog) +``` + +4. **鐢ㄦ埛浣撻獙浼樺寲**: + - 閲嶈鎿嶄綔浣跨敤ConfirmDialog杩涜浜屾纭 + - 閿欒淇℃伅浣跨敤甯︽爣棰樼殑Dialog锛屾彁渚涙竻鏅扮殑閿欒鍒嗙被 + - 闀挎椂闂存搷浣滄樉绀哄姞杞紻ialog锛岄伩鍏嶇敤鎴疯鎿嶄綔 + ## 璐$尞鎸囧崡 1. Fork 椤圭洰 diff --git a/generallibrary/src/main/AndroidManifest.xml b/generallibrary/src/main/AndroidManifest.xml index fccc705..fb429e6 100644 --- a/generallibrary/src/main/AndroidManifest.xml +++ b/generallibrary/src/main/AndroidManifest.xml @@ -42,6 +42,7 @@ <activity android:name="com.dayu.general.activity.NewCardActivity" /> <activity android:name="com.dayu.general.activity.ManageListActivity" /> <activity android:name="com.dayu.general.activity.SearchUserListActivity" /> + <activity android:name="com.dayu.general.activity.RechargeDetailActivity" /> <activity android:name="com.dayu.general.activity.NfcWreatActivity" android:exported="false" @@ -90,6 +91,8 @@ <!-- 鍐欏崱鎴愬姛椤甸潰 --> <activity android:name=".activity.CardWriteSuccessActivity" /> + <!-- 鎸傚け椤甸潰 --> + <activity android:name=".activity.LossCardActivity"/> <meta-data android:name="BUGLY_APP_VERSION" diff --git a/generallibrary/src/main/java/com/dayu/general/activity/BSCardFragment.kt b/generallibrary/src/main/java/com/dayu/general/activity/BSCardFragment.kt index 408e290..3ed6595 100644 --- a/generallibrary/src/main/java/com/dayu/general/activity/BSCardFragment.kt +++ b/generallibrary/src/main/java/com/dayu/general/activity/BSCardFragment.kt @@ -42,9 +42,7 @@ startActivity(intent) } binding.homeLossLL.setOnClickListener { - val intent = Intent(context, SearchCardListActivity::class.java).apply{ - putExtra("type", "loss") - } + val intent = Intent(context, LossCardActivity::class.java) startActivity(intent) } binding.homeReplaceLL.setOnClickListener{ diff --git a/generallibrary/src/main/java/com/dayu/general/activity/LossCardActivity.kt b/generallibrary/src/main/java/com/dayu/general/activity/LossCardActivity.kt new file mode 100644 index 0000000..424d5f0 --- /dev/null +++ b/generallibrary/src/main/java/com/dayu/general/activity/LossCardActivity.kt @@ -0,0 +1,306 @@ +package com.dayu.general.activity + +import android.os.Bundle +import androidx.recyclerview.widget.LinearLayoutManager +import com.dayu.baselibrary.net.subscribers.SubscriberListener +import com.dayu.baselibrary.utils.ToastUtil +import com.dayu.baselibrary.view.TitleBar.ClickType_LEFT_IMAGE +import com.dayu.baselibrary.view.TitleBar.ClickType_RIGHT_IMAGE +import com.dayu.general.BaseApplication +import com.dayu.general.adapter.CardListAdapter +import com.dayu.general.bean.net.SearchCardResult +import com.dayu.general.databinding.ActivityCardListBinding +import com.dayu.general.net.ApiManager +import com.dayu.general.net.BaseResponse +import com.dayu.general.view.CardRefundDialog +import com.dayu.general.view.SearchDialog +import com.scwang.smart.refresh.layout.api.RefreshLayout +import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener + +/** + * Description: + * Author: zuo + * Date: 2025/6/11 + */ +class LossCardActivity : BaseActivity() { + + var binding: ActivityCardListBinding? = null + private var cardAdapter: CardListAdapter? = null + var searchDialog: SearchDialog? = null + + // 鍒嗛〉鐩稿叧鍙橀噺 + private var currentPage = 1 + private val pageSize = 20 + private var hasMoreData = true + + // 淇濆瓨褰撳墠鎼滅储鏉′欢 + private var currentFarmerId = "" + private var currentFarmerName = "" + private var currentCardNumber = "" + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityCardListBinding.inflate(layoutInflater) + setContentView(binding?.root) + initView() + setupRecyclerView() + setupRefreshLayout() + + // 纭繚Footer鍒濆鐘舵�佹纭� + binding?.refreshLayout?.setEnableLoadMore(true) + } + + fun initView() { + searchDialog = SearchDialog(this) + searchDialog?.show() + binding?.titleBar?.setOnItemclickListner(ClickType_LEFT_IMAGE) { this.finish() } + // 璁剧疆鎼滅储鐩戝惉鍣� + searchDialog?.setOnSearchListener(object : SearchDialog.OnSearchListener { + override fun onSearch(farmerId: String, farmerName: String, cardNumber: String) { + // 淇濆瓨褰撳墠鎼滅储鏉′欢 + currentCardNumber = cardNumber + currentFarmerId = farmerId + currentFarmerName = farmerName + + // 閲嶇疆鍒嗛〉鐘舵�� + currentPage = 1 + hasMoreData = true + + // 閲嶇疆鏃犳洿澶氭暟鎹姸鎬� + binding?.refreshLayout?.resetNoMoreData() + + // 鎵ц鎼滅储 + searchCards(currentFarmerId, currentFarmerName, currentCardNumber, true) + } + }) + binding?.titleBar?.setOnItemclickListner(ClickType_RIGHT_IMAGE) { + // 鏄剧ず鎼滅储瀵硅瘽妗� + searchDialog?.show() + } + } + + private fun setupRecyclerView() { + cardAdapter = CardListAdapter(this) + binding?.recyclerView?.apply { + layoutManager = LinearLayoutManager(this@LossCardActivity) + adapter = cardAdapter + } + + // 璁剧疆鍒楄〃椤圭偣鍑讳簨浠� + cardAdapter?.setOnItemClickListener { card -> + // 鏄剧ず閫�娆惧璇濇 + val refundDialog = CardRefundDialog(this) + refundDialog.show() // 鍏堟樉绀哄璇濇 + refundDialog.setUserInfo( + card.clientName.toString(), + card.cardNum.toString(), + card.money.toString() + ) + refundDialog.setOnConfirmListener { refundAmount, remark -> + // TODO: 澶勭悊閫�娆鹃�昏緫 + lossPost(card.idCard.toString()) + } + } + + + } + + private fun setupRefreshLayout() { + binding?.refreshLayout?.apply { + // 璁剧疆Footer璺熼殢鍔熻兘锛岀‘淇濇棤鏇村鏁版嵁鏃禙ooter鑳芥纭樉绀� + setEnableFooterFollowWhenNoMoreData(true) + // 璁剧疆鍔犺浇鏇村瀹屾垚鍚庢粴鍔ㄥ唴瀹规樉绀烘柊鏁版嵁 + setEnableScrollContentWhenLoaded(true) + // 绂佺敤绾粴鍔ㄦā寮忥紝纭繚Footer鑳芥甯稿伐浣� + setEnableOverScrollDrag(false) + + // 璁剧疆鍒锋柊鍜屽姞杞芥洿澶氱洃鍚櫒 + setOnRefreshLoadMoreListener(object : OnRefreshLoadMoreListener { + override fun onRefresh(refreshLayout: RefreshLayout) { + // 閲嶇疆椤电爜骞跺埛鏂版暟鎹� + currentPage = 1 + hasMoreData = true + // 閲嶇疆鏃犳洿澶氭暟鎹姸鎬� + refreshLayout.resetNoMoreData() + searchCards(currentFarmerId, currentFarmerName, currentCardNumber, true) + } + + override fun onLoadMore(refreshLayout: RefreshLayout) { + // 濡傛灉杩樻湁鏇村鏁版嵁锛屽姞杞戒笅涓�椤� + if (hasMoreData) { + currentPage++ + searchCards(currentFarmerId, currentFarmerName, currentCardNumber, false) + } else { + // 瀹屾垚鍔犺浇骞舵樉绀哄凡鍒板簳鐘舵�� + refreshLayout.finishLoadMoreWithNoMoreData() + } + } + }) + } + } + + /** + * 鏍规嵁鍗″彿銆佸鎴风紪鍙峰拰瀹㈡埛濮撳悕鎼滅储鍗$墖 + * + * 姝ゅ嚱鏁版瀯寤轰竴涓弬鏁版槧灏勶紝鏍规嵁鎻愪緵鐨勫崱鍙枫�佸鎴风紪鍙峰拰瀹㈡埛濮撳悕鏉ユ悳绱㈠崱鐗� + * 瀹冧粎鍖呭惈鏈夋晥鐨勩�侀潪绌虹殑鎼滅储鍙傛暟锛屼互纭繚鎼滅储璇锋眰鐨勫噯纭�у拰鏁堢巼 + * + * @param cardNumber 鍗″彿 + * @param clientNumber 瀹㈡埛缂栧彿 + * @param clientName 瀹㈡埛濮撳悕 + * @param isRefresh 鏄惁涓哄埛鏂版搷浣� + */ + private fun searchCards( + farmerId: String, + farmerName: String, + cardNumber: String, + isRefresh: Boolean = true + ) { + val map = mutableMapOf<String, Any>() + + if (cardNumber.isNotEmpty()) { + map["cardNum"] = cardNumber + } + + if (farmerId.isNotEmpty()) { + map["clientNum"] = farmerId + } + + if (farmerName.isNotEmpty()) { + map["clientName"] = farmerName + } + + // 娣诲姞鍒嗛〉鍙傛暟 + map["pageCurr"] = currentPage + map["pageSize"] = pageSize + + // 浣跨敤姝g‘鐨勭被鍨嬪弬鏁� + ApiManager.getInstance().requestGetLoading( + this, + "sell/clientcard/getcards", + SearchCardResult::class.java, + map, + object : SubscriberListener<BaseResponse<SearchCardResult>>() { + override fun onNext(t: BaseResponse<SearchCardResult>) { + if (t.success) { + // 澶勭悊鎼滅储鎴愬姛鐨勬儏鍐� + val result = t.content + if (result != null) { + // 澶勭悊鎼滅储缁撴灉 + if (result.obj.isNotEmpty()) { + // 鏍规嵁鏄惁涓哄埛鏂版搷浣滃喅瀹氬浣曟洿鏂版暟鎹� + if (isRefresh) { + cardAdapter?.setData(result.obj) + } else { + cardAdapter?.addData(result.obj) + } + + // 鍒ゆ柇鏄惁杩樻湁鏇村鏁版嵁锛氭牴鎹綋鍓嶉〉鐮佸拰鎬婚〉鏁板垽鏂� + hasMoreData = currentPage < result.pageTotal + + // 瀹屾垚鍒锋柊鎴栧姞杞藉姩浣� + if (isRefresh) { + binding?.refreshLayout?.finishRefresh(true) + } else { + // 濡傛灉娌℃湁鏇村鏁版嵁浜嗭紝璁剧疆宸插埌搴曠姸鎬� + if (!hasMoreData) { + binding?.refreshLayout?.finishLoadMoreWithNoMoreData() + } else { + binding?.refreshLayout?.finishLoadMore(true) + } + } + } else { + if (isRefresh) { + cardAdapter?.setData(emptyList()) + binding?.refreshLayout?.finishRefresh(true) + ToastUtil.show("鏈壘鍒板尮閰嶇殑鍗$墖") + } else { + hasMoreData = false + // 浣跨敤finishLoadMoreWithNoMoreData鏄剧ず宸插埌搴曠姸鎬� + binding?.refreshLayout?.finishLoadMoreWithNoMoreData() + } + } + } else { + if (isRefresh) { + cardAdapter?.setData(emptyList()) + binding?.refreshLayout?.finishRefresh(true) + ToastUtil.show("鏈壘鍒板尮閰嶇殑鍗$墖") + } else { + hasMoreData = false + binding?.refreshLayout?.finishLoadMoreWithNoMoreData() + } + } + } else { + // 澶勭悊鎼滅储澶辫触鐨勬儏鍐� + finishRefreshOrLoad(isRefresh) + ToastUtil.show(t.msg) + } + } + + override fun onError(e: Throwable?) { + super.onError(e) + // 瀹屾垚鍒锋柊鎴栧姞杞藉姩浣� + finishRefreshOrLoad(isRefresh) + ToastUtil.show("鎼滅储澶辫触: ${e?.message ?: "鏈煡閿欒"}") + } + } + ) + } + + + private fun lossPost(cardNumber: String) { + val map = mutableMapOf<String, Any>() + + map["cardNum"] = cardNumber + map["operator"] = BaseApplication.userId + ApiManager.getInstance().requestGetLoading( + this, + "/sell/card/loss", + SearchCardResult::class.java, + map, + object : SubscriberListener<BaseResponse<SearchCardResult>>() { + override fun onNext(t: BaseResponse<SearchCardResult>) { + + + if (t.success) { + + } else { + // 澶勭悊鎼滅储澶辫触鐨勬儏鍐� + ToastUtil.show(t.msg) + } + } + + override fun onError(e: Throwable?) { + super.onError(e) + // 瀹屾垚鍒锋柊鎴栧姞杞藉姩浣� + ToastUtil.show("鎼滅储澶辫触: ${e?.message ?: "鏈煡閿欒"}") + } + } + ) + } + + + /** + * 瀹屾垚鍒锋柊鎴栧姞杞芥搷浣� + * @param isRefresh 鏄惁涓哄埛鏂版搷浣� + */ + private fun finishRefreshOrLoad(isRefresh: Boolean) { + if (isRefresh) { + binding?.refreshLayout?.finishRefresh(true) + } else { + // 濡傛灉娌℃湁鏇村鏁版嵁锛屼笉鍦ㄨ繖閲岃皟鐢╢inishLoadMore锛岀敱鍏蜂綋閫昏緫璋冪敤finishLoadMoreWithNoMoreData + // 濡傛灉鏈夋洿澶氭暟鎹紝鍒欐甯歌皟鐢╢inishLoadMore + if (hasMoreData) { + binding?.refreshLayout?.finishLoadMore(true) + } + // 娉ㄦ剰锛氬綋hasMoreData涓篺alse鏃讹紝涓嶈皟鐢ㄤ换浣昮inish鏂规硶锛� + // 鍥犱负宸茬粡鍦ㄥ叿浣撻�昏緫涓皟鐢ㄤ簡finishLoadMoreWithNoMoreData() + } + } + + override fun onDestroy() { + super.onDestroy() + searchDialog?.dismiss() + } + +} \ No newline at end of file diff --git a/generallibrary/src/main/java/com/dayu/general/activity/RechargeDetailActivity.kt b/generallibrary/src/main/java/com/dayu/general/activity/RechargeDetailActivity.kt new file mode 100644 index 0000000..3d1a949 --- /dev/null +++ b/generallibrary/src/main/java/com/dayu/general/activity/RechargeDetailActivity.kt @@ -0,0 +1,254 @@ +package com.dayu.general.activity + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import android.util.TypedValue +import android.view.View +import android.widget.RadioButton +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.dayu.baselibrary.net.subscribers.SubscriberListener +import com.dayu.baselibrary.utils.ToastUtil +import com.dayu.baselibrary.view.TitleBar +import com.dayu.general.R +import com.dayu.general.bean.net.CardInfoResult +import com.dayu.general.bean.net.PaymentMethod +import com.dayu.general.bean.net.PaymentMethodResponse +import com.dayu.general.databinding.ActivityRechargeDetailBinding +import com.dayu.general.net.ApiManager +import com.dayu.general.net.BaseResponse + +class RechargeDetailActivity : AppCompatActivity() { + + private lateinit var binding: ActivityRechargeDetailBinding + private var cardInfo: CardInfoResult? = null + private var cardAddress: String? = null + + // 鏀粯鏂瑰紡鐩稿叧灞炴�� + private var paymentMethod: String = "鐜伴噾" + private var paymentId: Long = 0 + private var paymentMethodList: List<PaymentMethod> = listOf() + + companion object { + private const val EXTRA_CARD_INFO = "extra_card_info" + private const val EXTRA_CARD_ADDRESS = "extra_card_address" + + fun start(context: Context, cardInfo: CardInfoResult?, cardAddress: String?) { + val intent = Intent(context, RechargeDetailActivity::class.java) + intent.putExtra(EXTRA_CARD_INFO, cardInfo) + intent.putExtra(EXTRA_CARD_ADDRESS, cardAddress) + context.startActivity(intent) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityRechargeDetailBinding.inflate(layoutInflater) + setContentView(binding.root) + + // 闅愯棌榛樿ActionBar + supportActionBar?.hide() + + // 鑾峰彇浼犻�掔殑鏁版嵁 + cardInfo = intent.getSerializableExtra(EXTRA_CARD_INFO) as? CardInfoResult + cardAddress = intent.getStringExtra(EXTRA_CARD_ADDRESS) + + initView() + displayCardInfo() + // 鑾峰彇鏀粯鏂瑰紡 + getPaymentMethods() + } + + private fun initView() { + // 璁剧疆TitleBar鐨勮繑鍥炴寜閽偣鍑讳簨浠� + binding.titleBar.setOnItemclickListner(TitleBar.ClickType_LEFT_IMAGE) { + finish() + } + + // 璁剧疆鎸夐挳鐐瑰嚮浜嬩欢 + binding.rechargeRegistBtn.setOnClickListener { + // 澶勭悊鍐欏崱閫昏緫 + handleWriteCard() + } + } + + /** + * 鑾峰彇鏀粯鏂瑰紡鍒楄〃 + */ + private fun getPaymentMethods() { + ApiManager.getInstance().requestGetLoading( + this, + "sell/paymentmethod/get", + PaymentMethodResponse::class.java, + null, + object : SubscriberListener<BaseResponse<PaymentMethodResponse>>() { + override fun onNext(response: BaseResponse<PaymentMethodResponse>) { + if (response.success) { + // 鑾峰彇鏀粯鏂瑰紡鍒楄〃 + val paymentMethods = response.content?.obj ?: listOf() + if (paymentMethods.isNotEmpty()) { + paymentMethodList = paymentMethods + // 鏇存柊鏀粯鏂瑰紡鏄剧ず + updatePaymentMethodRadioGroup() + } + } else { + Toast.makeText( + this@RechargeDetailActivity, + "鑾峰彇鏀粯鏂瑰紡澶辫触: ${response.msg}", + Toast.LENGTH_SHORT + ).show() + } + } + + override fun onError(e: Throwable?) { + super.onError(e) + Toast.makeText( + this@RechargeDetailActivity, + "鑾峰彇鏀粯鏂瑰紡澶辫触: ${e?.message ?: "缃戠粶寮傚父"}", + Toast.LENGTH_SHORT + ).show() + } + } + ) + } + + /** + * 鏇存柊鏀粯鏂瑰紡RadioGroup + */ + private fun updatePaymentMethodRadioGroup() { + // 娓呯┖鍘熸湁RadioButton + binding.newCardPaymentMethod.removeAllViews() + + // 鍔ㄦ�佹坊鍔燫adioButton + paymentMethodList.forEachIndexed { index, method -> + val radioButton = RadioButton(this) + radioButton.id = View.generateViewId() // 鐢熸垚鍞竴ID + radioButton.layoutParams = android.widget.LinearLayout.LayoutParams( + 0, + resources.getDimensionPixelSize(R.dimen.dimen_40), + 1.0f + ) + + // 濡傛灉涓嶆槸鏈�鍚庝竴涓寜閽紝娣诲姞鍙宠竟璺� + if (index < paymentMethodList.size - 1) { + (radioButton.layoutParams as android.widget.LinearLayout.LayoutParams).rightMargin = + resources.getDimensionPixelSize(R.dimen.dimen_15) + } + + radioButton.text = method.name + radioButton.background = resources.getDrawable(R.drawable.radio_selector) + radioButton.buttonDrawable = null + radioButton.gravity = android.view.Gravity.CENTER + radioButton.setTextColor(resources.getColorStateList(R.color.radio_button_text_color)) + radioButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f) + + // 娣诲姞鍒癛adioGroup + binding.newCardPaymentMethod.addView(radioButton) + + // 榛樿閫変腑绗竴涓� + if (index == 0) { + radioButton.isChecked = true + paymentMethod = method.name + paymentId = method.id + } + } + + // 璁剧疆鏀粯鏂瑰紡閫夋嫨鐩戝惉 + binding.newCardPaymentMethod.setOnCheckedChangeListener { group, checkedId -> + // 鏍规嵁閫変腑鐨処D鑾峰彇鏀粯鏂瑰紡 + for (i in 0 until group.childCount) { + val radioButton = group.getChildAt(i) as RadioButton + if (radioButton.id == checkedId) { + paymentMethod = radioButton.text.toString() + paymentId = paymentMethodList[i].id + break + } + } + } + } + + private fun displayCardInfo() { + if (cardInfo == null) { + ToastUtil.show("鍗′俊鎭负绌�") + finish() + return + } + + cardInfo?.let { info -> + // 璁剧疆鍗$墖淇℃伅 + binding.redInitCode.text = cardAddress ?: "" + binding.userName.text = info.userName ?: "" + binding.redCardNum.text = info.cardNum ?: "" + binding.redRemainderBlance.text = "${info.balance ?: 0} 鍏�" + + // 璁剧疆鍗$姸鎬佸拰瀵瑰簲棰滆壊 + val cardStatus = when (info.status) { + 1 -> "姝e父" + 2 -> "鎸傚け" + 3 -> "閿佸畾" + 4 -> "鏃犳晥鍗$墖" + else -> "鏈煡" + } + binding.redStatu.text = cardStatus + + // 鏍规嵁鍗$姸鎬佽缃笉鍚岄鑹� + val statusColor = when (info.status) { + 1 -> android.graphics.Color.parseColor("#4CAF50") // 缁胯壊-姝e父 + 2 -> android.graphics.Color.parseColor("#FF9800") // 姗欒壊-鎸傚け + 3 -> android.graphics.Color.parseColor("#F44336") // 绾㈣壊-閿佸畾 + else -> android.graphics.Color.parseColor("#757575") // 鐏拌壊-鏈煡 + } + binding.redStatu.setTextColor(statusColor) + } + } + + private fun handleWriteCard() { + // 楠岃瘉鍏呭�奸噾棰� + val rechargeAmountStr = binding.rechargeMorny.text.toString().trim() + if (rechargeAmountStr.isEmpty()) { + ToastUtil.show("璇疯緭鍏ュ厖鍊奸噾棰�") + return + } + + val rechargeAmount = try { + rechargeAmountStr.toDouble() + } catch (e: NumberFormatException) { + ToastUtil.show("璇疯緭鍏ユ湁鏁堢殑鍏呭�奸噾棰�") + return + } + + if (rechargeAmount <= 0) { + ToastUtil.show("鍏呭�奸噾棰濆繀椤诲ぇ浜�0") + return + } + + // 鑾峰彇璧犻�侀噾棰濓紙鍙�夛級 + val bonusAmountStr = binding.rechargeWater.text.toString().trim() + val bonusAmount = if (bonusAmountStr.isNotEmpty()) { + try { + bonusAmountStr.toDouble() + } catch (e: NumberFormatException) { + 0.0 + } + } else { + 0.0 + } + + // 鏄剧ず纭淇℃伅 + val totalAmount = rechargeAmount + bonusAmount + val confirmMessage = """ + 纭鍏呭�间俊鎭細 + 鍗″彿锛�${cardAddress} + 鍏呭�奸噾棰濓細${rechargeAmount}鍏� + 璧犻�侀噾棰濓細${bonusAmount}鍏� + 鎬婚噾棰濓細${totalAmount}鍏� + 鏀粯鏂瑰紡锛�${paymentMethod} + """.trimIndent() + + ToastUtil.show(confirmMessage) + + // TODO: 璋冪敤鍐欏崱API + // 杩欓噷鍙互娣诲姞瀹為檯鐨勫啓鍗¢�昏緫 + } +} \ No newline at end of file diff --git a/generallibrary/src/main/java/com/dayu/general/activity/RechargeFragment.kt b/generallibrary/src/main/java/com/dayu/general/activity/RechargeFragment.kt index 28d6e50..79c9fbd 100644 --- a/generallibrary/src/main/java/com/dayu/general/activity/RechargeFragment.kt +++ b/generallibrary/src/main/java/com/dayu/general/activity/RechargeFragment.kt @@ -9,6 +9,7 @@ import com.dayu.baselibrary.net.subscribers.SubscriberListener import com.dayu.baselibrary.tools.nfc.NfcReadAdapter import com.dayu.baselibrary.utils.ToastUtil +import com.dayu.baselibrary.view.ConfirmDialog import com.dayu.general.bean.net.CardInfoResult import com.dayu.general.databinding.FragmentRechargeBinding import com.dayu.general.net.ApiManager @@ -18,7 +19,6 @@ class RechargeFragment : Fragment() { var binding: FragmentRechargeBinding? = null private var cardNumber: String? = null - private var cardInfo: CardInfoResult? = null override fun onCreateView( inflater: LayoutInflater, @@ -38,7 +38,6 @@ private fun initView() { // 鍒濆鍖栫晫闈㈡樉绀鸿鍗$姸鎬� binding?.rechargeReadLL?.visibility = View.VISIBLE - binding?.rechargeTextLL?.visibility = View.GONE } @@ -46,8 +45,6 @@ private fun resetView() { // 閲嶇疆鐣岄潰鏄剧ず璇诲崱鐘舵�� binding?.rechargeReadLL?.visibility = View.VISIBLE - binding?.rechargeTextLL?.visibility = View.GONE - cardInfo = null } /** @@ -71,10 +68,7 @@ ToastUtil.show("璇诲崱澶辫触锛岃閲嶆柊鍒峰崱") return } - - // 鏄剧ず璇诲埌鐨勫崱鍙� - binding?.redInitCode?.text = cardNumber - + // 鏍规嵁鍗″彿鑾峰彇鍗$墖璇︾粏淇℃伅 getCardInfo(cardNumber!!) } catch (e: Exception) { @@ -89,28 +83,29 @@ */ private fun getCardInfo(cardNumber: String) { activity?.let { activity -> + val map = mutableMapOf<String, Any>() + map["cardAddr"] = cardNumber ApiManager.getInstance().requestGetLoading( activity, - "card/getCardInfo/$cardNumber", // 鍋囪API璺緞 + "terminal/card/readCard", // 鍋囪API璺緞 CardInfoResult::class.java, - null, + map, object : SubscriberListener<BaseResponse<CardInfoResult>>() { override fun onNext(t: BaseResponse<CardInfoResult>) { if (t.success) { - // 淇濆瓨鍗$墖淇℃伅 - cardInfo = t.content - // 鏄剧ず鍗$墖淇℃伅 - displayCardInfo(t.content) + // 璺宠浆鍒板厖鍊艰鎯呴〉闈� + RechargeDetailActivity.start(activity, t.content, cardNumber) } else { // 澶勭悊鑾峰彇澶辫触鐨勬儏鍐� - ToastUtil.show(t.msg) - binding?.redStatu?.text = "鍗$姸鎬佸紓甯�" + handleCardInfoError(t.code, t.msg) } } override fun onError(e: Throwable?) { super.onError(e) - ToastUtil.show("鑾峰彇鍗′俊鎭け璐�: ${e?.message ?: "鏈煡閿欒"}") + ToastUtil.show("鑾峰彇鍗′俊鎭け璐�: ${e?.message ?: "缃戠粶寮傚父锛岃妫�鏌ョ綉缁滆繛鎺�"}") + // 閲嶇疆鐣岄潰鐘舵�� + resetView() } } ) @@ -118,35 +113,38 @@ } /** - * 鏄剧ず鍗$墖淇℃伅 + * 澶勭悊鍗′俊鎭幏鍙栭敊璇� */ - private fun displayCardInfo(cardInfo: CardInfoResult?) { - if (cardInfo == null) { - ToastUtil.show("鍗′俊鎭负绌�") - return + private fun handleCardInfoError(code: String?, msg: String?) { + val errorTitle: String + val errorMessage: String + + when (code) { + "1001" -> { + // 鏁版嵁涓嶅瓨鍦ㄧ殑鐗规畩澶勭悊 + errorTitle = "鍗$墖鏈敞鍐�" + errorMessage = "璇ュ崱鐗囨湭鍦ㄧ郴缁熶腑娉ㄥ唽锛岃鍏堣繘琛屽紑鍗℃搷浣滃悗鍐嶅厖鍊笺��" + } + else -> { + // 鍏朵粬閿欒鐨勯�氱敤澶勭悊 + errorTitle = "鑾峰彇鍗′俊鎭け璐�" + errorMessage = when { + msg.isNullOrBlank() -> "鑾峰彇鍗′俊鎭け璐ワ紝璇烽噸鏂板埛鍗¢噸璇曘��" + msg.contains("鏁版嵁涓嶅瓨鍦�") -> "璇ュ崱鐗囨湭鍦ㄧ郴缁熶腑娉ㄥ唽锛岃鍏堣繘琛屽紑鍗℃搷浣滃悗鍐嶅厖鍊笺��" + msg.contains("缃戠粶") -> "缃戠粶杩炴帴寮傚父锛岃妫�鏌ョ綉缁滆繛鎺ュ悗閲嶆柊鍒峰崱銆�" + msg.contains("瓒呮椂") -> "缃戠粶璇锋眰瓒呮椂锛岃閲嶆柊鍒峰崱閲嶈瘯銆�" + else -> "鑾峰彇鍗′俊鎭け璐ワ細$msg\n\n璇烽噸鏂板埛鍗¢噸璇曘��" + } + } } - // 鍒囨崲鍒版樉绀轰俊鎭晫闈� - binding?.rechargeReadLL?.visibility = View.GONE - binding?.rechargeTextLL?.visibility = View.VISIBLE - - // 璁剧疆鍗$墖淇℃伅 - binding?.userName?.text = cardInfo.userName ?: "" - binding?.redUserCode?.text = cardInfo.userCode ?: "" - binding?.redRemainderBlance?.text = "${cardInfo.balance ?: 0} 鍏�" - - // 璁剧疆鍗$姸鎬� - val cardStatus = when(cardInfo.status) { - 1 -> "姝e父" - 2 -> "鎸傚け" - 3 -> "閿佸畾" - else -> "鏈煡" + // 鏄剧ず纭瀵硅瘽妗� + activity?.let { activity -> + val confirmDialog = ConfirmDialog(activity, errorTitle, errorMessage) { + // 鐐瑰嚮纭鎸夐挳鍚庡叧闂璇濇骞堕噸缃晫闈� + resetView() + } + confirmDialog.show() } - binding?.redStatu?.text = cardStatus - - } - - - } \ No newline at end of file diff --git a/generallibrary/src/main/java/com/dayu/general/activity/SearchUserListActivity.kt b/generallibrary/src/main/java/com/dayu/general/activity/SearchUserListActivity.kt index 2b39bc4..a4282a2 100644 --- a/generallibrary/src/main/java/com/dayu/general/activity/SearchUserListActivity.kt +++ b/generallibrary/src/main/java/com/dayu/general/activity/SearchUserListActivity.kt @@ -44,6 +44,9 @@ initView() setupRecyclerView() setupRefreshLayout() + + // 纭繚Footer鍒濆鐘舵�佹纭� + binding?.refreshLayout?.setEnableLoadMore(true) } @@ -62,6 +65,9 @@ // 閲嶇疆鍒嗛〉鐘舵�� currentPage = 1 hasMoreData = true + + // 閲嶇疆鏃犳洿澶氭暟鎹姸鎬� + binding?.refreshLayout?.resetNoMoreData() // 鎵ц鎼滅储 searchUser(farmerId, farmerName, cardNumber, true) @@ -95,12 +101,21 @@ private fun setupRefreshLayout() { binding?.refreshLayout?.apply { + // 璁剧疆Footer璺熼殢鍔熻兘锛岀‘淇濇棤鏇村鏁版嵁鏃禙ooter鑳芥纭樉绀� + setEnableFooterFollowWhenNoMoreData(true) + // 璁剧疆鍔犺浇鏇村瀹屾垚鍚庢粴鍔ㄥ唴瀹规樉绀烘柊鏁版嵁 + setEnableScrollContentWhenLoaded(true) + // 绂佺敤绾粴鍔ㄦā寮忥紝纭繚Footer鑳芥甯稿伐浣� + setEnableOverScrollDrag(false) + // 璁剧疆鍒锋柊鍜屽姞杞芥洿澶氱洃鍚櫒 setOnRefreshLoadMoreListener(object : OnRefreshLoadMoreListener { override fun onRefresh(refreshLayout: RefreshLayout) { // 閲嶇疆椤电爜骞跺埛鏂版暟鎹� currentPage = 1 hasMoreData = true + // 閲嶇疆鏃犳洿澶氭暟鎹姸鎬� + refreshLayout.resetNoMoreData() searchUser(currentFarmerId, currentFarmerName, currentCardNumber, true) } @@ -110,9 +125,8 @@ currentPage++ searchUser(currentFarmerId, currentFarmerName, currentCardNumber, false) } else { - // 瀹屾垚鍔犺浇骞舵彁绀烘病鏈夋洿澶氭暟鎹� - refreshLayout.finishLoadMore(500, true, false) - ToastUtil.show("娌℃湁鏇村鏁版嵁浜�") + // 瀹屾垚鍔犺浇骞舵樉绀哄凡鍒板簳鐘舵�� + refreshLayout.finishLoadMoreWithNoMoreData() } } }) @@ -162,9 +176,6 @@ map, object : SubscriberListener<BaseResponse<SearchUserResult>>() { override fun onNext(t: BaseResponse<SearchUserResult>) { - // 瀹屾垚鍒锋柊鎴栧姞杞藉姩浣� - finishRefreshOrLoad(isRefresh) - if (t.success) { // 澶勭悊鎼滅储鎴愬姛鐨勬儏鍐� val result = t.content @@ -180,23 +191,42 @@ // 鍒ゆ柇鏄惁杩樻湁鏇村鏁版嵁锛氭牴鎹綋鍓嶉〉鐮佸拰鎬婚〉鏁板垽鏂� hasMoreData = currentPage < result.pageTotal + + // 瀹屾垚鍒锋柊鎴栧姞杞藉姩浣� + if (isRefresh) { + binding?.refreshLayout?.finishRefresh(true) + } else { + // 濡傛灉娌℃湁鏇村鏁版嵁浜嗭紝璁剧疆宸插埌搴曠姸鎬� + if (!hasMoreData) { + binding?.refreshLayout?.finishLoadMoreWithNoMoreData() + } else { + binding?.refreshLayout?.finishLoadMore(true) + } + } } else { if (isRefresh) { userAdapter?.setData(emptyList()) + binding?.refreshLayout?.finishRefresh(true) ToastUtil.show("鏈壘鍒板尮閰嶇殑鐢ㄦ埛") } else { hasMoreData = false - ToastUtil.show("娌℃湁鏇村鏁版嵁浜�") + // 浣跨敤finishLoadMoreWithNoMoreData鏄剧ず宸插埌搴曠姸鎬� + binding?.refreshLayout?.finishLoadMoreWithNoMoreData() } } } else { if (isRefresh) { userAdapter?.setData(emptyList()) + binding?.refreshLayout?.finishRefresh(true) ToastUtil.show("鏈壘鍒板尮閰嶇殑鐢ㄦ埛") + } else { + hasMoreData = false + binding?.refreshLayout?.finishLoadMoreWithNoMoreData() } } } else { // 澶勭悊鎼滅储澶辫触鐨勬儏鍐� + finishRefreshOrLoad(isRefresh) ToastUtil.show(t.msg) } } @@ -219,7 +249,13 @@ if (isRefresh) { binding?.refreshLayout?.finishRefresh(true) } else { - binding?.refreshLayout?.finishLoadMore(true) + // 濡傛灉娌℃湁鏇村鏁版嵁锛屼笉鍦ㄨ繖閲岃皟鐢╢inishLoadMore锛岀敱鍏蜂綋閫昏緫璋冪敤finishLoadMoreWithNoMoreData + // 濡傛灉鏈夋洿澶氭暟鎹紝鍒欐甯歌皟鐢╢inishLoadMore + if (hasMoreData) { + binding?.refreshLayout?.finishLoadMore(true) + } + // 娉ㄦ剰锛氬綋hasMoreData涓篺alse鏃讹紝涓嶈皟鐢ㄤ换浣昮inish鏂规硶锛� + // 鍥犱负宸茬粡鍦ㄥ叿浣撻�昏緫涓皟鐢ㄤ簡finishLoadMoreWithNoMoreData() } } diff --git a/generallibrary/src/main/java/com/dayu/general/bean/net/CardInfoResult.kt b/generallibrary/src/main/java/com/dayu/general/bean/net/CardInfoResult.kt index cb1e39b..e9c544e 100644 --- a/generallibrary/src/main/java/com/dayu/general/bean/net/CardInfoResult.kt +++ b/generallibrary/src/main/java/com/dayu/general/bean/net/CardInfoResult.kt @@ -1,10 +1,12 @@ package com.dayu.general.bean.net +import java.io.Serializable + /** * 鍗$墖淇℃伅缁撴灉瀹炰綋绫� */ data class CardInfoResult( - val cardId: String? = null, // 鍗″彿 + val cardNum: String? = null, // 鍗″彿 val userName: String? = null, // 鐢ㄦ埛濮撳悕 val userCode: String? = null, // 鐢ㄦ埛缂栧彿 val phone: String? = null, // 鎵嬫満鍙� @@ -13,4 +15,4 @@ val status: Int? = 0, // 鍗$姸鎬�: 1-姝e父, 2-鎸傚け, 3-閿佸畾 val createTime: String? = null, // 鍒涘缓鏃堕棿 val updateTime: String? = null // 鏇存柊鏃堕棿 -) \ No newline at end of file +) : Serializable \ No newline at end of file diff --git a/generallibrary/src/main/java/com/dayu/general/view/CardRefundDialog.kt b/generallibrary/src/main/java/com/dayu/general/view/CardRefundDialog.kt index 8e52159..bb69c99 100644 --- a/generallibrary/src/main/java/com/dayu/general/view/CardRefundDialog.kt +++ b/generallibrary/src/main/java/com/dayu/general/view/CardRefundDialog.kt @@ -5,15 +5,21 @@ import android.os.Bundle import android.view.Gravity import android.view.WindowManager +import com.dayu.baselibrary.net.subscribers.SubscriberListener +import com.dayu.baselibrary.utils.ToastUtil +import com.dayu.general.BaseApplication import com.dayu.general.R import com.dayu.general.databinding.DialogCardRefundBinding +import com.dayu.general.net.ApiManager +import com.dayu.general.net.BaseResponse /** - * + *鍗$墖鎸傚け瀵硅瘽妗� */ class CardRefundDialog(context: Context) : Dialog(context) { private var binding: DialogCardRefundBinding? = null - private var onConfirmListener: (( String, String) -> Unit)? = null + private var onConfirmListener: ((String, String) -> Unit)? = null + private var onSuccessListener: (() -> Unit)? = null private var username: String? = null private var cardNumber: String? = null private var balance: String? = null @@ -40,14 +46,9 @@ binding?.btnConfirm?.setOnClickListener { val refundAmount = binding?.etRefundAmount?.text.toString() val remark = binding?.etRemark?.text.toString() - - if (refundAmount.isEmpty()) { - // TODO: 鏄剧ず閿欒鎻愮ず - return@setOnClickListener - } - - onConfirmListener?.invoke(refundAmount, remark) - dismiss() + + // 璋冪敤鎸傚け鎺ュ彛 + callReportLossApi(refundAmount, remark) } // 濡傛灉鏈夐璁剧殑鐢ㄦ埛淇℃伅锛岃缃畠浠� @@ -71,15 +72,66 @@ this.username = username this.cardNumber = cardNumber this.balance = balance - + binding?.apply { tvUsernameValue.text = username tvCardNumberValue.text = cardNumber - etBalance.setText(balance+"鍏�") + etBalance.setText(balance + "鍏�") } } - fun setOnConfirmListener(listener: ( String, String) -> Unit) { + fun setOnConfirmListener(listener: (String, String) -> Unit) { onConfirmListener = listener } + + fun setOnSuccessListener(listener: () -> Unit) { + onSuccessListener = listener + } + + /** + * 璋冪敤鎸傚け鎺ュ彛 + */ + private fun callReportLossApi(refundAmount: String, remark: String) { + val params = mutableMapOf<String, Any>() + params["cardNum"] = cardNumber ?: "" + + // 澶勭悊浣欓鏍煎紡锛屽幓闄ゅ崈浣嶅垎闅旂閫楀彿鍜�"鍏�"瀛楃 + val balanceValue = balance?.replace("鍏�", "")?.replace(",", "")?.toFloatOrNull() ?: 0f + params["money"] = balanceValue + + params["refund"] = refundAmount.toFloatOrNull() ?: 0f + params["remarks"] = remark.ifEmpty { "鎸傚け" } + params["operator"] = BaseApplication.userId + + ApiManager.getInstance().requestPostLoading( + context, + "terminal/card/termReportLoss", + ReportLossResult::class.java, + params, + object : SubscriberListener<BaseResponse<ReportLossResult>>() { + override fun onNext(response: BaseResponse<ReportLossResult>) { + if (response.success && response.code == "0001") { + ToastUtil.show("鎸傚け鎴愬姛") + onConfirmListener?.invoke(refundAmount, remark) + onSuccessListener?.invoke() + dismiss() + } else { + ToastUtil.show(response.msg ?: "鎸傚け澶辫触") + } + } + + override fun onError(e: Throwable?) { + super.onError(e) + ToastUtil.show("鎸傚け澶辫触: ${e?.message ?: "缃戠粶閿欒"}") + } + } + ) + } + + /** + * 鎸傚け鎺ュ彛杩斿洖缁撴灉 + */ + data class ReportLossResult( + val content: Boolean? = null + ) } \ No newline at end of file diff --git a/generallibrary/src/main/res/drawable/edit_text_bg.xml b/generallibrary/src/main/res/drawable/edit_text_bg.xml index 96c8a46..a4d550d 100644 --- a/generallibrary/src/main/res/drawable/edit_text_bg.xml +++ b/generallibrary/src/main/res/drawable/edit_text_bg.xml @@ -1,14 +1,17 @@ <?xml version="1.0" encoding="utf-8"?> -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="rectangle"> - <solid android:color="#FFFFFF" /> - <corners android:radius="8dp" /> - <stroke - android:width="1dp" - android:color="#E0E0E0" /> - <padding - android:bottom="8dp" - android:left="12dp" - android:right="12dp" - android:top="8dp" /> -</shape> \ No newline at end of file +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true"> + <shape android:shape="rectangle"> + <solid android:color="@android:color/white" /> + <stroke android:width="2dp" android:color="@color/base_blue_bg" /> + <corners android:radius="8dp" /> + </shape> + </item> + <item> + <shape android:shape="rectangle"> + <solid android:color="@android:color/white" /> + <stroke android:width="1dp" android:color="#e0e0e0" /> + <corners android:radius="8dp" /> + </shape> + </item> +</selector> \ No newline at end of file diff --git a/generallibrary/src/main/res/layout/activity_card_list.xml b/generallibrary/src/main/res/layout/activity_card_list.xml index 674de9e..ce3804f 100644 --- a/generallibrary/src/main/res/layout/activity_card_list.xml +++ b/generallibrary/src/main/res/layout/activity_card_list.xml @@ -43,8 +43,10 @@ android:overScrollMode="never" /> <com.scwang.smart.refresh.footer.ClassicsFooter + android:id="@+id/footer" android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + app:srlClassicsSpinnerStyle="Translate" /> </com.scwang.smart.refresh.layout.SmartRefreshLayout> diff --git a/generallibrary/src/main/res/layout/activity_card_write_success.xml b/generallibrary/src/main/res/layout/activity_card_write_success.xml new file mode 100644 index 0000000..2fa9734 --- /dev/null +++ b/generallibrary/src/main/res/layout/activity_card_write_success.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorBackground"> + + <com.dayu.baselibrary.view.TitleBar + android:id="@+id/titleBar" + android:layout_width="match_parent" + android:layout_height="@dimen/dimen_title_height" + android:background="@color/title_bar_bg" + android:elevation="4dp" + app:centerText="鍐欏崱缁撴灉" + app:leftImage="@mipmap/icon_back" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.cardview.widget.CardView + android:id="@+id/successContainer" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginStart="16dp" + android:layout_marginTop="24dp" + android:layout_marginEnd="16dp" + android:layout_marginBottom="80dp" + app:cardBackgroundColor="@android:color/white" + app:cardCornerRadius="12dp" + app:cardElevation="4dp" + app:layout_constraintBottom_toTopOf="@id/btnConfirm" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/titleBar"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:orientation="vertical" + android:padding="32dp"> + + <ImageView + android:id="@+id/successIcon" + android:layout_width="150dp" + android:layout_height="150dp" + android:scaleType="fitCenter" + android:src="@drawable/icon_success" /> + + <TextView + android:id="@+id/successTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:text="鍐欏崱鎴愬姛" + android:textColor="#4CAF50" + android:textSize="24sp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/successMessage" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:gravity="center" + android:text="鍗$墖淇℃伅宸叉垚鍔熷啓鍏n璇峰Ε鍠勪繚绠℃偍鐨勫崱鐗�" + android:textColor="#666666" + android:textSize="16sp" + android:lineSpacingExtra="4dp" /> + + </LinearLayout> + </androidx.cardview.widget.CardView> + + <Button + android:id="@+id/btnConfirm" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="32dp" + android:layout_marginEnd="32dp" + android:layout_marginBottom="24dp" + android:background="@drawable/bg_button_primary" + android:text="纭畾" + android:textColor="@android:color/white" + android:textSize="18sp" + android:textStyle="bold" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + +</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/generallibrary/src/main/res/layout/activity_recharge_detail.xml b/generallibrary/src/main/res/layout/activity_recharge_detail.xml new file mode 100644 index 0000000..19dad3f --- /dev/null +++ b/generallibrary/src/main/res/layout/activity_recharge_detail.xml @@ -0,0 +1,407 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/base_green_bg"> + <com.dayu.baselibrary.view.TitleBar + android:id="@+id/titleBar" + android:layout_width="match_parent" + android:layout_height="@dimen/dimen_title_height" + android:background="@color/title_bar_bg" + android:elevation="4dp" + app:centerText="鍏呭��" + app:leftImage="@mipmap/icon_back" + app:layout_constraintTop_toTopOf="parent" /> + <ScrollView + android:id="@+id/recharge_scrollView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_below="@+id/titleBar" + android:layout_above="@+id/recharge_registBtn" + android:fillViewport="true" + android:scrollbars="none"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="12dp"> + + <!-- 鍗$墖淇℃伅鍗$墖 --> + <androidx.cardview.widget.CardView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + app:cardCornerRadius="8dp" + app:cardElevation="2dp" + app:cardBackgroundColor="@android:color/white"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="12dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginBottom="12dp"> + + <View + android:layout_width="3dp" + android:layout_height="16dp" + android:background="@color/base_blue_bg" + android:layout_marginEnd="8dp" + android:layout_gravity="center_vertical" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鍗$墖淇℃伅" + android:textColor="#333333" + android:textSize="16sp" + android:textStyle="bold" + android:layout_gravity="center_vertical" /> + </LinearLayout> + <!-- 濮撳悕鍜岀敤鎴风紪鍙峰悎骞朵负涓�琛� --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginBottom="6dp" + android:orientation="horizontal" + android:background="@drawable/item_bg_selector" + android:paddingLeft="12dp" + android:paddingRight="12dp" + android:gravity="center_vertical"> + + <TextView + android:layout_width="70dp" + android:layout_height="wrap_content" + android:text="濮撳悕锛�" + android:textColor="#666666" + android:textSize="13sp" /> + + <TextView + android:id="@+id/userName" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textColor="#333333" + android:textSize="14sp" /> + <TextView + android:layout_width="70dp" + android:layout_height="wrap_content" + android:text="鍗$姸鎬侊細" + android:textColor="#666666" + android:textSize="13sp" /> + + <TextView + android:id="@+id/red_statu" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textColor="@color/red" + android:textSize="14sp" + android:textStyle="bold" /> + + </LinearLayout> + <!-- 鍗″彿 --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginBottom="6dp" + android:orientation="horizontal" + android:background="@drawable/item_bg_selector" + android:paddingLeft="12dp" + android:paddingRight="12dp" + android:gravity="center_vertical"> + + <TextView + android:layout_width="70dp" + android:layout_height="wrap_content" + android:text="鍗″湴鍧�锛�" + android:textColor="#666666" + android:textSize="13sp" /> + + <TextView + android:id="@+id/red_initCode" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="" + android:textColor="#333333" + android:textSize="14sp" + android:textStyle="bold" /> + </LinearLayout> + + <!-- 鍗$姸鎬� --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginBottom="6dp" + android:orientation="horizontal" + android:background="@drawable/item_bg_selector" + android:paddingLeft="12dp" + android:paddingRight="12dp" + android:gravity="center_vertical"> + + <TextView + android:layout_width="70dp" + android:layout_height="wrap_content" + android:text="鍗$紪鍙凤細" + android:textColor="#666666" + android:textSize="13sp" + /> + + <TextView + android:id="@+id/red_cardNum" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="" + android:textColor="#333333" + android:textSize="14sp" /> + </LinearLayout> + + + + <!-- 褰撳墠浣欓 --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:orientation="horizontal" + android:background="@drawable/item_bg_selector" + android:paddingLeft="12dp" + android:paddingRight="12dp" + android:gravity="center_vertical"> + + <TextView + android:layout_width="70dp" + android:layout_height="wrap_content" + android:text="褰撳墠浣欓锛�" + android:textColor="#666666" + android:textSize="13sp" /> + + <TextView + android:id="@+id/red_remainder_blance" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textColor="@color/base_blue_bg" + android:textSize="16sp" + android:textStyle="bold" /> + </LinearLayout> + </LinearLayout> + </androidx.cardview.widget.CardView> + + <!-- 鍏呭�间俊鎭崱鐗� --> + <androidx.cardview.widget.CardView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + app:cardCornerRadius="8dp" + app:cardElevation="2dp" + app:cardBackgroundColor="@android:color/white"> + + <LinearLayout + android:id="@+id/recharge_LL" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="12dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginBottom="12dp"> + + <View + android:layout_width="3dp" + android:layout_height="16dp" + android:background="@color/red" + android:layout_marginEnd="8dp" + android:layout_gravity="center_vertical" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鍏呭�间俊鎭�" + android:textColor="#333333" + android:textSize="16sp" + android:textStyle="bold" + android:layout_gravity="center_vertical" /> + </LinearLayout> + + <!-- 鍏呭�奸噾棰濆拰璧犻�侀噾棰濆悎骞朵负涓�琛� --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginBottom="8dp"> + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical" + android:layout_marginEnd="8dp"> + + <TextView + android:id="@+id/recharge_tx" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="6dp" + android:text="鍏呭�奸噾棰濓紙鍏冿級锛�" + android:textColor="@color/red" + android:textSize="14sp" + android:textStyle="bold" /> + + <EditText + android:id="@+id/recharge_morny" + android:layout_width="match_parent" + android:layout_height="42dp" + android:background="@drawable/edit_text_bg" + android:hint="璇疯緭鍏ュ厖鍊奸噾棰�" + android:inputType="numberDecimal" + android:padding="12dp" + android:textSize="14sp" + android:maxLines="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical" + android:layout_marginStart="8dp"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="6dp" + android:text="璧犻�侀噾棰濓紙鍏冿級锛�" + android:textColor="#666666" + android:textSize="14sp" /> + + <EditText + android:id="@+id/recharge_water" + android:layout_width="match_parent" + android:layout_height="42dp" + android:background="@drawable/edit_text_bg" + android:hint="璧犻�侀噾棰�(閫夊~)" + android:inputType="numberDecimal" + android:padding="12dp" + android:textSize="14sp" + android:maxLines="1" /> + </LinearLayout> + </LinearLayout> + </LinearLayout> + </androidx.cardview.widget.CardView> + + <!-- 鏀粯鏂瑰紡鍗$墖 --> + <androidx.cardview.widget.CardView + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:cardCornerRadius="8dp" + app:cardElevation="2dp" + app:cardBackgroundColor="@android:color/white"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="12dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginBottom="12dp"> + + <View + android:layout_width="3dp" + android:layout_height="16dp" + android:background="@color/base_blue_bg" + android:layout_marginEnd="8dp" + android:layout_gravity="center_vertical" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鏀粯鏂瑰紡" + android:textColor="#333333" + android:textSize="16sp" + android:textStyle="bold" + android:layout_gravity="center_vertical" /> + </LinearLayout> + + <RadioGroup + android:id="@+id/newCard_paymentMethod" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <RadioButton + android:id="@+id/newCard_cashPayment" + android:layout_width="0dp" + android:layout_height="42dp" + android:layout_marginEnd="8dp" + android:layout_weight="1" + android:background="@drawable/radio_selector" + android:button="@null" + android:checked="true" + android:gravity="center" + android:text="鐜伴噾" + android:textColor="@color/radio_button_text_color" + android:textSize="14sp" /> + + <RadioButton + android:id="@+id/newCard_posPayment" + android:layout_width="0dp" + android:layout_height="42dp" + android:layout_marginEnd="8dp" + android:layout_weight="1" + android:background="@drawable/radio_selector" + android:button="@null" + android:gravity="center" + android:text="POS鏈�" + android:textColor="@color/radio_button_text_color" + android:textSize="14sp" /> + + <RadioButton + android:id="@+id/newCard_bankTransfer" + android:layout_width="0dp" + android:layout_height="42dp" + android:layout_weight="1" + android:background="@drawable/radio_selector" + android:button="@null" + android:gravity="center" + android:text="閾惰杞处" + android:textColor="@color/radio_button_text_color" + android:textSize="14sp" /> + </RadioGroup> + </LinearLayout> + </androidx.cardview.widget.CardView> + </LinearLayout> + </ScrollView> + + <Button + android:id="@+id/recharge_registBtn" + android:layout_width="match_parent" + android:layout_height="50dp" + android:layout_alignParentBottom="true" + android:layout_marginLeft="12dp" + android:layout_marginTop="6dp" + android:layout_marginRight="12dp" + android:layout_marginBottom="12dp" + android:background="@drawable/recharge_button_ripple" + android:elevation="4dp" + android:gravity="center" + android:text="纭鍏呭�硷紙鍐欏崱锛�" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="bold" /> +</RelativeLayout> \ No newline at end of file diff --git a/generallibrary/src/main/res/layout/fragment_recharge.xml b/generallibrary/src/main/res/layout/fragment_recharge.xml index 0c190b0..0edf2a1 100644 --- a/generallibrary/src/main/res/layout/fragment_recharge.xml +++ b/generallibrary/src/main/res/layout/fragment_recharge.xml @@ -5,7 +5,6 @@ android:layout_height="match_parent" android:background="@color/base_green_bg"> - <LinearLayout android:id="@+id/recharge_read_LL" android:layout_width="match_parent" @@ -19,7 +18,6 @@ android:layout_height="match_parent" android:layout_margin="16dp" app:cardCornerRadius="8dp" - app:cardElevation="2dp"> <RelativeLayout @@ -53,7 +51,6 @@ android:layout_centerVertical="true" android:layout_marginBottom="40dp" android:gravity="center" - android:text="璇峰皢鍗¤创鍦ㄨ澶囦笂杩涜璇诲崱" android:textColor="#333333" android:textSize="@dimen/text_size" @@ -67,323 +64,22 @@ android:layout_gravity="center" android:scaleType="fitCenter" android:src="@mipmap/nfc_write" /> + + <!-- 鏄剧ず璇诲埌鐨勫崱鍙� --> + <TextView + android:id="@+id/red_initCode" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dp" + android:gravity="center" + android:text="" + android:textColor="#333333" + android:textSize="@dimen/new_card_size" + android:textStyle="bold" /> </LinearLayout> </RelativeLayout> </androidx.cardview.widget.CardView> </LinearLayout> - <ScrollView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_above="@+id/recharge_registBtn" - android:fillViewport="true" - android:visibility="gone"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:padding="16dp"> - - <LinearLayout - android:id="@+id/recharge_text_LL" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:visibility="visible"> - - - <androidx.cardview.widget.CardView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="10dp" - app:cardCornerRadius="8dp" - app:cardElevation="2dp"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:padding="12dp"> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="12dp" - android:text="鍗$墖淇℃伅" - android:textColor="#333333" - android:textSize="16sp" - android:textStyle="bold" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="5dp" - android:orientation="horizontal"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鍗″彿锛�" - android:textColor="#666666" - android:textSize="@dimen/text_size" /> - - <TextView - android:id="@+id/red_initCode" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="" - android:textColor="#333333" - android:textSize="@dimen/new_card_size" /> - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="5dp" - android:orientation="horizontal"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鍗$姸鎬侊細" - android:textColor="#666666" - android:textSize="@dimen/text_size" /> - - <TextView - android:id="@+id/red_statu" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textColor="@color/red" - android:textSize="@dimen/new_card_size" /> - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="5dp" - android:orientation="horizontal"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="濮撳悕锛�" - android:textColor="#666666" - android:textSize="@dimen/new_card_size" /> - - <TextView - android:id="@+id/userName" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textColor="#333333" - android:textSize="@dimen/new_card_size" /> - </LinearLayout> - - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="5dp" - android:orientation="horizontal"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鐢ㄦ埛缂栧彿锛�" - android:textColor="#666666" - android:textSize="@dimen/text_size" /> - - <TextView - android:id="@+id/red_userCode" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="" - android:textColor="#333333" - android:textSize="@dimen/new_card_size" /> - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="5dp" - android:orientation="horizontal" - android:visibility="visible"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="褰撳墠浣欓锛�" - android:textColor="#666666" - android:textSize="@dimen/text_size" /> - - <TextView - android:id="@+id/red_remainder_blance" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textColor="#333333" - android:textSize="@dimen/new_card_size" /> - </LinearLayout> - </LinearLayout> - </androidx.cardview.widget.CardView> - - <androidx.cardview.widget.CardView - android:layout_width="match_parent" - android:layout_height="wrap_content" - - app:cardCornerRadius="8dp" - app:cardElevation="2dp"> - - <LinearLayout - android:id="@+id/recharge_LL" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:padding="12dp"> - - - <TextView - android:id="@+id/red_recharge_water" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:text="鍏呭�兼按閲忥細" - android:textColor="#333333" - android:textSize="@dimen/text_size" - android:visibility="gone" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@color/base_green_bg" - android:orientation="vertical" - android:padding="12dp"> - - <TextView - android:id="@+id/recharge_tx" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:text="鍏呭�奸噾棰濓紙鍏冿級锛�" - android:textColor="@color/red" - android:textSize="@dimen/new_card_size" - android:textStyle="bold" /> - - <EditText - android:id="@+id/recharge_morny" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@android:color/white" - android:hint="璇疯緭鍏ュ厖鍊肩殑閲戦" - android:inputType="numberDecimal" - android:padding="5dp" - android:textSize="@dimen/new_card_size" /> - - <EditText - android:id="@+id/recharge_water" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="5dp" - android:background="@android:color/white" - android:hint="璇疯緭鍏ヨ禒閫佺殑閲戦(閫夊~)" - android:inputType="numberDecimal" - android:padding="5dp" - android:textSize="@dimen/new_card_size" /> - </LinearLayout> - </LinearLayout> - </androidx.cardview.widget.CardView> - - <androidx.cardview.widget.CardView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="10dp" - app:cardCornerRadius="8dp" - app:cardElevation="2dp"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:padding="12dp"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="10dp" - android:text="鏀粯鏂瑰紡" - android:textColor="#333333" - android:textSize="18sp" - android:textStyle="bold" /> - - <RadioGroup - android:id="@+id/newCard_paymentMethod" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - - <RadioButton - android:id="@+id/newCard_cashPayment" - android:layout_width="0dp" - android:layout_height="40dp" - android:layout_marginRight="15dp" - android:layout_weight="1" - android:background="@drawable/radio_selector" - android:button="@null" - android:checked="true" - android:gravity="center" - - android:text="鐜伴噾" - android:textColor="@color/radio_button_text_color" - android:textSize="@dimen/new_card_size" /> - - <RadioButton - android:id="@+id/newCard_posPayment" - android:layout_width="0dp" - android:layout_height="40dp" - android:layout_marginRight="15dp" - android:layout_weight="1" - android:background="@drawable/radio_selector" - android:button="@null" - android:gravity="center" - - android:text="POS鏈�" - android:textColor="@color/radio_button_text_color" - android:textSize="@dimen/new_card_size" /> - - <RadioButton - android:id="@+id/newCard_bankTransfer" - android:layout_width="0dp" - android:layout_height="40dp" - android:layout_weight="1" - android:background="@drawable/radio_selector" - android:button="@null" - android:gravity="center" - - android:text="閾惰杞处" - android:textColor="@color/radio_button_text_color" - android:textSize="@dimen/new_card_size" /> - </RadioGroup> - </LinearLayout> - </androidx.cardview.widget.CardView> - </LinearLayout> - </LinearLayout> - </ScrollView> - - <Button - android:id="@+id/recharge_registBtn" - android:layout_width="match_parent" - android:layout_height="50dp" - android:layout_alignParentBottom="true" - android:layout_marginLeft="16dp" - android:layout_marginTop="10dp" - android:layout_marginRight="16dp" - android:layout_marginBottom="10dp" - android:background="@drawable/recharge_button_ripple" - android:elevation="2dp" - android:gravity="center" - android:text="涓嬩竴姝ワ紙鍐欏崱锛�" - android:textColor="@color/white" - android:textSize="@dimen/new_card_size" - android:textStyle="bold" - android:visibility="gone" /> </RelativeLayout> \ No newline at end of file -- Gitblit v1.8.0