18034727885
2026-08-11 d9741079baf30415be9fa93dc9c1893ce2206c1e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.fangxinxing.xxfxx.ui.mine.money_bag
 
import android.text.InputFilter
import android.text.Spanned
import com.fangxinxing.xxfxx.R
import com.fangxinxing.xxfxx.base.MyBaseActivity
import com.fangxinxing.xxfxx.bean.LastWithdrawInfo
import com.fangxinxing.xxfxx.bean.UserBankInfoBean
import com.fangxinxing.xxfxx.bean.UserBean
import com.fangxinxing.xxfxx.netUtls.Api
import com.fangxinxing.xxfxx.netUtls.callNet
import com.fangxinxing.xxfxx.netUtls.getMapByAny
import com.fangxinxing.xxfxx.utils.Cache.CacheKey
import com.fangxinxing.xxfxx.utils.clickDelay
import com.fangxinxing.xxfxx.utils.getContent
import com.fangxinxing.xxfxx.utils.getFormatTwo
import kotlinx.android.synthetic.main.activity_apply_withdraw.et_money
import kotlinx.android.synthetic.main.activity_apply_withdraw.tv_withdraw
import org.jetbrains.anko.toast
 
//申请提现页面
class ApplyWithdrawActivity : MyBaseActivity() {
 
    override fun setContentView() {
        setContentView(R.layout.activity_apply_withdraw)
    }
 
    override fun initView() {
        setTitleText("申请提现")
        et_money.hint = "${getFormatTwo(CacheKey.getUserInfo().balance)}元可提现"
        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
            }
        })
        callMine()
    }
 
    private fun callMine() {
        val map = getMapByAny()
        callNet(Api.queryInfo, map) {
            val user = gson.fromJson<UserBean>(it, UserBean::class.java)
            CacheKey.saveUserInfo(user.data)
            et_money.hint = "${getFormatTwo(CacheKey.getUserInfo().balance)}元可提现"
        }
    }
 
    override fun setOnclick() {
        tv_withdraw.clickDelay {
            if (et_money.getContent().isEmpty()) {
                toast("请输入提现金额")
                return@clickDelay
            }
            val money = et_money.getContent().toDoubleOrNull() ?: 0.0
            if (money <= 0) {
                toast("提现金额必须大于0")
                return@clickDelay
            }
            if (money > CacheKey.getUserInfo().balance) {
                toast("提现金额不能大于${CacheKey.getUserInfo().balance}元")
                return@clickDelay
            }
            val map = getMapByAny()
            callNet(Api.queryLastWithdrawal, map) {
                val userBankInfoBean =
                    gson.fromJson<UserBankInfoBean>(it, UserBankInfoBean::class.java)
                userBankInfoBean.apply {
                    data = (data ?: LastWithdrawInfo()).apply {
                        this.money = money.toString()
                    }
                }
                startActivity(SetWithdrawAccountActivity.getIntent(this, userBankInfoBean.data))
                finish()
            }
        }
    }
}