import { PanelChildControl } from "../Control/PanelChildControl";
import { RecommendItem } from "./RecommendView";
import CpaItem from "./CpaItem";
import { ViewManager } from "../View/ViewManager";
import { GuangGao } from "../WXSDK/GuangGao";
import { PanelBaseControl } from "../Control/PanelBaseControl";

export default class FriendInviteView extends PanelBaseControl {
    static key:string = "FriendInviteView";
    constructor(){
        super("main","friendinvite");
    }

    private _nowList:RecommendItem[];
    private playertouxiang:fairygui.GLoader;
    private playername:fairygui.GTextField;
    private desc:fairygui.GTextField;
    private no:fairygui.GLoader;
    private yes:fairygui.GLoader;
    private gameicon:fairygui.GLoader;
    private gamename:fairygui.GTextField;
    //好友信息
    private friendinfo:any[] = [];

    protected onInit():void
    {
        this.initView();
        this.initEvent();
    }

    protected initView():void
    {
        this.GetFriendInfo();
        GuangGao.OpenBanner();
        // this.list_0.setVirtual();
        // this.list_0.itemRenderer = Laya.Handler.create( this,this.itemrenderlist,null,false );
    }
    
    protected initEvent():void
    {
        this.AddEventByType(this.no,Laya.Event.MOUSE_DOWN,this,this.ClickNo);
        this.AddEventByType(this.yes,Laya.Event.MOUSE_DOWN,this,this.ClickYes);
    //     this.AddEventByType( this.list_0,Laya.Event.MOUSE_DOWN,this,this.downclick );
    //     this.AddEventByType( this.list_0,Laya.Event.MOUSE_UP,this,this.upclick );
    //     this.AddEventByType( this.list_0,Laya.Event.MOUSE_OUT,this,this.upclick );
    }
    ClickNo(){
        ViewManager.Instance.close( FriendInviteView );
    }
    ClickYes(){

    }

    public dispose():void
    {
        // TimerService.Instance.removeUpdateTarget(this);
        super.dispose();
    }

    //获取好友信息
    GetFriendInfo(){
        Laya.Browser.window.wx.getPotentialFriendList({
            success(res){
                this.friendinfo = res;
                console.log("获取好友信息成功",res);
            },
            fail(e){
                console.log("获取好友信息失败",e);
            }
        })
    }
}