| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Newtonsoft.Json;
- using UnityEngine;
- using UnityEngine.UI;
- public class B08_TaskListItem : MonoBehaviour
- {
- public Text typeText;
- public Text titleText;
- public Text stateText;
- public Text dateText;
- public Text ctrlText;
- public GameObject more;
- public Button moreButton;
- public bool moreMessage = false;
- public RectTransform rect;
- public GameObject pointItemPrefab;
- public List<B08_TaskPointItem> PointItems = new List<B08_TaskPointItem>();
- public Transform itemContent;
- public B08_TaskInfoData InfoData;
- public GCYWLayer gcywLayer;
- public static B08_TaskListItem currentTaskListItem;
- public string id;
- public string xunjianType;
- public void Init()
- {
- rect = this.GetComponent<RectTransform>();
- typeText = this.transform.Find("typeText").GetComponent<Text>();
- titleText = this.transform.Find("titleText").GetComponent<Text>();
- stateText = this.transform.Find("stateText").GetComponent<Text>();
- dateText = this.transform.Find("dateText").GetComponent<Text>();
- ctrlText = this.transform.Find("ctrlText").GetComponent<Text>();
- more = this.transform.Find("more").gameObject;
- more.SetActive(false);
- moreButton = ctrlText.GetComponent<Button>();
- moreButton.onClick.AddListener(() => { ChangeMoreMessage(!moreMessage); });
- moreMessage = false;
- ctrlText.text = "<color=#00EFFF>详情</color>";
- rect.sizeDelta = new Vector2(360, 38);
- more.SetActive(false);
- }
- private async void ChangeMoreMessage(bool moreMes = false)
- {
- try
- {
- moreMessage = moreMes;
- if (moreMessage)
- {
- if (currentTaskListItem != null && currentTaskListItem != this)
- {
- if (currentTaskListItem.moreMessage)
- {
- currentTaskListItem.ChangeMoreMessage(false);
- }
- }
- ctrlText.text = "<color=#00FF3F>收起</color>";
- rect.sizeDelta = new Vector2(360, 354);
- more.SetActive(true);
-
- }
- else
- {
- ctrlText.text = "<color=#00EFFF>详情</color>";
- rect.sizeDelta = new Vector2(360, 38);
- more.SetActive(false);
- }
- var infoDataStr=await HttpHelper._Instance.B08_API_TaskInfo(id);
- Debug.Log(infoDataStr);
- if (moreMessage)
- {
- currentTaskListItem = this;
- InfoData = JsonConvert.DeserializeObject<B08_TaskInfo>(infoDataStr).Data;
- if (InfoData.taskItems == null) return;
- for (int i = 0; i < InfoData.taskItems.Length; i++)
- {
- B08_TaskPointItem tempItem = Instantiate(pointItemPrefab, itemContent).GetComponent<B08_TaskPointItem>();
- tempItem.SetData(gcywLayer, InfoData.taskItems[i], i, InfoData.createTime);
- var button = tempItem.GetComponent<ExtendedButton_PointItem>();
- button.index = i;
- //button.onPointerEnter += gcywLayer.SetTaskPointIconHeightLight;
- PointItems.Add(tempItem);
- }
- gcywLayer.SetTaskImgPanelData(InfoData.locations.locations, InfoData.createTime);
- }
- }
- catch (Exception e)
- {
- Debug.LogError(e.ToString());
- }
- }
- public void SetData(GCYWLayer baseLayer, B08_TaskListData data)
- {
- gcywLayer = baseLayer;
- id = data.id;
- xunjianType = data.xunjianType;
- InfoData = null;
- string typeStr = "";
- if (xunjianType == null)
- {
- xunjianType = "4";
- typeStr = "定期专项";
- }
- else
- {
- switch (xunjianType)
- {
- case "0":
- typeStr = "电气";
- break;
- case "1":
- typeStr = "闸站";
- break;
- case "2":
- typeStr = "堤防";
- break;
- case "3":
- typeStr = "交叉建筑";
- break;
- case "4":
- case "":
- typeStr = "定期专项";
- break;
- }
- }
- typeText.text = typeStr;
- titleText.text = data.title;
- switch (data.status)
- {
- case 0:
- stateText.text = "待派工";
- break;
- case 1:
- stateText.text = "待整改";
- break;
- case 2:
- stateText.text = "待验收";
- break;
- case 3:
- stateText.text = "已整改";
- break;
- }
- dateText.text = data.createTime;
- for (int i = 0; i < PointItems.Count; i++)
- {
- Destroy(PointItems[i].gameObject);
- }
- PointItems.Clear();
- }
- }
|