|
|
@@ -13,6 +13,7 @@ import android.view.ViewGroup; |
|
|
|
import android.view.animation.AccelerateDecelerateInterpolator; |
|
|
|
import android.view.animation.AnimationUtils; |
|
|
|
import android.view.inputmethod.EditorInfo; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.ImageView; |
|
|
|
import android.widget.LinearLayout; |
|
|
@@ -23,6 +24,7 @@ import com.gyf.immersionbar.ImmersionBar; |
|
|
|
import com.hjq.umeng.UmengClient; |
|
|
|
import com.hjq.widget.view.CountdownView; |
|
|
|
import com.hjq.widget.view.SubmitButton; |
|
|
|
import com.huntersun.vky.obublelib.util.ValidatorUtils; |
|
|
|
import com.huntersun.vkyes.etcopencard.R; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.Api; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.Converter; |
|
|
@@ -36,6 +38,7 @@ import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeB |
|
|
|
import com.huntersun.vkyes.etcopencard.project.tool.MyShared; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.ui.activity.MainActivity; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.ui.activity.after.CheckRunningWaterStep2Activity; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.ui.activity.after.ReplaceEtcStep4Activity; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.ui.activity.user.ForgetPwdStep1Activity; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; |
|
|
|
import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; |
|
|
@@ -60,9 +63,8 @@ import androidx.annotation.Nullable; |
|
|
|
* |
|
|
|
* @author admin |
|
|
|
*/ |
|
|
|
public final class LoginActivity extends AppActivity |
|
|
|
implements KeyboardWatcher.SoftKeyboardStateListener, |
|
|
|
TextView.OnEditorActionListener { |
|
|
|
public final class LoginActivity extends AppActivity implements KeyboardWatcher.SoftKeyboardStateListener, TextView.OnEditorActionListener { |
|
|
|
private CodeCountDown mCountDownTimerUtils; |
|
|
|
|
|
|
|
private static final String INTENT_KEY_IN_PHONE = "phone"; |
|
|
|
private static final String INTENT_KEY_IN_PASSWORD = "password"; |
|
|
@@ -87,20 +89,15 @@ public final class LoginActivity extends AppActivity |
|
|
|
|
|
|
|
private View mForgetView; |
|
|
|
private SubmitButton mCommitView; |
|
|
|
private Button mGetCodeBtn; |
|
|
|
private CountdownView mCountdownView; |
|
|
|
private LinearLayout mLayoutCode; |
|
|
|
|
|
|
|
private View mOtherView; |
|
|
|
|
|
|
|
private Boolean loginStart = true; //true 账号密码 false 手机号 |
|
|
|
|
|
|
|
/** |
|
|
|
* logo 缩放比例 |
|
|
|
*/ |
|
|
|
//logo缩放比例 |
|
|
|
private final float mLogoScale = 0.8f; |
|
|
|
/** |
|
|
|
* 动画时间 |
|
|
|
*/ |
|
|
|
//动画时间 |
|
|
|
private final int mAnimTime = 300; |
|
|
|
|
|
|
|
@Override |
|
|
@@ -116,14 +113,13 @@ public final class LoginActivity extends AppActivity |
|
|
|
mPasswordView = findViewById(R.id.et_login_password); |
|
|
|
mForgetView = findViewById(R.id.tv_login_forget); |
|
|
|
mCommitView = findViewById(R.id.btn_login_commit); |
|
|
|
mOtherView = findViewById(R.id.ll_login_other); |
|
|
|
//发送验证码 |
|
|
|
mGetCodeBtn = findViewById(R.id.mGetCodeBtn); |
|
|
|
mCountdownView = findViewById(R.id.cv_phone_reset_countdown); |
|
|
|
mCodeView = findViewById(R.id.et_phone_reset_code); |
|
|
|
mTvLoginCode = findViewById(R.id.tv_login_code); |
|
|
|
mLayoutCode = findViewById(R.id.layout_code); |
|
|
|
|
|
|
|
setOnClickListener(mForgetView, mCountdownView, mTvLoginCode, mCodeView, mCommitView); |
|
|
|
setOnClickListener(mForgetView, mCountdownView, mTvLoginCode, mCodeView, mCommitView, mGetCodeBtn); |
|
|
|
|
|
|
|
mPasswordView.setOnEditorActionListener(this); |
|
|
|
|
|
|
@@ -133,21 +129,21 @@ public final class LoginActivity extends AppActivity |
|
|
|
/** |
|
|
|
* 修改密码成功 |
|
|
|
*/ |
|
|
|
private void setDataToView(){ |
|
|
|
private void setDataToView() { |
|
|
|
//修改密码之后-自动填充 |
|
|
|
String phone = getIntent().getStringExtra("phone"); |
|
|
|
String pwd = getIntent().getStringExtra("pwd"); |
|
|
|
if(!FunHelper.isEmpty(phone)){ |
|
|
|
if (!FunHelper.isEmpty(phone)) { |
|
|
|
mPhoneView.setText(phone); |
|
|
|
}else{//手机号为空,取缓存的手机号码 |
|
|
|
} else {//手机号为空,取缓存的手机号码 |
|
|
|
// String mobile = (String) MyShared.getInstance().get(MyShared.USER_PHONE,""); |
|
|
|
// mPhoneView.setText(mobile); |
|
|
|
} |
|
|
|
if (!FunHelper.isEmpty(pwd)){ |
|
|
|
if (!FunHelper.isEmpty(pwd)) { |
|
|
|
mPasswordView.setText(pwd); |
|
|
|
} |
|
|
|
|
|
|
|
LiveEventBus.get("updatePwdSuccess", Boolean.class) .observe(this, s -> { |
|
|
|
LiveEventBus.get("updatePwdSuccess", Boolean.class).observe(this, s -> { |
|
|
|
finish(); |
|
|
|
}); |
|
|
|
} |
|
|
@@ -181,19 +177,19 @@ public final class LoginActivity extends AppActivity |
|
|
|
@SingleClick |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
if (view == mForgetView) { |
|
|
|
if (view == mForgetView) {//忘记密码 |
|
|
|
/* Intent intent = new Intent(); |
|
|
|
intent.putExtra("start", false); |
|
|
|
intent.setClass(LoginActivity.this, UpdatePasswordActivity.class); |
|
|
|
startActivity(intent);*/ |
|
|
|
|
|
|
|
Bundle bundle = new Bundle(); |
|
|
|
bundle.putString("phone",FunHelper.getText(mPhoneView)); |
|
|
|
jumpToPage(ForgetPwdStep1Activity.class,bundle); |
|
|
|
bundle.putString("phone", FunHelper.getText(mPhoneView)); |
|
|
|
jumpToPage(ForgetPwdStep1Activity.class, bundle); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (view == mTvLoginCode) { |
|
|
|
if (view == mTvLoginCode) {//登录 |
|
|
|
if ("手机号登录".equals(mTvLoginCode.getText().toString())) { |
|
|
|
mTvLoginCode.setText("账号密码登录"); |
|
|
|
mLayoutCode.setVisibility(View.VISIBLE); |
|
|
@@ -208,31 +204,18 @@ public final class LoginActivity extends AppActivity |
|
|
|
} |
|
|
|
|
|
|
|
//发送验证码 |
|
|
|
if (view == mCountdownView) { |
|
|
|
if (mPhoneView.getText().toString().length() != 11) { |
|
|
|
mPhoneView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim)); |
|
|
|
toast(R.string.common_phone_input_error); |
|
|
|
if (view == mGetCodeBtn) { |
|
|
|
if (FunHelper.isEmpty(FunHelper.getText(mPhoneView))) { |
|
|
|
toast("请输入手机号"); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 隐藏软键盘 |
|
|
|
hideKeyboard(getCurrentFocus()); |
|
|
|
showDialog("发送中..."); |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("mobile", mPhoneView.getText().toString()); |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE2, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
hideDialog(); |
|
|
|
toast("验证码发送成功!"); |
|
|
|
mCountdownView.start(); //开始倒计时 |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
hideDialog(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (!ValidatorUtils.isMobile(FunHelper.getText(mPhoneView))) { |
|
|
|
toast("请输入正确的手机号!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
sendCode(); |
|
|
|
} |
|
|
|
|
|
|
|
if (view == mCommitView) { //提交按钮 |
|
|
@@ -248,47 +231,18 @@ public final class LoginActivity extends AppActivity |
|
|
|
// 隐藏软键盘 |
|
|
|
hideKeyboard(getCurrentFocus()); |
|
|
|
|
|
|
|
if (FunHelper.isEmpty(value)){ |
|
|
|
toast( loginStart ? "请输入密码!" : "请输入验证码"); |
|
|
|
if (FunHelper.isEmpty(value)) { |
|
|
|
toast(loginStart ? "请输入密码!" : "请输入验证码"); |
|
|
|
mPasswordView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim)); |
|
|
|
mCommitView.showError(3000); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//提交数据处理 |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("mobile", mPhoneView.getText() + ""); |
|
|
|
params.put("password", value); |
|
|
|
params.put("appId", "52030131"); //综合业务支撑平台使用 |
|
|
|
//IFCODE66 |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE4, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
ResultBean.BizContent content = new ResultBean.BizContent(); |
|
|
|
content.setCode(bizContent.getCode()); |
|
|
|
//通过code换取appid |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE5, content, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
MyShared.getInstance().put(MyShared.OPENID, bizContent.getOpenId() + ""); |
|
|
|
MyShared.getInstance().put(MyShared.ACCESSTOKEN, bizContent.getAccessToken() + ""); |
|
|
|
MyShared.getInstance().put(MyShared.USER_PHONE,FunHelper.getText(mPhoneView)); |
|
|
|
|
|
|
|
// 跳转到首页 |
|
|
|
MainActivity.start(getContext()); |
|
|
|
finish(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
postDelayed(() -> { |
|
|
|
mCommitView.showError(3000); |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (loginStart) {//账号密码登录 |
|
|
|
loginByPwd(); |
|
|
|
} else {//验证码登录 |
|
|
|
loginByCode(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -364,4 +318,147 @@ public final class LoginActivity extends AppActivity |
|
|
|
.navigationBarColor(R.color.white); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 登录成功 |
|
|
|
*/ |
|
|
|
private void loginSuccess(ResultBean.BizContent bizContent) { |
|
|
|
MyShared.getInstance().put(MyShared.OPENID, bizContent.getOpenId() + ""); |
|
|
|
MyShared.getInstance().put(MyShared.ACCESSTOKEN, bizContent.getAccessToken() + ""); |
|
|
|
MyShared.getInstance().put(MyShared.USER_PHONE, FunHelper.getText(mPhoneView)); |
|
|
|
|
|
|
|
// 跳转到首页 |
|
|
|
MainActivity.start(getContext()); |
|
|
|
finish(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过code获取登录用户信息 |
|
|
|
* |
|
|
|
* @param code |
|
|
|
*/ |
|
|
|
private void getLoginInfo(String code) { |
|
|
|
ResultBean.BizContent content = new ResultBean.BizContent(); |
|
|
|
content.setCode(code); |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE5, content, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
loginSuccess(bizContent); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
postDelayed(() -> { |
|
|
|
mCommitView.showError(3000); |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 账号密码登录 |
|
|
|
*/ |
|
|
|
private void loginByPwd() { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("mobile", mPhoneView.getText() + ""); |
|
|
|
params.put("password", FunHelper.getText(mPasswordView)); |
|
|
|
params.put("appId", "52030131"); //综合业务支撑平台使用 |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE4, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
getLoginInfo(bizContent.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
postDelayed(() -> { |
|
|
|
mCommitView.showError(3000); |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 验证码登录 |
|
|
|
*/ |
|
|
|
private void loginByCode() { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("mobile", FunHelper.getText(mPhoneView)); |
|
|
|
params.put("code", FunHelper.getText(mCodeView)); |
|
|
|
params.put("appId", "52030131"); |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE55, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
getLoginInfo(bizContent.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
postDelayed(() -> { |
|
|
|
mCommitView.showError(3000); |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 发送验证码 |
|
|
|
*/ |
|
|
|
private void sendCode() { |
|
|
|
showDialog("发送中..."); |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("mobile", FunHelper.getText(mPhoneView)); |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE2, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
hideDialog(); |
|
|
|
toast("验证码发送成功!"); |
|
|
|
mCountDownTimerUtils = new CodeCountDown(LoginActivity.this, mGetCodeBtn, 60000, 1000,R.color.common_accent_color); |
|
|
|
mCountDownTimerUtils.start(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
hideDialog(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//旧版本 |
|
|
|
/* if (mPhoneView.getText().toString().length() != 11) { |
|
|
|
mPhoneView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.shake_anim)); |
|
|
|
toast(R.string.common_phone_input_error); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 隐藏软键盘 |
|
|
|
hideKeyboard(getCurrentFocus()); |
|
|
|
showDialog("发送中..."); |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("mobile", mPhoneView.getText().toString()); |
|
|
|
MyRetrofit.newInstance(IFCode.IFCODE2, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
hideDialog(); |
|
|
|
toast("验证码发送成功!"); |
|
|
|
mCountdownView.start(); //开始倒计时 |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError() { |
|
|
|
MyRetrofit.ReturnResult.super.onError(); |
|
|
|
hideDialog(); |
|
|
|
} |
|
|
|
});*/ |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
if (mCountDownTimerUtils != null) { |
|
|
|
mCountDownTimerUtils.cancel(); |
|
|
|
mCountDownTimerUtils = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |