PayInfoPanel.cs 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace LoyalSoftSDK
  6. {
  7. public class PayInfoPanel :BaseUIForm {
  8. private GameObject payItemPanel;
  9. private GameObject backBtn;
  10. private Transform content;
  11. private Text nohavedText;
  12. // Use this for initialization
  13. public override void Init()
  14. {
  15. curUIType = UIType.Normal;
  16. nohavedText = this.transform.Find("BackPanel/ScrollView/Viewport/NohavedText").gameObject.GetComponent<Text>();
  17. backBtn = this.transform.Find("BackPanel/BackButton").gameObject;
  18. EventTriggerListener.Get(backBtn).onClick = OnBackBtnClick;
  19. payItemPanel = this.transform.Find("BackPanel/PayItemPanel").gameObject;
  20. content = this.transform.Find("BackPanel/ScrollView/Viewport/Content").gameObject.transform;
  21. }
  22. public override void Display(BaseUIForm _parent, Dictionary<string, string> data)
  23. {
  24. for (int i = 0; i < content.childCount; i++)
  25. {
  26. Destroy(content.GetChild(i).gameObject);
  27. }
  28. string code;
  29. string infoStr;
  30. data.TryGetValue("code", out code);
  31. data.TryGetValue("data", out infoStr);
  32. if (code.Equals("err"))
  33. {
  34. nohavedText.text = "网络请求错误,请稍候再试!";
  35. nohavedText.gameObject.SetActive(true);
  36. }
  37. else
  38. {
  39. Dictionary<string, object> infoDic = MiniJSON.Json.Deserialize(infoStr) as Dictionary<string,object>;
  40. object InfoObj;
  41. infoDic.TryGetValue("array", out InfoObj);
  42. //Debug.Log((aa as List<object>).Count);
  43. //Debug.Log((aa as List<object>)[0] as Dictionary<string ,object>);
  44. if((InfoObj as List<object>).Count>0)
  45. {
  46. foreach (var info in InfoObj as List<object>)
  47. {
  48. object product_name;
  49. object cpOrderId;
  50. object amount;
  51. object order_ts;
  52. //object product_name;
  53. (info as Dictionary<string, object>).TryGetValue("product_name", out product_name);
  54. (info as Dictionary<string, object>).TryGetValue("cpOrderId", out cpOrderId);
  55. (info as Dictionary<string, object>).TryGetValue("amount", out amount);
  56. (info as Dictionary<string, object>).TryGetValue("order_ts", out order_ts);
  57. GameObject newitem = Instantiate(payItemPanel);
  58. newitem.transform.SetParent(content);
  59. newitem.transform.localScale = new Vector3(1f, 1f, 1f);
  60. PayItemPanel item = newitem.AddComponent<PayItemPanel>();
  61. newitem.SetActive(true);
  62. item.SetInfo(product_name.ToString(), cpOrderId.ToString(), order_ts.ToString(), amount.ToString());
  63. }
  64. nohavedText.gameObject.SetActive(false);
  65. }
  66. else
  67. {
  68. nohavedText.text = "暂无充值记录!";
  69. nohavedText.gameObject.SetActive(true);
  70. }
  71. }
  72. base.Display(_parent, data);
  73. }
  74. private void OnBackBtnClick(GameObject go)
  75. {
  76. GoBackParent();
  77. }
  78. }
  79. }