123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- "use strict";
- cc._RF.push(module, '8b8b9JtLw1C6aga3BAYTo/9', 'LocalStorageUtil');
- // Script/Framework/Utils/LocalStorageUtil.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 __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.LocalStorageUtil = void 0;
- var Singleton_1 = require("./Singleton");
- var LocalStorageUtil = /** @class */ (function (_super) {
- __extends(LocalStorageUtil, _super);
- function LocalStorageUtil() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- /**音乐 */
- _this.lst_music = "Bird_music";
- /**音效 */
- _this.lst_effect = "Bird_effect";
- /**倒计时时间*/
- _this.lst_CountTime = "BirdCountTime";
- /**倒计时秒数*/
- _this.lst_CountSecond = "BirdCountSecond";
- /**体力 */
- _this.lst_Tili = "BirdTili";
- /** 最后进入关卡*/
- _this.lst_playLevel = "Bird_playLevel";
- /** 通关进度*/
- _this.lst_passProgress = "Bird_passProgress";
- _this.list_foodLevel = "list_foodLevel";
- _this.list_kitchenLevel = "list_kitchenLevel";
- _this.list_missionComplete = "list_missionComplete";
- _this.list_missionReceive = "list_missionReceive";
- // 通关场景进度
- _this.Bird_passScene = "Bird_passScene";
- /** 通关进度*/
- _this.lst_InfiniteLevelDate = "Bird_infiniteLevelDate";
- _this.str_guideStep = "str_guideStep";
- /** 道具数量*/
- _this.lst_PropNum = "lst_PropNum";
- /** 金币*/
- _this.lst_Coin = "lst_UserCoin";
- _this.lst_UserDiamond = "lst_UserDiamond";
- /** 用户皮肤组*/
- _this.lst_getSkin = "Bird_getSkin";
- /** 用户当前使用皮肤*/
- _this.lst_dressOnSkin = "Bird_dressOnSkin";
- /** 新手引导标志*/
- _this.lst_guide = "Bird_guide";
- // /** 免费视频次数 */
- // public lst_free_watch_times: string = "sausage_free_watch_times";
- // /** 每日签到数据 */
- // public lst_daily_signin: string = "sausage_daily_signin";
- _this.secretkey = 'ccxh_ws111'; // 加密密钥
- _this.isSecret = false;
- return _this;
- }
- LocalStorageUtil.prototype.set = function (key, value) {
- try {
- if (key) {
- if (this.isSecret) {
- var dataString = JSON.stringify(value);
- value = window["encryptjs"].encrypt(dataString, this.secretkey, 256);
- }
- cc.sys.localStorage.setItem(key, value);
- }
- }
- catch (e) {
- console.error("设置数据出错!!!");
- }
- };
- //不存在key时返回null
- LocalStorageUtil.prototype.get = function (key) {
- try {
- if (key) {
- var value = cc.sys.localStorage.getItem(key);
- if (value) {
- if (this.isSecret)
- return JSON.parse(window["encryptjs"].decrypt(value, this.secretkey, 256));
- else
- return value;
- }
- }
- return null;
- }
- catch (e) {
- console.error("获取数据出错!!!");
- return null;
- }
- };
- /**存string */
- LocalStorageUtil.prototype.setString = function (key, value) {
- this.set(key, value);
- };
- /**取string */
- LocalStorageUtil.prototype.getString = function (key) {
- var value = this.get(key);
- return value;
- };
- /**存boolean */
- LocalStorageUtil.prototype.setBoolean = function (key, value) {
- var temp = value ? "1" : "0";
- this.set(key, temp);
- };
- /**取boolean */
- LocalStorageUtil.prototype.getBoolean = function (key) {
- var value = this.get(key);
- if (value) {
- if (value == "1")
- return true;
- else
- return false;
- }
- return null;
- };
- /**存number */
- LocalStorageUtil.prototype.setNumber = function (key, value, encode) {
- if (value != null && value != undefined) {
- // if (value == Math.floor(value) && encode) { //整数
- // value = EncryptUtil.enValue(value);
- // }
- this.set(key, value.toString());
- }
- };
- /**取number */
- LocalStorageUtil.prototype.getNumber = function (key, decode) {
- var temp = this.get(key);
- if (temp) {
- if (temp.indexOf(".") >= 0) {
- return parseFloat(temp);
- }
- else {
- var value = parseInt(temp);
- // return EncryptUtil.desValue(value);
- }
- }
- return temp;
- };
- /**存json */
- LocalStorageUtil.prototype.setJsonObj = function (key, value) {
- if (value != null && value != undefined) {
- this.set(key, JSON.stringify(value));
- }
- };
- /**取json */
- LocalStorageUtil.prototype.getJsonObj = function (key) {
- var temp = this.get(key);
- if (temp != null) {
- return JSON.parse(temp);
- }
- return temp;
- };
- /**清空本地存在数据 */
- LocalStorageUtil.prototype.clearAll = function () {
- cc.sys.localStorage.clear();
- };
- /**删除数据key */
- LocalStorageUtil.prototype.deleteKey = function (key) {
- var temp = this.get(key);
- if (temp != null) {
- cc.sys.localStorage.removeItem(key);
- }
- };
- return LocalStorageUtil;
- }(Singleton_1.Singleton));
- exports.LocalStorageUtil = LocalStorageUtil;
- cc._RF.pop();
|