Просмотр исходного кода

合并分支,还没有运行过

Bitliker 8 лет назад
Родитель
Сommit
2a3bf3af11

+ 4 - 4
WeiChat/build.gradle

@@ -60,12 +60,12 @@ android {
     }
  
     productFlavors {   // 友盟多渠道打包
-        wandoujia {}
+//        wandoujia {}
 //        _360 {}
         baidu {}
-        xiaomi {}
-        tencent {}
-        taobao {}
+//        xiaomi {}
+//        tencent {}
+//        taobao {}
     }
 
     productFlavors.all {

+ 4 - 15
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/fragment/WorksFragment.java

@@ -99,14 +99,10 @@ public class WorksFragment extends EasyFragment implements View.OnClickListener
         goods_find.setOnClickListener(this);
         mDataInquiryRl.setOnClickListener(this);
         mReportStatisticsRl.setOnClickListener(this);
-//
-//        if (CommonUtil.isReleaseVersion()) {
-//            mDataInquiryRl.setVisibility(View.GONE);
-//            mReportStatisticsRl.setVisibility(View.GONE);
-//        } else {
+
         mDataInquiryRl.setVisibility(View.VISIBLE);
         mReportStatisticsRl.setVisibility(View.VISIBLE);
-//        }
+
 
         if (CommonUtil.getSharedPreferencesBoolean(MyApplication.getInstance(), Constants.new_oa)) {
             tv_menu_oa.setVisibility(View.GONE);
@@ -124,20 +120,13 @@ public class WorksFragment extends EasyFragment implements View.OnClickListener
         }
         setDataInquiryRed(!RedSpUtil.api().getDataInquiry());
         setReportStatisRed(!RedSpUtil.api().getReportStatis());
-        UserRoleUtils.checkUserRole(this, getmRootView());
+       
     }
 
     @Override
     public void onResume() {
         super.onResume();
-        //判断是否启用功能模块
-        //  isStartNewApp(Constants.HTTP_SUCCESS_INIT);
-//        int new_function_notice = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.NEW_FUNCTION_NOTICE);
-//        if (new_function_notice == 1) {
-//            show_new_function_ll.setVisibility(View.INVISIBLE);
-//        } else {
-//            show_new_function_ll.setVisibility(View.VISIBLE);
-//        }
+        UserRoleUtils.checkUserRole(this, getmRootView());
     }
 
     @Override

+ 48 - 29
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/me/MeFragment.java

@@ -30,6 +30,8 @@ import com.common.system.PermissionUtil;
 import com.core.api.wxapi.ApiPlatform;
 import com.core.api.wxapi.ApiUAS;
 import com.core.api.wxapi.ApiUtils;
+import com.core.app.AppConfig;
+import com.core.app.AppConstant;
 import com.core.app.AppConstant;
 import com.core.app.Constants;
 import com.core.app.MyApplication;
@@ -176,6 +178,7 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
                     Map<String, Object> results = FlexJsonUtil.fromJson(msg
                             .getData().getString("result"));
                     if ((Boolean) results.get("success")) {
+                        
                         ViewUtil.ToastMessage(ct, "账套切换成功!", Style.holoGreenLight, 3000);
                         String sessionId = results.get("sessionId").toString();
                         String master = msg.getData().getString("master");
@@ -221,6 +224,24 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
         if (mNickNameTv != null) {
             mNickNameTv.setText(MyApplication.getInstance().mLoginUser.getNickName());
         }
+        platform = ApiUtils.getApiModel() instanceof ApiPlatform;
+        if (ApiUtils.getApiModel() instanceof ApiUAS) {
+            LogUtil.d(TAG,"uas 模式!");
+            //getChinaMaster();
+            company_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_commpany"));
+            // 这样写的目的,是为了初始化本页面的时候,时时根据英文名字来查询当前的中文账套
+            if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(ct, "Master_ch"))) {
+                master_tv.setText(CommonUtil.getSharedPreferences(ct, "Master_ch"));
+            }else{
+                master_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_master"));
+            }
+            rl_master_change.setVisibility(View.VISIBLE);
+        } else {
+            LogUtil.d(TAG,"b2b 模式!");
+            company_tv.setText(CommonUtil.getSharedPreferences(ct, "companyName"));
+            master_tv.setText(CommonUtil.getSharedPreferences(ct, "spaceId"));
+            rl_master_change.setVisibility(View.GONE);
+        }
     }
 
     @Override
