|
|
@@ -298,7 +298,8 @@ public class ViewUtil {
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
- @Deprecated
|
|
|
+
|
|
|
+ @Deprecated
|
|
|
public static void showDialogB2B(final String phone, final String password, final List<LoginEntity.Spaces> models) {
|
|
|
String[] items = new String[models.size()];
|
|
|
// int select = 0;
|
|
|
@@ -335,17 +336,17 @@ public class ViewUtil {
|
|
|
public static void LoginB2BTask(String phone, String password, Integer spaceId) {
|
|
|
mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_progress_b2b));
|
|
|
String url = ApiConfig.getInstance(new ApiPlatform()).getmApiBase().login;
|
|
|
- LogUtil.d("HttpLogs","b2b login url:"+url);
|
|
|
+ LogUtil.d("HttpLogs", "b2b login url:" + url);
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("appId", "b2b");
|
|
|
params.put("username", phone);
|
|
|
params.put("password", password);
|
|
|
// if (!BaseConfig.isDebug()) {
|
|
|
- params.put("spaceId", String.valueOf(spaceId));
|
|
|
+ params.put("spaceId", String.valueOf(spaceId));
|
|
|
// } else {
|
|
|
// params.put("spaceId", "76035");
|
|
|
// }
|
|
|
- LogUtil.d("HttpLogs","params:"+JSON.toJSONString(params));
|
|
|
+ LogUtil.d("HttpLogs", "params:" + JSON.toJSONString(params));
|
|
|
startNetThread(url, params, handler, Constants.SUCCESS_B2B, null, null, "post");
|
|
|
}
|
|
|
|
|
|
@@ -430,8 +431,8 @@ public class ViewUtil {
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_master", erp_master);
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_commpany", erp_company);
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_uu", String.valueOf(dataMap.get("uu")));
|
|
|
- LogUtil.d("ERPLOGIN","erp_uu1:"+String.valueOf(dataMap.get("uu")));
|
|
|
- LogUtil.d("ERPLOGIN","erp_uu2:"+CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_uu"));
|
|
|
+ LogUtil.d("ERPLOGIN", "erp_uu1:" + String.valueOf(dataMap.get("uu")));
|
|
|
+ LogUtil.d("ERPLOGIN", "erp_uu2:" + CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_uu"));
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_masterId", erp_masterId);
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_login", true);
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_emname", String.valueOf(dataMap.get("emname")));
|
|
|
@@ -449,8 +450,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
}, 1500);
|
|
|
if (ct instanceof Activity) {
|
|
|
- if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_baseurl"))){
|
|
|
- }else{
|
|
|
+ if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_baseurl"))) {
|
|
|
+ } else {
|
|
|
ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
|
}
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
|
|
|
@@ -479,7 +480,7 @@ public class ViewUtil {
|
|
|
CommonUtil.setSharedPreferences(ct, "user_password", erp_password);
|
|
|
}
|
|
|
if (ct == null) ct = MyApplication.getInstance();
|
|
|
-
|
|
|
+
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_login", false);
|
|
|
CommonUtil.setSharedPreferences(ct, "b2b_uu", b2b_uu);
|
|
|
mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_success_b2b));
|
|
|
@@ -489,14 +490,14 @@ public class ViewUtil {
|
|
|
mdProcessDialog.cancel();
|
|
|
}
|
|
|
}, 1500);
|
|
|
- if (ct instanceof Activity) {
|
|
|
- if (CommonUtil.getSharedPreferencesBoolean(MyApplication.getInstance(),"b2b_login")){
|
|
|
- }else{
|
|
|
- CommonUtil.setSharedPreferences(ct, "b2b_login", true);
|
|
|
- ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
|
- }
|
|
|
+ if (ct instanceof Activity) {
|
|
|
+ if (CommonUtil.getSharedPreferencesBoolean(MyApplication.getInstance(), "b2b_login")) {
|
|
|
+ } else {
|
|
|
+ CommonUtil.setSharedPreferences(ct, "b2b_login", true);
|
|
|
+ ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
sendBrodcast("B2B");
|
|
|
}
|
|
|
|
|
|
@@ -582,43 +583,42 @@ public class ViewUtil {
|
|
|
|
|
|
}
|
|
|
if (JSONUtil.validate(json)) {
|
|
|
- // showDialogCompany(json, phone, password);
|
|
|
+ // showDialogCompany(json, phone, password);
|
|
|
showLoginDialog(json, phone, password);
|
|
|
} else {
|
|
|
ToastMessage(ct, "接口数据非法!", Style.holoRedLight, 3000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
//解析登录信息
|
|
|
- public static void showLoginDialog(String loginResult,final String phone,final String password){
|
|
|
+ public static void showLoginDialog(String loginResult, final String phone, final String password) {
|
|
|
List<LoginEntity> loginMsg = JSON.parseArray(loginResult, LoginEntity.class);
|
|
|
- List<LoginEntity> loginEntities=new ArrayList<>();
|
|
|
- boolean isHasUas=false;
|
|
|
- if (!ListUtils.isEmpty(loginMsg)){
|
|
|
- if (loginMsg.size()>1) {
|
|
|
- isHasUas = true;
|
|
|
+ List<LoginEntity> loginEntities = new ArrayList<>();
|
|
|
+ boolean isHasUas = false;
|
|
|
+ if (!ListUtils.isEmpty(loginMsg)) {
|
|
|
+ if (loginMsg.size() > 1) {
|
|
|
+ isHasUas = true;
|
|
|
}
|
|
|
- for (int i = 0; i <loginMsg.size() ; i++) {
|
|
|
+ for (int i = 0; i < loginMsg.size(); i++) {
|
|
|
LoginEntity model = loginMsg.get(i);
|
|
|
if (model.getPlatform().equals("ERP")) {
|
|
|
- isHasUas=true;
|
|
|
+ isHasUas = true;
|
|
|
loginEntities.add(model);
|
|
|
} else if (model.getPlatform().equals("B2B")) {
|
|
|
List<LoginEntity.Spaces> sModel = model.getSpaces();
|
|
|
- if (!ListUtils.isEmpty(sModel)){
|
|
|
- for (int j = 0; j <sModel.size() ; j++) {
|
|
|
+ if (!ListUtils.isEmpty(sModel)) {
|
|
|
+ for (int j = 0; j < sModel.size(); j++) {
|
|
|
//去重逻辑
|
|
|
- boolean isHas=false;
|
|
|
- for (int k = 0; k <loginMsg.size() ; k++) {
|
|
|
- if (sModel.get(j).getName().equals(loginMsg.get(k).getName())){
|
|
|
- //存在 uas系统里面存在同名的
|
|
|
- isHas=true;
|
|
|
+ boolean isHas = false;
|
|
|
+ for (int k = 0; k < loginMsg.size(); k++) {
|
|
|
+ if (sModel.get(j).getName().equals(loginMsg.get(k).getName())) {
|
|
|
+ //存在 uas系统里面存在同名的
|
|
|
+ isHas = true;
|
|
|
}
|
|
|
}
|
|
|
- if (!isHas){
|
|
|
- LoginEntity bModel=new LoginEntity();
|
|
|
+ if (!isHas) {
|
|
|
+ LoginEntity bModel = new LoginEntity();
|
|
|
bModel.setEnuu(Integer.valueOf(sModel.get(j).getEnuu()));
|
|
|
bModel.setName(sModel.get(j).getName());
|
|
|
bModel.setSpaceId(sModel.get(j).getId());
|
|
|
@@ -626,7 +626,7 @@ public class ViewUtil {
|
|
|
loginEntities.add(bModel);
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (!isHasUas) {
|
|
|
//没有uas的情况
|
|
|
// model.setPlatform("个人");
|
|
|
@@ -634,23 +634,23 @@ public class ViewUtil {
|
|
|
// loginEntities.add(model);
|
|
|
CommonUtil.setSharedPreferences(MyApplication.getInstance(), "userRole", "1");
|
|
|
ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
|
- }else{
|
|
|
-
|
|
|
+ } else {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
- LogUtil.d("HttpLogs","login dialog:"+JSON.toJSONString(loginEntities));
|
|
|
- if (ListUtils.isEmpty(loginEntities))return;
|
|
|
- erpEntities=loginEntities;
|
|
|
+ LogUtil.d("HttpLogs", "login dialog:" + JSON.toJSONString(loginEntities));
|
|
|
+ if (ListUtils.isEmpty(loginEntities)) return;
|
|
|
+ erpEntities = loginEntities;
|
|
|
String[] items = new String[loginEntities.size()];
|
|
|
int select = 0;
|
|
|
for (int j = 0; j < loginEntities.size(); j++) {
|
|
|
items[j] = loginEntities.get(j).getName();
|
|
|
}
|
|
|
- if (!DialogUtils.isDialogShowing(loginERPDialog)){
|
|
|
- if (loginERPDialog!=null) {
|
|
|
+ if (!DialogUtils.isDialogShowing(loginERPDialog)) {
|
|
|
+ if (loginERPDialog != null) {
|
|
|
select = loginERPDialog.getSelectedIndex();
|
|
|
}
|
|
|
loginERPDialog = new MaterialDialog.Builder(ct)
|
|
|
@@ -665,7 +665,7 @@ public class ViewUtil {
|
|
|
LoginEntity entity = erpEntities.get(which);
|
|
|
erp_phone = phone;
|
|
|
erp_password = password;
|
|
|
- if ("ERP".equals(entity.getPlatform())){
|
|
|
+ if ("ERP".equals(entity.getPlatform())) {
|
|
|
erp_username = entity.getAccount();
|
|
|
erp_master = entity.getMaster();
|
|
|
erp_baseurl = entity.getWebsite();
|
|
|
@@ -676,7 +676,7 @@ public class ViewUtil {
|
|
|
LoginERPTask(entity.getWebsite(), entity.getMaster(), phone, password);
|
|
|
CommonUtil.clearSharedPreferences(MyApplication.getInstance(), "erp_masterlist"); //清除账套列表缓存
|
|
|
}
|
|
|
- if ("B2B".equals(entity.getPlatform())){
|
|
|
+ if ("B2B".equals(entity.getPlatform())) {
|
|
|
CommonUtil.setSharedPreferences(MyApplication.getInstance(), "spaceId", String.valueOf(entity.getSpaceId()));
|
|
|
CommonUtil.setSharedPreferences(MyApplication.getInstance(), "companyName", String.valueOf(entity.getName()));
|
|
|
CommonUtil.setSharedPreferences(MyApplication.getInstance(), "companyEnUu", String.valueOf(entity.getEnuu()));
|
|
|
@@ -686,7 +686,7 @@ public class ViewUtil {
|
|
|
CommonUtil.setSharedPreferences(MyApplication.getInstance(), "userRole", "3");
|
|
|
LoginB2BTask(phone, password, entity.getSpaceId());//登录B2B
|
|
|
}
|
|
|
- if("个人".equals(entity.getPlatform())){
|
|
|
+ if ("个人".equals(entity.getPlatform())) {
|
|
|
CommonUtil.setSharedPreferences(MyApplication.getInstance(), "userRole", "1");
|
|
|
ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
|
}
|
|
|
@@ -694,12 +694,12 @@ public class ViewUtil {
|
|
|
return true;
|
|
|
}
|
|
|
}).positiveText(ct.getString(R.string.common_sure)).show();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
@Deprecated
|
|
|
private static void showDialogCompany(String json, String phone, String password) {
|
|
|
List<LoginEntity> logMsg = JSON.parseArray(json, LoginEntity.class);
|
|
|
@@ -793,6 +793,7 @@ public class ViewUtil {
|
|
|
}
|
|
|
return userName;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @author LiuJie
|
|
|
* @功能:比较两个日期大小
|
|
|
@@ -1034,13 +1035,14 @@ public class ViewUtil {
|
|
|
public static void LoginERPTask(String url, String master, String username,
|
|
|
String password) {
|
|
|
mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_progress_erp));
|
|
|
- url = url + "mobile/login.action";
|
|
|
+// url = url + "mobile/login.action";
|
|
|
+ url = "http://192.168.253.29:8080/ERP/mobile/login.action";
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("username", username);
|
|
|
params.put("password", password);
|
|
|
params.put("master", master);
|
|
|
- LogUtil.i("login","url="+url);
|
|
|
- LogUtil.i("login","params="+JSONUtil.map2JSON(params));
|
|
|
+ LogUtil.i("login", "url=" + url);
|
|
|
+ LogUtil.i("login", "params=" + JSONUtil.map2JSON(params));
|
|
|
startNetThread(url, params, handler, Constants.SUCCESS_ERP, null, null, "post");
|
|
|
}
|
|
|
|