18034727885
2026-09-04 0635d28fe9c8cfe59eda6b077abf9abf665147e0
app/src/main/java/com/igo/user/ui/login/BindPhoneActivity.kt
@@ -2,6 +2,7 @@
import MainActivityViewModel
import android.app.Activity
import android.content.Intent
import android.os.CountDownTimer
import android.widget.EditText
import android.widget.TextView
@@ -14,31 +15,29 @@
import cn.sinata.xldutils.utils.optInt
import cn.sinata.xldutils.utils.optString
import cn.sinata.xldutils.utils.showAllowingStateLoss
import com.google.recaptcha.sample.RecaptchaVisual
import com.google.recaptcha.sample.RecaptchaVisualException
import com.igo.user.utils.recaptcha.RecaptchaVisualException
import com.igo.user.R
import com.igo.user.dialog.ImageCodeDialog
import com.igo.user.dialog.SingleWheelDialog
import com.igo.user.interfaces.StringCallback
import com.igo.user.network.HttpManager
import com.igo.user.network.request
import com.igo.user.ui.TransparentStatusBarActivity
import com.igo.user.ui.login.LoginActivity.Companion.BASE_URL
import com.igo.user.ui.login.LoginActivity.Companion.WEB_SITE_KEY
import com.igo.user.utils.Const
import kotlinx.coroutines.launch
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivityForResult
class BindPhoneActivity : TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_bind_phone
    private val areaCode by lazy { find<TextView>(R.id.areaCode) }
    private val tv_code by lazy { find<TextView>(R.id.tv_code) }
    private val tv_operator by lazy { find<TextView>(R.id.tv_operator) }
    private val tv_action by lazy { find<TextView>(R.id.tv_action) }
    private val et_phone by lazy { find<EditText>(R.id.et_phone) }
    private val et_code by lazy { find<EditText>(R.id.et_code) }
    private val viewModel: MainActivityViewModel by viewModels()
    private lateinit var recaptcha: RecaptchaVisual
//    private lateinit var recaptcha: RecaptchaVisual
    private val timer by lazy {
        object : CountDownTimer(60000, 1000) {
            override fun onFinish() {
@@ -53,6 +52,9 @@
    }
    override fun initClick() {
        areaCode.setOnClickListener {
            startActivityForResult<AreaCodeActivity>(10086)
        }
        tv_operator.setOnClickListener {
            val singleWheelDialog = SingleWheelDialog()
            singleWheelDialog.arguments = bundleOf("title" to getString(R.string.运营商),"data" to arrayListOf("MTN","TIGO","TELECEL","AIRTEL"))
@@ -70,15 +72,15 @@
//                myToast(getString(R.string.请选择运营商))
//                return@setOnClickListener
//            }
            val phone = et_phone.text.toString()
            var phone = et_phone.text.toString()
            if (!phone.isValidPhone()) {
                myToast(getString(R.string.请输入正确的手机号码))
                return@setOnClickListener
            }
            phone = areaCode.text.toString().replace("+","") + phone
            lifecycleScope.launch {
                try {
                    val token = recaptcha.runCaptcha().await()
                    val token = ""
                    viewModel.onLoginButtonClicked(token)
                    HttpManager.sendSms(phone, "", 1,token).request(
@@ -118,11 +120,12 @@
                myToast(getString(R.string.请选择运营商))
                return@setOnClickListener
            }
            val phone = et_phone.text.toString()
            var phone = et_phone.text.toString()
            if (!phone.isValidPhone()) {
                myToast(getString(R.string.请输入正确的手机号码))
                return@setOnClickListener
            }
            phone = areaCode.text.toString().replace("+","") + phone
            val code = et_code.text.toString()
            if (code.isEmpty()) {
                myToast(getString(R.string.请输入验证码))
@@ -151,7 +154,16 @@
    override fun initView() {
        title = getString(R.string.完善手机号)
        recaptcha = RecaptchaVisual(supportFragmentManager, WEB_SITE_KEY, BASE_URL)
//        recaptcha = RecaptchaVisual(supportFragmentManager, WEB_SITE_KEY, BASE_URL)
    }
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == Activity.RESULT_OK && requestCode == 10086) {
            data?.getStringExtra("code")?.let {
                areaCode.text = it
            }
        }
    }
}