@@ -243,47 +264,39 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
         }
     }
 
-    private String getImageUrl(int id) {
-        return CommonUtil.getAppBaseUrl(ct) + "common/downloadbyId.action?id=" + id + "&sessionId=" +
-                CommonUtil.getSharedPreferences(ct, "sessionId") +
-                "&sessionUser=" + CommonUtil.getSharedPreferences(ct, "erp_username") +
-                "&master=" + CommonUtil.getSharedPreferences(ct, "erp_master");
-    }
-
+//    private String getImageUrl(int id) {
+//        return CommonUtil.getAppBaseUrl(ct) + "common/downloadbyId.action?id=" + id + "&sessionId=" +
+//                CommonUtil.getSharedPreferences(ct, "sessionId") +
+//                "&sessionUser=" + CommonUtil.getSharedPreferences(ct, "erp_username") +
+//                "&master=" + CommonUtil.getSharedPreferences(ct, "erp_master");
+//    }
+    private static final String TAG = "MeFragment";
     private void initView() {
+        LogUtil.d(TAG,"initView()");
         ct = getActivity();
         findViewById(R.id.my_data_rl).setOnClickListener(this);
         findViewById(R.id.my_friend_rl).setOnClickListener(this);
         findViewById(R.id.my_space_rl).setOnClickListener(this);
         findViewById(R.id.local_video_rl).setOnClickListener(this);
         findViewById(R.id.setting_rl).setOnClickListener(this);
-
-        rl_company_change.setOnClickListener(this);
-        rl_master_change.setOnClickListener(this);
         rl_info.setOnClickListener(this);
         rl_scan_code.setOnClickListener(this);
         app_drafts_rl.setOnClickListener(this);
         app_friend_rl.setOnClickListener(this);
-
+        rl_company_change.setOnClickListener(this);
+        rl_master_change.setOnClickListener(this);
         mAvatarImg = (ImageView) findViewById(R.id.avatar_img);
         mNickNameTv = (TextView) findViewById(R.id.nick_name_tv);
         mPhoneNumTv = (TextView) findViewById(R.id.phone_number_tv);
-
-        //init data
-        if (ApiUtils.getApiModel() instanceof ApiUAS) {
-            company_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_commpany"));
-            master_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_master"));
-            rl_master_change.setVisibility(View.VISIBLE);
-        } else {
-            company_tv.setText(CommonUtil.getSharedPreferences(ct, "companyName"));
-            master_tv.setText(CommonUtil.getSharedPreferences(ct, "spaceId"));
-            rl_master_change.setVisibility(View.GONE);
-        }
+         
+        
+   
 
 
         IntentFilter loginFilter = new IntentFilter();
         loginFilter.addAction("com.app.home.update");
         LocalBroadcastManager.getInstance(ct).registerReceiver(updateLoginState, loginFilter);
+        
         String loginUserId = MyApplication.getInstance().mLoginUser.getUserId();
         AvatarHelper.getInstance().display(loginUserId, mAvatarImg, true, true);
         mNickNameTv.setText(MyApplication.getInstance().mLoginUser.getNickName());
@@ -300,11 +313,7 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
             }
         });
 
-        // 这样写的目的,是为了初始化本页面的时候,时时根据英文名字来查询当前的中文账套
-        if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(ct,
-                "Master_ch"))) {
-            master_tv.setText(CommonUtil.getSharedPreferences(ct, "Master_ch"));
-        }
+       
         getChinaMaster();
         updateStatus();
 
