NativeTryGamesWidget.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import TryGameNode from "./TryGameNode";
  2. import { utils } from "./Utils";
  3. import NativeTryGameNode from "./NativeTryGameNode";
  4. import PlatUtils from "./PlatUtils";
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass
  7. export default class NativeTryGamesWidget extends cc.Component {
  8. _tryGameNode: NativeTryGameNode = null;
  9. _btnClose: cc.Node = null;
  10. onLoad() {
  11. this._tryGameNode = this.getComponentInChildren("NativeTryGameNode");
  12. this._tryGameNode.node.active = false;
  13. this._btnClose = this._tryGameNode.node.getChildByName("BtnClose");
  14. }
  15. init() {
  16. if (!this._tryGameNode) {
  17. this._tryGameNode = this.getComponentInChildren("NativeTryGameNode");
  18. this._btnClose = this._tryGameNode.node.getChildByName("BtnClose");
  19. }
  20. if (utils.isShowNativeTryGamesWidget()) {
  21. let dataValid: boolean = true;
  22. if (utils.tryGameDate) {
  23. if (utils.tryGameDate.length <= 0) {
  24. cc.warn("res的长度不合法!");
  25. dataValid = false;
  26. }
  27. } else {
  28. cc.warn("res不存在!");
  29. dataValid = false;
  30. }
  31. utils.showLog("原生抖动dataValid:" + dataValid);
  32. if (dataValid) {
  33. utils.showLog("交叉推广数据:", JSON.stringify(utils.tryGameDate));
  34. this._tryGameNode.init({ "jump_refresh_time": utils.ServerConfig.icon_jump_native, "jump_list": utils.tryGameDate });
  35. this._tryGameNode.node.active = true;
  36. if (PlatUtils.IsHuaWei) {
  37. utils.showLog("华为平台,显示关闭按钮>>>>>")
  38. this._btnClose.active = true;
  39. }
  40. } else {
  41. this._tryGameNode.node.active = false;
  42. }
  43. } else {
  44. this._tryGameNode.node.active = false;
  45. }
  46. }
  47. close() {
  48. this._tryGameNode.node.opacity = 0;
  49. }
  50. }