18034727885
2026-04-09 6668460ef703ef6cbc3954ebd60c7fa11990d4c8
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.driver.igotrip.ui.mine
 
import android.util.TypedValue
import android.widget.EditText
import android.widget.TextView
import androidx.lifecycle.lifecycleScope
import cn.sinata.xldutils.utils.SPUtils
import cn.sinata.xldutils.utils.clickDelay
import cn.sinata.xldutils.utils.getContent
import com.driver.emanagercar.ui.base.Local.BaseLoginActivity
import com.driver.igotrip.R
import com.driver.igotrip.base.BaseEvent
import com.driver.igotrip.base.Const
import com.driver.igotrip.netUtls.Api
import com.driver.igotrip.netUtls.callNet
import com.driver.igotrip.netUtls.getMapByAny
import com.driver.igotrip.utils.Cache.CacheKey
import com.google.recaptcha.sample.RecaptchaVisual
import com.google.recaptcha.sample.RecaptchaVisualException
import com.lljjcoder.style.citylist.Toast.ToastUtils
import kotlinx.coroutines.launch
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
 
class SafeVerifyActivity: BaseLoginActivity() {
 
 
    companion object {
        const val WEB_SITE_KEY = "6LdZdPErAAAAAM5YvB_2ElX5VR4bG2hcNhAOO5cU"
        const val BASE_URL = "https://gopost.ci"
    }
 
    private val et_login_code_send by lazy { find<TextView>(R.id.et_login_code_send) }
    private val et_login_pwd by lazy { find<EditText>(R.id.et_login_pwd) }
    private val tv_phone by lazy { find<TextView>(R.id.tv_phone) }
    private val tv_next by lazy { find<TextView>(R.id.tv_next) }
 
//    private lateinit var recaptcha: RecaptchaVisual
 
    override fun tvInit(tv_code: TextView) {
        et_login_code_send.text = getString(R.string.获取验证码)
    }
 
    override fun tvIniting(tv_code: TextView, time: String) {
        et_login_code_send.text = getString(R.string.秒后重新获取,time)
    }
 
    override fun setContentView() {
        setContentView(R.layout.activity_safe_verify)
    }
 
    override fun initView() {
        setTitleText(getString(R.string.安全验证))
        val lang = SPUtils.getString(Const.language)
        if (lang == Const.Language.FRENCH) {
            et_login_pwd.setTextSize(TypedValue.COMPLEX_UNIT_SP,12f)
            et_login_code_send.setTextSize(TypedValue.COMPLEX_UNIT_SP,12f)
        }
//        recaptcha = RecaptchaVisual(supportFragmentManager, WEB_SITE_KEY, BASE_URL)
    }
 
    override fun onResume() {
        super.onResume()
        showPhone()
    }
 
    fun showPhone(){
        var phone = CacheKey.getUserInfo().phone
        tv_phone.text = getString(R.string.设置密码需先验证您的手机号,phone.substring(0,3),phone.substring(7))
    }
 
    override fun setOnclick() {
        et_login_code_send.setOnClickListener {
            sendSms()
        }
 
        tv_next.clickDelay {
            if (et_login_pwd.getContent().isEmpty()){
                toast(getString(R.string.请输入验证码))
                return@clickDelay
            }
            var phone = CacheKey.getUserInfo().phone
            var map = getMapByAny()
            map["code"] = et_login_pwd.getContent()
            map["phone"] = phone
            callNet(Api.checkCaptcha,map){
                startActivity<SettingLoginPwdActivity>()
            }
        }
    }
 
    private fun sendSms() {
        lifecycleScope.launch {
            try {
//                val token = recaptcha.runCaptcha().await()
 
                var map = getMapByAny()
                map["phone"] = CacheKey.getUserInfo().phone
                map["kaptcha"] = "kaptcha"
                map["type"] = 4
//                map["token"] = token
                callNet(Api.queryCaptcha, map) {
                    refreshTime(et_login_code_send)
                }
 
            } catch (error: RecaptchaVisualException) {
                ToastUtils.showShortToast(this@SafeVerifyActivity,error.message)
            }
        }
    }
 
 
    override fun onEventMainThread(event: BaseEvent?) {
        super.onEventMainThread(event)
        when(event?.code){
            BaseEvent.CLOSE_ACT_SAFE_VER -> {
                finish()
            }
        }
    }
}