@@ -321,7 +330,7 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
 //        iv_desc_oa.setVisibility(seting ? View.GONE : View.VISIBLE);
         CommonUtil.clearSharedPreferences(ct, "seting");
         CommonUtil.clearSharedPreferences(ct, "seting_1");
-        doHITask(); // TODO 测试按钮
+       // doHITask(); // TODO 测试按钮
 
         UserRoleUtils.checkUserRole(this, getmRootView());
     }
@@ -612,12 +621,22 @@ public class MeFragment extends EasyFragment implements View.OnClickListener {
     private BroadcastReceiver updateLoginState = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
             if (intent.getAction().equals("com.app.home.update")) {
-                String falg = intent.getStringExtra("falg");  // 过滤ERP登录成功//过滤falg
+                String falg = intent.getStringExtra("falg");
+                platform = ApiUtils.getApiModel() instanceof ApiPlatform;
+                LogUtil.d(TAG,"falg="+falg);
                 if (!"home".equals(falg)) {
                     updateStatus();
                 }
                 if ("ERP".equals(falg)) {
                     getChinaMaster();
+                    company_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_commpany"));
+                    master_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_master"));
+                    rl_master_change.setVisibility(View.VISIBLE);
+                }
+                if ("B2B".equals(falg)){
+                    company_tv.setText(CommonUtil.getSharedPreferences(ct, "companyName"));
+                    master_tv.setText(CommonUtil.getSharedPreferences(ct, "spaceId"));
+                    rl_master_change.setVisibility(View.GONE);
                 }
             }
         }

+ 2 - 7
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/message/MessageFragment.java

@@ -122,16 +122,11 @@ public class MessageFragment extends EasyFragment implements IMessageView, View.
 	@Override
 	public void onResume() {
 		super.onResume();
-		initHeader();
+		initHeaderView();
 		presenter.loadData();
 	}
 
