|
|
@@ -1,10 +1,15 @@ |
|
|
|
package com.bonait.bnframework.modules.welcome.activity; |
|
|
|
|
|
|
|
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; |
|
|
|
|
|
|
|
import android.animation.ObjectAnimator; |
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.content.Intent; |
|
|
|
import android.os.Bundle; |
|
|
|
import androidx.core.widget.NestedScrollView; |
|
|
|
|
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Looper; |
|
|
|
import android.text.Editable; |
|
|
|
import android.text.InputType; |
|
|
|
import android.text.TextUtils; |
|
|
@@ -22,8 +27,13 @@ import android.widget.ImageView; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
import android.widget.RelativeLayout; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.apkfuns.logutils.LogUtils; |
|
|
|
import com.bonait.bnframework.R; |
|
|
|
import com.bonait.bnframework.business.ConfigData; |
|
|
|
import com.bonait.bnframework.business.RecordManager; |
|
|
|
import com.bonait.bnframework.common.API.APIHelper; |
|
|
|
import com.bonait.bnframework.common.API.APIResultT; |
|
|
|
import com.bonait.bnframework.common.base.BaseActivity; |
|
|
|
import com.bonait.bnframework.common.bg.SnowView; |
|
|
|
import com.bonait.bnframework.common.constant.ConfigName; |
|
|
@@ -32,6 +42,11 @@ import com.bonait.bnframework.common.constant.SPConstants; |
|
|
|
import com.bonait.bnframework.common.db.QueryDB; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_USER; |
|
|
|
import com.bonait.bnframework.common.helper.ActiveMax; |
|
|
|
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; |
|
|
|
import com.bonait.bnframework.common.model.GoodsData; |
|
|
|
import com.bonait.bnframework.common.model.LoginBean; |
|
|
|
import com.bonait.bnframework.common.model.mode.BaseCodeJson; |
|
|
|
import com.bonait.bnframework.common.thread.ThreadManager; |
|
|
|
import com.bonait.bnframework.common.utils.AlertDialogUtils; |
|
|
|
import com.bonait.bnframework.common.utils.AnimationToolUtils; |
|
|
|
import com.bonait.bnframework.common.utils.AppUtils; |
|
|
@@ -44,8 +59,12 @@ import com.bonait.bnframework.modules.home.activity.BottomNavigation2Activity; |
|
|
|
import com.bonait.bnframework.modules.home.activity.BottomNavigationNewActivity; |
|
|
|
import com.bonait.bnframework.modules.welcome.model.AppLoginPo; |
|
|
|
import com.bonait.bnframework.test.TestActivity; |
|
|
|
import com.bonait.bnframework.ui.viewmodel.UpdateDataService; |
|
|
|
import com.bonait.bnframework.ui.widget.WaitProcessUtil; |
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.lzy.okgo.OkGo; |
|
|
|
import com.lzy.okgo.model.HttpParams; |
|
|
|
import com.lzy.okgo.model.Response; |
|
|
|
import com.mobsandgeeks.saripaar.ValidationError; |
|
|
|
import com.mobsandgeeks.saripaar.Validator; |
|
|
|
import com.mobsandgeeks.saripaar.annotation.NotEmpty; |
|
|
@@ -55,11 +74,14 @@ import com.qmuiteam.qmui.util.QMUIStatusBarHelper; |
|
|
|
|
|
|
|
import org.litepal.LitePal; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
import butterknife.ButterKnife; |
|
|
|
import butterknife.OnClick; |
|
|
|
import okhttp3.MediaType; |
|
|
|
import okhttp3.RequestBody; |
|
|
|
|
|
|
|
public class LoginActivity extends BaseActivity implements Validator.ValidationListener { |
|
|
|
|
|
|
@@ -100,6 +122,10 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL |
|
|
|
|
|
|
|
private Validator validator; |
|
|
|
|
|
|
|
private Handler handler = new Handler(Looper.getMainLooper()){ |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
|
|
|
@@ -203,39 +229,121 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL |
|
|
|
* 登录表单验证成功后,请求后台验证账号密码 |
|
|
|
* */ |
|
|
|
private void attemptLogin() { |
|
|
|
String url = Constants.SERVICE_IP + "/appLogin.do"; |
|
|
|
// String url = Constants.SERVICE_IP + "/appLogin.do"; |
|
|
|
|
|
|
|
final String userAccount = mEtAccount.getText().toString(); |
|
|
|
final String password = mEtPassword.getText().toString(); |
|
|
|
//密码加密 |
|
|
|
String newPassword = AppUtils.encryptSha256(password); |
|
|
|
|
|
|
|
BPA_USER user= QueryDB.UserLogin(userAccount,password); |
|
|
|
if(user!=null) |
|
|
|
{ |
|
|
|
ConfigName.getInstance().user=user; |
|
|
|
ConfigData.getInstance().SavePZ(); |
|
|
|
//跳转到主页 |
|
|
|
skipToMainActivity(); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.warning(getString(R.string.text_Login_Fass)); |
|
|
|
} |
|
|
|
if(!ConfigName.getInstance().isPhoneVersion){ |
|
|
|
//密码加密 |
|
|
|
String newPassword = AppUtils.encryptSha256(password); |
|
|
|
|
|
|
|
BPA_USER user= QueryDB.UserLogin(userAccount,password); |
|
|
|
if(user!=null) |
|
|
|
{ |
|
|
|
ConfigName.getInstance().user=user; |
|
|
|
ConfigData.getInstance().SavePZ(); |
|
|
|
//跳转到主页 |
|
|
|
skipToMainActivity(); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.warning(getString(R.string.text_Login_Fass)); |
|
|
|
} |
|
|
|
}else { |
|
|
|
WaitProcessUtil.getInstance().show(this,"登录","正在验证..."); |
|
|
|
ConfigName.getInstance().DeviceAutoKey = "266"; |
|
|
|
ConfigName.getInstance().DeviceId = "266"; |
|
|
|
UpdateDataService.key = "cb3d774a-b93d-41d6-85b6-667df9ec9a3b"; |
|
|
|
|
|
|
|
BPA_USER user= QueryDB.UserLogin(userAccount,password); |
|
|
|
if(user!=null) |
|
|
|
{ |
|
|
|
ToastUtils.info("验证成功,正在登录"); |
|
|
|
ConfigName.getInstance().user=user; |
|
|
|
ConfigData.getInstance().SavePZ(); |
|
|
|
WaitProcessUtil.getInstance().dismiss(); |
|
|
|
// 隐藏软键盘 |
|
|
|
KeyboardToolUtils.hideSoftInput(LoginActivity.this); |
|
|
|
Intent intent = new Intent(LoginActivity.this, BottomNavigationNewActivity.class); |
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
|
|
|
startActivity(intent); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// OkGo.<BaseCodeJson<AppLoginPo>>post(url) |
|
|
|
// .tag(this) |
|
|
|
// .params("username",userAccount) |
|
|
|
// .params("password",newPassword) |
|
|
|
// .execute(new JsonDialogCallback<BaseCodeJson<AppLoginPo>>(this) { |
|
|
|
// @Override |
|
|
|
// public void onSuccess(Response<BaseCodeJson<AppLoginPo>> response) { |
|
|
|
// BaseCodeJson<AppLoginPo> loginJson = response.body(); |
|
|
|
// if (loginJson != null) { |
|
|
|
// whichDepartment(userAccount,password,loginJson.getResult()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }); |
|
|
|
HashMap<String,String> params = new HashMap<>(); |
|
|
|
params.put("Account",userAccount); |
|
|
|
params.put("Password",password); |
|
|
|
String body = new Gson().toJson(params); |
|
|
|
OkGo.<APIResultT<LoginBean>>post("https://cfv.black-pa.com/saasbase/api/auth/login") |
|
|
|
.tag(this) |
|
|
|
.upRequestBody( |
|
|
|
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), |
|
|
|
body)) |
|
|
|
.execute(new JsonDialogCallback<APIResultT<LoginBean>>(this) { |
|
|
|
@Override |
|
|
|
public void onSuccess(Response<APIResultT<LoginBean>> response) { |
|
|
|
LogUtils.d("GetGoodsInfo s.code="+response.code()); |
|
|
|
LogUtils.d("GetGoodsInfo s.code="+response.body()); |
|
|
|
try{ |
|
|
|
if (response.body()!=null){ |
|
|
|
if(response.body().statusCode==200){ |
|
|
|
ToastUtils.info("验证成功,正在登录"); |
|
|
|
BPA_USER user2 = new BPA_USER(); |
|
|
|
user2.name = "研发用户"; |
|
|
|
user2.account = userAccount; |
|
|
|
user2.pass = password; |
|
|
|
user2.deviceID = "266"; |
|
|
|
user2.userID = "研发用户"; |
|
|
|
user2.exp = "研发用户"; |
|
|
|
QueryDB.AddUser(user2); |
|
|
|
|
|
|
|
ConfigName.getInstance().user.account = userAccount; |
|
|
|
ConfigName.getInstance().user.pass = password; |
|
|
|
ConfigData.getInstance().SavePZ(); |
|
|
|
|
|
|
|
ConfigName.getInstance().user=user2; |
|
|
|
LogUtils.d("GetGoodsInfo s.code=200"); |
|
|
|
|
|
|
|
WaitProcessUtil.getInstance().dismiss(); |
|
|
|
// 隐藏软键盘 |
|
|
|
KeyboardToolUtils.hideSoftInput(LoginActivity.this); |
|
|
|
Intent intent = new Intent(LoginActivity.this, BottomNavigationNewActivity.class); |
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
|
|
|
startActivity(intent); |
|
|
|
// 结束所有Activity |
|
|
|
ActivityLifecycleManager.get().finishAllActivity(); |
|
|
|
LogUtils.d("GetGoodsInfo startActivity"); |
|
|
|
}else { |
|
|
|
ToastUtils.warning("登录失败,"+response.body().errors); |
|
|
|
} |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
ToastUtils.warning("接口数据解析异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError(Response<APIResultT<LoginBean>> response) { |
|
|
|
super.onError(response); |
|
|
|
WaitProcessUtil.getInstance().dismiss(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFinish() { |
|
|
|
super.onFinish(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
if(handler!=null){ |
|
|
|
handler.removeCallbacksAndMessages(null); |
|
|
|
handler = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|