Sun_moves/library/imports/45/454ad829-851a-40ea-8ab9-941e828357ca.js
2024-05-31 10:16:31 +08:00

155 lines
6.3 KiB
JavaScript

"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 });
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, requireComponent = _a.requireComponent;
var GameData_1 = require("./GameData");
var Storage_1 = require("./Storage");
// import {StorageMessage} from "./StorageMessage";
// import { apiSign } from "./crypto/sign";
var NewClass = /** @class */ (function (_super) {
__extends(NewClass, _super);
function NewClass() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.label = null;
_this.text = 'hello';
return _this;
// update (dt) {}
}
NewClass.prototype.start = function () {
var userId = Storage_1.StorageMessage.getStorage("user");
if (userId == "undifend" || userId == null) {
this.setId();
}
else {
var data = Storage_1.StorageMessage.getStorage("user");
data = this.getId(data);
var timestamp = parseInt(new Date().getTime() / 1000 + "");
if ((timestamp - data[2]) > 86400) {
this.setId();
return;
}
GameData_1.default._instance.GM_INFO.userId = data[1];
GameData_1.default._instance.GM_INFO.userId = parseInt(GameData_1.default._instance.GM_INFO.userId);
}
};
NewClass.prototype.setId = function () {
GameData_1.default._instance.GM_INFO.userId = this.getUserId();
if (GameData_1.default._instance.GM_INFO.userId == null) {
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 idTemp = "gameId=" + GameData_1.default._instance.GM_INFO.gameId +
"?userId= " + GameData_1.default._instance.GM_INFO.userId + "?time=" + timestamp;
Storage_1.StorageMessage.setStorage("user", idTemp);
GameData_1.default._instance.GM_INFO.userId = parseInt(GameData_1.default._instance.GM_INFO.userId);
}
};
NewClass.prototype.createTexture = function () {
var _this = this;
var url = "http://static.sparkus.cn/shoot-sun/assets/resources/native/7a/7a8b41ad-9425-44e2-8f55-7740f12b0e0a.jpg";
cc.assetManager.loadRemote(url, function (err, texture) {
console.log(err, texture);
if (texture) {
var sprite = _this.node.getChildByName("icon").getComponent(cc.Sprite);
sprite.spriteFrame = new cc.SpriteFrame(texture);
}
});
};
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]);
});
// GameData._instance.GM_INFO.userId = arr2[0] + "";
return arr2_1[0];
}
else {
return null;
}
};
NewClass.prototype.getId = function (str) {
var pathStr = str;
var arr = pathStr.split("?");
if (pathStr.length >= 0 && arr.length > 0) {
var arr2_2 = [];
arr.map(function (item) {
arr2_2.push(item.split("=")[1]);
});
// GameData._instance.GM_INFO.userId = arr2[1] + "";
return arr2_2;
}
else {
return null;
}
};
NewClass.prototype.startGame = function () {
GameData_1.default._instance.GM_INFO.custom = 0;
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.openLevel = function () {
this.node.getChildByName("Level").active = true;
};
NewClass.prototype.closeBtn = function () {
this.node.getChildByName("Level").active = false;
};
NewClass.prototype.back = function (data) {
// debugger;
};
NewClass.prototype.openBtn = function () {
GameData_1.default._instance.GM_INFO.custom = 0;
cc.director.loadScene("GuideScene");
};
NewClass.prototype.openRank = function () {
cc.director.loadScene("RankScene");
};
__decorate([
property(cc.Label)
], NewClass.prototype, "label", void 0);
__decorate([
property
], NewClass.prototype, "text", void 0);
NewClass = __decorate([
ccclass
], NewClass);
return NewClass;
}(cc.Component));
exports.default = NewClass;
cc._RF.pop();