From 63eba1a8a153a39724b86e60a66090a225251291 Mon Sep 17 00:00:00 2001
From: Client_PangDeRong <593317293@qq.com>
Date: 星期五, 12 十月 2018 15:22:57 +0800
Subject: [PATCH] 4074 【前端】限时抢购开发
---
System/OpenServerActivity/FlashSaleTimeCell.cs | 72 +++++++++++++++++++++++++++++++++--
1 files changed, 67 insertions(+), 5 deletions(-)
diff --git a/System/OpenServerActivity/FlashSaleTimeCell.cs b/System/OpenServerActivity/FlashSaleTimeCell.cs
index 468eebd..be25e1f 100644
--- a/System/OpenServerActivity/FlashSaleTimeCell.cs
+++ b/System/OpenServerActivity/FlashSaleTimeCell.cs
@@ -1,22 +1,84 @@
锘縰sing UnityEngine;
using UnityEngine.UI;
using EnhancedUI.EnhancedScroller;
+using System;
namespace Snxxz.UI
{
public class FlashSaleTimeCell : ScrollerUI
{
[SerializeField] Text remainText;
-
- FlashRushToBuyModel rushToBuyModel { get { return ModelCenter.Instance.GetModel<FlashRushToBuyModel>(); } }
+ [SerializeField] Button saleTimeBtn;
+ [SerializeField] GameObject unSelectImg;
+ [SerializeField] GameObject selectImg;
+ FlashRushToBuyModel rushToBuyModel { get { return ModelCenter.Instance.GetModel<FlashRushToBuyModel>(); } }
+ OperationFlashRushToBuy operation;
+ int dayIndex = -1;
+ int timeIndex = -1;
+ private void Awake()
+ {
+ saleTimeBtn.AddListener(() =>
+ {
+ rushToBuyModel.UpdateSelectFlashSaleTime(dayIndex, timeIndex);
+ });
+ }
+ private void OnEnable()
+ {
+ GlobalTimeEvent.Instance.secondEvent += UpdateBuyState;
+ }
+ private void OnDisable()
+ {
+ GlobalTimeEvent.Instance.secondEvent -= UpdateBuyState;
+ }
public override void Refresh(CellView cell)
{
- var operation = rushToBuyModel.GetOperationFlashRushToBuy();
-
+ operation = rushToBuyModel.GetOperationFlashRushToBuy();
+ dayIndex = -1;
+ timeIndex = -1;
if (operation == null) return;
-
+ int days = operation.totalDays;
+ dayIndex = cell.index/(operation.flashShops.Count / days);
+ timeIndex = cell.index % (operation.flashShops.Count / days);
+ if(dayIndex == rushToBuyModel.presentFlashShop.dayIndex
+ && timeIndex == rushToBuyModel.presentFlashShop.timeIndex)
+ {
+ selectImg.SetActive(true);
+ unSelectImg.SetActive(false);
+ }
+ else
+ {
+ selectImg.SetActive(false);
+ unSelectImg.SetActive(true);
+ }
+ UpdateBuyState();
+ }
+
+ public void UpdateBuyState()
+ {
+ if (operation == null) return;
+
+ int seconds = 0;
+ OperationTime operationTime = operation.times[timeIndex];
+ var date = operation.startDate;
+ int buyState = operation.GetBuyTimeState(TimeUtility.ServerNow, dayIndex, timeIndex, out seconds);
+ switch (buyState)
+ {
+ case -1:
+ this.gameObject.SetActive(true);
+ string timeStr = operation.ToDisplayBuyTime(date.month, dayIndex + date.day, operationTime.startHour, operationTime.startMinute);
+ remainText.text = StringUtility.Contact(timeStr, "寮�鎶�");
+ break;
+ case 0:
+ this.gameObject.SetActive(true);
+ remainText.text = StringUtility.Contact("绉掓潃杩涜涓�", TimeUtility.SecondsToHMS(seconds));
+ break;
+ case 1:
+ this.gameObject.SetActive(false);
+ rushToBuyModel.UpdateSelectFlashSaleTime(dayIndex, timeIndex);
+ break;
+ }
}
}
}
--
Gitblit v1.8.0