This commit is contained in:
陈向学 2024-11-22 09:42:51 +08:00
parent 2b21c2f469
commit 617cc9d161
1 changed files with 40 additions and 14 deletions

View File

@ -14,8 +14,8 @@ public class WorkPlacePanel : MonoBehaviour
public void Init(string custCodes, WorkPlaceItem workPlaceItem)
{
this.workPlaceItem = workPlaceItem;
InitModel(custCodes);
rectTransform = GetComponent<RectTransform>();
InitModel(custCodes);
}
/// <summary>
/// 生成企业图标
@ -31,10 +31,11 @@ public class WorkPlacePanel : MonoBehaviour
//获取关区下所有企业信息
//string url = "http://" + FirstPanel.instance.serverIP + ":4000/api/Corporation/GetAllPosition?customCodes=" + custCodes;
string url = "http://" + FirstPanel.instance.serverIP + ":4000/api/GetModelList?PageIndex=1&PageSize=999999";
string url = "http://" + FirstPanel.instance.serverIP + ":4000/api/GetModelVersionList";
Debug.Log("获取企业模型:" + url);
StartCoroutine(FirstPanel.instance.CallGet(url, (isok, result) =>
{
Debug.Log("获取企业模型返回 "+ result);
if (isok)
{
//生成企业模型
@ -45,7 +46,10 @@ public class WorkPlacePanel : MonoBehaviour
foreach (JsonData item in tmp)
{
erprise_model_version v = JsonMapper.ToObject<erprise_model_version>(item.ToJson());
list.Add(v);
if (!string.IsNullOrEmpty(v.MapLatitude) && !string.IsNullOrEmpty(v.MapLongitude))
{
list.Add(v);
}
}
//本关区的
@ -75,6 +79,20 @@ public class WorkPlacePanel : MonoBehaviour
Application.ExternalCall("ClickCustom", JsonMapper.ToJson(showAll));
Debug.Log("调前端显示企业" + custCodes);
//福清默认放大
if (workPlaceItem.workPlaceName == "驻福清办事处")
{
SetPos(new Vector2(124.3824f, 583.4997f));
SetScale(3);
}
else
{
SetPos(Vector2.zero);
SetScale(1);
}
#if UNITY_EDITOR
Debug.Log(JsonMapper.ToJson(showAll));
#endif
@ -91,16 +109,7 @@ public class WorkPlacePanel : MonoBehaviour
PointerEventData evnetdata = (PointerEventData)baseEvent;
if (evnetdata.button == PointerEventData.InputButton.Left)
{
rectTransform.anchoredPosition += evnetdata.delta;
//¸üÐÂ×ø±ê
List<erprise_model_version> list = new List<erprise_model_version>();
transform.GetComponentsInChildren<ModelItem>(true).ToList().ForEach(a =>
{
a.SetNowPostion();
list.Add(a.modelData);
});
Application.ExternalCall("OnBanShiChuChange", JsonMapper.ToJson(list));
SetPos(rectTransform.anchoredPosition + evnetdata.delta);
}
}
public void OnScorll(BaseEventData baseEvent)
@ -108,7 +117,24 @@ public class WorkPlacePanel : MonoBehaviour
PointerEventData evnetdata = (PointerEventData)baseEvent;
float value = (rectTransform.localScale.x + evnetdata.scrollDelta.y* 0.1f);
value = Mathf.Clamp(value, 1f, 3f);
rectTransform.localScale=new Vector3(value, value, value);
SetScale(value);
}
private void SetPos(Vector2 anchoredPosition)
{
rectTransform.anchoredPosition = anchoredPosition;
//更新坐标
List<erprise_model_version> list = new List<erprise_model_version>();
transform.GetComponentsInChildren<ModelItem>(true).ToList().ForEach(a =>
{
a.SetNowPostion();
list.Add(a.modelData);
});
Application.ExternalCall("OnBanShiChuChange", JsonMapper.ToJson(list));
}
private void SetScale(float scale)
{
rectTransform.localScale = new Vector3(scale, scale, scale);
//更新坐标
List<erprise_model_version> list = new List<erprise_model_version>();