2021-04-21 16:16:14 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.Apis;
|
|
|
|
|
|
using Assets.Scripts.UI.Control;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class FeedbackController : PFUIPanel
|
|
|
|
|
|
{
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
Transform main,images;
|
|
|
|
|
|
PFUIInputField content;
|
|
|
|
|
|
Dictionary<string, string> paths;
|
|
|
|
|
|
Sprite plus;
|
|
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
2021-04-23 15:36:18 +08:00
|
|
|
|
//ApiBase.SetCookie("3B7C1A274805FBB658A16F7B658F7FC3B01599154A952C20011B0F207A9F7B9709CAB23AD8B62FF5F85806DD0AD5059223FD6A582EF79B3F211E64572290202D2821928E824BA6C5313C32C4291763A3797304AE193B272DB9907F7D5AB46D53");
|
2021-04-21 16:16:14 +08:00
|
|
|
|
main = transform.Find("Main");
|
|
|
|
|
|
images = main.Find("Images");
|
|
|
|
|
|
paths = new Dictionary<string, string>();
|
|
|
|
|
|
plus = Resources.Load<Sprite>("Images/c-1");
|
|
|
|
|
|
for (int i = 0; i < images.childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var img = images.GetChild(i);
|
|
|
|
|
|
int index = i;
|
|
|
|
|
|
UIManager.AddEvent(img.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick,
|
|
|
|
|
|
(e)=> AddImage(e,index));
|
|
|
|
|
|
UIManager.AddEvent(img.Find("close").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick,
|
|
|
|
|
|
(e) => { DelImage(e, img,index); });
|
|
|
|
|
|
img.Find("close").gameObject.SetActive(false);
|
|
|
|
|
|
img.GetComponent<Image>().sprite = plus;
|
|
|
|
|
|
//if (i > 0) SetImageActive(img, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
UIManager.AddEvent(main.Find("BtnSubmit").gameObject, EventTriggerType.PointerClick, (b) => Submit());
|
|
|
|
|
|
UIManager.AddEvent(main.Find("BtnCancel").gameObject, EventTriggerType.PointerClick, (b) => Close());
|
|
|
|
|
|
UIManager.AddEvent(main.Find("Exit").gameObject, EventTriggerType.PointerClick, (b) => Close());
|
|
|
|
|
|
content = main.Find("Content").Find("input").GetComponent<PFUIInputField>();
|
|
|
|
|
|
content.GetComponent<InputField>().onValueChanged.AddListener((s) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
content.transform.Find("Number").GetComponent<Text>().text = $"<color=#9e9ead>{s.Length}</color>/200";
|
|
|
|
|
|
});
|
|
|
|
|
|
content.transform.Find("Number").GetComponent<Text>().text = $"<color=#9e9ead>0</color>/200";
|
|
|
|
|
|
|
|
|
|
|
|
LoadUserInfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
public override void Show()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Show();
|
|
|
|
|
|
paths.Clear();
|
|
|
|
|
|
for (int i = 0; i < images.childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
images.GetChild(i).GetComponent<Image>().sprite = plus;
|
2021-04-26 16:25:52 +08:00
|
|
|
|
images.GetChild(i).Find("close").gameObject.SetActive(false);
|
2021-04-21 16:16:14 +08:00
|
|
|
|
//if (i > 0) SetImageActive(img, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
content.Text = "";
|
|
|
|
|
|
LoadUserInfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
void SetImageActive(Transform img, bool b)
|
|
|
|
|
|
{
|
|
|
|
|
|
img.GetComponent<Button>().interactable = b;
|
|
|
|
|
|
img.GetComponent<Button>().enabled = b;
|
|
|
|
|
|
img.GetComponent<CanvasGroup>().alpha = Convert.ToInt32(b);
|
|
|
|
|
|
}
|
|
|
|
|
|
void LoadUserInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (App.CurrentUser == null) return;
|
|
|
|
|
|
main.Find("Email").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Phone;
|
2021-04-27 18:26:30 +08:00
|
|
|
|
main.Find("ID").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Id.ToString("#000000");
|
2021-04-21 16:16:14 +08:00
|
|
|
|
main.Find("Version").Find("Value").Find("Text").GetComponent<Text>().text = App.AppVersion;
|
|
|
|
|
|
main.Find("Time").Find("Value").Find("Text").GetComponent<Text>().text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AddImage(BaseEventData e,int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
var self = ((PointerEventData)e).pointerEnter;
|
|
|
|
|
|
Utils.OpenFile((path) =>
|
|
|
|
|
|
{
|
2021-04-26 16:25:52 +08:00
|
|
|
|
if (paths.ContainsValue(path))
|
|
|
|
|
|
{
|
2021-04-28 15:21:06 +08:00
|
|
|
|
Utils.showToast(gameObject, "Picture already exists, please choose another picture");//图片已存在,请选择其他图片
|
2021-04-26 16:25:52 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2021-04-21 16:16:14 +08:00
|
|
|
|
self.GetComponent<Image>().sprite = Utils.PngToSprite(path, 110, 110);
|
|
|
|
|
|
self.transform.Find("close").gameObject.SetActive(true);
|
|
|
|
|
|
paths[self.name] = path;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
void DelImage(BaseEventData e,Transform self,int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
self.GetComponent<Image>().sprite = plus;
|
|
|
|
|
|
paths.Remove(self.name);
|
|
|
|
|
|
self.Find("close").gameObject.SetActive(false);
|
|
|
|
|
|
//self.SetSiblingIndex(paths.Count);
|
|
|
|
|
|
//if (paths.Count < 2)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// SetImageActive(images.GetChild(paths.Count+1), false);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//for(int i = index)
|
|
|
|
|
|
//if (index < 2) SetImageActive(images.GetChild(index + 1), false);
|
|
|
|
|
|
//SetImageActive(images.GetChild(index), false);
|
|
|
|
|
|
}
|
|
|
|
|
|
async void Submit()
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = paths.OrderBy(x => x.Key).Select(x => x.Value).ToList();
|
|
|
|
|
|
//var list = images.GetComponents<Transform>().Where(x => x.tag != null && x.tag != "Untagged").Select(x=>x.tag).ToList();
|
|
|
|
|
|
var r = await ConfigHelper.userApi.AddFeedBack(content.Text, list);
|
|
|
|
|
|
if (!r.result)
|
|
|
|
|
|
{
|
|
|
|
|
|
Utils.showToast(gameObject, r.errMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-04-28 15:21:06 +08:00
|
|
|
|
Utils.showToast(gameObject, "Submitted", type: 1);//已提交
|
2021-04-29 23:45:29 +08:00
|
|
|
|
Close();
|
2021-04-21 16:16:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|