"use strict";
var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) { 
 function r() { 
 this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var DataManager_1 = require("./../../libs/tw/manager/DataManager");
var sceneTypes_1 = require("./../types/sceneTypes");
var Scene_1 = require("../views/Scene");
var panelCtrl_1 = require("../ctrls/panelCtrl");
var NetManager_1 = require("../../libs/tw/manager/NetManager");
var Loading_1 = require("../loading/Loading");
var Buried_1 = require("../../libs/tw/util/Buried");
var topLayerCtrl_1 = require("../ctrls/topLayerCtrl");
var NetName_1 = require("../../libs/tw/enum/NetName");
var ExChangeItem_1 = require("../ui/ExChangeItem");
var RunAni_1 = require("../panels/RunAni");
var GDispatcher_1 = require("../../libs/tc/util/GDispatcher");
var StartScene1 = (function (_super) {
    __extends(StartScene1, _super);
    function StartScene1(data) {
        return _super.call(this, data) || this;
    }
    Object.defineProperty(StartScene1.prototype, "skinKey", {
        get: function () { return 'StartScene'; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StartScene1.prototype, "groupName", {
        get: function () { return 'start_scene'; },
        enumerable: true,
        configurable: true
    });
    StartScene1.prototype.initEvents = function () {
        _super.prototype.initEvents.call(this);
        this.ruleBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ruleBtn, this);
        this.prizeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_prizeBtn, this);
        this.signBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_signBtn, this);
        this.skip0.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_skip0, this);
        this.skip1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_skip1, this);
        for (var i = 0; i < 7; i++) {
            this['dayGroup' + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick_dayGroup, this);
            this['dayGroup' + i].name = i;
        }
        for (var i = 0; i < 3; i++) {
            this['getBtn' + i].name = i;
            this['getBtn' + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_getBtn, this);
            this['earnBtn' + i].name = i;
            this['earnBtn' + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_earnBtn, this);
        }
        GDispatcher_1.GDispatcher.addEvent('refreshMoney', this.refreshMoney, this);
        GDispatcher_1.GDispatcher.addEvent('refreshMangheBtn', this.refreshMangheBtn, this);
    };
    StartScene1.prototype.removeEvents = function () {
        _super.prototype.removeEvents.call(this);
        this.ruleBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ruleBtn, this);
        this.prizeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_prizeBtn, this);
        this.signBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_signBtn, this);
        this.skip0.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_skip0, this);
        this.skip1.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_skip1, this);
        for (var i = 0; i < 7; i++) {
            this['dayGroup' + i].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick_dayGroup, this);
        }
        for (var i = 0; i < 3; i++) {
            this['getBtn' + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_getBtn, this);
            this['earnBtn' + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_earnBtn, this);
        }
        GDispatcher_1.GDispatcher.removeEvent('refreshMoney', this.refreshMoney);
        GDispatcher_1.GDispatcher.removeEvent('refreshMangheBtn', this.refreshMangheBtn);
    };
    StartScene1.prototype.start = function (data) {
        _super.prototype.start.call(this, data);
        this.percentHeight = 100;
    };
    StartScene1.prototype.preLoadRes = function () {
        return __awaiter(this, void 0, void 0, function () {
            var mcJson, mcImg;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: 
                    //加载背景并设置背景图片
                    // this.bgtexture = await RES.getResAsync('startBg_jpg');
                    return [4 /*yield*/, RES.loadGroup('common')];
                    case 1:
                        //加载背景并设置背景图片
                        // this.bgtexture = await RES.getResAsync('startBg_jpg');
                        _a.sent();
                        // console.log('载背景并设置背景图片mainscene');
                        return [4 /*yield*/, RES.loadGroup('runani')];
                    case 2:
                        // console.log('载背景并设置背景图片mainscene');
                        _a.sent();
                        return [4 /*yield*/, RES.getResAsync('snowAct_json')];
                    case 3:
                        mcJson = _a.sent();
                        return [4 /*yield*/, RES.getResAsync('snowAct_png')];
                    case 4:
                        mcImg = _a.sent();
                        this.mcFactory = new egret.MovieClipDataFactory(mcJson, mcImg);
                        return [2 /*return*/, new Promise(function (resolve, reject) {
                                resolve();
                            })];
                }
            });
        });
    };
    StartScene1.prototype.onSkinComplete = function () {
        _super.prototype.onSkinComplete.call(this);
        // setTimeout(() => {
        // 	let scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
        // 	window.scrollTo(0, Math.max(scrollHeight - 1, 0));
        // }, 100);
        // this.mainbg.texture = this.bgtexture;
        this.once(egret.Event.ADDED_TO_STAGE, this.onLoad, this);
        if (this.stage) {
            this.onLoad();
        }
    };
    StartScene1.prototype.onLoad = function () {
        var startDpmOut = Buried_1.Buried.connectDpm(110, 1, 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 2, 1); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 3, 1); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 4, 1); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 4, 2); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 4, 3); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 4, 4); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 13, 1); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        startDpmOut = Buried_1.Buried.connectDpm(110, 14, 1); // 点击埋点   
        startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.showLog(exposure);
        // this.scorller.viewport.scrollV = 0;
        this.initUI();
        var str = window.location.href;
        // console.log(11111111);
        // if(str.indexOf('?') == -1){
        //     if(str.indexOf('refreshwww') == -1){
        //         window.location.href = str + '?refreshwww=1'
        //         console.log(2222222);
        //     }
        // }else{
        //     if(str.indexOf('refreshwww') == -1){
        //         window.location.href = str + '&refreshwww=1'
        //         console.log(3333333);
        //     }
        // }
        // this.invalidateState();
        // this.roleMc.play(6);
    };
    StartScene1.prototype.initUI = function () {
        //叶子
        // var bbb = new LeavesAni();
        // this.mainGroup.addChild(bbb);
        // bbb.play();
        var _this = this;
        //添加人物相关
        this.addRunAni();
        this.initData();
        //初始化稻穗
        this.initSnow();
        //处理接口
        Loading_1.default.instace.show();
        //设置兑换奖品
        NetManager_1.NetManager.ins.getProjectData(function (success) {
            if (!success) {
                panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.EXMSG_PANEL);
                Loading_1.default.instace.hide();
                return;
            }
            console.log('getProjectDatasuccess', success);
            var projectArr = DataManager_1.DataManager.ins.getData(NetName_1.NetName.GET_PROJECT_DATA).data;
            DataManager_1.DataManager.ins.getGameInfoData.projectArr = projectArr;
            if (projectArr && projectArr.length) {
                for (var i = 0; i < projectArr.length; i++) {
                    var pItem = new ExChangeItem_1.ExChangeItem(function (data, item) {
                        //点击兑换按钮
                        console.log('点击兑换按钮');
                        if (data.needAmount > DataManager_1.DataManager.ins.getGameInfoData.totalAmount) {
                            //稻穗不足
                            panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.NOREDMAPLE_PANEL);
                        }
                        else {
                            if (data.sufficient) {
                                panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.LOTBOX_PANEL, {
                                    needAmount: data.needAmount,
                                    blackBoxFlag: data.blackBoxFlag,
                                    prizeId: data.prizeId,
                                    icon: data.icon,
                                    name: data.name,
                                    item: item
                                });
                                // if(data.blackBoxFlag){
                                //     //如果是盲盒
                                // }else{
                                //     Loading.instace.show();
                                //     NetManager.ins.exchangeProject((success)=>{
                                //         if(success){
                                //             PanelCtrl.instance.show(ModuleTypes.EXCHANGESUC_PANEL);
                                //             item.exchangeBtn.currentState = 'disabled';
                                //             item.exchangeBtn.touchEnabled = false;
                                //             this.refreshMoney();
                                //         }else{
                                //             PanelCtrl.instance.show(ModuleTypes.EXMSG_PANEL);
                                //             Loading.instace.hide();
                                //         }
                                //         Loading.instace.hide();
                                //     }, data.prizeId);
                                // }
                            }
                            else {
                                //库存不充足弹未中奖
                                panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.OUTOFPRIZE_PANEL);
                            }
                        }
                    });
                    var data = projectArr[i];
                    if (data.blackBoxFlag) {
                        _this.mhItem = pItem;
                    }
                    pItem.pData = data;
                    pItem.name = i + '';
                    if (pItem.itemImg) {
                        pItem.itemImg.source = data.icon;
                    }
                    pItem.itemValue.text = data.needAmount + ' 稻穗';
                    var pname = data.name;
                    if (pname.length > 7) {
                        pname = pname.substr(0, 6) + '…';
                    }
                    pItem.itemNameLb.text = pname;
                    console.log('pname', pname);
                    if (data.sufficient) {
                        if (data.exchangeFlag) {
                            pItem.exchangeBtn.currentState = 'disabled';
                            pItem.exchangeBtn.touchEnabled = false;
                        }
                        else {
                            pItem.exchangeBtn.currentState = '';
                            pItem.exchangeBtn.touchEnabled = true;
                        }
                    }
                    else {
                        pItem.exchangeBtn.currentState = 'noNum';
                        pItem.exchangeBtn.touchEnabled = false;
                    }
                    _this.itemGroup.addChild(pItem);
                    pItem.x = i * 200;
                }
            }
        });
        //设置任务状态
        NetManager_1.NetManager.ins.getTaskData(function (success) {
            if (!success) {
                panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.EXMSG_PANEL);
                Loading_1.default.instace.hide();
                return;
            }
            var taskData = DataManager_1.DataManager.ins.getData(NetName_1.NetName.GET_TASK_DATA).data;
            DataManager_1.DataManager.ins.getGameInfoData.taskData = taskData;
            _this.taskTipsLb.text = '已完成：' + taskData.finishCnt + '/' + taskData.totalCnt;
            _this.paymentLb.text = '+' + taskData.payment.prizeAmount + '稻穗';
            _this.repaymentLb.text = '+' + taskData.repayment.prizeAmount + '稻穗';
            _this.smartparkingLb.text = '+' + taskData.smartparking.prizeAmount + '稻穗';
            if (taskData.smartparking) {
                _this.setTaskBtn(taskData.smartparking.status, 0);
            }
            if (taskData.repayment) {
                _this.setTaskBtn(taskData.repayment.status, 1);
            }
            if (taskData.payment) {
                _this.setTaskBtn(taskData.payment.status, 2);
            }
            Loading_1.default.instace.hide();
        });
        panelCtrl_1.default.instance.isLoseCoin = false;
    };
    StartScene1.prototype.initSnow = function () {
        for (var i = 0; i < 7; i++) {
            var snowAct = new egret.MovieClip(this.mcFactory.generateMovieClipData());
            snowAct.x = 10;
            snowAct.play(-1);
            this['light' + i].addChild(snowAct);
        }
    };
    StartScene1.prototype.addRunAni = function () {
        this.roleMc = new RunAni_1.RunAni();
        this.mainGroup.addChild(this.roleMc);
        this.roleMc.y = 25;
    };
    StartScene1.prototype.setTaskBtn = function (status, bidx) {
        switch (status) {
            case 0:
                this['getBtn' + bidx].visible = false;
                this['earnBtn' + bidx].visible = true;
                if (bidx == 0) {
                    var startDpmOut = Buried_1.Buried.connectDpm(110, 5, 1); // 点击埋点   
                    var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
                    var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
                    NetManager_1.NetManager.ins.showLog(exposure);
                }
                else if (bidx == 1) {
                    var startDpmOut = Buried_1.Buried.connectDpm(110, 5, 2); // 点击埋点   
                    var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
                    var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
                    NetManager_1.NetManager.ins.showLog(exposure);
                }
                else if (bidx == 2) {
                    var startDpmOut = Buried_1.Buried.connectDpm(110, 5, 3); // 点击埋点   
                    var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
                    var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
                    NetManager_1.NetManager.ins.showLog(exposure);
                }
                break;
            case 1:
                this['getBtn' + bidx].visible = true;
                this['earnBtn' + bidx].visible = false;
                this['getBtn' + bidx].currentState = '';
                this['getBtn' + bidx].touchEnabled = true;
                if (bidx == 0) {
                    var startDpmOut = Buried_1.Buried.connectDpm(110, 6, 1); // 点击埋点   
                    var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
                    var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
                    NetManager_1.NetManager.ins.showLog(exposure);
                }
                else if (bidx == 1) {
                    var startDpmOut = Buried_1.Buried.connectDpm(110, 6, 2); // 点击埋点   
                    var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
                    var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
                    NetManager_1.NetManager.ins.showLog(exposure);
                }
                else if (bidx == 2) {
                    var startDpmOut = Buried_1.Buried.connectDpm(110, 6, 3); // 点击埋点   
                    var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
                    var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
                    NetManager_1.NetManager.ins.showLog(exposure);
                }
                break;
            case 2:
                this['getBtn' + bidx].visible = true;
                this['earnBtn' + bidx].visible = false;
                this['getBtn' + bidx].currentState = 'disabled';
                this['getBtn' + bidx].touchEnabled = false;
                break;
        }
    };
    StartScene1.prototype.initData = function (isPlay) {
        var _this = this;
        if (isPlay === void 0) { isPlay = false; }
        this.myMoneyLb.text = '我的稻穗:' + DataManager_1.DataManager.ins.getGameInfoData.totalAmount;
        var serialDays = DataManager_1.DataManager.ins.getGameInfoData.serialDays;
        var sDStr = '';
        if (serialDays > 99) {
            sDStr = '99+';
        }
        else {
            sDStr = serialDays;
        }
        var currSign = DataManager_1.DataManager.ins.getGameInfoData.todaySignFlag;
        if (currSign) {
            this.signBtn.currentState = 'disabled';
            this.signBtn.touchChildren = false;
            this.signBtn.touchEnabled = false;
        }
        else {
            this.signBtn.currentState = '';
            this.signBtn.touchChildren = true;
            this.signBtn.touchEnabled = true;
        }
        this.signDayLb.text = '已经连续签到 ' + sDStr + ' 天';
        var cycleDays = DataManager_1.DataManager.ins.getGameInfoData.cycleDays;
        this.setDayGroup(cycleDays);
        if (isPlay) {
            if (cycleDays) {
                console.log('cycleDays', cycleDays);
                this.roleMc.play(cycleDays, function () {
                    var light = _this['light' + (cycleDays - 1)];
                    light.visible = true;
                    //1.0光效旋转动效
                    // egret.Tween.removeTweens(light);
                    // egret.Tween.get(light, {loop:true}).to({rotation:360}, 5000);
                    var score1 = _this['score' + (cycleDays - 1) + '1'];
                    var score2 = _this['score' + (cycleDays - 1) + '2'];
                    score1.alpha = 0;
                    egret.Tween.get(score1).to({ alpha: 1 }, 500);
                    egret.Tween.get(score2).to({ alpha: 0 }, 500).call(function () {
                        score1.alpha = 1;
                        score2.alpha = 1;
                        score1.visible = true;
                        score2.visible = false;
                    });
                    var sData = DataManager_1.DataManager.ins.getData(NetName_1.NetName.SIGN).data;
                    setTimeout(function () {
                        panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.SIGNSUC_PANEL, { sData: sData });
                    }, 200);
                });
            }
        }
        else {
            this.roleMc.reset(cycleDays);
        }
        // if(cycleDays == 0){
        //     this.setDayGroup(0)
        // }else{
        //     this.setDayGroup(3);
        // }
    };
    //设置界面日期显示
    StartScene1.prototype.setDayGroup = function (currIdx) {
        this.touchEnabled;
        for (var i = 0; i < 7; i++) {
            if (i >= currIdx) {
                this['sGroup' + i + '1'].visible = false;
                this['sGroup' + i + '2'].visible = true;
                this['dayGroup' + i].touchChildren = false;
                this['dayGroup' + i].touchEnabled = false;
                this['score' + i + '1'].visible = false;
                this['score' + i + '2'].visible = true;
                this['light' + i].visible = false;
            }
            else {
                this['sGroup' + i + '1'].visible = true;
                this['sGroup' + i + '2'].visible = false;
                this['dayGroup' + i].touchChildren = true;
                this['dayGroup' + i].touchEnabled = true;
                this['score' + i + '1'].visible = true;
                this['score' + i + '2'].visible = false;
                this['light' + i].visible = true;
            }
            var data = DataManager_1.DataManager.ins.getGameInfoData.signPrizeAmountArr;
            if (i == 1 || i == 3 || i == 6) {
                this['sLb' + i + '1'].text = '+' + data[i];
                this['sLb' + i + '2'].text = '+' + data[i];
            }
            else {
                this['score' + i + '1'].text = '+' + data[i];
                this['score' + i + '2'].text = '+' + data[i];
            }
        }
    };
    //领取稻穗按钮
    StartScene1.prototype.onTap_getBtn = function (e) {
        var _this = this;
        var gbidx = e.currentTarget.name;
        var startDpmOut = Buried_1.Buried.connectDpm(110, 6, Number(gbidx) + 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
        var taskCode;
        var tdata = DataManager_1.DataManager.ins.getGameInfoData.taskData;
        var tinfo;
        switch (gbidx) {
            case 0:
                taskCode = tdata.smartparking.code;
                tinfo = tdata.smartparking;
                break;
            case 1:
                taskCode = tdata.repayment.code;
                tinfo = tdata.repayment;
                break;
            case 2:
                taskCode = tdata.payment.code;
                tinfo = tdata.payment;
                break;
        }
        Loading_1.default.instace.show();
        NetManager_1.NetManager.ins.getMoneyData(function (success) {
            if (success) {
                var data = DataManager_1.DataManager.ins.getData(NetName_1.NetName.GET_MONEY_DATA).data;
                topLayerCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.TOAST_PANEL, { msg: '领取成功 +' + data.prizeAmount + '稻穗' });
                console.log('tinfo', tinfo);
                tinfo.status = 2;
                _this.setTaskBtn(tinfo.status, gbidx);
                _this.refreshMoney();
            }
            else {
                topLayerCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.TOAST_PANEL, { msg: '网络异常，领取失败！' }); //????????
            }
            Loading_1.default.instace.hide();
        }, taskCode);
    };
    //跳转链接按钮
    StartScene1.prototype.onTap_earnBtn = function (e) {
        var _this = this;
        var idx = e.currentTarget.name;
        panelCtrl_1.default.instance.btnDelay(this['getBtn' + e.currentTarget.name]);
        var startDpmOut = Buried_1.Buried.connectDpm(110, 5, Number(idx) + 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
        var url;
        var u = navigator.userAgent; //, app = navigator.appVersion;
        var android = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
        var iphone = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        if (idx == 0) {
            url = window['url0'] ? window['url0'] : 'szbank://trans?isLogin=0|title=智慧停车|commercialId=100000000005|directUrl=http://www.bankofsz.com/becpChannel/web/main.html';
            setTimeout(function () {
                if (iphone) {
                    _this.jumpTh(url); //智慧停车
                }
                if (android) {
                    _this.jumpM(url); //安卓跳转
                }
            }, 200);
        }
        else if (idx == 1) {
            url = window['url1'] ? window['url1'] : '/page/creditCard/payPromptly/main.html';
            this.jumpH(url);
        }
        else if (idx == 2) {
            url = window['url2'] ? window['url2'] : '/page/lifeFees/lifeFees.html';
            this.jumpH(url);
        }
    };
    /**
     * 跳转第三方
     */
    StartScene1.prototype.jumpTh = function (url) {
        var param = {
            linktype: '05',
            skipflag: '',
            skipaddr: url,
            detailtype: ''
        };
        window['ThirdApp'].webViewJump(param);
    };
    StartScene1.prototype.jumpM = function (url) {
        var param = {
            linktype: '01',
            // 跳转外部浏览器;05 跳转第三方页面;06 跳转TAB
            skipflag: '20180122',
            skipaddr: '20180122',
            detailtype: ''
        };
        window['ThirdApp'].webViewJump(param);
    };
    /**
     * 跳转部分H5
     */
    StartScene1.prototype.jumpH = function (url) {
        var _this = this;
        var param = {
            linktype: '03',
            skipflag: '0',
            skipaddr: url,
            detailtype: ''
        };
        // ThirdApp.webViewJump(param);
        // 修改新方案
        if (window['ThirdApp'].os == 'android') {
            // 关闭当前webview
            this.closeThirdPage();
            window['ThirdApp'].webViewJump(param);
            //   setTimeout(()=> {
            //     window['ThirdApp'].webViewJump(param);
            //   }, 800);
        }
        else {
            window['ThirdApp'].webViewJump(param);
            setTimeout(function () {
                _this.closeThirdPage();
            }, 800);
        }
    };
    /**
      * 关闭第三方页面
    */
    StartScene1.prototype.closeThirdPage = function () {
        var param = {
            "finishType": "0",
        };
        window['ThirdApp'].colseViewPage(param);
    };
    //刷新稻穗数
    StartScene1.prototype.refreshMoney = function () {
        var _this = this;
        NetManager_1.NetManager.ins.consumerData(function (success) {
            if (!success) {
                panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.EXMSG_PANEL);
                Loading_1.default.instace.hide();
                console.log('consumerData defaild');
                return;
            }
            var data = DataManager_1.DataManager.ins.getData(NetName_1.NetName.CONSUMER_DATA).data;
            DataManager_1.DataManager.ins.getGameInfoData.totalAmount = DataManager_1.DataManager.ins.getData(NetName_1.NetName.CONSUMER_DATA).data.totalAmount;
            _this.myMoneyLb.text = '我的稻穗:' + DataManager_1.DataManager.ins.getGameInfoData.totalAmount;
        });
    };
    //设置盲盒按钮
    StartScene1.prototype.refreshMangheBtn = function () {
        if (this.mhItem) {
            this.mhItem.exchangeBtn.currentState = 'disabled';
            this.mhItem.exchangeBtn.touchEnabled = false;
        }
    };
    StartScene1.prototype.onClick_dayGroup = function (e) {
        var idx = e.currentTarget.name;
        panelCtrl_1.default.instance.btnDelay(this['dayGroup' + idx]);
        console.log('idx=' + idx);
        panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.SPOTINTRO_PANEL, { spotIndex: idx });
    };
    StartScene1.prototype.onTap_ruleBtn = function () {
        console.log('点击rule');
        panelCtrl_1.default.instance.btnDelay(this.ruleBtn);
        panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.RULE_PANEL);
        var startDpmOut = Buried_1.Buried.connectDpm(110, 2, 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
    };
    StartScene1.prototype.onTap_prizeBtn = function () {
        console.log('点击prizeBtn');
        panelCtrl_1.default.instance.btnDelay(this.prizeBtn); //devhttp://activity.m.duibadev.com.cn/projectx/p274df766/fe1df32fa.html
        window.location.href = window['prizeUel'] ? window['prizeUel'] : 'http://activity.m.duibatest.com.cn/projectx/p0b7552ae/fe1df32fa.html';
        var startDpmOut = Buried_1.Buried.connectDpm(110, 3, 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
    };
    StartScene1.prototype.onTap_signBtn = function () {
        var _this = this;
        // PanelCtrl.instance.btnDelay(this.signBtn);
        if (this.notSign) {
            return;
        }
        //鲁金雷项目关联接口
        NetManager_1.NetManager.ins.taskFinish(function () { });
        var startDpmOut = Buried_1.Buried.connectDpm(110, 1, 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
        this.signBtn.currentState = 'disabled'; //fe1df32fa
        this.signBtn.touchEnabled = false;
        this.notSign = true;
        console.log('signBtn');
        NetManager_1.NetManager.ins.sign(function (success) {
            if (success) {
                _this.refreshSignData();
                _this.refreshMoney();
                // let sData = DataManager.ins.getData(NetName.SIGN).data;
                // setTimeout(() => {
                //     PanelCtrl.instance.show(ModuleTypes.SIGNSUC_PANEL, {sData:sData});
                // }, 500);
            }
            else {
                _this.signBtn.touchEnabled = true;
                _this.signBtn.currentState = '';
                topLayerCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.TOAST_PANEL, { msg: '网络异常！签到失败，请重试' });
            }
            _this.notSign = false;
        });
    };
    //刷新签到数据
    StartScene1.prototype.refreshSignData = function () {
        var _this = this;
        NetManager_1.NetManager.ins.getSignData(function (success) {
            if (!success) {
                panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.EXMSG_PANEL);
                Loading_1.default.instace.hide();
                console.log('getSignData defaild');
                return;
            }
            var data = DataManager_1.DataManager.ins.getData(NetName_1.NetName.SIGN_DATA).data;
            // const data = {serialDays: 24, todaySignFlag: false, cycleDays: 6, signPrizeAmountArr: Array(7)}//测试用
            // console.log('data=', data)
            var cycleDays = data.cycleDays;
            if (cycleDays == 8) {
                DataManager_1.DataManager.ins.getGameInfoData.cycleDays = 0;
                cycleDays = 0;
            }
            DataManager_1.DataManager.ins.getGameInfoData.cycleDays = cycleDays;
            DataManager_1.DataManager.ins.getGameInfoData.serialDays = data.serialDays;
            DataManager_1.DataManager.ins.getGameInfoData.todaySignFlag = data.todaySignFlag;
            DataManager_1.DataManager.ins.getGameInfoData.signPrizeAmountArr = data.signPrizeAmountArr;
            _this.initData(true);
        });
    };
    StartScene1.prototype.onTap_skip0 = function () {
        panelCtrl_1.default.instance.btnDelay(this.skip0);
        window.location.href = window['skip0'] ? window['skip0'] : 'https://activity.m.duiba.com.cn/hdtool/index?id=3742069&banner';
        var startDpmOut = Buried_1.Buried.connectDpm(110, 13, 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
    };
    StartScene1.prototype.onTap_skip1 = function () {
        panelCtrl_1.default.instance.btnDelay(this.skip1);
        // window.location.href = window['skip1'] ? window['skip1'] : 'https://activity.m.duiba.com.cn/projectx/p89bd3ef5/index.html?appID=62244&banner'
        window.location.href = window['skip1'] ? window['skip1'] : '';
        var startDpmOut = Buried_1.Buried.connectDpm(110, 14, 1); // 点击埋点   
        var startDcmOut = Buried_1.Buried.connectDcm(202, 0, 0); // 曝光埋点
        var exposure = Buried_1.Buried.createExposure(startDpmOut, startDcmOut);
        NetManager_1.NetManager.ins.clickLog(exposure);
    };
    //获取我的奖品
    StartScene1.prototype.gotoRecord = function () {
        var recordUrl;
        var oaId;
        // if (DataManager.ins.customCfgData) {
        //     oaId = DataManager.ins.customCfgData.oaId;
        //     recordUrl = DataManager.ins.customCfgData.recordUrl;
        // } else {
        //     oaId = DataManager.ins.gameCfgData.gameInfo.oaId;
        //     recordUrl = window['recordUrl'];
        // }
        if (recordUrl.indexOf('?') != -1) {
            recordUrl += '&origins=' + oaId + '00';
        }
        else {
            recordUrl += '?origins=' + oaId + '00';
        }
        // recordUrl += ',' + (window['plugId'] ? window['plugId'] : 4500) + '01';
        // for(let i = 0; i < window['plugIdArr'].length; i++){
        //     recordUrl += ',' + window['plugIdArr'][i] + '01';
        // }
        return recordUrl;
    };
    return StartScene1;
}(Scene_1.default));
exports.default = StartScene1;
__reflect(StartScene1.prototype, "\"/Users/zuopeng/DBGitLab/db-game-template/egret/src/startScene/StartScene\".StartScene1");
//# sourceMappingURL=StartScene.js.map