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

优化支付方式顺序

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