wjc
2025-03-03 2225b1f0727fb74e10ac5692e68e4cd48f4f62d7
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -168,7 +168,7 @@
                        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())) {
@@ -724,19 +724,21 @@
                    break;
                    //本地json资源文件获取
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_GET_LOCAL_JSON: {
                        String url = getKeyValue("url", getKeyValue("data", data));
                        String deviceModel = getKeyValue("deviceModel", getKeyValue("data", data));
//                      String url = getKeyValue("url", getKeyValue("data", data));
                        String fileName = getKeyValue("fileName", getKeyValue("data", data));//唯一标识
                        String deviceType = getKeyValue("deviceType", getKeyValue("data", data));//设备类型
                        String deviceModel = getKeyValue("deviceModel", getKeyValue("data", data));//设备模型
                        String language = getKeyValue("language", getKeyValue("data", data));
                        String json = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(url, deviceModel);
                        String json = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(fileName + ".json", deviceModel);
                        if (TextUtils.isEmpty(json)) {
                            //本地没有缓存
                            HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(url, deviceModel, new CloudCallBeak<String>() {
                            HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(fileName, deviceType, deviceModel, new CloudCallBeak<String>() {
                                @Override
                                public void onSuccess(String obj) {
//                                    if (callback != null) {
//                                        uniSuccessCallback(type, obj, callback);
//                                    }
                                    String s = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(url, deviceModel);
                                    String s = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(fileName, deviceModel);
                                    //本地缓存数据
                                    if (callback != null) {
                                        try {
@@ -780,31 +782,47 @@
                        }
                    }
                    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) {
@@ -2832,17 +2850,18 @@
            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) {