JieKouDiaoYongRiZhi.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Bitsplash.DatePicker;
  5. using LitJson;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. public class JieKouDiaoYongRiZhi : MonoBehaviour
  9. {
  10. public PageBtnControl pbt;
  11. public List<GameObject> list = new List<GameObject>();
  12. long startl;
  13. long sendl;
  14. public DatePickerDropDown ds1;
  15. public DatePickerDropDown ds2;
  16. public void chooseA()
  17. {
  18. StartCoroutine(chooseYanChi(ds1.Label,(l)=> {
  19. startl=l;
  20. }));
  21. }
  22. public void chooseB()
  23. {
  24. StartCoroutine(chooseYanChi(ds2.Label, (l) => {
  25. sendl=l+86400;
  26. }));
  27. }
  28. IEnumerator chooseYanChi(Text t,Action<long> callback)
  29. {
  30. yield return null;
  31. string dateString = t.text;
  32. Debug.Log("chooseYanChi===>"+ds1.Label.text);
  33. DateTime dateTime = DateTime.Parse(dateString);
  34. long timestamp = ((DateTimeOffset)dateTime).ToUnixTimeSeconds();
  35. Debug.Log("Timestamp: " + timestamp);
  36. callback.Invoke(timestamp);
  37. }
  38. public void sousuo()
  39. {
  40. page(1);
  41. }
  42. void OnEnable()
  43. {
  44. startl = 0;
  45. sendl =((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
  46. pbt.curretPage =1;
  47. page(1);
  48. ds1.Label.text ="选择日期";
  49. ds2.Label.text ="选择日期";
  50. }
  51. int total =1;
  52. public void page(int i)
  53. {
  54. JsonData d =new JsonData();
  55. d["start_time"] =startl;
  56. d["end_time"] =sendl;
  57. d["page"] =i;
  58. d["size"] =MaxLiebiao;
  59. Debug.Log("initPage"+i);
  60. StartCoroutine(DataManager.Instance.GetqueryThirdParty(d,(msg)=>{
  61. JsonData jd =JsonMapper.ToObject(msg);
  62. total = int.Parse( jd["data"]["page"]["total_page"].ToString());
  63. if( pbt.allPage!=total)
  64. {
  65. pbt.allPage = total;
  66. pbt.InitData();
  67. }
  68. Debug.Log("总共"+int.Parse( jd["data"]["page"]["total_count"].ToString()));
  69. for (int i = 0; i < MaxLiebiao; i++)
  70. {
  71. if(jd["data"]["list"].ToString()!="[]"&&jd["data"]["list"].Count> i)
  72. {
  73. list[i].GetComponent<JieKouRiZhiItem>().init(jd["data"]["list"][i]);
  74. list[i].SetActive(true);
  75. }else
  76. {
  77. list[i].SetActive(false);
  78. }
  79. }
  80. }));
  81. }
  82. private void Awake() {
  83. }
  84. int MaxLiebiao=5;
  85. }