using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GCGame.Table;
using Games.ChatHistory;
using UnityEngine.UI;
using System;

// 运营活动相关的跳转链接
public class ChatLinkActUI : ChatLinkName
{
    // 因为vip公用此脚本,设Vip的入口ID和活动为 -1
    private int enhanceID;
    private int actID;

    public override void SetLinkBySendStr(Text text, ChatHistoryItem chatHistory, string linkStr, string[] linkParams)
    {
        StrSend = linkStr;
        StrInput = linkStr;

        if (linkParams.Length == 1 && Convert.ToInt32(linkParams[0]) == (int)ChatLinkType.Act_PRIVILEGEVIP)
        {
            // vip
            StrShow = StrDictionary.GetClientDictionaryString("#{79318}");
            enhanceID = -1;
            actID = -1;
        }
        else if (linkParams.Length == 1 && Convert.ToInt32(linkParams[0]) == (int)ChatLinkType.Act_Vip)
        {
            StrShow = StrDictionary.GetClientDictionaryString("#{79318}");
            enhanceID = -2;
            actID = -2;
        }
        else if (linkParams.Length == 3 && Convert.ToInt32(linkParams[0]) == (int)ChatLinkType.Act_Gift)
        {
            // 运营活动
            enhanceID = Convert.ToInt32(linkParams[1]);
            actID = Convert.ToInt32(linkParams[2]);
        }
        else
        {
            return;
        }

        switch (actID)
        {
            //79317	系统滚屏	    【我要领取】
            //79318   系统滚屏    【我要激活】
            //79319   系统滚屏    【我要购买】
            case 134://超值受宠
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case -1:    // 特权vip
                StrShow = StrDictionary.GetClientDictionaryString("#{79318}");
                break;
            case 132:   //零元购
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 250:   // 月卡
                StrShow = StrDictionary.GetClientDictionaryString("#{79319}");
                break;
            case 140:   //投资理财
                StrShow = StrDictionary.GetClientDictionaryString("#{79319}");
                break;
            case 101:   //开服累充
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 42:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 1042:  // 材料领不停
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 40:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 1040:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 120:   // 每日首冲
            case 1120:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 121:   // 每日累充
            case 1121:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 41:    // 单笔首充
            case 1041:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 60:    // 超值礼包
            case 1060:
                StrShow = StrDictionary.GetClientDictionaryString("#{79319}");
                break;
            case 61:    // 连充特惠
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            case 102:    // 开服连充
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
            default:
                StrShow = StrDictionary.GetClientDictionaryString("#{79317}");
                break;
        }
    }

    protected override void LinkClick(int linkindex)
    {
        switch(enhanceID)
        {
            case -2:
                PrivilegeVipRoot.DefaultPageIndex = 1;
                YuanBaoShopLogic.OpenVipPage();
                break;
            // vip 特权
            case -1:
                YuanBaoShopLogic.OpenVipPage();
                break;
            case 0:
                // 福利大厅 有分页
                UIManager.ShowUI(UIInfo.WelfareRoot,
                (bool bSuccess, object param) =>
                {
                    if (bSuccess)
                    {
                        // 等级礼包NodeID = 203
                        WelfareRootCtr.Instance.OpenWith(actID);
                    }
                }); break;
            case 1:
                // 进阶特惠 有分页
                if (MarketingActsRoot.Instance() != null)
                {
                    if (MarketingActsRoot.Instance().ShowActById(enhanceID))
                    {
                        MarketingWinRootCS.OpenWithAct = actID;
                    }
                }
                break;
            case 5:
                // 开服活动 有分页
                if (MarketingActsRoot.Instance() != null)
                {
                    if(MarketingActsRoot.Instance().ShowActById(enhanceID))
                    {
                        OpenServiceRootCS.OpenWithAct = actID;
                    }
                }
                break;
            case 6:
                // 每日首冲/累充 有分页
                if (MarketingActsRoot.Instance() != null)
                {
                    if(MarketingActsRoot.Instance().ShowActById(enhanceID))
                    {
                        DailyRechargeRoot.OpenWithAct = actID;
                    }
                }
                break;
            default:
                // 其他无分页活动
                if (MarketingActsRoot.Instance() != null)
                {
                    MarketingActsRoot.Instance().ShowActById(enhanceID);
                }
                break;
        }
    }
}