-	private void initHeader() {
-		if (headAdapter == null) {
-			headAdapter = new HeadAdapter(presenter.getHeaderModels());
-			headerLV.setAdapter(headAdapter);
-		}
-	}
+ 
 
 	private void initEvent() {
 		message_net_set.setOnClickListener(this);

+ 28 - 2
WeiChat/src/main/java/com/xzjmyk/pm/activity/util/im/UserRoleUtils.java

@@ -48,10 +48,36 @@ public class UserRoleUtils {
                     }
                 }
                 if (userRole.equals("2")){//uas用户
-    
+                    if (fragment instanceof MessageFragment){
+                        view.findViewById(R.id.schedule_rl).setVisibility(View.VISIBLE);//审批流
+                        view.findViewById(R.id.waitting_work_rl).setVisibility(View.VISIBLE);//待办工作
+                        view.findViewById(R.id.subscribe_rl).setVisibility(View.VISIBLE);//我的订阅
+                    }
+                    if (fragment instanceof WorksFragment){
+                        view.findViewById(R.id.rl_uas_sys).setVisibility(View.VISIBLE);
+                        view.findViewById(R.id.my_client_rl).setVisibility(View.VISIBLE);
+                        view.findViewById(R.id.setting_rl).setVisibility(View.VISIBLE);
+                    }
+                    if (fragment instanceof MeFragment){
+                        view.findViewById(R.id.rl_company_change).setVisibility(View.VISIBLE);
+                        view.findViewById(R.id.rl_master_change).setVisibility(View.VISIBLE);
+                    }
+                    if (fragment instanceof SettingActivity){
+                        view.findViewById(R.id.sign_in_rl).setVisibility(View.VISIBLE);
+                        view.findViewById(R.id.sign_out_rl).setVisibility(View.VISIBLE);
+                    }
                 }
                 if(userRole.equals("3")){//平台用户
-    
+                    if (fragment instanceof MessageFragment){
+                        view.findViewById(R.id.schedule_rl).setVisibility(View.GONE);//审批流
+                        view.findViewById(R.id.waitting_work_rl).setVisibility(View.GONE);//待办工作
+                        view.findViewById(R.id.subscribe_rl).setVisibility(View.GONE);//我的订阅
+                    }
+                    if (fragment instanceof WorksFragment){
+                        view.findViewById(R.id.rl_uas_sys).setVisibility(View.GONE);
+                        view.findViewById(R.id.my_client_rl).setVisibility(View.GONE);
+                        view.findViewById(R.id.setting_rl).setVisibility(View.GONE);
+                    }
                 }
             }else{
     

+ 2 - 2
app_core/common/src/main/java/com/core/api/wxapi/ApiPlatform.java

@@ -2,7 +2,7 @@ package com.core.api.wxapi;
 
 import android.util.Log;
 
-import com.core.utils.CommonUtil;
+import com.common.config.BaseConfig;
 
 
 /**
@@ -16,7 +16,7 @@ public class ApiPlatform extends ApiBase implements ApiModel {
     private String mBaseUrl = "";
 
     public ApiPlatform() {
-        if (CommonUtil.isReleaseVersion()) {
+        if (BaseConfig.isDebug()) {
             mBaseUrl = "http://uas.ubtob.com/";
             super.login = "https://uas.ubtob.com/sso/login";
         } else {

+ 0 - 1
app_core/common/src/main/java/com/core/api/wxapi/ApiUtils.java

@@ -16,7 +16,6 @@ public class ApiUtils {
       */
     public static ApiModel getApiModel(){
         Context ct=MyApplication.getInstance().getApplicationContext();
-//        Boolean b2bLogin=   CommonUtil.getSharedPreferencesBoolean(ct,"b2b_login");
         Boolean erpLogin= CommonUtil.getSharedPreferencesBoolean(ct, "erp_login");
         if(erpLogin){
             return new ApiUAS();

+ 115 - 108
app_core/common/src/main/java/com/core/model/LoginEntity.java

@@ -5,113 +5,120 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class LoginEntity {
+    //uas
+    private String account;
+    private String platform;
+    private String master;
+    private Integer enuu;
+    private String website;
+    private String name;
+    private Integer masterId;
+    //b2b
+    private Integer spaceId;
+    private List<Spaces> spaces = new ArrayList<>();
 	
-	private String account;
-	private String platform;
-	private String master;
-	private Integer enuu;
-	private String website;
-	private String name;
-	private Integer masterId;
-	
-	private List<Spaces> spaces=new ArrayList<>();
-	
-	/**
-	  * @desc:b2b
-	  * @author:Arison on 2017/3/6
-	  */
-	public class Spaces{
-		private Integer id;
-		private String enuu;
-		private String name;
-
-		public String getEnuu() {
-			return enuu;
-		}
-
-		public void setEnuu(String enuu) {
-			this.enuu = enuu;
-		}
-
-		public String getName() {
-			return name;
-		}
-
-		public void setName(String name) {
-			this.name = name;
-		}
-
-		public Integer getId() {
-			return id;
-		}
-
-		public void setId(Integer id) {
-			this.id = id;
-		}
-	}
-
-	public Integer getMasterId() {
-		return masterId;
-	}
-
-	public void setMasterId(Integer masterId) {
-		this.masterId = masterId;
-	}
-
-	public String getAccount() {
-		return account;
-	}
-
-	public void setAccount(String account) {
-		this.account = account;
-	}
-
-	public String getPlatform() {
-		return platform;
-	}
-
-	public void setPlatform(String platform) {
-		this.platform = platform;
-	}
-
-	public String getMaster() {
-		return master;
-	}
-
-	public void setMaster(String master) {
-		this.master = master;
-	}
-
-	public String getWebsite() {
-		return website;
-	}
-
-	public void setWebsite(String website) {
-		this.website = website;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public Integer getEnuu() {
-		return enuu;
-	}
-
-	public void setEnuu(Integer enuu) {
-		this.enuu = enuu;
-	}
-
-
-	public List<Spaces> getSpaces() {
-		return spaces;
-	}
-
-	public void setSpaces(List<Spaces> spaces) {
-		this.spaces = spaces;
-	}
+    public class Spaces {
+        private Integer id;
+        private String enuu;
+        private String name;
+
+        public String getEnuu() {
+            return enuu;
+        }
+
+        public void setEnuu(String enuu) {
+            this.enuu = enuu;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public Integer getId() {
+            return id;
+        }
+
+        public void setId(Integer id) {
+            this.id = id;
+        }
+    }
+
+    public Integer getMasterId() {
+        return masterId;
+    }
+
+    public void setMasterId(Integer masterId) {
+        this.masterId = masterId;
+    }
+
+    public String getAccount() {
+        return account;
+    }
+
+    public void setAccount(String account) {
+        this.account = account;
+    }
+
+    public String getPlatform() {
+        return platform;
+    }
+
+    public void setPlatform(String platform) {
+        this.platform = platform;
+    }
+
+    public String getMaster() {
+        return master;
+    }
+
+    public void setMaster(String master) {
+        this.master = master;
+    }
+
+    public String getWebsite() {
+        return website;
+    }
+
+    public void setWebsite(String website) {
+        this.website = website;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Integer enuu) {
+        this.enuu = enuu;
+    }
+
+
+    public List<Spaces> getSpaces() {
+        return spaces;
+    }
+
+    public void setSpaces(List<Spaces> spaces) {
+        this.spaces = spaces;
+    }
+
+    public Integer getSpaceId() {
+        return spaceId;
+    }
+
+    public void setSpaceId(Integer spaceId) {
+        this.spaceId = spaceId;
+    }
+
+
 }

+ 123 - 40
app_core/common/src/main/java/com/core/net/http/ViewUtil.java

@@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.common.LogUtil;
+import com.common.config.BaseConfig;
 import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
 import com.common.data.StringUtil;
@@ -299,7 +300,7 @@ public class ViewUtil {
 //        }
 
     }
-
+      @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,16 @@ public class ViewUtil {
     // 登录B2B
     public static void LoginB2BTask(String phone, String password, Integer spaceId) {
         mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_progress_b2b));
-        String url = ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().login;
+        String url = ApiConfig.getInstance(new ApiPlatform()).getmApiBase().login;
+        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 (CommonUtil.isReleaseVersion()) {
+        if (BaseConfig.isDebug()) {
             params.put("spaceId", String.valueOf(spaceId));
-            Log.i("fang,url", String.valueOf(spaceId) + url + "");
         } else {
             params.put("spaceId", "76035");
-            Log.i("fang,url", "76035," + url);
         }
         startNetThread(url, params, handler, Constants.SUCCESS_B2B, null, null, "post");
     }
@@ -394,8 +394,6 @@ public class ViewUtil {
                     if (JSONUtil.validate(msg.getData().getString("result"))) {
                         ToastMessage(MyApplication.getInstance(),
                                 JSON.parseObject(msg.getData().getString("result")).getString("exception"), Style.holoRedLight, 3000);
-//                        ToastMessage(MyApplication.getInstance(),"账号或密码错误,请重新输入");
-
                     } else {
                         boolean isNetHas = NetUtils.isNetWorkConnected(ct);
                         if (isNetHas)
@@ -480,7 +478,8 @@ public class ViewUtil {
             CommonUtil.setSharedPreferences(ct, "user_password", erp_password);
         }
         if (ct == null) ct = MyApplication.getInstance();
-        CommonUtil.setSharedPreferences(ct, "b2b_login", true);
+      
+        CommonUtil.setSharedPreferences(ct, "erp_login", false);
         CommonUtil.setSharedPreferences(ct, "b2b_uu", b2b_uu);
         mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_success_b2b));
         handler.postDelayed(new Runnable() {
@@ -489,14 +488,14 @@ public class ViewUtil {
                 mdProcessDialog.cancel();
             }
         }, 1500);
-        if (!hasErp) {
             if (ct instanceof Activity) {
-//                if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_baseurl"))){
-//                }else{
-                ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
-//                }
-            }
+                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,38 +581,102 @@ 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);
         }
     }
 
-    //TODO 针对于平台的测试、正式数据库不一致
-    private static String getNameByB2b(String userName, String phone) {
-        if (StringUtil.isEmpty(phone)) return userName;
-        LogUtil.d("phone=" + phone);
-        if (phone.equals("13111110001")) {
-            return "吕全明";
-        } else if (phone.equals("13111110002")) {
-            return "曹秋莲";
-        } else if (phone.equals("13111110003")) {
-            return "陈爱平";
-        } else if (phone.equals("13111110004")) {
-            return "CS008";
-        } else if (phone.equals("13111110005")) {
-            return "CS009";
-        } else if (phone.equals("15012345676")) {
-            return "品质";
-        } else if (phone.equals("15012345678")) {
-            return "邓国超移动";
+   
+
+    //解析登录信息
+    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<>();
+        if (!ListUtils.isEmpty(loginMsg)){
+            for (int i = 0; i <loginMsg.size() ; i++) {
+                LoginEntity model = loginMsg.get(i);
+                if (model.getPlatform().equals("ERP")) {
+                    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++) {
+                            //去重逻辑
+                            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();
+                                bModel.setEnuu(Integer.valueOf(sModel.get(j).getEnuu()));
+                                bModel.setName(sModel.get(j).getName());
+                                bModel.setSpaceId(sModel.get(j).getId());
+                                bModel.setPlatform("B2B");
+                                loginEntities.add(bModel);
+                            }
+                        }
+                    }
+                }
+            }
+            //
+            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) {
+                    select = loginERPDialog.getSelectedIndex();
+                }
+                loginERPDialog = new MaterialDialog.Builder(ct)
+                        .title(ct.getString(R.string.user_dialog_company))
+                        .items(items)
+                        .itemsCallbackSingleChoice(select,
+                                new MaterialDialog.ListCallbackSingleChoice() {
+                                    @Override
+                                    public boolean onSelection(MaterialDialog dialog,
+                                                               View view, int which, CharSequence text) {
+                                        if (!StringUtil.isEmpty(text.toString())) {
+                                            LoginEntity entity = erpEntities.get(which);
+                                            if ("ERP".equals(entity.getPlatform())){
+                                                erp_phone = phone;
+                                                erp_password = password;
+                                                erp_username = entity.getAccount();
+                                                erp_master = entity.getMaster();
+                                                erp_baseurl = entity.getWebsite();
+                                                erp_company = entity.getName();
+                                                erp_uu = String.valueOf(entity.getEnuu());
+                                                erp_masterId = String.valueOf(entity.getMasterId());
+                                                CommonUtil.setSharedPreferences(MyApplication.getInstance(), "userRole", "2");
+                                                LoginERPTask(entity.getWebsite(), entity.getMaster(), phone, password);
+                                                CommonUtil.clearSharedPreferences(MyApplication.getInstance(), "erp_masterlist");  //清除账套列表缓存
+                                            }
+                                            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()));
+                                                CommonUtil.setSharedPreferences(MyApplication.getInstance(), "userRole", "3");
+                                                LoginB2BTask(phone, password, entity.getSpaceId());//登录B2B
+                                            }
+                                        }
+                                        return true;
+                                    }
+                                }).positiveText(ct.getString(R.string.common_sure)).show();
+                
+            }
         }
