From bec7858e5c5be9f93928483b21837b26666b6d1a Mon Sep 17 00:00:00 2001 From: SnowShow Date: Wed, 2 Apr 2025 17:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9json=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=8E=A5=E5=8F=A3=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=86=97=E4=BD=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/Config/SearhProjectDataConfig.cs | 0 .../Config/SearhProjectDataConfig.cs.meta | 2 + .../Core/System/CompanyDataConfigSystem.cs | 8 ++- .../AR Brochure/Utility/JsonHttpUtility.cs | 43 +++++++++++++++ .../Utility/JsonHttpUtility.cs.meta | 2 + .../AR Brochure/Utility/Old/HttpHandleTool.cs | 53 +------------------ 6 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs create mode 100644 EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs.meta create mode 100644 EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs create mode 100644 EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs.meta diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs new file mode 100644 index 00000000..e69de29b diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs.meta b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs.meta new file mode 100644 index 00000000..801d0f50 --- /dev/null +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Common/Data/Config/SearhProjectDataConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 33805700c367ede48908889e8492c787 \ No newline at end of file diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Core/System/CompanyDataConfigSystem.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Core/System/CompanyDataConfigSystem.cs index 2d1aa3df..898542ad 100644 --- a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Core/System/CompanyDataConfigSystem.cs +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Core/System/CompanyDataConfigSystem.cs @@ -17,7 +17,8 @@ namespace GameLogic { return projectData; } - var jsonData = await HttpHandleTool.UnityWebRequestPostJsonByUserCode(page, userCode); + string jsonParm = $"{{\"userCode\":\"{userCode}\"}}"; + var jsonData = await JsonHttpUtility.UnityWebRequestPostJsonByUserCode(page, jsonParm); var projectConfigRoot = JsonUtility.FromJson(jsonData); return GetProjectData(projectConfigRoot.data,userCode); @@ -29,12 +30,15 @@ namespace GameLogic { return projectData; } - var jsonData = await HttpHandleTool.UnityWebRequestPostJsonByUserCode(page, userCode); + string jsonParm = $"{{\"userCode\":\"{userCode}\"}}"; + var jsonData = await JsonHttpUtility.UnityWebRequestPostJsonByUserCode(page, jsonParm); var projectConfigRoot = JsonUtility.FromJson(jsonData); return GetProjectData(projectConfigRoot.data,userCode); } + + #region 场景数据 public ProjectData GetProjectData(string company = null) diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs new file mode 100644 index 00000000..52abae85 --- /dev/null +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs @@ -0,0 +1,43 @@ + +using System.Text; +using Cysharp.Threading.Tasks; +using UnityEngine; +using UnityEngine.Networking; + +namespace GameLogic +{ + public static class JsonHttpUtility + { + + + + public static async UniTask UnityWebRequestPostJsonByUserCode(string page, string data) + { + string url = $"https://www.arsnowslide.com/brounche/brochure/project/selAllProjectsOnWxByPage/{page}"; + using (UnityWebRequest request = new UnityWebRequest(url, "POST")) + { + // 手动构建 JSON 字符串 + string jsonData = data; + byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonData); + request.uploadHandler = new UploadHandlerRaw(bodyRaw); + request.downloadHandler = new DownloadHandlerBuffer(); + request.SetRequestHeader("Content-Type", "application/json"); + + await request.SendWebRequest().ToUniTask(); + + if (request.result == UnityWebRequest.Result.Success) + { + return request.downloadHandler.text; + } + else + { + Debug.LogError($"POST Request failed: {request.error}"); + return ""; + } + } + } + + + } + +} diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs.meta b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs.meta new file mode 100644 index 00000000..31c6d6cf --- /dev/null +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/JsonHttpUtility.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f5f8458a222147e44880cc6c73beccc5 \ No newline at end of file diff --git a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/Old/HttpHandleTool.cs b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/Old/HttpHandleTool.cs index 811936bf..b65acf7b 100644 --- a/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/Old/HttpHandleTool.cs +++ b/EintooAR/Assets/GameScripts/HotFix/GameLogic/AR Brochure/Utility/Old/HttpHandleTool.cs @@ -341,58 +341,7 @@ namespace GameLogic } } } - - - - public static async UniTask UnityWebRequestPostJsonByUserCode(string url, string userCode,string page= "") - { - using (UnityWebRequest request = new UnityWebRequest(url, "POST")) - { - // 手动构建 JSON 字符串 - string jsonData = $"{{\"userCode\":\"{userCode}\"}}"; - byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonData); - request.uploadHandler = new UploadHandlerRaw(bodyRaw); - request.downloadHandler = new DownloadHandlerBuffer(); - request.SetRequestHeader("Content-Type", "application/json"); - - await request.SendWebRequest().ToUniTask(); - - if (request.result == UnityWebRequest.Result.Success) - { - return request.downloadHandler.text; - } - else - { - Debug.LogError($"POST Request failed: {request.error}"); - return ""; - } - } - } - public static async UniTask UnityWebRequestPostJsonByUserCode(string page, string userCode) - { - string url = $"https://www.arsnowslide.com/brounche/brochure/project/selAllProjectsOnWxByPage/{page}"; - using (UnityWebRequest request = new UnityWebRequest(url, "POST")) - { - // 手动构建 JSON 字符串 - string jsonData = $"{{\"userCode\":\"{userCode}\"}}"; - byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonData); - request.uploadHandler = new UploadHandlerRaw(bodyRaw); - request.downloadHandler = new DownloadHandlerBuffer(); - request.SetRequestHeader("Content-Type", "application/json"); - - await request.SendWebRequest().ToUniTask(); - - if (request.result == UnityWebRequest.Result.Success) - { - return request.downloadHandler.text; - } - else - { - Debug.LogError($"POST Request failed: {request.error}"); - return ""; - } - } - } + #endregion }