MoreGamePopNode.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * @description 互推弹出红包界面
  3. * @author kaka
  4. */
  5. import JsbSystem from "../../../mk/system/JsbSystem";
  6. import { DataEventId } from "../../data/GameData";
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class MoreGamePopNode extends cc.Component {
  10. @property(cc.Sprite)
  11. icon: cc.Sprite = null;
  12. @property(cc.Label)
  13. labName: cc.Label = null;
  14. data = null
  15. start() {
  16. gData.moreGame.init_moreGameList = true;
  17. }
  18. update() {
  19. if (gData.moreGame.init_moreGameList) {
  20. this.init();
  21. }
  22. }
  23. lateUpdate() {
  24. gData.moreGame.init_moreGameList = false;
  25. }
  26. init() {
  27. if (!CC_JSB) {
  28. return;
  29. }
  30. this.data = gData.moreGame.getRandomNormal();
  31. if (this.data) {
  32. cc.loader.load(this.data.icon, (err, res) => {
  33. if (err) {
  34. console.log('err:', err);
  35. return;
  36. }
  37. let tex: cc.Texture2D = res as cc.Texture2D;
  38. this.icon.spriteFrame = new cc.SpriteFrame(tex);
  39. })
  40. this.labName.string = this.data.title
  41. }
  42. }
  43. cool = false
  44. creatorDownLoadTask() {
  45. mk.audio.playEffect('button');
  46. if (!CC_JSB) {
  47. return;
  48. }
  49. if (this.cool) {
  50. return
  51. }
  52. this.cool = true
  53. mk.data.sendDataEvent(DataEventId.hutuiFunction, "互推插屏下载");
  54. if (this.data.appType == 1) {
  55. if (!JsbSystem.ifCanStartGame(this.data.packageName, true)) {
  56. gData.moreGame.createNewTask(this.data, 1)
  57. }
  58. }
  59. else if (this.data.appType == 2) {
  60. cc.sys.openURL(this.data.recommendLink);
  61. }
  62. gData.moreGame.popNodeGetRedBag();
  63. }
  64. }