lmw
2023-06-20 7e4a923b472a1ffb9d6deeb80302551ba4178ca3
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
package com.fanghua.driver.ui.mine.setting
 
import android.widget.TextView
import cn.sinata.xldutils.utils.StringUtils
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.fanghua.driver.utils.Cache.CacheKey
import com.google.gson.Gson
import kotlinx.android.synthetic.main.verify_phone.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
 
class VerifyPhoneActivity : 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.verify_phone)
    }
 
    override fun initView() {
        setTitleText("手机验证")
    }
 
    override fun setOnclick() {
        tv_get_code.clickDelay {
            val phone = et_phone.getContent()
            if (phone!=CacheKey.getKeyStr("phone")){
                toast("手机号错误")
                return@clickDelay
            }
            var map = getMapByAny()
            map["phone"] = phone
            map["receiver"] = "86"
            map["type"] = 1
            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)
            }
        }
 
        tv_action.clickDelay {
            val phone = et_phone.getContent()
            if (phone!=CacheKey.getKeyStr("phone")){
                toast("手机号错误")
                return@clickDelay
            }
            val code = et_code.getString()
            if (code.length<5){
                showToast("请输入5位验证码")
            }else{
                var map = getMapByAny()
                map["code"] = code
                map["phone"] = phone
                callNet(Api.checkCaptcha,map){
                    val fromJson = Gson().fromJson(it, BaseBean::class.java)
                    if (fromJson.resultUtil.code == 10000){
                        startActivity<SetNewPwdActivity>()
                        finish()
                    } else
                        toast(fromJson.resultUtil.msg)
                }
            }
        }
    }
 
}