提交 d35e0f7d authored 作者: lgd's avatar lgd

1.登录添加判断erpId逻辑

2.//TODO 设备三个子菜单,坩埚下单,mes其他页面,mes用户反馈空也展示,编辑任务担当无法修改.支数参数
上级 9ff652ed
package com.wd.workoffice.presenter; package com.wd.workoffice.presenter;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.wd.workoffice.app.BaseBean; import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.bean.UserInfoBean;
import com.wd.workoffice.contract.LoginContract; import com.wd.workoffice.contract.LoginContract;
import com.wd.workoffice.model.LoginModel; import com.wd.workoffice.model.LoginModel;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver; import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.util.UserKeeper; import com.wd.workoffice.util.UserKeeper;
...@@ -12,6 +17,7 @@ import java.util.Map; ...@@ -12,6 +17,7 @@ import java.util.Map;
import flexible.xd.android_base.mvpBase.BasePresenter; import flexible.xd.android_base.mvpBase.BasePresenter;
import flexible.xd.android_base.network.rtfhttp.Transformer; import flexible.xd.android_base.network.rtfhttp.Transformer;
import flexible.xd.android_base.utils.ToastUtil;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
...@@ -65,8 +71,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.View, LoginContr ...@@ -65,8 +71,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.View, LoginContr
mView.onError(data.getMessage()); mView.onError(data.getMessage());
return; return;
} }
UserKeeper.getInstance().keepLoginInfo(JSON.toJSONString(data.getData())); getUserInfo(JSON.toJSONString(data.getData()));
mView.loginSuccess();
} else { } else {
ResponseBody data = response.errorBody(); ResponseBody data = response.errorBody();
mView.hideLoading(); mView.hideLoading();
...@@ -76,8 +81,8 @@ public class LoginPresenter extends BasePresenter<LoginContract.View, LoginContr ...@@ -76,8 +81,8 @@ public class LoginPresenter extends BasePresenter<LoginContract.View, LoginContr
mView.onError(backData.getMessage()); mView.onError(backData.getMessage());
return; return;
} }
UserKeeper.getInstance().keepLoginInfo(JSON.toJSONString(backData.getData())); // UserKeeper.getInstance().keepLoginInfo(JSON.toJSONString(backData.getData()));
mView.loginSuccess(); // mView.loginSuccess();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -126,6 +131,34 @@ public class LoginPresenter extends BasePresenter<LoginContract.View, LoginContr ...@@ -126,6 +131,34 @@ public class LoginPresenter extends BasePresenter<LoginContract.View, LoginContr
// }); // });
} }
private void getUserInfo(String loginInfo) {
RtfUtils.getRtf().userInfo().compose(Transformer.schedule()).subscribe(new WorkObserver<BaseBean>() {
@Override
public void doOnSubscribe(Disposable d) {
}
@Override
public void onFail(String errorMsg) {
}
@Override
public void onSuccess(BaseBean data) {
if (data.getCode() != 0) {
return;
}
JSONObject userData = JSON.parseObject(data.getData().toString());
if (UserKeeper.getInstance().getMesLogin()&&
!TextUtils.equals(UserKeeper.getInstance().getMesErpId(),userData.getString("erpId"))){
ToastUtil.showShort("员工编号不一致");
return;
}
UserKeeper.getInstance().keepLoginInfo(loginInfo);
mView.loginSuccess();
UserKeeper.getInstance().keepUserInfo(data.getData().toString());
}
});
}
@Override @Override
public LoginContract.Model bindModel() { public LoginContract.Model bindModel() {
return LoginModel.newInstance(); return LoginModel.newInstance();
......
...@@ -44,23 +44,6 @@ public class MainLoginActivity extends WorkBaseActivity { ...@@ -44,23 +44,6 @@ public class MainLoginActivity extends WorkBaseActivity {
@Override @Override
protected void initData() { protected void initData() {
if (!UserKeeper.getInstance().getIsAgree()) {
// View view = LayoutInflater.from(this).inflate(R.layout.activity_about, null);
// AlertDialog.Builder builder =new AlertDialog.Builder(this);
//
// builder.setView(view).setNegativeButton("暂不使用", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// }
// }).setPositiveButton("确定", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// UserKeeper.getInstance().keepIsAgree(true);
// }
// }).show();
}
} }
......
...@@ -136,10 +136,15 @@ public class MesLoginActivity extends WorkToolBarActivity { ...@@ -136,10 +136,15 @@ public class MesLoginActivity extends WorkToolBarActivity {
toast(data.getMessage()); toast(data.getMessage());
return; return;
} }
JSONObject userData = JSON.parseObject(data.getData().toString());
if (!TextUtils.isEmpty(UserKeeper.getInstance().getLoginInfo())&&
!TextUtils.equals(UserKeeper.getInstance().getUserErpId(),userData.getString("userCode"))){
toast("员工编号不一致");
return;
}
toast("登录成功"); toast("登录成功");
UserKeeper.getInstance().keepMesLogin(true); UserKeeper.getInstance().keepMesLogin(true);
JSONObject userData = JSON.parseObject(data.getData().toString()); UserKeeper.getInstance().keepMesLoginInfo(JSON.toJSONString(userData));
UserKeeper.getInstance().keepMesUid(userData.getString("userId"));
Intent intent = new Intent(MesLoginActivity.this, MainActivity.class); Intent intent = new Intent(MesLoginActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent); startActivity(intent);
......
...@@ -4,6 +4,7 @@ package com.wd.workoffice.util; ...@@ -4,6 +4,7 @@ package com.wd.workoffice.util;
import android.text.TextUtils; import android.text.TextUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.wd.workoffice.bean.TokenBean; import com.wd.workoffice.bean.TokenBean;
import com.wd.workoffice.bean.UserInfoBean; import com.wd.workoffice.bean.UserInfoBean;
...@@ -21,6 +22,7 @@ public class UserKeeper { ...@@ -21,6 +22,7 @@ public class UserKeeper {
private final String LOGIN_INFO = "_LOGIN_INFO"; private final String LOGIN_INFO = "_LOGIN_INFO";
private final String USER_INFO = "_USER_INFO"; private final String USER_INFO = "_USER_INFO";
private final String MES_LOGIN = "_MES_LOGIN"; private final String MES_LOGIN = "_MES_LOGIN";
private final String MES_LOGIN_INFO = "_MES_LOGIN_INFO";
private final String MES_UID = "_MES_UID"; private final String MES_UID = "_MES_UID";
private final String COOKIE = "_COOKIE"; private final String COOKIE = "_COOKIE";
private final String IS_AGREE = "_IS_AGREE"; private final String IS_AGREE = "_IS_AGREE";
...@@ -39,22 +41,22 @@ public class UserKeeper { ...@@ -39,22 +41,22 @@ public class UserKeeper {
return keeper; return keeper;
} }
/** // /**
* 同意协议 // * 同意协议
* // *
* @param info // * @param info
*/ // */
public void keepIsAgree(Boolean info) { // public void keepIsAgree(Boolean info) {
sp.put(IS_AGREE, info); // sp.put(IS_AGREE, info);
} // }
//
public Boolean getIsAgree() { // public Boolean getIsAgree() {
return sp.getBoolean(IS_AGREE); // return sp.getBoolean(IS_AGREE);
} // }
//
public void clearIsAgree() { // public void clearIsAgree() {
sp.put(IS_AGREE, false); // sp.put(IS_AGREE, false);
} // }
/** /**
* mescookie * mescookie
...@@ -90,18 +92,47 @@ public class UserKeeper { ...@@ -90,18 +92,47 @@ public class UserKeeper {
sp.put(MES_LOGIN, false); sp.put(MES_LOGIN, false);
} }
public void keepMesUid(String info) { /**
sp.put(MES_UID, info); * mes的用户信息
*
* @param info
*/
public void keepMesLoginInfo(String info) {
sp.put(MES_LOGIN_INFO, info);
}
public String getMesLoginInfo() {
return sp.getString(MES_LOGIN_INFO);
} }
public String getMesUid() { public void clearMesLoginInfo() {
return sp.getString(MES_UID); sp.put(MES_LOGIN_INFO, "");
} }
/**
* mes的用户id
*
* @param
*/
public void clearMesUid() { public String getMesUid() {
sp.put(MES_UID, ""); JSONObject mesInfo = JSON.parseObject(getMesLoginInfo());
if (!TextUtils.isEmpty(getMesLoginInfo())){
return mesInfo.getString("userId");
}
return "";
}
public String getMesErpId() {
JSONObject mesInfo = JSON.parseObject(getMesLoginInfo());
if (!TextUtils.isEmpty(getMesLoginInfo())){
return mesInfo.getString("userCode");
}
return "";
} }
/**
* bat 用户信息
* @param info
*/
public void keepLoginInfo(String info) { public void keepLoginInfo(String info) {
sp.put(LOGIN_INFO, info); sp.put(LOGIN_INFO, info);
} }
...@@ -230,6 +261,7 @@ public class UserKeeper { ...@@ -230,6 +261,7 @@ public class UserKeeper {
clearLoginInfo(); clearLoginInfo();
clearUserInfo(); clearUserInfo();
clearMesLogin(); clearMesLogin();
clearMesUid(); clearMesLoginInfo();
clearCookie();
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论