|
@@ -8,10 +8,10 @@ using UnityEngine.UI;
|
|
|
|
|
|
public class CaoZuoRizhi : MonoBehaviour
|
|
|
{
|
|
|
+ public PageBtnControl pbt;
|
|
|
public UIScrollScript uiScroll;
|
|
|
- public GameObject go;
|
|
|
|
|
|
- List<GameObject> list = new List<GameObject>();
|
|
|
+ public List<GameObject> list = new List<GameObject>();
|
|
|
|
|
|
long startl;
|
|
|
long sendl;
|
|
@@ -45,151 +45,56 @@ sendl=l+86400;
|
|
|
|
|
|
public void sousuo()
|
|
|
{
|
|
|
- RemoveAll();
|
|
|
- JsonData d =new JsonData();
|
|
|
- d["start_time"] =startl;
|
|
|
- d["end_time"] =sendl;
|
|
|
- d["page"] =1;
|
|
|
- d["size"] =MaxLiebiao;
|
|
|
- Debug.Log("sousuo==>"+d.ToJson());
|
|
|
- startinit=false;
|
|
|
- StartCoroutine(getreplist(d));
|
|
|
+ page(1);
|
|
|
}
|
|
|
- bool startinit=false;
|
|
|
void OnEnable()
|
|
|
{
|
|
|
+ startl = 0;
|
|
|
+ sendl =((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
|
|
+ pbt.curretPage =1;
|
|
|
+ page(1);
|
|
|
+
|
|
|
ds1.Label.text ="选择日期";
|
|
|
ds2.Label.text ="选择日期";
|
|
|
- uiScroll.Init();
|
|
|
- RemoveAll();
|
|
|
+ }
|
|
|
+ int total =1;
|
|
|
+ public void page(int i)
|
|
|
+ {
|
|
|
JsonData d =new JsonData();
|
|
|
- d["start_time"] =0;
|
|
|
- d["end_time"] =((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
|
|
- startl = 0;
|
|
|
- sendl =((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
|
|
- d["page"] =1;
|
|
|
+ d["start_time"] =startl;
|
|
|
+ d["end_time"] =sendl;
|
|
|
+ d["page"] =i;
|
|
|
d["size"] =MaxLiebiao;
|
|
|
- startinit=false;
|
|
|
- StartCoroutine(getreplist(d));
|
|
|
-
|
|
|
- uiScroll.onUpdateItem -= ContentUpdateItem;
|
|
|
- uiScroll.onUpdateItem += ContentUpdateItem;
|
|
|
-
|
|
|
- uiScroll.onEatUpItem -= EatUpItem;
|
|
|
- uiScroll.onEatUpItem += EatUpItem;
|
|
|
+ Debug.Log("initPage"+i);
|
|
|
+ StartCoroutine(DataManager.Instance.GetRePort(d,(msg)=>{
|
|
|
+ JsonData jd =JsonMapper.ToObject(msg);
|
|
|
+ total = int.Parse( jd["data"]["page"]["total_page"].ToString());
|
|
|
+ if( pbt.allPage!=total)
|
|
|
+ {
|
|
|
+ pbt.allPage = total;
|
|
|
+ pbt.InitData();
|
|
|
+ }
|
|
|
+ Debug.Log("总共"+int.Parse( jd["data"]["page"]["total_count"].ToString()));
|
|
|
+ for (int i = 0; i < MaxLiebiao; i++)
|
|
|
+ {
|
|
|
+ if(jd["data"]["list"].ToString()!="[]"&&jd["data"]["list"].Count> i)
|
|
|
+ {
|
|
|
+ list[i].GetComponent<RiZhiItem>().init(jd["data"]["list"][i]);
|
|
|
+ list[i].SetActive(true);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ list[i].SetActive(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }));
|
|
|
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- private void EatUpItem()
|
|
|
- {
|
|
|
- if(nextdata!=null)
|
|
|
- StartCoroutine(getreplist(nextdata));
|
|
|
- nextdata=null;
|
|
|
}
|
|
|
|
|
|
- private void ContentUpdateItem(GameObject item, int wrapIndex, int realIndex)
|
|
|
- {
|
|
|
-
|
|
|
- if (realIndex >= 0&&datamsg.Count>realIndex)
|
|
|
- {
|
|
|
- RiZhiItem xitem = item.GetComponent<RiZhiItem>();
|
|
|
- xitem.init(datamsg[realIndex]);
|
|
|
- item.SetActive(true);
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- item.SetActive(false);
|
|
|
- }
|
|
|
- }
|
|
|
private void Awake() {
|
|
|
-
|
|
|
- list.Add(go);
|
|
|
- }
|
|
|
- public void RemoveAll()
|
|
|
- {
|
|
|
- uiScroll.Init();
|
|
|
- nextdata=null;
|
|
|
- datamsg=new List<JsonData>();
|
|
|
+
|
|
|
}
|
|
|
- List<JsonData> datamsg =new List<JsonData>();
|
|
|
- int MaxLiebiao=15;
|
|
|
-
|
|
|
- public JsonData nextdata;
|
|
|
- public IEnumerator getreplist(JsonData jd)
|
|
|
- {
|
|
|
- int page =int.Parse( jd["page"].ToString());
|
|
|
- int total =int.Parse( jd["page"].ToString());
|
|
|
- Debug.Log("getreplist start"+uiScroll.GetComponent<RectTransform>().anchoredPosition.y);
|
|
|
- yield return StartCoroutine(DataManager.Instance.GetRePort(jd,(msg)=>{
|
|
|
- JsonData jd =JsonMapper.ToObject(msg);
|
|
|
- for (int i = list.Count; i < MaxLiebiao; i++)
|
|
|
- {
|
|
|
- GameObject n =GameObject.Instantiate(go,go.transform.parent);
|
|
|
- list.Add(n);
|
|
|
- }
|
|
|
- total=int.Parse( jd["data"]["page"]["total_page"].ToString());
|
|
|
- if(!startinit)
|
|
|
- {
|
|
|
- Debug.Log("总共"+int.Parse( jd["data"]["page"]["total_count"].ToString()));
|
|
|
-
|
|
|
- for (int i = 0; i < MaxLiebiao; i++)
|
|
|
- {
|
|
|
+ int MaxLiebiao=10;
|
|
|
|
|
|
- if(jd["data"]["list"].ToString()!="[]"&&jd["data"]["list"].Count> i)
|
|
|
- {
|
|
|
- list[i].GetComponent<RiZhiItem>().init(jd["data"]["list"][i]);
|
|
|
- list[i].SetActive(true);
|
|
|
- datamsg.Add(jd["data"]["list"][i]);
|
|
|
- }else
|
|
|
- {
|
|
|
- list[i].SetActive(false);
|
|
|
- }
|
|
|
- }
|
|
|
- uiScroll.InitList(0, datamsg.Count);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- for (int i = 0; i < MaxLiebiao; i++)
|
|
|
- {
|
|
|
- if(jd["data"]["list"].Count> i)
|
|
|
- {
|
|
|
- datamsg.Add(jd["data"]["list"][i]);
|
|
|
- }
|
|
|
- }
|
|
|
- uiScroll.InitList(0, datamsg.Count);
|
|
|
- }
|
|
|
- startinit=true;
|
|
|
- Debug.Log("getreplist end"+datamsg.Count);
|
|
|
- if(datamsg.Count == 0 )
|
|
|
- {
|
|
|
- go.transform.parent.parent.parent.gameObject.SetActive(false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- go.transform.parent.parent.parent.gameObject.SetActive(true);
|
|
|
|
|
|
- }
|
|
|
- Invoke("UpdatePos",0.1f);
|
|
|
- Debug.Log("getreplist start"+uiScroll.GetComponent<RectTransform>().anchoredPosition.y);
|
|
|
-
|
|
|
- }));
|
|
|
- if(page+1<=total)
|
|
|
- {
|
|
|
- jd["page"] = (page+1);
|
|
|
- nextdata = jd;
|
|
|
- // yield return getreplist(jd);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nextdata=null;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- void UpdatePos()
|
|
|
- {
|
|
|
- uiScroll.GetComponent<RectTransform>().anchoredPosition= new Vector2(uiScroll.GetComponent<RectTransform>().anchoredPosition.x,uiScroll.GetComponent<RectTransform>().anchoredPosition.y+1);
|
|
|
- }
|
|
|
}
|