lmw
2024-05-27 c00669a852702e1aa1326872bb916f9a079b57e2
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
123
package com.future.driver.ui.pub
 
import android.widget.TextView
import cn.sinata.xldutils.utils.clickDelay
import cn.sinata.xldutils.utils.getString
import com.amap.api.location.AMapLocationListener
import com.kuaiyun.emanagercar.ui.base.Local.BaseLoginActivity
import com.future.driver.R
import com.future.driver.base.gaode.AMapKit
import com.future.driver.bean.QueryPhoneBean
import com.future.driver.netUtls.Api
import com.future.driver.netUtls.callNet
import com.future.driver.netUtls.getMapByAny
import com.future.driver.utils.PhoneCheckUtil
import kotlinx.android.synthetic.main.activity_forget_pwd.*
import kotlinx.android.synthetic.main.include_login_code.*
import kotlinx.android.synthetic.main.include_login_phone.*
import kotlinx.android.synthetic.main.include_login_pwd.*
import org.jetbrains.anko.toast
 
class ForgetPwdActivity: BaseLoginActivity() {
 
    var first = false
 
    override fun tvInit(tv_code: TextView) {
        et_login_code_send.text = "获取验证码"
    }
 
    override fun tvIniting(tv_code: TextView, time: String) {
        et_login_code_send.text = time+"秒后重新获取"
    }
 
    override fun setContentView() {
        setContentView(R.layout.activity_forget_pwd)
 
    }
 
 
 
    override fun initView() {
        setTitleText("忘记密码")
        AMapKit.initLocation(this, AMapLocationListener {
            if (!first && it != null){
                getPhone(it.adCode)
            }
        })
    }
 
 
 
 
    private fun getPhone(adcode:String) {
        first = true
        var map = getMapByAny()
        map["code"] = adcode
        callNet(Api.queryPhone,map){
            var data: QueryPhoneBean = gson.fromJson(it,QueryPhoneBean::class.java)
            tv_hint_phone.text = "若手机不能使用,请联系客服:"+data.data.phone
        }
    }
 
    override fun setOnclick() {
        et_login_code_send.clickDelay {
            if (et_login_phone.getString().isEmpty()){
                toast("请输入手机号")
                return@clickDelay
            }
            if (!PhoneCheckUtil.phoneCheck(et_login_phone.getString())){
                toast("手机号格式错误")
                return@clickDelay
            }
            var map = getMapByAny()
            map["phone"] = et_login_phone.getString()
            map["type"] =4
            callNet(Api.queryCaptcha,map){
                toast("发送成功")
                refreshTime(et_login_code_send)
            }
        }
 
        iv_eye.clickDelay {
            showEye(iv_eye,et_login_pwd)
        }
 
        tv_sure.clickDelay {
            if (et_login_phone.getString().isEmpty()){
                toast("请输入手机号")
                return@clickDelay
            }
            if (!PhoneCheckUtil.phoneCheck(et_login_phone.getString())){
                toast("手机号格式错误")
                return@clickDelay
            }
            if (et_login_pwd.getString().isEmpty()){
                toast("请输入密码")
                return@clickDelay
            }
            if (et_login_pwd.getString().length < 8){
                toast("密码不能小于8位")
                return@clickDelay
            }
            if (et_login_code.getString().isEmpty()){
                toast("请输入验证码")
                return@clickDelay
            }
            if (!PhoneCheckUtil.isCheckPwd(et_login_pwd.getString())){
                toast("密码必须包含数字,大小写字母,特殊字符")
                return@clickDelay
            }
 
            var map = getMapByAny()
            map["code"] = et_login_code.getString()
            map["phone"] = et_login_phone.getString()
            callNet(Api.checkCaptcha,map){
                map["password"] = et_login_pwd.getString()
                callNet(Api.resetPassword,map){
                    toast("修改成功")
                    onBackPressed()
                }
            }
        }
    }
}