package com.future.driver.ui.mine.money_bag
|
|
import android.text.InputFilter
|
import android.text.Spanned
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.utils.clickDelay
|
import cn.sinata.xldutils.utils.getContent
|
import com.future.driver.R
|
import com.future.driver.base.MyBaseActivity
|
import com.future.driver.bean.CardListBean
|
import com.future.driver.bean.UserBean
|
import com.future.driver.netUtls.Api
|
import com.future.driver.netUtls.callNet
|
import com.future.driver.netUtls.getMapByAny
|
import com.future.driver.ui.DialogUtil
|
import com.future.driver.ui.adapter.CardListPopAdapter
|
import com.future.driver.utils.Cache.CacheKey
|
import kotlinx.android.synthetic.main.activity_apply_money.*
|
import kotlinx.android.synthetic.main.item_card_select.view.*
|
import org.jetbrains.anko.toast
|
|
class ApplyMoneyActivity : MyBaseActivity() {
|
|
var maxMoney = CacheKey.getUserInfo().balance
|
|
val type by lazy {
|
intent.getStringExtra("type")
|
}
|
|
override fun setContentView() {
|
setContentView(R.layout.activity_apply_money)
|
}
|
|
override fun initView() {
|
maxMoney = if (type == "2"){
|
CacheKey.getUserInfo().laveBusinessMoney
|
}else{
|
CacheKey.getUserInfo().balance
|
}
|
setTitleText("申请提现")
|
et_money.hint = "填写提现金额(最多可提¥$maxMoney)"
|
|
et_money.filters = arrayOf<InputFilter>(object : InputFilter {
|
override fun filter(
|
source: CharSequence,
|
start: Int,
|
end: Int,
|
dest: Spanned,
|
dstart: Int,
|
dend: Int
|
): CharSequence? {
|
if (source == "." && dest.toString().isEmpty()) {
|
return "0."
|
}
|
if (dest.toString().contains(".")) {
|
val index: Int = dest.toString().indexOf(".")
|
val length: Int = dest.toString().substring(index).length
|
if (length == 3) {
|
return ""
|
}
|
}
|
return null
|
}
|
})
|
}
|
|
override fun setOnclick() {
|
tv_get_money.clickDelay {
|
// if (et_card_num.getContent().trim().isEmpty()){
|
// toast("请输入银行卡号码")
|
// return@clickDelay
|
// }
|
// if (et_name.getContent().isEmpty()){
|
// toast("请输入名字")
|
// return@clickDelay
|
// }
|
if (et_money.getContent().isEmpty()){
|
toast("请输入提现金额")
|
return@clickDelay
|
}
|
// if (!PhoneCheckUtil.checkBankCard(et_card_num.getContent().trim())){
|
// toast("银行卡号码错误")
|
// return@clickDelay
|
// }
|
if (et_money.getContent().toDouble() > maxMoney){
|
toast("提现金额不能超过最大余额")
|
return@clickDelay
|
}
|
if (bankBean == null){
|
toast("请选择银行卡")
|
return@clickDelay
|
}
|
var map = getMapByAny()
|
map["code"] = bankBean!!.code
|
map["money"] = et_money.getContent()
|
map["name"] = bankBean!!.name
|
map["type"] = type
|
callNet(Api.withdrawal,map){
|
DialogUtil.getOnlySureDialog(this, "提交成功!我们将尽快为您处理!") {
|
onBackPressed()
|
}
|
callNet(Api.queryInfo, getMapByAny()){
|
var user = gson.fromJson<UserBean>(it, UserBean::class.java)
|
CacheKey.saveUserInfo(user.data)
|
maxMoney = CacheKey.getUserInfo().balance
|
et_money.hint = "填写提现金额(最多可提¥$maxMoney)"
|
|
}
|
|
}
|
}
|
|
rl_select_card.clickDelay {
|
var pop = DialogUtil.getPopupwindow(this,R.layout.item_card_select)
|
pop.contentView.recycler_view_card.layoutManager = LinearLayoutManager(this)
|
var adapter = CardListPopAdapter()
|
pop.contentView.recycler_view_card.adapter = adapter
|
pop.contentView.view_close.clickDelay {
|
pop.dismiss()
|
}
|
var map = getMapByAny()
|
map["pageNum"] = 1
|
map["size"] = 10
|
callNet(Api.queryBankCard,map,{
|
var beanList = gson.fromJson<CardListBean>(it, CardListBean::class.java).data
|
adapter.data.addAll(beanList)
|
adapter.notifyDataSetChanged()
|
if (adapter.data.isNullOrEmpty()){
|
pop.dismiss()
|
toast("暂未绑定银行卡,请前往绑定银行卡")
|
}
|
adapter.setOnItemClickListener { view, position ->
|
bankBean = adapter.data[position]
|
tv_select_card.text = adapter.data[position].bank
|
pop.dismiss()
|
}
|
}){
|
pop.dismiss()
|
}
|
pop.showDown(window.decorView)
|
}
|
}
|
|
var bankBean:CardListBean.DataBean? = null
|
}
|