//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, March 04, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//成交记录
|
namespace vnxbqy.UI
|
{
|
|
public class TransactionRecordWin : Window ,SecondWindowInterface
|
{
|
[SerializeField] ScrollerController m_ScrollerController;
|
[SerializeField] ScrollerController m_ScrollerControllerType;
|
[SerializeField] GameObject m_TypeTip;
|
[SerializeField] Text m_TypeText;
|
[SerializeField] Button m_TypeButon;
|
[SerializeField] GameObject m_TextObj;
|
|
AuctionModel model { get { return ModelCenter.Instance.GetModel<AuctionModel>(); } }
|
|
List<string> itemGuids = new List<string>();
|
|
int AuctionType = 0;
|
int MaxCount = 0;
|
|
#region Built-in
|
public Button close { get; set; }
|
|
protected override void BindController()
|
{
|
if (this is SecondWindowInterface)
|
{
|
var frame = this.GetComponentInChildren<SecondFrameLoader2>();
|
frame.Create();
|
close = frame.GetComponentInChildren<Button>();
|
}
|
}
|
|
protected override void AddListeners()
|
{
|
m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
|
m_ScrollerControllerType.OnRefreshCell += OnRefreshGridCellType;
|
m_ScrollerController.lockType = EnhanceLockType.KeepVertical;
|
var count = FuncConfigConfig.Get("AuctionHouse").Numerical3;
|
MaxCount = int.Parse(count);
|
|
close.AddListener(() =>
|
{
|
CloseImmediately();
|
});
|
m_TypeButon.AddListener(() =>
|
{
|
if (!m_TypeTip.activeSelf)
|
{
|
m_TypeTip.SetActive(true);
|
}
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
AuctionType = 0;
|
AuctionInquiry.Instance.SendQueryAuctionRecord(AuctionType);//查询拍卖记录
|
if (m_TypeTip.activeSelf)
|
{
|
m_TypeTip.SetActive(false);
|
}
|
m_TypeText.text = GetTextName(AuctionType);
|
OnCreateGridTypeCell(m_ScrollerControllerType);
|
OnCreateGridCell(m_ScrollerController);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
model.auctionRecordRefresh += PlayerAuctionRecordUpdate;
|
}
|
|
protected override void OnPreClose()
|
{
|
model.auctionRecordRefresh -= PlayerAuctionRecordUpdate;
|
}
|
|
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
private void PlayerAuctionRecordUpdate()
|
{
|
OnCreateGridCell(m_ScrollerController);
|
}
|
private void OnCreateGridCell(ScrollerController gridCtrl)
|
{
|
GetAuctionRecordList();
|
if (itemGuids.Count > 0)
|
{
|
m_TextObj.SetActive(false);
|
}
|
else
|
{
|
m_TextObj.SetActive(true);
|
}
|
gridCtrl.Refresh();
|
for (int i = 0; i < itemGuids.Count; i++)
|
{
|
if (i < MaxCount)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
}
|
gridCtrl.Restart();
|
}
|
private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
{
|
int index = cell.index;
|
var guid = itemGuids[index];
|
|
AuctionItem item;
|
if (!model.TryGetAuctionRecordItem(guid, out item))
|
{
|
return;
|
}
|
|
var itemConfig = ItemConfig.Get(item.itemId);
|
|
ItemCell itemCell = cell.transform.Find("ItemCell1").GetComponent<ItemCell>();
|
Text textName = cell.transform.Find("ItemName").GetComponent<Text>();
|
RichText transactionStatusText = cell.transform.Find("TransactionStatusText").GetComponent<RichText>();
|
Text timeText = cell.transform.Find("TimeText").GetComponent<Text>();
|
ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, true, (ulong)item.itemCount);
|
|
GameObject SuccessfulBiddingObj = cell.transform.Find("SuccessfulBiddingObj").gameObject;//竞拍成功(竞拍成功)
|
TextEx SuccessfulBiddingText = cell.transform.Find("SuccessfulBiddingObj/SuccessfulBiddingText").GetComponent<TextEx>();
|
Text JadeMoney = cell.transform.Find("SuccessfulBiddingObj/JadeMoney").GetComponent<Text>();
|
|
GameObject AuctionFailedObj = cell.transform.Find("AuctionFailedObj").gameObject;//竞拍失败
|
Text JadeMoney_1 = cell.transform.Find("AuctionFailedObj/JadeMoney").GetComponent<Text>();
|
switch (item.recordResult)
|
{
|
case 0://流拍
|
transactionStatusText.SetActive(true);
|
SuccessfulBiddingObj.SetActive(false);
|
AuctionFailedObj.SetActive(false);
|
transactionStatusText.text = Language.Get("PMH_11");
|
break;
|
case 1://拍卖成交(竞拍成功)
|
SuccessfulBiddingObj.SetActive(true);
|
transactionStatusText.SetActive(false);
|
AuctionFailedObj.SetActive(false);
|
SuccessfulBiddingText.text = Language.Get("PMH_15");
|
JadeMoney.text = item.biddingPrice.ToString();
|
break;
|
case 2://回收
|
transactionStatusText.SetActive(true);
|
SuccessfulBiddingObj.SetActive(false);
|
AuctionFailedObj.SetActive(false);
|
transactionStatusText.text = Language.Get("PMH_14");
|
break;
|
case 3://竞价成功
|
SuccessfulBiddingObj.SetActive(true);
|
transactionStatusText.SetActive(false);
|
AuctionFailedObj.SetActive(false);
|
string strName = string.Empty;
|
SuccessfulBiddingText.text = Language.Get("PMH_13");
|
JadeMoney.text = item.biddingPrice.ToString();
|
break;
|
case 4://竞价失败
|
AuctionFailedObj.SetActive(true);
|
SuccessfulBiddingObj.SetActive(false);
|
transactionStatusText.SetActive(false);
|
JadeMoney_1.text = item.biddingPrice.ToString();
|
break;
|
case 5://仙盟流拍到全服
|
transactionStatusText.SetActive(true);
|
SuccessfulBiddingObj.SetActive(false);
|
AuctionFailedObj.SetActive(false);
|
transactionStatusText.text = Language.Get("PMH_12");
|
break;
|
case 6://下架
|
transactionStatusText.SetActive(true);
|
SuccessfulBiddingObj.SetActive(false);
|
AuctionFailedObj.SetActive(false);
|
transactionStatusText.text = Language.Get("PMH_116");
|
JadeMoney.text = item.biddingPrice.ToString();
|
break;
|
}
|
|
itemCell.Init(cellModel);
|
itemCell.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemConfig.ID);
|
});
|
textName.text = UIHelper.GetItemName(itemConfig.ID, true);
|
textName.color = UIHelper.GetUIColor(itemConfig.ItemColor, true);
|
timeText.text = item.putAwayTime.ToString("dd-MM-yyyy HH:mm:ss");
|
}
|
|
private void OnCreateGridTypeCell(ScrollerController gridCtrl)
|
{
|
|
gridCtrl.Refresh();
|
for (int i = 0; i < 3; i++)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
gridCtrl.Restart();
|
}
|
private void OnRefreshGridCellType(ScrollerDataType type, CellView cell)
|
{
|
int idnex = cell.index;
|
Text textName = cell.transform.Find("Text").GetComponent<Text>();
|
Button button = cell.GetComponent<Button>();
|
textName.text = GetTextName(idnex);
|
button.SetListener(() =>
|
{
|
if (idnex != AuctionType)
|
{
|
AuctionType = idnex;
|
AuctionInquiry.Instance.SendQueryAuctionRecord(idnex);//查询拍卖记录
|
m_TypeTip.SetActive(false);
|
OnCreateGridCell(m_ScrollerController);
|
m_TypeText.text = GetTextName(AuctionType);
|
}
|
});
|
}
|
|
private string GetTextName(int index)
|
{
|
string str = string.Empty;
|
switch (index)
|
{
|
case 0:
|
str = Language.Get("PMH_08");
|
break;
|
case 1:
|
str = Language.Get("PMH_09");
|
break;
|
case 2:
|
str = Language.Get("PMH_10");
|
break;
|
}
|
return str;
|
}
|
|
private void GetAuctionRecordList()
|
{
|
this.itemGuids.Clear();
|
var itemGuids = model.GetAuctionRecords();
|
foreach (var guid in itemGuids)
|
{
|
AuctionItem item;
|
if (model.TryGetAuctionRecordItem(guid, out item))
|
{
|
if (item.recordType == AuctionType)
|
{
|
this.itemGuids.Add(guid);
|
}
|
}
|
|
}
|
this.itemGuids.Sort(Compare);
|
}
|
|
int Compare(string x, string y)
|
{
|
AuctionItem lhs;
|
AuctionItem rhs;
|
if (model.TryGetAuctionRecordItem(x, out lhs)
|
&& model.TryGetAuctionRecordItem(y, out rhs))
|
{
|
return -lhs.putAwayTime.CompareTo(rhs.putAwayTime);
|
}
|
return 1;
|
}
|
}
|
|
}
|
|
|
|
|