From 57ac99fc81f694d7e4c9e2e2c67594899fbfec79 Mon Sep 17 00:00:00 2001 From: HuangZiBo <1278481331@qq.com> Date: Wed, 27 Nov 2024 15:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E7=B3=BB=E7=BB=9F8.*?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Scripts/AddressSystem8.meta | 8 +++ .../Scripts/AddressSystem8/AdressList83.cs | 56 ++++++++++++++++ .../AddressSystem8/AdressList83.cs.meta | 11 ++++ .../Scripts/AddressSystem8/areaInfo84.cs | 41 ++++++++++++ .../Scripts/AddressSystem8/areaInfo84.cs.meta | 11 ++++ .../Scripts/AddressSystem8/newAddress81.cs | 54 ++++++++++++++++ .../AddressSystem8/newAddress81.cs.meta | 11 ++++ .../Scripts/AddressSystem8/updateAddress82.cs | 55 ++++++++++++++++ .../AddressSystem8/updateAddress82.cs.meta | 11 ++++ .../Assets/Scripts/Login/Global.cs | 64 +++++++++++++++++++ 10 files changed, 322 insertions(+) create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8.meta create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs create mode 100644 TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs.meta diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8.meta b/TheStrongestSnail/Assets/Scripts/AddressSystem8.meta new file mode 100644 index 0000000..865bdc4 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7817750da9f5560439d1eb63ee627b12 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs b/TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs new file mode 100644 index 0000000..73c736b --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs @@ -0,0 +1,56 @@ +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +public class AdressList83 : MonoBehaviour +{ + public AdressResponse adressResponse; + public async Task AdressList() + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head83 = new Dictionary + { + { "Authorization", Global.global.serverResponse.data.token } + }; + + // 异步发送请求 + string response83 = await web.SendRequest(web.URL + "/snail/area/list", "POST", "{}", head83); + + // 调试输出接收到的响应 + Debug.Log("8.3地址列表: " + response83); + + // 将响应反序列化为 AdressResponse 对象 + try + { + adressResponse = JsonConvert.DeserializeObject(response83); + Debug.Log(adressResponse.data + "======================================="); + + // 遍历 data 列表中的每个地址 + if (adressResponse.data != null) + { + foreach (var address in adressResponse.data) + { + Debug.Log($"地址ID: {address.id}"); + Debug.Log($"收件人: {address.receiveName}"); + Debug.Log($"电话号码: {address.receivePhone}"); + Debug.Log($"区域: {address.area}"); + Debug.Log($"详细地址: {address.address}"); + Debug.Log($"状态: {address.status}"); + Debug.Log($"创建时间: {address.createTime}"); + } + } + } + catch (Exception ex) + { + Debug.LogError("反序列化响应失败: " + ex.Message); + } + + // 返回解析后的对象 + return adressResponse; + } +} + + diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs.meta b/TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs.meta new file mode 100644 index 0000000..08e8f27 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/AdressList83.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a9168746876aa5641a232e18f6521f0f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs b/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs new file mode 100644 index 0000000..dbff8ad --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs @@ -0,0 +1,41 @@ +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +//8.4查看地址详情 +public class areaInfo84 : MonoBehaviour +{ + public AdressInfoResponse adressInfoResponse; + + public async Task AdressInfo(int areaId) + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head84 = new Dictionary + { + { "Authorization", Global.global.serverResponse.data.token } + }; + + // 异步发送请求 + string response84 = await web.SendRequest(web.URL + "/snail/area/queryInfo?areaId=" + areaId, "GET", "{}", head84); + + // 调试输出接收到的响应 + Debug.Log("8.4地址详情====================: " + response84); + + // 将响应反序列化为 AdressInfoResponse 对象 + try + { + adressInfoResponse = JsonConvert.DeserializeObject(response84); + } + catch (Exception ex) + { + Debug.LogError("反序列化响应失败: " + ex.Message); + } + + // 返回解析后的对象 + return adressInfoResponse; + } + +} \ No newline at end of file diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs.meta b/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs.meta new file mode 100644 index 0000000..ad05561 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/areaInfo84.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9ccf0e8c5e7c5c04cad7d8d51f60f45a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs b/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs new file mode 100644 index 0000000..a5b303a --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +public class newAddress81 : MonoBehaviour +{ + //返回的(解析后) + public newAddressResponse newAddressResponse; + + + //public async Task queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId + public async Task newAddress(string receiveName, string receivePhone,string area, string address) + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head81 = new Dictionary + { + { "Authorization", Global.global.serverResponse.data.token } + }; + + // 请求体 + newAddressBody newAddressBody = new newAddressBody + { + receivePhone = receivePhone, + area = area, + address = address, + receiveName = receiveName, + }; + //Debug.Log("8.1=====入参======"+ JsonConvert.SerializeObject(newAddressBody)); + // 异步发送请求 + //string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525); + + string response81 = await web.SendRequest(web.URL + "/snail/area/save", "POST", JsonConvert.SerializeObject(newAddressBody), head81); + + // 调试输出接收到的响应 + Debug.Log("8.1新增地址:======== " + response81); + + //将响应反序列化为 KnightRoomList 对象 + try + { + newAddressResponse = JsonConvert.DeserializeObject(response81); + //Debug.Log(newAddressResponse.data+""); + } + catch (Exception ex) + { + Debug.LogError("反序列化响应失败: " + ex.Message); + } + + // 返回解析后的 对象 + return newAddressResponse; + } +} diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs.meta b/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs.meta new file mode 100644 index 0000000..93b78dc --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/newAddress81.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8bcf0ca7e73b01340b8599d93b481d20 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs b/TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs new file mode 100644 index 0000000..7f94ff8 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs @@ -0,0 +1,55 @@ +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +public class updateAddress82 : MonoBehaviour +{ + //返回的(解析后) + public updateAddressResponse updateAddressResponse; + + + //public async Task queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId + public async Task updateAddress(int id,string receiveName, string receivePhone, string area, string address) + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head81 = new Dictionary + { + { "Authorization", Global.global.serverResponse.data.token } + }; + + // 请求体 + updateAddressBody updateAddressBody = new updateAddressBody + { + id = id, + receivePhone = receivePhone, + area = area, + address = address, + receiveName = receiveName, + }; + Debug.Log("8.2=====入参======" + JsonConvert.SerializeObject(updateAddressBody)); + // 异步发送请求 + //string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525); + + string response82 = await web.SendRequest(web.URL + "/snail/area/update", "POST", JsonConvert.SerializeObject(updateAddressBody), head81); + + // 调试输出接收到的响应 + Debug.Log("8.2修改地址:+++++++++++++ " + response82); + + //将响应反序列化为 KnightRoomList 对象 + try + { + updateAddressResponse = JsonConvert.DeserializeObject(response82); + Debug.Log(updateAddressResponse.data + "======================================="); + } + catch (Exception ex) + { + Debug.LogError("反序列化响应失败: " + ex.Message); + } + + // 返回解析后的 对象 + return updateAddressResponse; + } +} diff --git a/TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs.meta b/TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs.meta new file mode 100644 index 0000000..8a44c26 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/AddressSystem8/updateAddress82.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 116c11222e679614485aa33594326768 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/Login/Global.cs b/TheStrongestSnail/Assets/Scripts/Login/Global.cs index 70c9691..e91e36f 100644 --- a/TheStrongestSnail/Assets/Scripts/Login/Global.cs +++ b/TheStrongestSnail/Assets/Scripts/Login/Global.cs @@ -765,4 +765,68 @@ public class InviteUserInfo public string memberTime { get; set; } public bool? isMember { get; set; } public string unionId { get; set; } +} +//=========81========================================== +//娣诲姞鍦板潃璇锋眰浣 +public class newAddressBody +{ + public string receiveName { get; set; } + public string receivePhone { get; set; } + public string area { get; set; } + public string address { get; set; } +} +public class newAddressResponse : Response +{ + public string data; +} +//======8.2================================================ +//璇锋眰浣 +public class updateAddressBody +{ + public int id { get; set; } + public string receiveName { get; set; } + public string receivePhone { get; set; } + public string area { get; set; } + public string address { get; set; } +} +//杩斿洖 +public class updateAddressResponse : Response +{ + public string data; +} +//=========8.3================================================= +[Serializable] +public class Address +{ + public int id; + public int userId; + public string receiveName; + public string receivePhone; + public string area; + public string address; + public int status; + public string createTime; +} + +[Serializable] +public class AdressResponse : Response +{ + public List
data; // 鍖呭惈澶氫釜鍦板潃鐨勫垪琛 +} +//8.4=================================================================== +public class AdressInfoResponse : Response +{ + public AddressInfoData data { get; set; } +} + +public class AddressInfoData +{ + public int id { get; set; } + public int userId { get; set; } + public string receiveName { get; set; } + public string receivePhone { get; set; } + public string area { get; set; } + public string address { get; set; } + public int status { get; set; } + public string createTime { get; set; } } \ No newline at end of file