CaoZuoRizhi.cs 2.5 KB

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