65 lines
2.4 KiB
C#
65 lines
2.4 KiB
C#
|
using Newtonsoft.Json;
|
|||
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class productInfo22 : MonoBehaviour
|
|||
|
{
|
|||
|
//public async Task<MallResponsePro> getMallList(int productType, int pageNo, int pageSize)
|
|||
|
public async Task<getProductResponse> productInfo(int productId)
|
|||
|
{
|
|||
|
// <><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
|||
|
Dictionary<string, string> head22 = new Dictionary<string, string>
|
|||
|
{
|
|||
|
{ "Authorization", Global.global.serverResponse.data.token }
|
|||
|
};
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
getProdectBody getProdectBody = new getProdectBody
|
|||
|
{
|
|||
|
productId = productId,
|
|||
|
};
|
|||
|
|
|||
|
Debug.Log("====<3D><><EFBFBD><EFBFBD>====" + JsonConvert.SerializeObject(getProdectBody));
|
|||
|
// <20>첽<EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
string response22 = await web.SendRequest(web.URL + "/snail/product/page", "POST", JsonConvert.SerializeObject(getProdectBody), head22);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
Debug.Log("2.1<EFBFBD>̳<EFBFBD><EFBFBD>б<EFBFBD>:=============== " + response22);
|
|||
|
getProductResponse getProductResponse1 = new getProductResponse();
|
|||
|
try
|
|||
|
{
|
|||
|
// <20><> JSON <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>Ϊ MallResponse <20><><EFBFBD><EFBFBD>
|
|||
|
getProductResponse1 = JsonConvert.DeserializeObject<getProductResponse>(response22);
|
|||
|
|
|||
|
// <20>пգ<D0BF><D5A3><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD> getProductResponse <20><> getProductResponse.data <20>Ƿ<EFBFBD>Ϊ null
|
|||
|
if (getProductResponse1 != null && getProductResponse1.Data != null && getProductResponse1.Data.DataList != null)
|
|||
|
{
|
|||
|
Debug.Log($"Total Products: {getProductResponse1.Data.DataList.Count}");
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
|
|||
|
foreach (var product in getProductResponse1.Data.DataList)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>Ϣ
|
|||
|
Debug.Log($"Product ID: {product.ProductId}");
|
|||
|
Debug.Log($"Product Name: {product.ProductName}");
|
|||
|
Debug.Log($"Product Price: {product.Price}");
|
|||
|
Debug.Log($"Product Pic: {product.ProductPic}");
|
|||
|
Debug.Log($"Product Cover: {product.ProductCover}");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Debug.LogWarning("<22><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϊ<EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>");
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Debug.LogError("<22><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>Ӧʧ<D3A6><CAA7>: " + ex.Message);
|
|||
|
}
|
|||
|
return getProductResponse1;
|
|||
|
}
|
|||
|
}
|