商店修改
This commit is contained in:
parent
f10cdf47f8
commit
7360d00793
@ -17,7 +17,7 @@ public class Scene_main_jiekou :Base
|
|||||||
private MallResponsePro _mallResponsePro;//商城列表结构体
|
private MallResponsePro _mallResponsePro;//商城列表结构体
|
||||||
private getMallList21 _getMallList21;//商城列表获取方法
|
private getMallList21 _getMallList21;//商城列表获取方法
|
||||||
//商城info字典
|
//商城info字典
|
||||||
public Dictionary<int, ProductPro> shopItemDic;
|
public Dictionary<int, ProductPro> shopItemDic = new Dictionary<int, ProductPro>();
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
||||||
@ -52,21 +52,26 @@ public class Scene_main_jiekou :Base
|
|||||||
|
|
||||||
public async Task ShopInfo()
|
public async Task ShopInfo()
|
||||||
{
|
{
|
||||||
//瓊품헌왕
|
// 每次调用时清空字典,确保是最新数据
|
||||||
shopItemDic = null;
|
shopItemDic.Clear();
|
||||||
|
|
||||||
|
// 清空商城数据
|
||||||
_mallResponsePro = null;
|
_mallResponsePro = null;
|
||||||
_getMallList21 = null;
|
_getMallList21 = null;
|
||||||
|
|
||||||
|
// 重新实例化商城相关对象
|
||||||
//路畇畇흙
|
|
||||||
_mallResponsePro = new MallResponsePro();
|
_mallResponsePro = new MallResponsePro();
|
||||||
_getMallList21 = new getMallList21();
|
_getMallList21 = new getMallList21();
|
||||||
|
|
||||||
|
// 异步获取商城数据
|
||||||
_mallResponsePro = await _getMallList21.getMallList(1, 1, 20);
|
_mallResponsePro = await _getMallList21.getMallList(1, 1, 20);
|
||||||
|
|
||||||
|
// 将商品信息存入字典
|
||||||
foreach (ProductPro go in _mallResponsePro.Data.DataList)
|
foreach (ProductPro go in _mallResponsePro.Data.DataList)
|
||||||
{
|
{
|
||||||
shopItemDic.Add(go.ProductId,go);
|
// 更新字典中的商品信息
|
||||||
}
|
shopItemDic[go.ProductId] = go;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ public class main_shop :BaseUIPanel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//await Scene_main_jiekou.instance.ShopInfo();
|
await Scene_main_jiekou.instance.ShopInfo();
|
||||||
//获取商城列表
|
//获取商城列表
|
||||||
Debug.Log("»ñÈ¡É̳ÇÁбí");
|
Debug.Log("获取商城列表才能实例化panel,但是更新显示让panel来");
|
||||||
// 实例化 Panel
|
// 实例化 Panel
|
||||||
GameObject.Instantiate(Panel, canvas.transform);
|
GameObject.Instantiate(Panel, canvas.transform);
|
||||||
|
|
||||||
|
@ -37,19 +37,19 @@ public class itemInfo : MonoBehaviour
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initShow(int id, Sprite icon, string name, float price)
|
public void initShow(int id, Sprite icon, string name, string price)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
iconImage.sprite = icon;
|
iconImage.sprite = icon;
|
||||||
nameText.text = name;
|
nameText.text = name;
|
||||||
priceText.text = price.ToString();
|
priceText.text = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initShow(int id, string name, float price)
|
public void initShow(int id, string name, string price)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
nameText.text = name;
|
nameText.text = name;
|
||||||
priceText.text = price.ToString();
|
priceText.text = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,10 @@ public class shopPanel: ui_huodong
|
|||||||
|
|
||||||
void initShop()
|
void initShop()
|
||||||
{
|
{
|
||||||
|
int index = 0;
|
||||||
int index= Scene_main_jiekou.instance._mallResponsePro.Data.TotalCount;//商城的商品数量
|
foreach (KeyValuePair<int, ProductPro> go in Scene_main_jiekou.instance.shopItemDic)
|
||||||
|
|
||||||
foreach (itemInfo item in itemInfos)
|
|
||||||
{
|
{
|
||||||
if (index>0)
|
itemInfos[index].initShow(go.Value.ProductId,go.Value.ProductName,go.Value.ProductPic.ToString());
|
||||||
{
|
|
||||||
item.gameObject.SetActive(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user