Pu Zhibing
2025-12-11 ab0c19e49fabdb8cc6eea454ea455bce2efbb718
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
package com.igo.user.ui.mine
 
import android.app.Activity
import android.view.View
import android.widget.EditText
import android.widget.TextView
import androidx.core.os.bundleOf
import cn.sinata.xldutils.utils.myToast
import com.igo.user.IGoApplication
import com.igo.user.R
import com.igo.user.dialog.AlertDialog
import com.igo.user.network.HttpManager
import com.igo.user.network.request
import com.igo.user.ui.TransparentStatusBarActivity
import com.igo.user.utils.NumberInputFilter
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity
 
class WithdrawActivity:TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_withdraw
    private var balance = 0.0
 
    private val tv_action by lazy { find<TextView>(R.id.tv_action) }
    private val tv_phone by lazy { find<TextView>(R.id.tv_phone) }
    private val tv_type by lazy { find<TextView>(R.id.tv_type) }
    private val et_money by lazy { find<EditText>(R.id.et_money) }
    private val et_remark by lazy { find<EditText>(R.id.et_remark) }
 
    override fun initClick() {
        tv_action.setOnClickListener {
            val s = et_money.text.toString()
            if (s.isEmpty()){
                myToast(getString(R.string.请输入提现金额))
                return@setOnClickListener
            }
            val money = s.toDouble()
            if (money == 0.0){
                myToast(getString(R.string.请输入提现金额))
                return@setOnClickListener
            }
            tv_action.isEnabled = false
            HttpManager.withdrawal(et_remark.text.toString(),money).request(this,success = {_,_->
                balance -= money
                et_money.hint = getString(R.string.多少钱可提现,balance).replace(",",".")
                et_money.filters = arrayOf(NumberInputFilter(balance))
                et_money.setText("")
                setResult(Activity.RESULT_OK)
                val alertDialog = AlertDialog()
                alertDialog.arguments = bundleOf("msg" to getString(R.string.提现提交成功))
                alertDialog.show(supportFragmentManager,"success")
            },error = {_,_->
                tv_action.isEnabled = true
            })
        }
    }
 
    override fun initView() {
        title = getString(R.string.提现)
        titleBar.addRightButton(getString(R.string.withdraw_record),onClickListener = View.OnClickListener {
            startActivity<WithdrawRecordActivity>()
        })
        balance = intent.getDoubleExtra("balance",0.0)
        et_money.hint = getString(R.string.多少钱可提现,balance).replace(",",".")
        et_money.filters = arrayOf(NumberInputFilter(balance))
        tv_phone.text = IGoApplication.phone
        tv_type.text = IGoApplication.phoneOperator
    }
 
}