602c3aa8-0ee0-4fbb-8dcd-5d18712773c9.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. "use strict";
  2. cc._RF.push(module, '602c3qoDuBPu43NXRhxJ3PJ', 'UISignPage');
  3. // scripts/UI/UISignPage.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 Msg_1 = require("../Framework/Msg");
  65. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  66. var TweenEffect_1 = require("../Framework/TweenEffect");
  67. // @ts-ignore
  68. var i18n = require('LanguageData');
  69. var ATRewardedVideoJSSDK_1 = require("../AnyThinkAds/ATRewardedVideoJSSDK");
  70. var ATAndroidJS2_1 = require("../ATAndroidJS2");
  71. var GlobalManager_1 = require("../GlobalManager");
  72. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  73. var REWARD_SIGN = [500, 1000, 1500, 50, 2000, 2500, 100];
  74. var DayItem = /** @class */ (function () {
  75. function DayItem(index, node) {
  76. this._index = -1;
  77. this._node = null;
  78. this._normal = null;
  79. this._current = null;
  80. this._got = null;
  81. this._label = null;
  82. this._index = index;
  83. this._node = node;
  84. this._normal = this._node.getChildByName("st1");
  85. this._current = this._node.getChildByName("st2");
  86. this._got = this._node.getChildByName("st3");
  87. if (this._node.getChildByName("rewardLabel")) {
  88. this._label = this._node.getChildByName("rewardLabel").getComponent(cc.Label);
  89. this._label.node.scale = 0.7;
  90. this._label.node.setPosition(this._node.x, this._node.y - 60);
  91. this._label.node.setParent(this._node.parent);
  92. this._label.string = "+" + REWARD_SIGN[this._index];
  93. }
  94. }
  95. DayItem.prototype.setStatus = function (status) {
  96. if (status == 0) {
  97. this._normal.active = true;
  98. this._current.active = false;
  99. this._got.active = false;
  100. this._label.node.active = true;
  101. }
  102. else if (status == 1) {
  103. this._normal.active = false;
  104. this._current.active = true;
  105. this._got.active = false;
  106. this._label.node.active = true;
  107. }
  108. else if (status == 2) {
  109. this._normal.active = true;
  110. this._current.active = false;
  111. this._got.active = true;
  112. this._label.node.active = false;
  113. }
  114. };
  115. DayItem.prototype.update = function () {
  116. // 上一次领取的是第几天,从0开始
  117. var lastDayIndex = CocosZ_1.cocosz.dataMgr.LastDailyBonusIndex;
  118. // 超过一天, 重置一下天数
  119. if (lastDayIndex == 6) {
  120. lastDayIndex = -1;
  121. }
  122. // 上次领取的时间
  123. var lastDayTime = CocosZ_1.cocosz.dataMgr.LastDailyBonusTime;
  124. var canGet = false;
  125. if (new Date().toDateString() != lastDayTime && this._index == lastDayIndex + 1) {
  126. canGet = true;
  127. }
  128. // cc.log(`lastDayIndex: ${lastDayIndex} --- lastDayTime: ${lastDayTime}`);
  129. // this._got.active = false;
  130. // this._normal.active = false;
  131. // this._current.active = false;
  132. if (this._index <= lastDayIndex) {
  133. // 已经领取过了
  134. // this._got.active = true;
  135. this.setStatus(2);
  136. }
  137. else {
  138. if (canGet) {
  139. this.setStatus(1);
  140. // this._current.active = true;
  141. }
  142. else {
  143. this.setStatus(0);
  144. // this._normal.active = true;
  145. }
  146. }
  147. };
  148. return DayItem;
  149. }());
  150. var UISignPanel = /** @class */ (function (_super) {
  151. __extends(UISignPanel, _super);
  152. function UISignPanel() {
  153. var _this = _super.call(this, Constant_1.PanelName.UISignPanel) || this;
  154. _this._mask = null;
  155. _this._panel = null;
  156. _this._btnGet = null;
  157. _this._btnDouble = null;
  158. _this._btnClose = null;
  159. _this._day = [];
  160. _this.adKey = "zh_ad_type";
  161. _this.isValid() && _this.onLoad();
  162. return _this;
  163. }
  164. UISignPanel.prototype.onLoad = function () {
  165. this._panel = this._page.getChildByName("Panel");
  166. this._mask = this._page.getChildByName("mask");
  167. var btnNames = ["BtnClose", "BtnDouble", "BtnGet"];
  168. for (var i = 0; i < btnNames.length; i++) {
  169. var btn = cc.find(btnNames[i], this._panel);
  170. if (!btn)
  171. continue;
  172. btn.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  173. if (btn.name == "BtnGet") {
  174. this._btnGet = btn;
  175. }
  176. else if (btn.name == "BtnDouble") {
  177. this._btnDouble = btn;
  178. this._btnDouble.active = CocosZ_1.cocosz.isADON;
  179. }
  180. else {
  181. this._btnClose = btn;
  182. }
  183. }
  184. for (var i = 0; i < 6; i++) {
  185. var dayItem = new DayItem(i, this._panel.getChildByName("Day_" + (i + 1)));
  186. this._day.push(dayItem);
  187. }
  188. this.initAdForPage();
  189. };
  190. UISignPanel.prototype.initAdForPage = function () {
  191. if (cc.sys.os === cc.sys.OS_ANDROID) {
  192. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  193. console.log("zh:checkstatus:", ATRewardedVideoJSSDK_1.default.checkAdStatus(ATAndroidJS2_1.default.getPlacementId()));
  194. var setting = {};
  195. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  196. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting);
  197. }
  198. };
  199. UISignPanel.prototype.onOpen = function () {
  200. // 上报 首页签到
  201. Utils_1.utils.umaEvent("gamegamesign");
  202. Utils_1.utils.SendEvent("1页面-签到");
  203. this._initPanel();
  204. };
  205. UISignPanel.prototype._initPanel = function () {
  206. TweenEffect_1.default.panel_open_scale(this._panel);
  207. // 缩放
  208. this._updateDayItem();
  209. };
  210. UISignPanel.prototype._updateDayItem = function () {
  211. for (var i = 0; i < 6; i++) {
  212. this._day[i].update();
  213. }
  214. };
  215. UISignPanel.prototype._onBtnClickedHandler = function (event, data) {
  216. return __awaiter(this, void 0, void 0, function () {
  217. var _this = this;
  218. return __generator(this, function (_a) {
  219. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  220. switch (event.target.name) {
  221. case "BtnGet": {
  222. if (!this._canGetBonus()) {
  223. Msg_1.default.Show(i18n.t("msg.jryqd")); //今日已领取奖励
  224. return [2 /*return*/];
  225. }
  226. this._getReward(false);
  227. break;
  228. }
  229. case "BtnDouble": {
  230. if (!this._canGetBonus()) {
  231. Msg_1.default.Show(i18n.t("msg.jryqd")); //今日已领取奖励
  232. return [2 /*return*/];
  233. }
  234. // 注册方法 , this.ClickClose.bind(this));
  235. GlobalManager_1.default.getInstance().registerMethod('_getReward_eventForAd', this._getReward_eventForAd.bind(this));
  236. cc.sys.localStorage.setItem(this.adKey, 'qianDao_dblq'); //
  237. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  238. console.log('zh:AD ready for idx2');
  239. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  240. }
  241. else {
  242. this.initAdForPage();
  243. console.log('zh:AD not ready for idx2');
  244. this._getReward_eventForAd(true);
  245. }
  246. if (2 > 1) {
  247. return [2 /*return*/]; //下面是原始的代码
  248. }
  249. Utils_1.utils.SendEvent("视频-双倍签到-播放");
  250. CocosZ_1.cocosz.watchAD(function () {
  251. Utils_1.utils.SendEvent("视频-双倍签到-成功");
  252. _this._getReward(true);
  253. }, function () {
  254. Utils_1.utils.SendEvent("视频-双倍签到-失败");
  255. });
  256. break;
  257. }
  258. case "BtnClose": {
  259. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UISignPanel);
  260. break;
  261. }
  262. }
  263. return [2 /*return*/];
  264. });
  265. });
  266. };
  267. UISignPanel.prototype._getReward = function (double) {
  268. if (double == false) {
  269. // 上报 普通签到
  270. Utils_1.utils.umaEvent("gamesignordinary");
  271. Utils_1.utils.SendEvent("签到-普通");
  272. }
  273. else {
  274. // 上报 双倍签到
  275. Utils_1.utils.umaEvent("gamedoublesign");
  276. Utils_1.utils.SendEvent("签到-双倍");
  277. }
  278. // 签到索引
  279. var lastDayIndex = CocosZ_1.cocosz.dataMgr.LastDailyBonusIndex;
  280. if (lastDayIndex == 6) {
  281. lastDayIndex = -1;
  282. }
  283. var curDayIndex = lastDayIndex + 1;
  284. // 奖励数量
  285. var count = REWARD_SIGN[curDayIndex];
  286. if (double) {
  287. count *= 2;
  288. }
  289. if (curDayIndex == 3 || curDayIndex == 6) {
  290. // 钻石
  291. Msg_1.default.Show(i18n.t("msg.gxhdzs") + count);
  292. CocosZ_1.cocosz.dataMgr.DiamondCount += count;
  293. // 飞金币事件
  294. setTimeout(function () {
  295. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_Fly_Coin, iconName: 'diamond', frameNodeName: 'CoinLabel2' });
  296. }, 500);
  297. }
  298. else {
  299. // 金币
  300. Msg_1.default.Show(i18n.t("msg.gxhdjb") + count);
  301. CocosZ_1.cocosz.dataMgr.CoinCount += count;
  302. // 飞金币事件
  303. setTimeout(function () {
  304. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_Fly_Coin, iconName: 'coin', frameNodeName: 'CoinLabel' });
  305. }, 500);
  306. }
  307. // 本地信息
  308. CocosZ_1.cocosz.dataMgr.LastDailyBonusIndex = curDayIndex;
  309. CocosZ_1.cocosz.dataMgr.LastDailyBonusTime = new Date().toDateString();
  310. // 刷新UI
  311. // this._updateDayItem();
  312. // 关闭弹窗
  313. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UISignPanel);
  314. };
  315. //AD
  316. UISignPanel.prototype._getReward_eventForAd = function (double) {
  317. console.log('zh:AD eventForAd 被触发:', double);
  318. if (double == false) {
  319. // 上报 普通签到
  320. Utils_1.utils.umaEvent("gamesignordinary");
  321. Utils_1.utils.SendEvent("签到-普通");
  322. }
  323. else {
  324. // 上报 双倍签到
  325. Utils_1.utils.umaEvent("gamedoublesign");
  326. Utils_1.utils.SendEvent("签到-双倍");
  327. }
  328. // 签到索引
  329. var lastDayIndex = CocosZ_1.cocosz.dataMgr.LastDailyBonusIndex;
  330. if (lastDayIndex == 6) {
  331. lastDayIndex = -1;
  332. }
  333. var curDayIndex = lastDayIndex + 1;
  334. // 奖励数量
  335. var count = REWARD_SIGN[curDayIndex];
  336. if (double) {
  337. count *= 2;
  338. }
  339. if (curDayIndex == 3 || curDayIndex == 6) {
  340. // 钻石
  341. Msg_1.default.Show(i18n.t("msg.gxhdzs") + count);
  342. CocosZ_1.cocosz.dataMgr.DiamondCount += count;
  343. // 飞金币事件
  344. setTimeout(function () {
  345. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_Fly_Coin, iconName: 'diamond', frameNodeName: 'CoinLabel2' });
  346. }, 500);
  347. }
  348. else {
  349. // 金币
  350. Msg_1.default.Show(i18n.t("msg.gxhdjb") + count);
  351. CocosZ_1.cocosz.dataMgr.CoinCount += count;
  352. // 飞金币事件
  353. setTimeout(function () {
  354. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_Fly_Coin, iconName: 'coin', frameNodeName: 'CoinLabel' });
  355. }, 500);
  356. }
  357. // 本地信息
  358. CocosZ_1.cocosz.dataMgr.LastDailyBonusIndex = curDayIndex;
  359. CocosZ_1.cocosz.dataMgr.LastDailyBonusTime = new Date().toDateString();
  360. // 刷新UI
  361. // this._updateDayItem();
  362. // 关闭弹窗
  363. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UISignPanel);
  364. };
  365. UISignPanel.prototype._canGetBonus = function () {
  366. // cocosz.dataMgr.LastDailyBonusTime = 'Fri Dec 18 2024';
  367. return (new Date().toDateString() != CocosZ_1.cocosz.dataMgr.LastDailyBonusTime);
  368. };
  369. UISignPanel = __decorate([
  370. ccclass
  371. ], UISignPanel);
  372. return UISignPanel;
  373. }(UIPage_1.default));
  374. exports.default = UISignPanel;
  375. cc._RF.pop();