| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | //成交记录 |
| | | namespace Snxxz.UI { |
| | | namespace Snxxz.UI
|
| | | { |
| | | |
| | | public class TransactionRecordWin : Window |
| | | { |
| | | |
| | | {
|
| | | [SerializeField] ScrollerController m_ScrollerController;
|
| | | [SerializeField] ScrollerController m_ScrollerControllerType; |
| | | [SerializeField] Button m_ClosButton; |
| | | [SerializeField] GameObject m_TypeTip; |
| | | [SerializeField] Text m_TypeText; |
| | | [SerializeField] Button m_TypeButon;
|
| | | [SerializeField] GameObject m_TextObj;
|
| | | AuctionInquiryModel model { get { return ModelCenter.Instance.GetModel<AuctionInquiryModel>(); } }
|
| | | AuctionHelpModel auctionHelpModel { get { return ModelCenter.Instance.GetModel<AuctionHelpModel>(); } } |
| | | private List<AuctionItemClass> AuctionRecordList = new List<AuctionItemClass>(); |
| | | int AuctionType = 0; |
| | | #region Built-in |
| | | protected override void BindController() |
| | | { |
| | | {
|
| | | m_ScrollerController.OnRefreshCell += OnRefreshGridCell; |
| | | m_ScrollerControllerType.OnRefreshCell += OnRefreshGridCellType;
|
| | | m_ScrollerController.lockType = EnhanceLockType.KeepVertical; |
| | | AuctionInquiry.Instance.SendQueryAuctionRecord();//查询拍卖记录 |
| | | } |
| | | |
| | | protected override void AddListeners() |
| | | { |
| | | m_ClosButton.AddListener(() =>
|
| | | {
|
| | | CloseImmediately();
|
| | | }); |
| | | m_TypeButon.AddListener(() =>
|
| | | {
|
| | | if (!m_TypeTip.activeSelf)
|
| | | {
|
| | | m_TypeTip.SetActive(true);
|
| | | }
|
| | | }); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | AuctionType = 0; |
| | | if (m_TypeTip.activeSelf)
|
| | | {
|
| | | m_TypeTip.SetActive(false);
|
| | | } |
| | | m_TypeText.text = GetTextName(AuctionType); |
| | | OnCreateGridTypeCell(m_ScrollerControllerType); |
| | | OnCreateGridCell(m_ScrollerController); |
| | | } |
| | | |
| | | protected override void OnAfterOpen() |
| | | { |
| | | model.PlayerAuctionRecordUpdate += PlayerAuctionRecordUpdate; |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | } |
| | | |
| | | {
|
| | | model.PlayerAuctionRecordUpdate -= PlayerAuctionRecordUpdate; |
| | | }
|
| | |
|
| | |
|
| | |
|
| | | protected override void OnAfterClose() |
| | | { |
| | | } |
| | | }
|
| | | #endregion |
| | | |
| | | private void PlayerAuctionRecordUpdate()
|
| | | {
|
| | | OnCreateGridCell(m_ScrollerController);
|
| | | } |
| | | private void OnCreateGridCell(ScrollerController gridCtrl)
|
| | | {
|
| | | GetAuctionRecordList();
|
| | | if (AuctionRecordList.Count > 0)
|
| | | {
|
| | | m_TextObj.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_TextObj.SetActive(true);
|
| | | }
|
| | | gridCtrl.Refresh();
|
| | | for (int i = 0; i < AuctionRecordList.Count; i++)
|
| | | {
|
| | | gridCtrl.AddCell(ScrollerDataType.Header, i);
|
| | | }
|
| | | gridCtrl.Restart();
|
| | | } |
| | | private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | int index = cell.index;
|
| | | var auctionRecord = AuctionRecordList[index];
|
| | | var itemConfig = ItemConfig.Get(auctionRecord.ItemID);
|
| | | if (itemConfig == null)
|
| | | {
|
| | | DebugEx.LogError("物品表没有找到该物品,物品ID为" + auctionRecord.ItemID);
|
| | | return;
|
| | | }
|
| | | ItemCell itemCell = cell.transform.Find("ItemCell1").GetComponent<ItemCell>();
|
| | | Text textName = cell.transform.Find("ItemName").GetComponent<Text>();
|
| | | Text transactionStatusText = cell.transform.Find("TransactionStatusText").GetComponent<Text>();
|
| | | Text timeText = cell.transform.Find("TimeText").GetComponent<Text>();
|
| | | ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, true, (ulong)1, itemConfig.BindType);
|
| | | itemCell.Init(cellModel);
|
| | | textName.text = itemConfig.ItemName;
|
| | | transactionStatusText.text = GetRecordResultName(auctionRecord.RecordResult);
|
| | | timeText.text = auctionRecord.TimeStr;
|
| | | }
|
| | |
|
| | | 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;
|
| | | 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 = "我的拍品";
|
| | | break;
|
| | | case 1:
|
| | | str = "仙盟拍品";
|
| | | break;
|
| | | case 2:
|
| | | str = "我的竞拍";
|
| | | break;
|
| | | }
|
| | | return str;
|
| | | } |
| | | |
| | | private string GetRecordResultName(int index)
|
| | | {
|
| | | string str = string.Empty;
|
| | | switch (index)
|
| | | {
|
| | | case 0:
|
| | | str = "流拍";
|
| | | break;
|
| | | case 1:
|
| | | str = "拍卖成交";
|
| | | break;
|
| | | case 2:
|
| | | str = "回收";
|
| | | break;
|
| | | case 3:
|
| | | str = "竞价成功";
|
| | | break;
|
| | | case 4:
|
| | | str = "竞价失败";
|
| | | break;
|
| | |
|
| | | }
|
| | | return str;
|
| | | } |
| | | private void GetAuctionRecordList()
|
| | | {
|
| | | AuctionRecordList.Clear();
|
| | | foreach (var value in model.PlayerAuctionRecordDic.Values)
|
| | | {
|
| | | if (value.RecordType == AuctionType)
|
| | | {
|
| | | AuctionRecordList.Add(value);
|
| | | }
|
| | | }
|
| | | } |
| | | } |
| | | |
| | | } |