Commit 8797c2a5 authored by 张释方's avatar 张释方

优化支付方式顺序

parent 7b3f6b7f
...@@ -202,10 +202,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -202,10 +202,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
if (it.list.isNullOrEmpty()) { if (it.list.isNullOrEmpty()) {
return@Observer return@Observer
} else { } else {
//设置 默认支付方式 (根据返回参数的第一个值)
if (it.list!![0].isNotEmpty()) {
setfirstpaymentwey(it.list!![0])
}
for (str in it.list!!) { for (str in it.list!!) {
if (str.isNotEmpty() && str.equals("WEIXIN")) { if (str.isNotEmpty() && str.equals("WEIXIN")) {
//第一个位置是否展示 //第一个位置是否展示
...@@ -214,18 +210,18 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -214,18 +210,18 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
iv_ly_payfirst.setImageResource(R.mipmap.icon_pay_wx) iv_ly_payfirst.setImageResource(R.mipmap.icon_pay_wx)
tv_ly_payfirst.setText("微信支付") tv_ly_payfirst.setText("微信支付")
ly_payfirst.visibility = View.VISIBLE ly_payfirst.visibility = View.VISIBLE
}else{ } else {
iv_ly_paysecond.setImageResource(R.mipmap.icon_pay_wx) iv_ly_paysecond.setImageResource(R.mipmap.icon_pay_wx)
tv_ly_paysecond.setText("微信支付") tv_ly_paysecond.setText("微信支付")
ly_paysecond.visibility=View.VISIBLE ly_paysecond.visibility = View.VISIBLE
} }
if (TextUtils.isEmpty(currentPayType)) { /*if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "WEIXIN" currentPayType = "WEIXIN"
} }
// ly_payfirst.visibility = View.VISIBLE ly_payfirst.visibility = View.VISIBLE
// if (TextUtils.isEmpty(currentPayType)) { if (TextUtils.isEmpty(currentPayType)) {
// currentPayType = "WEIXIN" currentPayType = "WEIXIN"
// } }*/
} }
if (str.equals("ALIPAY")) { if (str.equals("ALIPAY")) {
//第一个位置是否展示 //第一个位置是否展示
...@@ -234,19 +230,21 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -234,19 +230,21 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
iv_ly_payfirst.setImageResource(R.mipmap.icon_pay_zfb) iv_ly_payfirst.setImageResource(R.mipmap.icon_pay_zfb)
tv_ly_payfirst.setText("支付宝支付") tv_ly_payfirst.setText("支付宝支付")
ly_payfirst.visibility = View.VISIBLE ly_payfirst.visibility = View.VISIBLE
}else{ } else {
iv_ly_paysecond.setImageResource(R.mipmap.icon_pay_zfb) iv_ly_paysecond.setImageResource(R.mipmap.icon_pay_zfb)
tv_ly_paysecond.setText("支付宝支付") tv_ly_paysecond.setText("支付宝支付")
ly_paysecond.visibility=View.VISIBLE ly_paysecond.visibility = View.VISIBLE
} }
if (TextUtils.isEmpty(currentPayType)) { /*if (TextUtils.isEmpty(currentPayType)) {
currentPayType = "ALIPAY" currentPayType = "ALIPAY"
} }
// ly_second.visibility = View.VISIBLE ly_second.visibility = View.VISIBLE
// if (TextUtils.isEmpty(currentPayType)) { if (TextUtils.isEmpty(currentPayType)) {
// currentPayType = "ALIPAY" currentPayType = "ALIPAY"
// } }*/
} }
//设置 默认支付方式 (根据返回参数的第一个值)
setOnChecked(1, tv_ly_payfirst.text)
} }
} }
...@@ -270,28 +268,19 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -270,28 +268,19 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
return true return true
} }
private fun setfirstpaymentwey(paymentwey: String) {
if (paymentwey.equals("WEIXIN")) {
setOnChecked(1)
} else {
setOnChecked(2)
}
}
override fun onClick(v: View?) { override fun onClick(v: View?) {
when (v?.id) { when (v?.id) {
R.id.iv_left_icon -> { R.id.iv_left_icon -> {
backvipDialog() backvipDialog()
} }
R.id.ly_payfirst -> {//微信支付 R.id.ly_payfirst -> {
//设置选中样式 //设置选中样式
setOnChecked(1) setOnChecked(1, tv_ly_payfirst.text)
currentPayType = "WEIXIN"
} }
R.id.ly_paysecond -> {//支付宝支付 R.id.ly_paysecond -> {
//设置选中样式 //设置选中样式
setOnChecked(2) setOnChecked(2, tv_ly_paysecond.text)
currentPayType = "ALIPAY"
} }
R.id.bt_try -> {//点击开通全球会员按钮 R.id.bt_try -> {//点击开通全球会员按钮
if (UserManager.INSTANCE.userIsLogin()) { if (UserManager.INSTANCE.userIsLogin()) {
...@@ -303,6 +292,16 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -303,6 +292,16 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
} }
} }
//设置选中标记
private fun setpayweyflag(textflag: CharSequence?) {
if (textflag!!.equals("微信支付")) {
currentPayType = "WEIXIN"
} else {
currentPayType = "ALIPAY"
}
}
private fun payVip() { private fun payVip() {
if (vipList != null && vipList!!.size > 0 && gridPaymentAdapter != null) { if (vipList != null && vipList!!.size > 0 && gridPaymentAdapter != null) {
if (TextUtils.equals("WEIXIN", currentPayType)) { if (TextUtils.equals("WEIXIN", currentPayType)) {
...@@ -337,18 +336,21 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -337,18 +336,21 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
/** /**
* 设置选中支付方式view样式 * 设置选中支付方式view样式
* 1--微信支付 * 1--第一个支付方式
* 2--支付宝支付 * 2--第二个支付方式
*/ */
private fun setOnChecked(paymentflag: Int?) { private fun setOnChecked(paymentflag: Int?, textflag: CharSequence?) {
//设置选中方式
setpayweyflag(textflag)
//设置选中方式样式
when (paymentflag) { when (paymentflag) {
1 -> {//选中微信 1 -> {//选中第一个
iv_weixin.setImageResource(R.mipmap.pay_select) iv_payfirst.setImageResource(R.mipmap.pay_select)
iv_alipay.setImageResource(R.mipmap.pay_unselect) iv_paysecond.setImageResource(R.mipmap.pay_unselect)
} }
2 -> {//选中支付宝 2 -> {//选中第二个
iv_weixin.setImageResource(R.mipmap.pay_unselect) iv_payfirst.setImageResource(R.mipmap.pay_unselect)
iv_alipay.setImageResource(R.mipmap.pay_select) iv_paysecond.setImageResource(R.mipmap.pay_select)
} }
} }
} }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners <corners
android:topLeftRadius="25dp" android:topLeftRadius="20dp"
android:topRightRadius="25dp" /> android:topRightRadius="25dp" />
<solid android:color="#E6FFFFFF" /> <solid android:color="#E6FFFFFF" />
</shape> </shape>
\ No newline at end of file
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
android:textSize="18sp" /> android:textSize="18sp" />
<ImageView <ImageView
android:id="@+id/iv_weixin" android:id="@+id/iv_payfirst"
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
android:textSize="18sp" /> android:textSize="18sp" />
<ImageView <ImageView
android:id="@+id/iv_alipay" android:id="@+id/iv_paysecond"
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
......
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
android:background="@drawable/shape_dialog_bg"> android:background="@drawable/shape_dialog_bg">
<ImageView <ImageView
android:id="@+id/iv_close" android:id="@+id/iv_close"
android:layout_width="30dp" android:layout_width="20dp"
android:layout_height="30dp" android:layout_height="20dp"
android:layout_margin="8dp" android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="5dp"
android:src="@mipmap/icon_hot_view_close" android:src="@mipmap/icon_hot_view_close"
android:layout_gravity="end"/> android:layout_gravity="end"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment