商城接口完
This commit is contained in:
parent
cf3e3b01b6
commit
35e3700b9c
@ -865,7 +865,7 @@ public class ProductPro
|
||||
public int SellOpen { get; set; }
|
||||
public string CreateTime { get; set; } // CreateTime可能是 null,表示没有时间信息
|
||||
}
|
||||
//2.1===================================================
|
||||
//2.2===================================================
|
||||
public class getProdectBody
|
||||
{
|
||||
public int productId { get; set; }
|
||||
@ -873,19 +873,19 @@ public class getProdectBody
|
||||
[System.Serializable]
|
||||
public class getProductResponse:Response
|
||||
{
|
||||
public MallProduct Data;
|
||||
public ProductInfo Data;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MallProduct
|
||||
{
|
||||
public int PageNo;
|
||||
public int PageSize;
|
||||
public int TotalCount;
|
||||
public List<ProductInfo> DataList;
|
||||
}
|
||||
//public class MallProduct
|
||||
//{
|
||||
// public int PageNo;
|
||||
// public int PageSize;
|
||||
// public int TotalCount;
|
||||
// public List<ProductInfo> DataList;
|
||||
//}
|
||||
|
||||
[System.Serializable]
|
||||
//[System.Serializable]
|
||||
public class ProductInfo
|
||||
{
|
||||
public int ProductId;
|
||||
|
@ -18,16 +18,16 @@ public class productInfo22 : MonoBehaviour
|
||||
|
||||
// 请求体
|
||||
getProdectBody getProdectBody = new getProdectBody
|
||||
{
|
||||
{
|
||||
productId = productId,
|
||||
};
|
||||
|
||||
Debug.Log("====入参====" + JsonConvert.SerializeObject(getProdectBody));
|
||||
// 异步发送请求
|
||||
string response22 = await web.SendRequest(web.URL + "/snail/product/page", "POST", JsonConvert.SerializeObject(getProdectBody), head22);
|
||||
string response22 = await web.SendRequest(web.URL + "/snail/product/info", "POST", JsonConvert.SerializeObject(getProdectBody), head22);
|
||||
|
||||
// 调试输出接收到的响应
|
||||
Debug.Log("2.1商城列表:=============== " + response22);
|
||||
Debug.Log("2.2ÉÌÆ·ÏêÇé:=============== " + response22);
|
||||
getProductResponse getProductResponse1 = new getProductResponse();
|
||||
try
|
||||
{
|
||||
@ -35,20 +35,9 @@ public class productInfo22 : MonoBehaviour
|
||||
getProductResponse1 = JsonConvert.DeserializeObject<getProductResponse>(response22);
|
||||
|
||||
// 判空:首先检查 getProductResponse 和 getProductResponse.data 是否为 null
|
||||
if (getProductResponse1 != null && getProductResponse1.Data != null && getProductResponse1.Data.DataList != null)
|
||||
if (getProductResponse1 != null && getProductResponse1.Data != null && getProductResponse1.Data != null)
|
||||
{
|
||||
Debug.Log($"Total Products: {getProductResponse1.Data.DataList.Count}");
|
||||
|
||||
// 遍历商品列表
|
||||
foreach (var product in getProductResponse1.Data.DataList)
|
||||
{
|
||||
// 这里输出每个商品的信息
|
||||
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}");
|
||||
}
|
||||
Debug.Log("8=========D"+getProductResponse1.Data.ProductId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -21,6 +21,14 @@ public class Scene_main_jiekou :Base
|
||||
|
||||
public getProductResponse _getProductResponse;
|
||||
|
||||
//玩家的详细地址,电话。。。。。
|
||||
private AdressList83 _adressList83;
|
||||
private AdressResponse _adressResponse;
|
||||
|
||||
|
||||
//买东西
|
||||
private BuyProduct23 _buyProduct23;
|
||||
public bool IsBuyGet = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
||||
@ -84,7 +92,28 @@ public class Scene_main_jiekou :Base
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task ShopOneItem(int id)
|
||||
{
|
||||
_adressResponse = new AdressResponse();
|
||||
_adressList83 = new AdressList83();
|
||||
|
||||
_adressResponse = await _adressList83.AdressList();
|
||||
|
||||
_buyProduct23 = new BuyProduct23();
|
||||
|
||||
BuyProductResponse buyRes = await _buyProduct23.BuyProduct(id, _adressResponse.data[0].userId, _adressResponse.data[0].receiveName, _adressResponse.data[0].receivePhone, _adressResponse.data[0].area, _adressResponse.data[0].address);
|
||||
|
||||
if (buyRes.code == 200)
|
||||
{
|
||||
IsBuyGet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsBuyGet = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,5 +19,13 @@ public class main_BaseShowPanel : MonoBehaviour
|
||||
panel.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
||||
panel.transform.DOScale(1f, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
public void addEventPopUp(string Details, float time = 5f)//Ìí¼Óµ¯´°
|
||||
{
|
||||
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
|
||||
prefab.GetComponent<EventPopUp>().time = time;
|
||||
Canvas canvas = GetComponentInParent<Canvas>();
|
||||
prefab.GetComponent<EventPopUp>().text = Details;
|
||||
Instantiate(prefab, canvas.transform);
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ public class shopPanel: ui_huodong
|
||||
// 更新当前 itemInfo 显示项
|
||||
itemInfos[index].gameObject.SetActive(true); // 显示当前项
|
||||
itemInfos[index].initShow(go.Value.ProductId, go.Value.ProductName,go.Value.Price.ToString());
|
||||
itemInfos[index].GetComponent<Button>().onClick.AddListener(async()=> {
|
||||
itemInfos[index].GetComponent<Button>().onClick.AddListener(async()=> {
|
||||
await Scene_main_jiekou.instance.ShopItemDetail(go.Value.ProductId);
|
||||
GameObject.Instantiate(Panel, GameObject.Find("Canvas").transform).GetComponent<wokePanel>().initShow(go.Value.ProductName, go.Value.ProductName, go.Value.Price.ToString(), Scene_main_jiekou.instance._getProductResponse.Data.DataList[0].ProductName);
|
||||
GameObject.Instantiate(Panel, GameObject.Find("Canvas").transform).GetComponent<wokePanel>().initShow(go.Value.ProductId,go.Value.ProductName, go.Value.ProductName, go.Value.Price.ToString(), Scene_main_jiekou.instance._getProductResponse.Data.ProductName+":²âÊÔÎı¾");
|
||||
});
|
||||
index++;
|
||||
|
||||
|
@ -6,6 +6,7 @@ using TMPro;
|
||||
|
||||
public class wokePanel : ui_huodong
|
||||
{
|
||||
|
||||
public Sprite icon;
|
||||
[Header("大的物品名的TextPro")]
|
||||
public TextMeshProUGUI BigNameText;
|
||||
@ -16,22 +17,50 @@ public class wokePanel : ui_huodong
|
||||
[Header("物品价格的详细介绍")]
|
||||
public Text info;
|
||||
|
||||
private int id;
|
||||
|
||||
public Button BuyBtn;
|
||||
|
||||
public void initShow(Sprite icon,string BigNameText,string NameText,string priceText,string info)
|
||||
public void initShow(int id,string iconUrl,string BigNameText,string NameText,string priceText,string info)
|
||||
{
|
||||
this.icon = icon;
|
||||
this.id = id;
|
||||
//this.icon = icon;
|
||||
this.BigNameText.text = BigNameText;
|
||||
this.NameText.text = NameText;
|
||||
this.priceText.text = "¥" + priceText;
|
||||
this.info.text = info;
|
||||
|
||||
BuyBtn.onClick.AddListener(async()=> {
|
||||
await Scene_main_jiekou.instance.ShopOneItem(id);
|
||||
if (Scene_main_jiekou.instance.IsBuyGet)
|
||||
{
|
||||
addEventPopUp("购买成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
addEventPopUp("购买失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initShow(string BigNameText, string NameText, string priceText, string info)
|
||||
public void initShow(int id,string BigNameText, string NameText, string priceText, string info)
|
||||
{
|
||||
this.id = id;
|
||||
this.BigNameText.text = BigNameText;
|
||||
this.NameText.text = NameText;
|
||||
this.priceText.text = "¥"+priceText;
|
||||
this.info.text = info;
|
||||
|
||||
BuyBtn.onClick.AddListener(async () => {
|
||||
await Scene_main_jiekou.instance.ShopOneItem(id);
|
||||
if (Scene_main_jiekou.instance.IsBuyGet)
|
||||
{
|
||||
addEventPopUp("购买成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
addEventPopUp("购买失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -367, y: 281}
|
||||
m_SizeDelta: {x: 174.6571, y: 50.15329}
|
||||
m_AnchoredPosition: {x: 3.8647, y: -8.8514}
|
||||
m_SizeDelta: {x: 916.3866, y: 629.8559}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &499058874787693950
|
||||
CanvasRenderer:
|
||||
@ -73,7 +73,7 @@ MonoBehaviour:
|
||||
m_BestFit: 0
|
||||
m_MinSize: 0
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_Alignment: 0
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
@ -790,6 +790,7 @@ MonoBehaviour:
|
||||
NameText: {fileID: 499058876205321731}
|
||||
priceText: {fileID: 499058876083203626}
|
||||
info: {fileID: 499058874787693951}
|
||||
BuyBtn: {fileID: 499058874945094317}
|
||||
--- !u!1 &499058875926305708
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
Loading…
Reference in New Issue
Block a user