-        return userName;
     }
-
-    /**
-     * @desc:解析登录数据
-     * @author:Arison on 2017/3/6
-     */
+    
+    
+    @Deprecated
     private static void showDialogCompany(String json, String phone, String password) {
         List<LoginEntity> logMsg = JSON.parseArray(json, LoginEntity.class);
         erpEntities = new ArrayList<>();
@@ -685,7 +748,27 @@ public class ViewUtil {
 
     ;
 
-
+    //TODO 针对于平台的测试、正式数据库不一致
+    private static String getNameByB2b(String userName, String phone) {
+        if (StringUtil.isEmpty(phone)) return userName;
+        LogUtil.d("phone=" + phone);
+        if (phone.equals("13111110001")) {
+            return "吕全明";
+        } else if (phone.equals("13111110002")) {
+            return "曹秋莲";
+        } else if (phone.equals("13111110003")) {
+            return "陈爱平";
+        } else if (phone.equals("13111110004")) {
+            return "CS008";
+        } else if (phone.equals("13111110005")) {
+            return "CS009";
+        } else if (phone.equals("15012345676")) {
+            return "品质";
+        } else if (phone.equals("15012345678")) {
+            return "邓国超移动";
+        }
+        return userName;
+    }
     /**
      * @author LiuJie
      * @功能:比较两个日期大小

+ 1 - 1
app_core/common/src/main/java/com/core/utils/CommonUtil.java

@@ -462,7 +462,7 @@ public class CommonUtil {
 
     public static String getUserRole() {
         String userRole = getSharedPreferences(MyApplication.getInstance(), "userRole");
-        return userRole == null ? "" : userRole;
+        return userRole == null ? "2" : userRole;
     }
 
 

+ 8 - 8
app_modular/appbooking/src/main/java/com/modular/booking/activity/services/BServiceAddActivity.java

@@ -35,7 +35,6 @@ import com.me.network.app.http.rx.ResultListener;
 import com.me.network.app.http.rx.ResultSubscriber;
 import com.modular.booking.R;
 import com.modular.booking.model.SBListModel;
-import com.modular.booking.model.TestString;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -486,9 +485,9 @@ public class BServiceAddActivity extends OABaseActivity implements View.OnClickL
                     JSONArray array = getJSONArray(o.toString(), "result");
                     SelectBean bean = null;
                     ArrayList<SelectBean> selectBeens = new ArrayList<SelectBean>();
-                    if (ListUtils.isEmpty(array)) {
-                        array = JSONUtil.getJSONArray(TestString.STORE_SERVICE, "result");
-                    }
+//                    if (ListUtils.isEmpty(array)) {
+//                        array = JSONUtil.getJSONArray(TestString.STORE_SERVICE, "result");
+//                    }
                     if (!ListUtils.isEmpty(array)) {
                         for (int i = 0; i < array.size(); i++) {
                             JSONObject object = array.getJSONObject(i);
@@ -537,9 +536,9 @@ public class BServiceAddActivity extends OABaseActivity implements View.OnClickL
                     SelectBean bean = null;
                     ArrayList<SelectBean> selectBeens = new ArrayList<SelectBean>();
                     //TODO 测试数据
-                    if (ListUtils.isEmpty(array)) {
-                        array = JSONUtil.getJSONArray(TestString.STORE_SERVICE, "result");
-                    }
+//                    if (ListUtils.isEmpty(array)) {
+//                        array = JSONUtil.getJSONArray(TestString.STORE_SERVICE, "result");
+//                    }
                     if (!ListUtils.isEmpty(array)) {
                         for (int i = 0; i < array.size(); i++) {
                             JSONObject object = array.getJSONObject(i);
@@ -586,7 +585,8 @@ public class BServiceAddActivity extends OABaseActivity implements View.OnClickL
             progressDialog.dismiss();
             return;
         } else {
-            LogUtil.i("map=" + JSONUtil.map2JSON(map));
+            LogUtil.i("map=1" + JSONUtil.map2JSON(map));
+            LogUtil.i("map=2" + JSON.toJSONString(map));
 //			if (1 == 1) {
 //				submiting = false;
 //				progressDialog.dismiss();