| | |
| | | jsonObject.addProperty("user_name", UserConfigManage.getInstance().getUserName()); |
| | | jsonObject.addProperty("user_image_url", UserConfigManage.getInstance().getUserImageUrl()); |
| | | jsonObject.addProperty("user_account", UserConfigManage.getInstance().getAccount()); |
| | | |
| | | jsonObject.addProperty("appLanguage", UserConfigManage.getInstance().getCurrentAppLanguage()); |
| | | jsonObject.addProperty("token", HDLLinkPMUser.getInstance().getAccessToken()); |
| | | jsonObject.addProperty("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken()); |
| | | if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) { |
| | |
| | | } |
| | | } |
| | | break; |
| | | //uni获取图片 |
| | | case HDLUniMP.UNI_EVENT_REPLY_OTHER_GET_SELECTED_IMAGE: { |
| | | |
| | | } |
| | | break; |
| | | } |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_COMMON_MODEL.equals(topic)) { |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_UNI_SEND_TO_CLOUD.equals(topic)) { |
| | | //网络请求模块 |
| | | if (type.equals(HDLUniMP.UNI_EVENT_REPLY_UNI_SEND_TO_CLOUD)) { |
| | | String url = getKeyValue("url", getKeyValue("data", data)); |
| | | JsonObject jObject = new JsonObject(); |
| | | String body = getKeyValue("body", getKeyValue("data", data)); |
| | | if (!TextUtils.isEmpty(body)) { |
| | | try { |
| | | jObject = new Gson().fromJson(body, JsonObject.class); |
| | | } catch (Exception ignored) { |
| | | JsonObject jObject = new JsonObject(); |
| | | String body = getKeyValue("data", data); |
| | | if (!TextUtils.isEmpty(body)) { |
| | | try { |
| | | jObject = new Gson().fromJson(body, JsonObject.class); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | HttpClient.getInstance().requestHttp(type, jObject.toString(), new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String jsonStr) { |
| | | //本地缓存数据 |
| | | if (callback != null) { |
| | | try { |
| | | if (jsonStr.startsWith("{")) { |
| | | uniSuccessCallback(mode_type, new Gson().fromJson(jsonStr, JsonObject.class), callback); |
| | | } else if (jsonStr.startsWith("[")) { |
| | | uniSuccessCallback(mode_type, new Gson().fromJson(jsonStr, JsonArray.class), callback); |
| | | } else { |
| | | uniSuccessCallback(mode_type, jsonStr, callback); |
| | | } |
| | | } catch (Exception e) { |
| | | uniSuccessCallback(mode_type, jsonStr, callback); |
| | | } |
| | | } |
| | | } |
| | | HttpClient.getInstance().requestHttp(url, jObject.toString(), new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String jsonStr) { |
| | | uniSuccessCallback(mode_type, jsonStr, callback); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | uniExceptionCallback(mode_type, e, callback); |
| | | } |
| | | }); |
| | | } |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | uniExceptionCallback(mode_type, e, callback); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | |
| | | if (data == null) { |
| | | data = new JSONObject(); |
| | | } |
| | | if (isTokenAndRefreshToken) { |
| | | //小程序那里有自己的请求方法,但需要原生提供这些数据 |
| | | data.put("token", HDLLinkPMUser.getInstance().getAccessToken()); |
| | | data.put("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken()); |
| | | if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) { |
| | | AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl()); |
| | | } |
| | | data.put("serverAddress", AppConfigManage.getUserRegionUrl()); |
| | | data.put("appKey", AppConfigManage.getAppKey()); |
| | | data.put("appSecret", AppConfigManage.getAppSecret()); |
| | | } |
| | | // if (isTokenAndRefreshToken) { |
| | | // //小程序那里有自己的请求方法,但需要原生提供这些数据 |
| | | // data.put("token", HDLLinkPMUser.getInstance().getAccessToken()); |
| | | // data.put("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken()); |
| | | // if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) { |
| | | // AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl()); |
| | | // } |
| | | // data.put("serverAddress", AppConfigManage.getUserRegionUrl()); |
| | | // data.put("appKey", AppConfigManage.getAppKey()); |
| | | // data.put("appSecret", AppConfigManage.getAppSecret()); |
| | | // } |
| | | data.put("appLanguage", UserConfigManage.getInstance().getCurrentAppLanguage()); |
| | | uniCallBackBaseBean.setData(data); |
| | | return getJSONObject(uniCallBackBaseBean); |
| | | } catch (Exception e) { |