
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/Load.js';
                    var __require = nodeEnv ? function (request) {
                        return cc.require(request);
                    } : function (request) {
                        return __quick_compile_project__.require(request, __filename);
                    };
                    function __define (exports, require, module) {
                        if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
cc._RF.push(module, '454adgphRpA6oq5lB6Cg1fK', 'Load');
// Script/Load.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, requireComponent = _a.requireComponent;
var GameData_1 = require("./GameData");
var Storage_1 = require("./Storage");
var NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    NewClass.prototype.start = function () {
        this.Authentication();
    };
    //鉴权，判断有无缓存userid,有的话判断是否过期，没有的话重新获取userid 并且缓存上
    NewClass.prototype.Authentication = function () {
        var name = "user_" + GameData_1.default._instance.GM_INFO.gameId;
        var data = Storage_1.StorageMessage.getStorage(name);
        if (data == "undifend" || data == null || data == "") {
            console.log("没缓存");
            this.setUserId(name);
        }
        else {
            console.log("有缓存");
            var timestamp = parseInt(new Date().getTime() / 1000 + "");
            if ((timestamp - data.time) > 86400) {
                console.log("缓存过期");
                this.setUserId(name);
                return;
            }
            GameData_1.default._instance.GM_INFO.userId = parseInt(data.userId);
        }
    };
    //设置userId,链接有获取，没有跳转授权
    NewClass.prototype.setUserId = function (name) {
        GameData_1.default._instance.GM_INFO.userId = this.getUserId();
        if (GameData_1.default._instance.GM_INFO.userId == null) {
            console.log("链接没ID准备跳转");
            var url = "http://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback=" + location.href;
            window.location.href = url;
        }
        else {
            var timestamp = parseInt(new Date().getTime() / 1000 + "");
            var idData = {
                userId: GameData_1.default._instance.GM_INFO.userId + "",
                time: timestamp
            };
            Storage_1.StorageMessage.setStorage(name, idData);
            console.log("有ID：", GameData_1.default._instance.GM_INFO.userId);
            GameData_1.default._instance.GM_INFO.userId = parseInt(GameData_1.default._instance.GM_INFO.userId);
        }
    };
    //获取user id 有参数为获取gameid userid 时间戳， 无参数为只获取链接尾缀上的userId
    NewClass.prototype.getUserId = function () {
        var pathStr = window.location.search;
        var arr = pathStr.split("&");
        if (pathStr.length >= 0 && arr.length > 0) {
            var arr2_1 = [];
            arr.map(function (item) {
                arr2_1.push(item.split("=")[1]);
            });
            return arr2_1[0];
        }
        else {
            return null;
        }
    };
    //开始游戏，跳转至引导页面
    NewClass.prototype.startGame = function () {
        cc.director.loadScene("GuideScene");
    };
    //备用，用来测试跳转 指定关卡
    NewClass.prototype.clickBtn = function (event, data) {
        GameData_1.default._instance.GM_INFO.custom = parseInt(data);
        cc.director.loadScene("GameScene");
    };
    //打开排行榜
    NewClass.prototype.openRank = function () {
        cc.director.loadScene("RankScene");
    };
    NewClass.prototype.update = function (dt) {
    };
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;

cc._RF.pop();
                    }
                    if (nodeEnv) {
                        __define(__module.exports, __require, __module);
                    }
                    else {
                        __quick_compile_project__.registerModuleFunc(__filename, function () {
                            __define(__module.exports, __require, __module);
                        });
                    }
                })();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 7896 characters]