package com.fanghua.driver.ui.mine.money_bag
|
|
import cn.sinata.xldutils.utils.visible
|
import com.fanghua.driver.R
|
import com.fanghua.driver.base.BaseEvent
|
import com.fanghua.driver.base.MyBaseActivity
|
import kotlinx.android.synthetic.main.activity_my_qr_code.*
|
import org.greenrobot.eventbus.Subscribe
|
import org.jetbrains.anko.startActivity
|
|
class MyQrCodeActivity : MyBaseActivity() {
|
override fun setContentView() {
|
setContentView(R.layout.activity_my_qr_code)
|
}
|
|
private var wx = ""
|
private var ali = ""
|
|
override fun initView() {
|
setTitleText("收款码")
|
wx = intent.getStringExtra("wx")?:""
|
ali = intent.getStringExtra("ali")?:""
|
refreshUi()
|
}
|
|
private fun refreshUi() {
|
if (wx.isNotEmpty() && ali.isNotEmpty()) {
|
tv_1.text = "微信"
|
tv_code_1.text = "已设置"
|
tv_2.text = "支付宝"
|
tv_code_2.text = "已设置"
|
} else if (wx.isNotEmpty()) {
|
tv_1.text = "微信"
|
tv_code_1.text = "已设置"
|
tv_2.text = "支付宝"
|
} else if (ali.isNotEmpty()) {
|
tv_1.text = "支付宝"
|
tv_code_1.text = "已设置"
|
tv_2.text = "微信"
|
}
|
if (!(wx.isEmpty()&&ali.isEmpty())){
|
tv_2.visible()
|
tv_code_2.visible()
|
line.visible()
|
}
|
}
|
|
override fun setOnclick() {
|
tv_code_1.setOnClickListener {
|
if (tv_1.text == "收款码"){
|
startActivity<AddPayQRCodeActivity>()
|
}else{
|
val way = tv_1.text.toString()
|
startActivity<UpQrCodeActivity>("code" to (if (way == "微信") wx else ali),"way" to way)
|
}
|
}
|
|
tv_code_2.setOnClickListener {
|
if (tv_code_2.text.isEmpty()){
|
startActivity<AddPayQRCodeActivity>("way" to tv_2.text.toString())
|
}else{
|
val way = tv_2.text.toString()
|
startActivity<UpQrCodeActivity>("code" to (if (way == "微信") wx else ali),"way" to way)
|
}
|
}
|
}
|
|
@Subscribe
|
fun onCodeChange(e:BaseEvent){
|
if (e.code == BaseEvent.CODE_CHANGE){
|
if (e.msg == "zfbCollectionCode")
|
ali = e.msgTwo
|
else
|
wx = e.msgTwo
|
refreshUi()
|
}
|
}
|
|
}
|