using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace LoyalSoftSDK { public class PayInfoPanel :BaseUIForm { private GameObject payItemPanel; private GameObject backBtn; private Transform content; private Text nohavedText; // Use this for initialization public override void Init() { curUIType = UIType.Normal; nohavedText = this.transform.Find("BackPanel/ScrollView/Viewport/NohavedText").gameObject.GetComponent(); backBtn = this.transform.Find("BackPanel/BackButton").gameObject; EventTriggerListener.Get(backBtn).onClick = OnBackBtnClick; payItemPanel = this.transform.Find("BackPanel/PayItemPanel").gameObject; content = this.transform.Find("BackPanel/ScrollView/Viewport/Content").gameObject.transform; } public override void Display(BaseUIForm _parent, Dictionary data) { for (int i = 0; i < content.childCount; i++) { Destroy(content.GetChild(i).gameObject); } string code; string infoStr; data.TryGetValue("code", out code); data.TryGetValue("data", out infoStr); if (code.Equals("err")) { nohavedText.text = "网络请求错误,请稍候再试!"; nohavedText.gameObject.SetActive(true); } else { Dictionary infoDic = MiniJSON.Json.Deserialize(infoStr) as Dictionary; object InfoObj; infoDic.TryGetValue("array", out InfoObj); //Debug.Log((aa as List).Count); //Debug.Log((aa as List)[0] as Dictionary); if((InfoObj as List).Count>0) { foreach (var info in InfoObj as List) { object product_name; object cpOrderId; object amount; object order_ts; //object product_name; (info as Dictionary).TryGetValue("product_name", out product_name); (info as Dictionary).TryGetValue("cpOrderId", out cpOrderId); (info as Dictionary).TryGetValue("amount", out amount); (info as Dictionary).TryGetValue("order_ts", out order_ts); GameObject newitem = Instantiate(payItemPanel); newitem.transform.SetParent(content); newitem.transform.localScale = new Vector3(1f, 1f, 1f); PayItemPanel item = newitem.AddComponent(); newitem.SetActive(true); item.SetInfo(product_name.ToString(), cpOrderId.ToString(), order_ts.ToString(), amount.ToString()); } nohavedText.gameObject.SetActive(false); } else { nohavedText.text = "暂无充值记录!"; nohavedText.gameObject.SetActive(true); } } base.Display(_parent, data); } private void OnBackBtnClick(GameObject go) { GoBackParent(); } } }