| | |
| | | import com.doumee.keyCabinet.http.param.DevLoginParam; |
| | | import com.doumee.lib_coremodel.base.BaseModel; |
| | | import com.doumee.lib_coremodel.base.DataViewModel; |
| | | import com.doumee.lib_coremodel.http.rxJava.SimpleObserver; |
| | | import com.doumee.lib_coremodel.http.utils.RxUtils; |
| | | import com.doumee.keyCabinet.MApplication; |
| | | import com.doumee.keyCabinet.R; |
| | | import com.doumee.keyCabinet.bean.ConfigBean; |
| | | import com.doumee.keyCabinet.bean.DevConfigBean; |
| | | import com.doumee.keyCabinet.http.Apis; |
| | | import com.doumee.keyCabinet.http.param.BaseResponse; |
| | |
| | | doAction(1); |
| | | } |
| | | public void devLogin(){ |
| | | if (true) { |
| | | return; |
| | | } |
| | | if(isReq){ |
| | | return; |
| | | } |
| | | isReq = true; |
| | | //清除登录信息 |
| | | MApplication.setCookie(""); |
| | | MApplication.saveConfigBean(new ConfigBean()); |
| | | RequestBaseObject<DevLoginParam> request = new RequestBaseObject<>(); |
| | | DevLoginParam param = new DevLoginParam(); |
| | | param.setDevCode(LMobileInfo.getDeviceUniqueId()); |
| | | request.setParam(param); |
| | | getRetrofitService(Apis.class).devLogin(0, |
| | | ParamsUtil.encodeRequestBody(request)) |
| | | .compose(RxUtils.schedulersTransformer()) |
| | | .subscribe(new SimpleObserver<Response<BaseResponse<DevConfigBean>>>(rxJavaGcManager) { |
| | | @Override |
| | | public void onNext(@NonNull Response<BaseResponse<DevConfigBean>> base) { |
| | | Headers headers = base.headers();//我们通过Response的headers对象获取到响应头信息。 |
| | | List<String> values = headers.values("Set-Cookie");//通过“Set-Cookie”字段获取到服务器返回的Cookie信息 |
| | | if(values!=null&&values.size()>0){ |
| | | MApplication.setCookie(values.get(0)); |
| | | } |
| | | BaseResponse<DevConfigBean> response = base.body(); |
| | | if(response==null){ |
| | | toast(MApplication.mContext.getString(R.string.guide_toast_1)); |
| | | doAction(1); |
| | | return; |
| | | } |
| | | if("000000".equals(response.getErrorCode())){ |
| | | if(response.getRecord()!=null){ |
| | | if("0".equals(response.getRecord().getStatus())){ |
| | | jyVisibility.set(View.VISIBLE); |
| | | doAction(1); |
| | | return; |
| | | }else { |
| | | jyVisibility.set(View.GONE); |
| | | } |
| | | devLD.setValue(response.getRecord()); |
| | | }else { |
| | | toast(MApplication.mContext.getString(R.string.guide_toast_1)); |
| | | doAction(1); |
| | | } |
| | | }else if("33010101".equals(response.getErrorCode())) { |
| | | doAction(1); |
| | | toast(MApplication.mContext.getString(R.string.guide_toast_2)+ |
| | | MApplication.mContext.getString(R.string.symbol_colon)+param.getDevCode()); |
| | | }else { |
| | | toast(response.getErrorMsg()); |
| | | doAction(1); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(@NonNull Throwable e) { |
| | | toast(e.getMessage()); |
| | | doAction(1); |
| | | } |
| | | |
| | | @Override |
| | | public void onComplete() { |
| | | isReq = false; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public MutableLiveData<DevConfigBean> getDevLD() { |