MoreGamePopNode.ts 1.8 KB

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