import { WXSDK } from "./WXSDK";
import { AccountManager } from "./AccountManager";
import ListItem from "../Tools/ListItem";
import { CheckMain } from "../Tools/CheckMain";


export class ZSSdk {
    static data: any;
    static isReady: boolean = false;
    static SetHuTuiList(list: Laya.List, scrol: number = 1, type: string = "") { //scrol 1:竖的  2横的
        console.log("互推数据--",ZSSdk.data);
        console.log("互推数据准备状态---",ZSSdk.isReady);
        let arr = ZSSdk.data.promotion;
        if (!arr || arr.length == 0) return;
        list.selectEnable = false;
        scrol == 1 ? list.vScrollBarSkin = "" : list.hScrollBarSkin = "";
        list.renderHandler = Laya.Handler.create(this, ZSSdk.updateItem, [type], false);
        list.array = arr;
        list.refresh();
    }
    private  static updateItem(type: string, cell: Laya.Box, index: number) {
        var aditem = cell.getComponent(ListItem) as ListItem;
        aditem.Refresh(type);
    }
    static loadData() {
        zs.sdk.loadAd((res) => {
            console.log("[LOG]互推数据");
            console.log(res);
            ZSSdk.data = res;
            console.log("拉取互推数据--",ZSSdk.data);
            ZSSdk.isReady = true;
        })
    }
    //小程序跳转
    // static navigate2Mini(data: zs.sdk.adData) {
    //     zs.sdk.navigate2Mini(data, AccountManager.Instance.curplayerData.openid, () => {
    //         WXSDK.AldEvent("成功跳转到" + data.app_title);
    //     }, () => {
    //         WXSDK.AldEvent("跳转" + data.app_title +"失败");
    //         // if(ZSSdk.CanCheat){
    //         //     if(ViewManager.Instance.showexportview == 0){
    //         //         ViewManager.Instance.OpenPopView(ViewType.ExportView);
    //         //     }
    //         // }
    //     }, () => {
    //     });
    // }
    // /**是否误触 */
    // public static get CanCheat(): boolean {
    //     var checkscence = AccountManager.Instance.curplayerData.CheckScene;
    //     if (checkscence == false) {
    //         return true;
    //     }
    //     if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
    //         || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
    //         return true;
    //     }
    //     return false;
    // }
}

