1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TaskPhotoPanel : MonoBehaviour
- {
- public RawImage img;
- public Text posText;
- public Text messageText;
- public Text pageText;
- public Button lastItem;
- public Button nextItem;
- public B08_TaskItems task_item;
- public int currentIndex = 0;
- public Text dateText;
- public string _timeInfo;
- private void Awake()
- {
- lastItem.onClick.AddListener(Last);
- nextItem.onClick.AddListener(Next);
- }
- public void SetData(B08_TaskItems item, string _time)
- {
- currentIndex = 0;
- task_item = item;
- _timeInfo = _time;
-
- posText.text = task_item.faItemName;
- messageText.text = task_item.remark == null? "暂无内容": task_item.remark;
- dateText.text = task_item.finishedTime == null?_timeInfo: task_item.finishedTime;
- ChangePage(currentIndex);
- }
- public void Next()
- {
- if (currentIndex < task_item.files.Length - 1)
- {
- currentIndex++;
- ChangePage(currentIndex);
- }
- }
- public void Last()
- {
- if (currentIndex > 0)
- {
- currentIndex--;
- ChangePage(currentIndex);
- }
- }
- public void ChangePage(int pageIndex)
- {
- img.texture = null;
- if (task_item.files.Length < 1)
- {
- pageText.text = $"0/0";
- return;
- }
- var currentData = task_item.files[pageIndex];
- if (currentData.filePath!=null&&!currentData.filePath.Equals(""))
- {
- string path = "http://58.19.230.46:9180/prod-api/uploads/" + currentData.filePath;
- TextureLoadHelp._Instance.LoadTexFromUrl(path, img);
- }
- else {
- img.texture = null;
- }
- //Debug.Log(currentData.faItemName + " " + currentData.startTime + " " + currentData.finishedTime);
-
- pageText.text = $"{pageIndex + 1}/{task_item.files.Length}";
- }
- }
|