3f5abfc3-c452-4067-a4e0-6d552242aad2.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. "use strict";
  2. cc._RF.push(module, '3f5ab/DxFJAZ6TgbVUiQqrS', 'QCrossWidgetItem');
  3. // common-plugin/Scripts/QCrossWidgetItem.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. Object.defineProperty(exports, "__esModule", { value: true });
  25. var Utils_1 = require("./Utils");
  26. var PlatUtils_1 = require("./PlatUtils");
  27. var YZ_Constant_1 = require("./YZ_Constant");
  28. var CompatibleTool_1 = require("./CompatibleTool");
  29. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  30. var QCrossWidgetItem = /** @class */ (function (_super) {
  31. __extends(QCrossWidgetItem, _super);
  32. function QCrossWidgetItem() {
  33. var _this = _super !== null && _super.apply(this, arguments) || this;
  34. /*
  35. {
  36. "name": "翻滚的香肠大冒险",
  37. "appid": "wx2c4ed4218224b042",
  38. "icon": "https://xcx.youletd.com/img/icon/fgdxc.png",
  39. "logo": "https://xcx.youletd.com/img/logo/4.png",
  40. "is_jump": "true",
  41. "path": "",
  42. "qr_code": "https://xcx.youletd.com/img/qrcode/q_fgdxc.jpg"
  43. }
  44. */
  45. _this.data = null;
  46. _this._sprite = null;
  47. _this._dataDirty = false;
  48. _this._isReward = false;
  49. _this._location = null;
  50. return _this;
  51. }
  52. QCrossWidgetItem.prototype.onLoad = function () {
  53. this._sprite = this.node.getComponent(cc.Sprite);
  54. };
  55. QCrossWidgetItem.prototype.init = function (data) {
  56. this.data = data;
  57. this._dataDirty = true;
  58. };
  59. QCrossWidgetItem.prototype.update = function (dt) {
  60. if (this._dataDirty) {
  61. this._dataDirty = false;
  62. this.updateItem();
  63. }
  64. };
  65. QCrossWidgetItem.prototype.onEnable = function () {
  66. this.node.on(cc.Node.EventType.TOUCH_END, this._onItemClickHandler, this);
  67. };
  68. QCrossWidgetItem.prototype.onDisable = function () {
  69. this.node.targetOff(this);
  70. };
  71. QCrossWidgetItem.prototype._onItemClickHandler = function () {
  72. var _this = this;
  73. console.log("_onItemClickHandler");
  74. if (PlatUtils_1.default.IsDouyin) {
  75. Utils_1.utils.Tool_Douyin.showMoreGamesModal();
  76. return;
  77. }
  78. if (this.data && this.data.appid) {
  79. this._postClickData(this.data.appid);
  80. }
  81. //如果是激励模式就直接跳转
  82. if (this._location == YZ_Constant_1.SubLocation.isReward) {
  83. Utils_1.utils.navigateToMiniGame(this.data, function (ret) {
  84. if (ret) {
  85. // 上报数据
  86. if (_this.data && _this.data.appid) {
  87. _this._postData(_this.data.appid);
  88. }
  89. Utils_1.utils.showLog("激励插屏跳转成功!下发奖励!");
  90. Utils_1.utils.adManager.videoCallBack && Utils_1.utils.adManager.videoCallBack(ret);
  91. Utils_1.utils.adManager.videoCallBack = null;
  92. }
  93. else {
  94. Utils_1.utils.showLog("激励插屏跳转失败!");
  95. Utils_1.utils.adManager.videoCallBack && Utils_1.utils.adManager.videoCallBack(false, "获取试玩奖励失败!");
  96. }
  97. Utils_1.utils.adManager.videoCallBack = null;
  98. Utils_1.utils.adManager.hideRewardInsert();
  99. });
  100. return;
  101. }
  102. if (this.data.is_jump && this.data.is_jump == "true" && this.data.appid) {
  103. Utils_1.utils.showLog("直接跳转!", this.data.appid);
  104. Utils_1.utils.navigateToMiniGame(this.data, function (ret) {
  105. if (ret) {
  106. // 上报数据
  107. if (_this.data && _this.data.appid) {
  108. _this._postData(_this.data.appid);
  109. }
  110. }
  111. });
  112. }
  113. else if (this.data.is_jump && this.data.is_jump == "false" && this.data.qr_code) {
  114. if (PlatUtils_1.default.IsWechat) {
  115. Utils_1.utils.showLog("二维码跳转!", this.data.qr_code);
  116. Utils_1.utils.wechatTool.previewImage(this.data.qr_code);
  117. // // 上报数据
  118. // if (this.data && this.data.appid) {
  119. // this._postData(this.data.appid);
  120. // }
  121. }
  122. else {
  123. Utils_1.utils.showLog("不支持二维码跳转!");
  124. }
  125. }
  126. else {
  127. Utils_1.utils.showLog("没有is_jump直接跳转!", this.data.appid);
  128. if (this.data.appid) {
  129. Utils_1.utils.navigateToMiniGame(this.data, function (ret) {
  130. if (ret) {
  131. // 上报数据
  132. if (_this.data.appid) {
  133. _this._postData(_this.data.appid);
  134. }
  135. }
  136. });
  137. }
  138. }
  139. };
  140. QCrossWidgetItem.prototype.updateItem = function () {
  141. var _this = this;
  142. if (this.data && this.data.logo) {
  143. var temp = cc.loader.getRes(this.data.logo);
  144. if (temp) {
  145. if (cc.isValid(this) && this._sprite) {
  146. var size = this.node.getContentSize();
  147. this._sprite.spriteFrame = new cc.SpriteFrame(temp);
  148. this.node.setContentSize(size);
  149. }
  150. }
  151. else {
  152. CompatibleTool_1.default.LoadRes(this.data.logo, function (err, texture) {
  153. if (!err && cc.isValid(_this) && _this._sprite) {
  154. var size = _this.node.getContentSize();
  155. _this._sprite.spriteFrame = new cc.SpriteFrame(texture);
  156. _this.node.setContentSize(size);
  157. }
  158. });
  159. }
  160. }
  161. };
  162. /**
  163. * 上报跳转成功
  164. * @param appid
  165. */
  166. QCrossWidgetItem.prototype._postData = function (appid) {
  167. Utils_1.utils.postDataByLocation(appid, this._location, 1);
  168. };
  169. /**
  170. * 上报点击
  171. * @param appid
  172. */
  173. QCrossWidgetItem.prototype._postClickData = function (appid) {
  174. Utils_1.utils.postDataByLocation(appid, this._location, 0);
  175. };
  176. QCrossWidgetItem = __decorate([
  177. ccclass
  178. ], QCrossWidgetItem);
  179. return QCrossWidgetItem;
  180. }(cc.Component));
  181. exports.default = QCrossWidgetItem;
  182. cc._RF.pop();