lmw
2023-05-27 ff365ff4346d220edf2ec1d0041f2284befe3870
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
package com.fanghua.driver.ui.mine
 
import android.widget.TextView
import cn.sinata.xldutils.utils.clickDelay
import cn.sinata.xldutils.utils.getContent
import cn.sinata.xldutils.utils.getString
import com.fanghua.driver.R
import com.fanghua.driver.base.local.BaseLoginActivity
import com.fanghua.driver.bean.BaseBean
import com.fanghua.driver.netUtls.Api
import com.fanghua.driver.netUtls.callNet
import com.fanghua.driver.netUtls.getMapByAny
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_verify_code.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
 
 
class VerifyCodeActivity : BaseLoginActivity() {
    override fun tvInit(tv_code: TextView) {
        tv_get_code.text = "获取验证码"
    }
 
    override fun tvIniting(tv_code: TextView, time: String) {
        tv_get_code.text = time+"秒后重新获取"
    }
 
    override fun setContentView() {
        setContentView(R.layout.activity_verify_code)
    }
 
    private val phone by lazy { intent.getStringExtra("phone") }
 
    override fun initView() {
        setTitleText("身份验证")
        tv_phone.text = phone
    }
 
    override fun setOnclick() {
        tv_action.clickDelay {
            val code = et_code.getString()
            if (code.length<5){
                showToast("请输入5位验证码")
            }else{
                var map = getMapByAny()
                map["code"] = et_code.getContent()
                map["phone"] = phone
                callNet(Api.checkCaptcha,map){
                    val fromJson = Gson().fromJson(it, BaseBean::class.java)
                    if (fromJson.resultUtil.code == 10000)
                        startActivity<SetNewPhoneActivity>("phone" to phone)
                    else
                        toast(fromJson.resultUtil.msg)
                }
            }
        }
 
        tv_get_code.clickDelay {
            var map = getMapByAny()
            map["phone"] = phone
            map["receiver"] = "86"
            map["type"] = 2
            callNet(Api.queryCaptcha, map) {
                val fromJson = Gson().fromJson(it, BaseBean::class.java)
                if (fromJson.resultUtil.code == 10000)
                    refreshTime(tv_get_code)
                else
                    toast(fromJson.resultUtil.msg)
            }
        }
    }
 
}