From 3bc8d709e19d7ed0f26cb5af3aa82091e26bd9b5 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 18 十月 2024 13:55:35 +0800
Subject: [PATCH] 修复Token未失效提到登录界面问题
---
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index 98aa56d..80fb4b7 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -46,6 +46,7 @@
import com.hdl.photovoltaic.ui.bean.BUserInfo;
import com.hdl.photovoltaic.ui.bean.CUserInfo;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
+import com.hdl.photovoltaic.ui.bean.DeviceInfoBean;
import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
import com.hdl.photovoltaic.ui.bean.Geolocation;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
@@ -165,6 +166,16 @@
jsonObject.addProperty("user_name", UserConfigManage.getInstance().getUserName());
jsonObject.addProperty("user_image_url", UserConfigManage.getInstance().getUserImageUrl());
jsonObject.addProperty("user_account", UserConfigManage.getInstance().getAccount());
+
+ jsonObject.addProperty("token", HDLLinkPMUser.getInstance().getAccessToken());
+ jsonObject.addProperty("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken());
+ if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) {
+ AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl());
+ }
+ jsonObject.addProperty("serverAddress", AppConfigManage.getUserRegionUrl());
+ jsonObject.addProperty("appKey", AppConfigManage.getAppKey());
+ jsonObject.addProperty("appSecret", AppConfigManage.getAppSecret());
+
uniSuccessCallback(mode_type, jsonObject, callback);
}
@@ -362,6 +373,11 @@
//蹇嵎寮�鍚�嗗彉鍣�
case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OPEN_DEVICE_LIST: {
this.uniSetDeviceStartup(mode_type, data, callback);
+ }
+ break;
+ //鑾峰彇璁惧璇︽儏
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OPEN_DEVICE_info: {
+ this.uniGetDeviceInfo(mode_type, data, callback);
}
break;
}
@@ -2475,10 +2491,35 @@
public void uniSetDeviceStartup(String type, Object data, DCUniMPJSCallback callback) {
String homeId = getKeyValue("homeId", getKeyValue("data", data));
String aryJson = getKeyValue("deviceIds", getKeyValue("data", data));
- HdlDeviceLogic.getInstance().setDeviceStartup(homeId, aryJson, new CloudCallBeak<Boolean>() {
+ JsonArray jsonArray = new Gson().fromJson(aryJson, JsonArray.class);
+ HdlDeviceLogic.getInstance().setDeviceStartup(homeId, jsonArray, new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean obj) {
uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
+ /**
+ * 鑾峰彇璁惧璇︽儏
+ *
+ * @param type 绫诲瀷
+ * @param data uni璇锋眰鏁版嵁
+ * @param callback uni鍥炶皟
+ */
+ public void uniGetDeviceInfo(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String aryJson = getKeyValue("deviceIds", getKeyValue("data", data));
+ JsonArray jsonArray = new Gson().fromJson(aryJson, JsonArray.class);
+ HdlDeviceLogic.getInstance().getDeviceInfo(homeId, jsonArray, new CloudCallBeak<List<DeviceInfoBean>>() {
+ @Override
+ public void onSuccess(List<DeviceInfoBean> list) {
+ uniSuccessCallback(type, list, callback);
}
@Override
@@ -2560,8 +2601,8 @@
}
if (isTokenAndRefreshToken) {
//灏忕▼搴忛偅閲屾湁鑷繁鐨勮姹傛柟娉�,浣嗛渶瑕佸師鐢熸彁渚涜繖浜涙暟鎹�
- data.put("token", UserConfigManage.getInstance().getToken());
- data.put("refreshToken", UserConfigManage.getInstance().getRefreshToken());
+ data.put("token", HDLLinkPMUser.getInstance().getAccessToken());
+ data.put("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken());
if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) {
AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl());
}
--
Gitblit v1.8.0