|
|
|
|
@ -3,8 +3,10 @@ package com.rehome.zhdcoa.ui.activity;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.Contans;
|
|
|
|
|
import com.rehome.zhdcoa.R;
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivity;
|
|
|
|
|
@ -13,11 +15,18 @@ import com.rehome.zhdcoa.bean.ResultBean;
|
|
|
|
|
import com.rehome.zhdcoa.bean.UpdatePwd;
|
|
|
|
|
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.NohttpUtils;
|
|
|
|
|
import com.rehome.zhdcoa.utils.RSAUtils;
|
|
|
|
|
import com.rehome.zhdcoa.utils.SPUtils;
|
|
|
|
|
import com.rehome.zhdcoa.utils.UiUtlis;
|
|
|
|
|
import com.rehome.zhdcoa.weiget.AuditDialog;
|
|
|
|
|
import com.rehome.zhdcoa.weiget.ClearEditText;
|
|
|
|
|
import com.yolanda.nohttp.NoHttp;
|
|
|
|
|
import com.yolanda.nohttp.RequestMethod;
|
|
|
|
|
import com.yolanda.nohttp.rest.Request;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
@ -50,7 +59,9 @@ public class UpdatePwdActivity extends BaseActivity {
|
|
|
|
|
public void initView() {
|
|
|
|
|
findView();
|
|
|
|
|
|
|
|
|
|
etFormerPwd.setText("Rehome.zhps@996");
|
|
|
|
|
// etFormerPwd.setText("Rehome.zhps@2020");
|
|
|
|
|
// etNewPwd.setText("Rehome.zhps@996");
|
|
|
|
|
// etNewPwdSure.setText("Rehome.zhps@996");
|
|
|
|
|
|
|
|
|
|
initToolbar("修改密码", "修改", new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
@ -107,16 +118,66 @@ public class UpdatePwdActivity extends BaseActivity {
|
|
|
|
|
private void updatePwd() {
|
|
|
|
|
|
|
|
|
|
String json = createJson();
|
|
|
|
|
|
|
|
|
|
showLog(json);
|
|
|
|
|
|
|
|
|
|
RequestBody body = RequestBody.create(MediaType.parse("application/json"),json);
|
|
|
|
|
HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<ResultBean>(context) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Call<ResultBean> call, Response<ResultBean> response) {
|
|
|
|
|
|
|
|
|
|
// RequestBody body = RequestBody.create(MediaType.parse("application/json"), json);
|
|
|
|
|
// HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<String>(context) {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onSuccess(Call<String> call, Response<String> response) {
|
|
|
|
|
//
|
|
|
|
|
// showLog("--------------------");
|
|
|
|
|
// String result = response.body();
|
|
|
|
|
// String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
|
|
|
|
|
// showLog(result);
|
|
|
|
|
// showLog(jsonDecode);
|
|
|
|
|
// if (TextUtils.isEmpty(jsonDecode)) {
|
|
|
|
|
// showToast(UiUtlis.getString(context, R.string.data_error));
|
|
|
|
|
// } else {
|
|
|
|
|
// ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
|
|
|
|
|
// if (bean != null) {
|
|
|
|
|
// if (!bean.getTotal().equals("0")) {
|
|
|
|
|
// if (bean.getRows().get(0).getResult().equals("1")) {
|
|
|
|
|
// toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
|
|
|
|
|
// SPUtils.put(context, Contans.SP.PASS_WORD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()));
|
|
|
|
|
// SPUtils.put(context, Contans.SP.OLD_PWD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()));
|
|
|
|
|
// SPUtils.put(
|
|
|
|
|
// context,
|
|
|
|
|
// Contans.SP.AF_PASS_WORD,
|
|
|
|
|
// RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString())
|
|
|
|
|
// );
|
|
|
|
|
// finish();
|
|
|
|
|
// } else {
|
|
|
|
|
// toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onError(Call<String> call, Throwable t) {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
String url = Contans.BASE_URL + Contans.UPLOAD_PHONE_OR_PWD_URL;
|
|
|
|
|
Request<String> request = NoHttp.createStringRequest(url, RequestMethod.POST);
|
|
|
|
|
request.setDefineRequestBodyForJson(json);
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(this, 0, "正在提交数据...", request, new HttpListener<String>() {
|
|
|
|
|
|
|
|
|
|
ResultBean bean = response.body();
|
|
|
|
|
@Override
|
|
|
|
|
public void onSucceed(int what, com.yolanda.nohttp.rest.Response<String> response) {
|
|
|
|
|
|
|
|
|
|
showLog("----------------");
|
|
|
|
|
String result = response.get();
|
|
|
|
|
String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
|
|
|
|
|
showLog(result);
|
|
|
|
|
// showLog(jsonDecode);
|
|
|
|
|
if (TextUtils.isEmpty(jsonDecode)) {
|
|
|
|
|
showToast(UiUtlis.getString(context, R.string.data_error));
|
|
|
|
|
} else {
|
|
|
|
|
ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
|
|
|
|
|
if (bean != null) {
|
|
|
|
|
if (!bean.getTotal().equals("0")) {
|
|
|
|
|
if (bean.getRows().get(0).getResult().equals("1")) {
|
|
|
|
|
@ -134,11 +195,11 @@ public class UpdatePwdActivity extends BaseActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(Call<ResultBean> call, Throwable t) {
|
|
|
|
|
public void onFailed(int what, com.yolanda.nohttp.rest.Response<String> response) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -147,17 +208,18 @@ public class UpdatePwdActivity extends BaseActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String createJson() {
|
|
|
|
|
|
|
|
|
|
UpdatePwd updatePwd = new UpdatePwd();
|
|
|
|
|
List<UpdatePwd.RowsBean> list = new ArrayList<>();
|
|
|
|
|
UpdatePwd.RowsBean rowsBean = new UpdatePwd.RowsBean();
|
|
|
|
|
rowsBean.setManid(userInfo.getManid());
|
|
|
|
|
rowsBean.setNewpwd(etNewPwd.getText().toString());
|
|
|
|
|
rowsBean.setPwded(etFormerPwd.getText().toString());
|
|
|
|
|
rowsBean.setType("0");
|
|
|
|
|
list.add(rowsBean);
|
|
|
|
|
updatePwd.setRows(list);
|
|
|
|
|
String json = GsonUtils.GsonString(updatePwd);
|
|
|
|
|
return json;
|
|
|
|
|
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
|
|
|
|
|
return jsonEncrypt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean validaData() {
|
|
|
|
|
|