TaskPhotoPanel.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class TaskPhotoPanel : MonoBehaviour
  7. {
  8. public RawImage img;
  9. public Text posText;
  10. public Text messageText;
  11. public Text pageText;
  12. public Button lastItem;
  13. public Button nextItem;
  14. public B08_TaskItems[] task_items;
  15. public int currentIndex = 0;
  16. public Text dateText;
  17. private void Awake()
  18. {
  19. lastItem.onClick.AddListener(Last);
  20. nextItem.onClick.AddListener(Next);
  21. }
  22. public void SetData(B08_TaskItems[] items)
  23. {
  24. currentIndex = 0;
  25. task_items = items;
  26. ChangePage(currentIndex);
  27. }
  28. public void Next()
  29. {
  30. if (currentIndex < task_items.Length - 1)
  31. {
  32. currentIndex++;
  33. ChangePage(currentIndex);
  34. }
  35. }
  36. public void Last()
  37. {
  38. if (currentIndex > 0)
  39. {
  40. currentIndex--;
  41. ChangePage(currentIndex);
  42. }
  43. }
  44. public void ChangePage(int pageIndex)
  45. {
  46. var currentData = task_items[pageIndex];
  47. string path ="http://58.19.230.46:9180/prod-api/uploads/"+currentData.files[0].filePath;
  48. TextureLoadHelp._Instance.LoadTexFromUrl(path, img);
  49. Debug.Log(currentData.faItemName+" "+currentData.startTime+" "+currentData.finishedTime);
  50. posText.text = currentData.faItemName;
  51. messageText.text = currentData.faItemName;
  52. pageText.text = $"{pageIndex + 1}/{task_items.Length}";
  53. dateText.text = currentData.startTime;
  54. }
  55. }