package com.fanghua.driver.ui.pub
|
|
import android.text.Editable
|
import android.text.TextWatcher
|
import android.widget.TextView
|
import cn.sinata.xldutils.utils.clickDelay
|
import cn.sinata.xldutils.utils.getString
|
import com.fanghua.driver.R
|
import com.fanghua.driver.base.MyApplication
|
import com.fanghua.driver.base.local.BaseLoginActivity
|
import com.fanghua.driver.bean.LoginBean
|
import com.fanghua.driver.netUtls.Api
|
import com.fanghua.driver.netUtls.callNet
|
import com.fanghua.driver.netUtls.getMapByAny
|
import com.fanghua.driver.ui.main.MainActivity
|
import com.fanghua.driver.utils.Cache.CacheKey
|
import kotlinx.android.synthetic.main.activity_input_code.*
|
import org.jetbrains.anko.startActivity
|
import org.jetbrains.anko.toast
|
|
class InputCodeActivity:BaseLoginActivity() {
|
private val phone by lazy { intent.getStringExtra("phone") }
|
|
override fun tvInit(tv_code: TextView) {
|
tv_code.text = "重新获取"
|
}
|
|
override fun tvIniting(tv_code: TextView, time: String) {
|
tv_code.text = "重新获取($time)"
|
}
|
|
override fun setContentView() {
|
setContentView(R.layout.activity_input_code)
|
}
|
|
override fun initView() {
|
setTitleText("芳华代驾司机")
|
tv_phone.text = phone
|
et_code.addTextChangedListener(object :TextWatcher{
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
et_code.setSelection(et_code.text.length)
|
}
|
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
|
}
|
|
override fun afterTextChanged(s1: Editable?) {
|
val s = s1.toString()
|
when(s.length){
|
0->{
|
tv_code_1.text = ""
|
tv_code_2.text = ""
|
tv_code_3.text = ""
|
tv_code_4.text = ""
|
tv_code_5.text = ""
|
}
|
1->{
|
tv_code_1.text = s[0].toString()
|
tv_code_2.text = ""
|
tv_code_3.text = ""
|
tv_code_4.text = ""
|
tv_code_5.text = ""
|
}
|
2->{
|
tv_code_1.text = s[0].toString()
|
tv_code_2.text = s[1].toString()
|
tv_code_3.text = ""
|
tv_code_4.text = ""
|
tv_code_5.text = ""
|
}
|
3->{
|
tv_code_1.text = s[0].toString()
|
tv_code_2.text = s[1].toString()
|
tv_code_3.text = s[2].toString()
|
tv_code_4.text = ""
|
tv_code_5.text = ""
|
}
|
4->{
|
tv_code_1.text = s[0].toString()
|
tv_code_2.text = s[1].toString()
|
tv_code_3.text = s[2].toString()
|
tv_code_4.text = s[3].toString()
|
tv_code_5.text = ""
|
}
|
5->{
|
tv_code_1.text = s[0].toString()
|
tv_code_2.text = s[1].toString()
|
tv_code_3.text = s[2].toString()
|
tv_code_4.text = s[3].toString()
|
tv_code_5.text = s[4].toString()
|
}
|
}
|
}
|
})
|
refreshTime(tv_get_code)
|
}
|
override fun setOnclick() {
|
tv_get_code.clickDelay {
|
var map = getMapByAny()
|
map["phone"] = phone
|
map["receiver"] = "86"
|
map["type"] = 1
|
callNet(Api.queryCaptcha,map){
|
toast("发送成功")
|
refreshTime(tv_get_code)
|
}
|
}
|
|
tv_login.clickDelay {
|
val code = et_code.getString()
|
if (code.length!=5)
|
toast("请输入5位验证码")
|
else{
|
var map = getMapByAny()
|
map["phone"] = phone
|
map["code"] = code
|
map["receiver"] = "86"
|
callNet(Api.driverCodeLogin,map){
|
var bean = gson.fromJson<LoginBean>(it, LoginBean::class.java)
|
if (bean.resultUtil.code == 10000){
|
CacheKey.putKeyStr("phone",phone)
|
CacheKey.putKeyStr("token",bean.resultUtil.data.token)
|
CacheKey.putKeyStr("hasPwd",bean.resultUtil.data.isSetPassword.toString())
|
MyApplication.getInstance()!!.setAlisa()
|
toast("登录成功")
|
setResult(RESULT_OK)
|
finish()
|
}else{
|
toast(bean.resultUtil.msg)
|
}
|
}
|
}
|
}
|
|
}
|
|
}
|