5ae233f9-b494-4aba-b27c-d173a385e998.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. "use strict";
  2. cc._RF.push(module, '5ae23P5tJRKurJ80XOjhemY', 'UITimePage');
  3. // scripts/UI/UITimePage.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. 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;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  25. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  26. return new (P || (P = Promise))(function (resolve, reject) {
  27. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  28. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  29. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  30. step((generator = generator.apply(thisArg, _arguments || [])).next());
  31. });
  32. };
  33. var __generator = (this && this.__generator) || function (thisArg, body) {
  34. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  35. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  36. function verb(n) { return function (v) { return step([n, v]); }; }
  37. function step(op) {
  38. if (f) throw new TypeError("Generator is already executing.");
  39. while (_) try {
  40. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  41. if (y = 0, t) op = [op[0] & 2, t.value];
  42. switch (op[0]) {
  43. case 0: case 1: t = op; break;
  44. case 4: _.label++; return { value: op[1], done: false };
  45. case 5: _.label++; y = op[1]; op = [0]; continue;
  46. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  47. default:
  48. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  49. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  50. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  51. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  52. if (t[2]) _.ops.pop();
  53. _.trys.pop(); continue;
  54. }
  55. op = body.call(thisArg, _);
  56. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  57. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  58. }
  59. };
  60. Object.defineProperty(exports, "__esModule", { value: true });
  61. var UIPage_1 = require("../Framework/UIPage");
  62. var Constant_1 = require("../Framework/Constant");
  63. var CocosZ_1 = require("../Framework/CocosZ");
  64. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  65. var TweenEffect_1 = require("../Framework/TweenEffect");
  66. var gameDate_1 = require("../Game/gameDate");
  67. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  68. var ItemTime = /** @class */ (function () {
  69. function ItemTime(i, n) {
  70. this._id = 0;
  71. this._node = null;
  72. this._txt_zxsc = null;
  73. this._txt_ylq = null;
  74. this._btn = null;
  75. this._label_coin = null;
  76. this._label_diamond = null;
  77. this._label_time = null;
  78. this._id = i;
  79. this._node = n;
  80. this._info = gameDate_1.default.TimeReward[i];
  81. this._txt_zxsc = this._node.getChildByName("txt_zxsc");
  82. this._txt_ylq = this._node.getChildByName("txt_ylq");
  83. this._btn = this._node.getChildByName("btn");
  84. this._btn.on(cc.Node.EventType.TOUCH_END, this.click, this);
  85. this._label_coin = this._node.getChildByName("label_coin").getComponent(cc.Label);
  86. this._label_coin.string = this._info.coinNum + "";
  87. this._label_diamond = this._node.getChildByName("label_diamond").getComponent(cc.Label);
  88. this._label_diamond.string = this._info.diamondNum + "";
  89. this._label_time = this._node.getChildByName("label_time").getComponent(cc.Label);
  90. this._label_time.string = CocosZ_1.cocosz.StoHMS(this._info.time);
  91. }
  92. ItemTime.prototype.click = function () {
  93. // 领取奖励
  94. var arrRecieve = CocosZ_1.cocosz.dataMgr.receiveToday;
  95. if (arrRecieve[this._id] == 0) {
  96. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  97. arrRecieve[this._id] = 1;
  98. CocosZ_1.cocosz.dataMgr.receiveToday = arrRecieve;
  99. this.update();
  100. CocosZ_1.cocosz.dataMgr.CoinCount += this._info.coinNum;
  101. CocosZ_1.cocosz.dataMgr.DiamondCount += this._info.diamondNum;
  102. }
  103. };
  104. ItemTime.prototype.update = function () {
  105. // 时间达到
  106. if (CocosZ_1.cocosz.dataMgr.OnlineToday >= this._info.time) {
  107. var arrRecieve = CocosZ_1.cocosz.dataMgr.receiveToday;
  108. // 已领取
  109. if (arrRecieve[this._id]) {
  110. this._btn.active = this._txt_zxsc.active = this._label_time.node.active = false;
  111. this._txt_ylq.active = true;
  112. }
  113. // 待领取
  114. else {
  115. this._txt_ylq.active = this._txt_zxsc.active = this._label_time.node.active = false;
  116. this._btn.active = true;
  117. }
  118. }
  119. // 时间未达到
  120. else {
  121. this._txt_ylq.active = this._btn.active = false;
  122. this._txt_zxsc.active = this._label_time.node.active = true;
  123. }
  124. };
  125. return ItemTime;
  126. }());
  127. /**
  128. * 皮肤试用面板
  129. */
  130. var UITimePanel = /** @class */ (function (_super) {
  131. __extends(UITimePanel, _super);
  132. function UITimePanel() {
  133. var _this = _super.call(this, Constant_1.PanelName.UITimePanel) || this;
  134. _this.mask = null;
  135. _this.panel = null;
  136. _this.label_online = null;
  137. _this.itemList = [];
  138. _this.isValid() && _this.onLoad();
  139. return _this;
  140. }
  141. UITimePanel.prototype.onLoad = function () {
  142. this.mask = this._page.getChildByName("mask");
  143. this.panel = this._page.getChildByName("panel");
  144. // 按钮
  145. var btnNames = ["BtnBack"];
  146. for (var i = 0; i < btnNames.length; i++) {
  147. var btn = cc.find(btnNames[i], this.panel);
  148. if (btn) {
  149. btn.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  150. }
  151. }
  152. // 在线时间
  153. this.label_online = this.panel.getChildByName("label_online").getComponent(cc.Label);
  154. };
  155. UITimePanel.prototype.onOpen = function () {
  156. Utils_1.utils.SendEvent("页面-在线奖励");
  157. this._initPanel();
  158. };
  159. UITimePanel.prototype.onClose = function () { };
  160. UITimePanel.prototype._initPanel = function () {
  161. var _this = this;
  162. TweenEffect_1.default.panel_mask_opacity(this.mask);
  163. TweenEffect_1.default.panel_open_moveY(this.panel);
  164. // 列表
  165. for (var i = 0; i < 5; i++) {
  166. var n = this.panel.getChildByName("item" + i);
  167. if (n) {
  168. var item = new ItemTime(i, n);
  169. this.itemList.push(item);
  170. }
  171. }
  172. cc.tween(this._page)
  173. .call(function () { _this.updateTime(); })
  174. .delay(1)
  175. .union()
  176. .repeatForever()
  177. .start();
  178. };
  179. UITimePanel.prototype.updateTime = function () {
  180. // 显示在线时间
  181. this.label_online.string = CocosZ_1.cocosz.StoHMS(CocosZ_1.cocosz.dataMgr.OnlineToday);
  182. // 更新列表
  183. this.itemList.forEach(function (v) {
  184. v.update();
  185. });
  186. };
  187. /**
  188. * 所有按钮点击事件
  189. * @param event
  190. * @param data
  191. */
  192. UITimePanel.prototype._onBtnClickedHandler = function (event, data) {
  193. return __awaiter(this, void 0, void 0, function () {
  194. return __generator(this, function (_a) {
  195. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  196. switch (event.target.name) {
  197. case "BtnBack": {
  198. TweenEffect_1.default.panel_close_moveY(this.panel, function () {
  199. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UITimePanel);
  200. });
  201. break;
  202. }
  203. }
  204. return [2 /*return*/];
  205. });
  206. });
  207. };
  208. UITimePanel = __decorate([
  209. ccclass
  210. ], UITimePanel);
  211. return UITimePanel;
  212. }(UIPage_1.default));
  213. exports.default = UITimePanel;
  214. cc._RF.pop();