18034727885
2026-03-18 7804ce8edeba51418b5fde2d306e5f476dfb5993
app/src/main/java/com/driver/igotrip/ui/mine/SafeVerifyActivity.kt
@@ -3,6 +3,7 @@
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
@@ -14,15 +15,28 @@
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.获取验证码)
@@ -43,6 +57,7 @@
            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() {
@@ -57,12 +72,7 @@
    override fun setOnclick() {
        et_login_code_send.setOnClickListener {
            var map = getMapByAny()
            map["phone"] = CacheKey.getUserInfo().phone
            map["type"] = 4
            callNet(Api.queryCaptcha, map) {
                refreshTime(et_login_code_send)
            }
            sendSms()
        }
        tv_next.clickDelay {
@@ -80,6 +90,27 @@
        }
    }
    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){