| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.hdl.photovoltaic.bean.LoginBean; |
| | | import com.hdl.photovoltaic.bean.LoginUserRegionBean; |
| | | import com.hdl.photovoltaic.bean.ResponsePack; |
| | | import com.hdl.photovoltaic.config.ConfigManagement; |
| | | import com.hdl.photovoltaic.ui.bean.LoginBean; |
| | | import com.hdl.photovoltaic.ui.bean.LoginUserRegionBean; |
| | | import com.hdl.photovoltaic.bean.HttpResponsePack; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.internet.HttpClient; |
| | | import com.hdl.photovoltaic.internet.api.HttpApi; |
| | | import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak; |
| | |
| | | |
| | | |
| | | /** |
| | | * 初始化账号的Url区域地址(可能状态码:Success NotAccount NotNetWork) |
| | | * 初始化账号的Url区域地址 |
| | | * |
| | | * @param i_account 账号 |
| | | */ |
| | | public void regionByAccount(String i_account, CloudCallBeak<LoginUserRegionBean> cloudCallBeak) { |
| | | JsonObject jsonObject = new JsonObject(); |
| | | jsonObject.addProperty("account", i_account); |
| | | String full = ConfigManagement.getAPPRegionUrl() + HttpApi.POST_RegionByUserAccount; |
| | | String full = AppConfigManage.getAPPRegionUrl() + HttpApi.POST_RegionByUserAccount; |
| | | HttpClient.getInstance().requestFullHttp(full, jsonObject.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(ResponsePack responsePack) { |
| | | if (responsePack.getData() != null) { |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | if (httpResponsePack.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String json = gson.toJson(responsePack.getData()); |
| | | String json = gson.toJson(httpResponsePack.getData()); |
| | | LoginUserRegionBean loginUserRegionBean = new Gson().fromJson(json, LoginUserRegionBean.class); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(loginUserRegionBean); |
| | |
| | | |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(ResponsePack responsePack) { |
| | | if (responsePack.getData() != null) { |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | if (httpResponsePack.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String json = gson.toJson(responsePack.getData()); |
| | | String json = gson.toJson(httpResponsePack.getData()); |
| | | LoginBean loginBean = new Gson().fromJson(json, LoginBean.class); |
| | | saveUserData(loginBean); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(loginBean); |
| | | } else { |
| | |
| | | return mailbox.matches(regex); |
| | | } |
| | | |
| | | /** |
| | | * 登录成功保存 |
| | | */ |
| | | private void saveUserData(LoginBean obj) { |
| | | if (obj != null) { |
| | | UserConfigManage.getInstance().setLogin(true); |
| | | UserConfigManage.getInstance().setAcceiptPolicy(true); |
| | | UserConfigManage.getInstance().setLoginDateTime(System.currentTimeMillis()); |
| | | UserConfigManage.getInstance().setUserId(obj.getUserId()); |
| | | UserConfigManage.getInstance().setAccount(obj.getAccount()); |
| | | UserConfigManage.getInstance().setToken(obj.getAccessToken()); |
| | | UserConfigManage.getInstance().setHeaderPrefix(obj.getHeaderPrefix()); |
| | | UserConfigManage.getInstance().setRefreshToken(obj.getRefreshToken()); |
| | | boolean isUserId = UserConfigManage.getInstance().getUserId().equals(obj.getUserId()); |
| | | UserConfigManage.getInstance().setTheSameLoginAccount(isUserId); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |