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)
|
}
|
}
|
}
|
}
|
|
}
|