import { DispatcherManager } from "../utils/DispatcherManager";
import CpaEvent from "./CpaEvent";
import { FYHD_Sdk } from "../WXSDK/FYHD_Sdk";

export class recommendPan
{
    constructor(data:Object)
    {
        this.game_flg = data["game_flg"];
        this.game_id = data["game_id"];
        this.game_name = data["game_name"];
        this.id = data["id"];
        this.location_flg = data["location_flg"];
        this.location_id = data["location_id"];
        this.location_name = data["location_name"];
        this.matter_type = data["matter_type"];
    }
    game_flg:string;
    game_id:number;
    game_name:string;
    id:string;
    location_flg:string;
    location_id:number;
    location_name:string;
    matter_type:string;
}

export class Recommend
{
    constructor()
    {
        Recommend.InitData();
    }

    static getdata = false;
    static InitData()
    {
        Recommend.cainixihuanData = Recommend.GetCaiNiXiaHuanDatas();
        Recommend.jiesuanData = Recommend.GetJIeSuanDatas();
        Recommend.gdyxData = Recommend.GetGDYXDatas();
        Recommend.baokuanyouxiData = Recommend.GetBaoKuanYouXiDatas();
        Recommend.moreData = Recommend.GetMoreDatas();
        for(var key in FYHD_Sdk.pushData)
        {
            Recommend.recommendDic[FYHD_Sdk.pushData[key].location_flg]  = new recommendPan(FYHD_Sdk.pushData[key]);
        }
        Recommend.getdata = true;
        DispatcherManager.dispatchEvent( CpaEvent.YQHomeData );
        console.log("互推数据初始化recommend--------------");
    }

    static recommendDic = {};
    static cainixihuanData:RecommendItem[] = [];
    static baokuanyouxiData:RecommendItem[] = [];
    static gdyxData:RecommendItem[] = [];
    static jiesuanData:RecommendItem[] = [];
    static moreData:RecommendItem[] = [];


    static GetSSDatas():RecommendItem[]
    {
        var items:RecommendItem[] = [];
        if(!FYHD_Sdk.pushData)return items;
        for(var i = 0;i < FYHD_Sdk.pushData.length;i++)
        {
            items.push(new RecommendItem(FYHD_Sdk.pushData[i]));
        }
        return items;
    }

    static GetCaiNiXiaHuanDatas():RecommendItem[]
    {
        var items:RecommendItem[] = [];
        if(!FYHD_Sdk.pushData)return items;
        for(var i = 0;i < FYHD_Sdk.pushData.length;i++)
        {
            items.push(new RecommendItem(FYHD_Sdk.pushData[i]));
        }
        return items;
    }
    static GetMoreDatas():RecommendItem[]
    {
        var items:RecommendItem[] = [];
        if(!FYHD_Sdk.pushData)return items;
        for(var i = 0;i < FYHD_Sdk.pushData.length;i++)
        {
            items.push(new RecommendItem(FYHD_Sdk.pushData[i]));
        }
        return items;
    }

    static GetBaoKuanYouXiDatas():RecommendItem[]
    {
        var items:RecommendItem[] = [];
        if(!FYHD_Sdk.pushData)return items;
        for(var i = 0;i < FYHD_Sdk.pushData.length;i++)
        { 
            items.push(new RecommendItem(FYHD_Sdk.pushData[i]));
        }
        return items;
    }

    static GetJIeSuanDatas():RecommendItem[]
    {
        var items:RecommendItem[] = [];
        if(!FYHD_Sdk.pushData)return items;
        for(var i = 0;i < FYHD_Sdk.pushData.length;i++)
        {
            items.push(new RecommendItem(FYHD_Sdk.pushData[i]));
        }
        return items;
    }

    static GetGDYXDatas():RecommendItem[]
    {
        var items:RecommendItem[] = [];
        if(!FYHD_Sdk.pushData)return items;
        for(var i = 0;i < FYHD_Sdk.pushData.length;i++)
        {
            items.push(new RecommendItem(FYHD_Sdk.pushData[i]));
        }
        return items;
    }
}

export class RecommendItem
{
    constructor(Data:Object)
    {
        this.icon = Data["icon"];
        this.to_appid = Data["to_appid"];
        this.togame_name = Data["togame_name"];
        this.jump_path = Data["jump_path"];
        this.jump_type = Data["jump_type"];
        this.panel = Data["panel"];
        this.qrcode = Data["qrcode"];
    }
    icon:string;
    to_appid:string;
    togame_name:string;
    jump_path:string;
    jump_type:number;
    panel:number;
    qrcode:string;
}


export default class RecommendView
{
    
    constructor() { 
        
     }
}