TaskPhotoPanel.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_item;
  15. public int currentIndex = 0;
  16. public Text dateText;
  17. public string _timeInfo;
  18. private void Awake()
  19. {
  20. lastItem.onClick.AddListener(Last);
  21. nextItem.onClick.AddListener(Next);
  22. }
  23. public void SetData(B08_TaskItems item, string _time)
  24. {
  25. currentIndex = 0;
  26. task_item = item;
  27. _timeInfo = _time;
  28. posText.text = task_item.faItemName;
  29. messageText.text = task_item.remark == null? "暂无内容": task_item.remark;
  30. dateText.text = task_item.finishedTime == null?_timeInfo: task_item.finishedTime;
  31. ChangePage(currentIndex);
  32. }
  33. public void Next()
  34. {
  35. if (currentIndex < task_item.files.Length - 1)
  36. {
  37. currentIndex++;
  38. ChangePage(currentIndex);
  39. }
  40. }
  41. public void Last()
  42. {
  43. if (currentIndex > 0)
  44. {
  45. currentIndex--;
  46. ChangePage(currentIndex);
  47. }
  48. }
  49. public void ChangePage(int pageIndex)
  50. {
  51. img.texture = null;
  52. if (task_item.files.Length < 1)
  53. {
  54. pageText.text = $"0/0";
  55. return;
  56. }
  57. var currentData = task_item.files[pageIndex];
  58. if (currentData.filePath!=null&&!currentData.filePath.Equals(""))
  59. {
  60. string path = "http://58.19.230.46:9180/prod-api/uploads/" + currentData.filePath;
  61. TextureLoadHelp._Instance.LoadTexFromUrl(path, img);
  62. }
  63. else {
  64. img.texture = null;
  65. }
  66. //Debug.Log(currentData.faItemName + " " + currentData.startTime + " " + currentData.finishedTime);
  67. pageText.text = $"{pageIndex + 1}/{task_item.files.Length}";
  68. }
  69. }