|
|
|
@ -1,14 +1,34 @@
|
|
|
|
package com.rehome.zhdcoa.ui.activity
|
|
|
|
package com.rehome.zhdcoa.ui.activity
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.Intent
|
|
|
|
|
|
|
|
import android.os.Build
|
|
|
|
|
|
|
|
import android.provider.Settings
|
|
|
|
import android.text.Editable
|
|
|
|
import android.text.Editable
|
|
|
|
import android.text.TextUtils
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
|
|
|
import android.util.Log
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
|
|
|
import com.google.gson.Gson
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.App
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.Contans
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.R
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
import com.rehome.zhdcoa.base.BaseCallBack
|
|
|
|
import com.rehome.zhdcoa.base.BaseCallBack
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.bean.LoginCommitBean
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.bean.UserInfoBean
|
|
|
|
import com.rehome.zhdcoa.bean.YzmBean
|
|
|
|
import com.rehome.zhdcoa.bean.YzmBean
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWjmmGetVerificationCodeBinding
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWjmmGetVerificationCodeBinding
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.ui.toastview.toastviewbymyself
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.GsonUtils
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener
|
|
|
|
import com.rehome.zhdcoa.utils.HttpUtils
|
|
|
|
import com.rehome.zhdcoa.utils.HttpUtils
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.RSAUtils
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.SPUtils
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.UiUtlis
|
|
|
|
|
|
|
|
import com.xiaomi.mipush.sdk.MiPushClient
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.NoHttp
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.RequestMethod
|
|
|
|
import okhttp3.FormBody
|
|
|
|
import okhttp3.FormBody
|
|
|
|
import okhttp3.RequestBody
|
|
|
|
import okhttp3.RequestBody
|
|
|
|
import retrofit2.Call
|
|
|
|
import retrofit2.Call
|
|
|
|
@ -17,6 +37,9 @@ import java.util.*
|
|
|
|
|
|
|
|
|
|
|
|
class WjmmGetVerificationCodeActivity :
|
|
|
|
class WjmmGetVerificationCodeActivity :
|
|
|
|
BaseActivityOaToolbarViewBinding<ActivityWjmmGetVerificationCodeBinding>() {
|
|
|
|
BaseActivityOaToolbarViewBinding<ActivityWjmmGetVerificationCodeBinding>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var token: String = ""
|
|
|
|
|
|
|
|
|
|
|
|
override fun getViewBinding() = ActivityWjmmGetVerificationCodeBinding.inflate(layoutInflater)
|
|
|
|
override fun getViewBinding() = ActivityWjmmGetVerificationCodeBinding.inflate(layoutInflater)
|
|
|
|
|
|
|
|
|
|
|
|
override fun getToolbar() = binding.toolbarView.toolbar
|
|
|
|
override fun getToolbar() = binding.toolbarView.toolbar
|
|
|
|
@ -61,63 +84,124 @@ class WjmmGetVerificationCodeActivity :
|
|
|
|
checkVerificationCode()
|
|
|
|
checkVerificationCode()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.txGh.setText("ZHPS_Admin")
|
|
|
|
|
|
|
|
binding.sjh.setText("13600341775")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun getYzm() {
|
|
|
|
private fun getYzm() {
|
|
|
|
val body: RequestBody = FormBody.Builder()
|
|
|
|
// val body: RequestBody = FormBody.Builder()
|
|
|
|
.add(
|
|
|
|
// .add(
|
|
|
|
"userid",
|
|
|
|
// "userid",
|
|
|
|
Objects.requireNonNull<Editable>(binding.txGh.text).toString().trim()
|
|
|
|
// Objects.requireNonNull<Editable>(binding.txGh.text).toString().trim()
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.add(
|
|
|
|
// .add(
|
|
|
|
"telphone",
|
|
|
|
// "telphone",
|
|
|
|
Objects.requireNonNull<Editable>(binding.sjh.text).toString().trim()
|
|
|
|
// Objects.requireNonNull<Editable>(binding.sjh.text).toString().trim()
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.add("type", "1")
|
|
|
|
// .add("type", "1")
|
|
|
|
.build()
|
|
|
|
// .build()
|
|
|
|
HttpUtils.getApi().postYzm(body).enqueue(object : BaseCallBack<YzmBean?>(context) {
|
|
|
|
val json: String = getYzmParam()
|
|
|
|
override fun onSuccess(call: Call<YzmBean?>?, response: Response<YzmBean?>?) {
|
|
|
|
|
|
|
|
val bean = response?.body()
|
|
|
|
val url = Contans.BASE_URL + Contans.GETYZMANDCHECKYZMANDMODIFYMIMA
|
|
|
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(json)
|
|
|
|
|
|
|
|
showLog(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
|
|
|
|
|
|
|
override fun onSucceed(what: Int, response: com.yolanda.nohttp.rest.Response<String?>?) {
|
|
|
|
|
|
|
|
val jsonResult = response?.get()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showLog("-----getYzm------")
|
|
|
|
|
|
|
|
showLog(jsonResult)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult)
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(jsonDecode)) {
|
|
|
|
|
|
|
|
showToast(UiUtlis.getString(context, R.string.data_error))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
val bean: YzmBean? =
|
|
|
|
|
|
|
|
GsonUtils.GsonToBean(jsonDecode, YzmBean::class.java)
|
|
|
|
|
|
|
|
showLog(jsonDecode);
|
|
|
|
if (bean != null && bean.rows != null && bean.rows.size > 0 && bean.rows[0].result == "1") {
|
|
|
|
if (bean != null && bean.rows != null && bean.rows.size > 0 && bean.rows[0].result == "1") {
|
|
|
|
showToast(bean.rows[0].msg)
|
|
|
|
showToast(bean.rows[0].msg)
|
|
|
|
binding.yzm.visibility = View.VISIBLE
|
|
|
|
binding.yzm.visibility = View.VISIBLE
|
|
|
|
binding.verificationCodeLine.visibility = View.VISIBLE
|
|
|
|
binding.verificationCodeLine.visibility = View.VISIBLE
|
|
|
|
binding.buttonNext.visibility = View.VISIBLE
|
|
|
|
binding.buttonNext.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
if(bean.rows[0].token!=null){
|
|
|
|
|
|
|
|
token = bean.rows[0].token
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (bean != null) {
|
|
|
|
if (bean != null) {
|
|
|
|
showToast(bean.rows[0].msg)
|
|
|
|
showToast(bean.rows[0].msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onError(call: Call<YzmBean?>?, t: Throwable?) {
|
|
|
|
override fun onFailed(what: Int, response: com.yolanda.nohttp.rest.Response<String?>?) {
|
|
|
|
|
|
|
|
Log.i("login", "onError")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}, true, true, "请稍候...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HttpUtils.getApi().postYzm(body).enqueue(object : BaseCallBack<YzmBean?>(context) {
|
|
|
|
|
|
|
|
// override fun onSuccess(call: Call<YzmBean?>?, response: Response<YzmBean?>?) {
|
|
|
|
|
|
|
|
// val bean = response?.body()
|
|
|
|
|
|
|
|
// if (bean != null && bean.rows != null && bean.rows.size > 0 && bean.rows[0].result == "1") {
|
|
|
|
|
|
|
|
// showToast(bean.rows[0].msg)
|
|
|
|
|
|
|
|
// binding.yzm.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
// binding.verificationCodeLine.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
// binding.buttonNext.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// if (bean != null) {
|
|
|
|
|
|
|
|
// showToast(bean.rows[0].msg)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// override fun onError(call: Call<YzmBean?>?, t: Throwable?) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//调用接口检查输入的验证码是否正确
|
|
|
|
//调用接口检查输入的验证码是否正确
|
|
|
|
private fun checkVerificationCode() {
|
|
|
|
private fun checkVerificationCode() {
|
|
|
|
val body: RequestBody = FormBody.Builder()
|
|
|
|
// val body: RequestBody = FormBody.Builder()
|
|
|
|
.add(
|
|
|
|
// .add(
|
|
|
|
"userid",
|
|
|
|
// "userid",
|
|
|
|
Objects.requireNonNull<Editable>(binding.txGh.text).toString().trim()
|
|
|
|
// Objects.requireNonNull<Editable>(binding.txGh.text).toString().trim()
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.add(
|
|
|
|
// .add(
|
|
|
|
"telphone",
|
|
|
|
// "telphone",
|
|
|
|
Objects.requireNonNull<Editable>(binding.sjh.text).toString().trim()
|
|
|
|
// Objects.requireNonNull<Editable>(binding.sjh.text).toString().trim()
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.add("type", "3")
|
|
|
|
// .add("type", "3")
|
|
|
|
.add(
|
|
|
|
// .add(
|
|
|
|
"verificationcode",
|
|
|
|
// "verificationcode",
|
|
|
|
Objects.requireNonNull<Editable>(binding.yzm.text).toString().trim()
|
|
|
|
// Objects.requireNonNull<Editable>(binding.yzm.text).toString().trim()
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
.build()
|
|
|
|
// .build()
|
|
|
|
HttpUtils.getApi().postCheckVerificationCode(body)
|
|
|
|
|
|
|
|
.enqueue(object : BaseCallBack<YzmBean?>(context) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onSuccess(call: Call<YzmBean?>?, response: Response<YzmBean?>?) {
|
|
|
|
val json: String = getCheckYzmParam()
|
|
|
|
val bean = response?.body()
|
|
|
|
val url = Contans.BASE_URL + Contans.GETYZMANDCHECKYZMANDMODIFYMIMA
|
|
|
|
|
|
|
|
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(json)
|
|
|
|
|
|
|
|
showLog(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
|
|
|
|
|
|
|
override fun onSucceed(what: Int, response: com.yolanda.nohttp.rest.Response<String?>?) {
|
|
|
|
|
|
|
|
val jsonResult = response?.get()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showLog("-----CheckYzm------")
|
|
|
|
|
|
|
|
showLog(jsonResult)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult)
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(jsonDecode)) {
|
|
|
|
|
|
|
|
showToast(UiUtlis.getString(context, R.string.data_error))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
val bean: YzmBean? =
|
|
|
|
|
|
|
|
GsonUtils.GsonToBean(jsonDecode, YzmBean::class.java)
|
|
|
|
|
|
|
|
showLog(jsonDecode);
|
|
|
|
if (bean != null && bean.rows != null && bean.rows.size > 0 && bean.rows[0].result == "2") {
|
|
|
|
if (bean != null && bean.rows != null && bean.rows.size > 0 && bean.rows[0].result == "2") {
|
|
|
|
//验证码正确
|
|
|
|
//验证码正确
|
|
|
|
val intent = Intent(
|
|
|
|
val intent = Intent(
|
|
|
|
@ -126,6 +210,11 @@ class WjmmGetVerificationCodeActivity :
|
|
|
|
)
|
|
|
|
)
|
|
|
|
intent.putExtra("gh", binding.txGh.text.toString().trim())
|
|
|
|
intent.putExtra("gh", binding.txGh.text.toString().trim())
|
|
|
|
intent.putExtra("sjh", binding.sjh.text.toString().trim())
|
|
|
|
intent.putExtra("sjh", binding.sjh.text.toString().trim())
|
|
|
|
|
|
|
|
if(TextUtils.isEmpty(token)){
|
|
|
|
|
|
|
|
intent.putExtra("token", "")
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
intent.putExtra("token", token)
|
|
|
|
|
|
|
|
}
|
|
|
|
startActivity(intent)
|
|
|
|
startActivity(intent)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (bean != null) {
|
|
|
|
if (bean != null) {
|
|
|
|
@ -133,10 +222,67 @@ class WjmmGetVerificationCodeActivity :
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onError(call: Call<YzmBean?>?, t: Throwable?) {
|
|
|
|
override fun onFailed(what: Int, response: com.yolanda.nohttp.rest.Response<String?>?) {
|
|
|
|
|
|
|
|
Log.i("login", "onError")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, true, true, "请稍候...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HttpUtils.getApi().postCheckVerificationCode(body)
|
|
|
|
|
|
|
|
// .enqueue(object : BaseCallBack<YzmBean?>(context) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// override fun onSuccess(call: Call<YzmBean?>?, response: Response<YzmBean?>?) {
|
|
|
|
|
|
|
|
// val bean = response?.body()
|
|
|
|
|
|
|
|
// if (bean != null && bean.rows != null && bean.rows.size > 0 && bean.rows[0].result == "2") {
|
|
|
|
|
|
|
|
// //验证码正确
|
|
|
|
|
|
|
|
// val intent = Intent(
|
|
|
|
|
|
|
|
// context,
|
|
|
|
|
|
|
|
// WjmmActivity::class.java
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// intent.putExtra("gh", binding.txGh.text.toString().trim())
|
|
|
|
|
|
|
|
// intent.putExtra("sjh", binding.sjh.text.toString().trim())
|
|
|
|
|
|
|
|
// startActivity(intent)
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// if (bean != null) {
|
|
|
|
|
|
|
|
// showToast(bean.rows[0].msg)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// override fun onError(call: Call<YzmBean?>?, t: Throwable?) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
fun getYzmParam(): String {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val param= mutableMapOf<String,String>()
|
|
|
|
|
|
|
|
param["userid"] = Objects.requireNonNull<Editable>(binding.txGh.text).toString().trim()
|
|
|
|
|
|
|
|
param["type"] = "1"
|
|
|
|
|
|
|
|
param["telphone"] = Objects.requireNonNull<Editable>(binding.sjh.text).toString().trim()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val json = Gson().toJson(param)
|
|
|
|
|
|
|
|
val jsonEncrypt = RSAUtils.encryptBASE64Str(json)
|
|
|
|
|
|
|
|
showLog(json);
|
|
|
|
|
|
|
|
showLog(jsonEncrypt)
|
|
|
|
|
|
|
|
return jsonEncrypt
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getCheckYzmParam(): String {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val param= mutableMapOf<String,String>()
|
|
|
|
|
|
|
|
param["userid"] = Objects.requireNonNull<Editable>(binding.txGh.text).toString().trim()
|
|
|
|
|
|
|
|
param["type"] = "3"
|
|
|
|
|
|
|
|
param["telphone"] = Objects.requireNonNull<Editable>(binding.sjh.text).toString().trim()
|
|
|
|
|
|
|
|
param["verificationcode"] = Objects.requireNonNull<Editable>(binding.yzm.text).toString().trim()
|
|
|
|
|
|
|
|
param["token"] = token
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val json = Gson().toJson(param)
|
|
|
|
|
|
|
|
val jsonEncrypt = RSAUtils.encryptBASE64Str(json)
|
|
|
|
|
|
|
|
showLog(json);
|
|
|
|
|
|
|
|
return jsonEncrypt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|