少年修仙传客户端代码仓库
client_Zxw
2019-03-04 a9fde76db412c726d78e431f063f4796b661d036
6251 子 【开发】【2.0】拍卖行开发单
4个文件已修改
187 ■■■■■ 已修改文件
System/Auction/AuctionHouseWin.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Auction/AuctionInquiryModel.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Auction/FullServiceAuctionWin.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Auction/TransactionRecordWin.cs 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Auction/AuctionHouseWin.cs
@@ -98,7 +98,7 @@
        private void OnClickTransactionRecordButton()
        {
            WindowCenter.Instance.Open<TransactionRecordWin>();
        }
        private void CloseChild()
        {
System/Auction/AuctionInquiryModel.cs
@@ -49,7 +49,7 @@
       
        public Dictionary<string, AuctionItemClass> PlayerAuctionRecordDic = new Dictionary<string, AuctionItemClass>();//拍卖行玩家拍卖记录
        public event Action PlayerAuctionRecordUpdate;
        public Dictionary<string, AddAuctionItemInfoClass> AddAuctionItemInfoDic = new Dictionary<string, AddAuctionItemInfoClass>();//关注的拍品的上架提醒(弹框显示)
        public event Action AddAuctionItemInfoUpdate;
@@ -151,6 +151,7 @@
            }
        }
        public event Action PlayerAuctionRecordUpdate;//拍卖记录新增拍卖记录
        public void PlayerAuctionRecord(HB503_tagGCPlayerAuctionRecordInfo info)//拍卖行玩家拍卖记录
        {
            for (int i = 0; i < info.Count; i++)
System/Auction/FullServiceAuctionWin.cs
@@ -87,7 +87,7 @@
        }
        private void BiddingItemInfoUpdate()
        {
            throw new NotImplementedException();
        }
        private void OnClickJobTipBtn()
        {
System/Auction/TransactionRecordWin.cs
@@ -8,38 +8,200 @@
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);
                }
            }
        }
    }
}