RedCodePanel.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import AdM from "../manager/AdM";
  2. import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
  3. import UiM, { PANEL_NAME } from "../manager/UiM";
  4. import BasePanel from "../uiFrames/BasePanel";
  5. import UIMng, { PanelType } from "../uiFrames/UIMng";
  6. import CashOut from "./CashOut";
  7. import OfficialNode from "./OfficialNode";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export default class RedCodePanel extends BasePanel {
  11. @property(cc.Node)
  12. panelNode: cc.Node = null;
  13. @property(cc.Label)
  14. labOfficial: cc.Label = null;
  15. @property(cc.Label)
  16. labRed: cc.Label = null;
  17. @property(cc.Label)
  18. labMoney: cc.Label = null;
  19. @property(cc.Label)
  20. labRedCode: cc.Label = null;
  21. @property(cc.Node)
  22. parNode: cc.Node = null;
  23. videoNode = null
  24. officialStr = "白羊游戏社"
  25. redCodeStr = "领红包"
  26. code = ""
  27. coolTime = false
  28. start() {
  29. this.coolTime = false
  30. this.labOfficial.string = `“${this.officialStr}”`
  31. this.labRed.string = `“${this.redCodeStr}”`
  32. }
  33. OnEnter(param: any) {
  34. this.panelNode.scale = 0;
  35. this.node.active = true;
  36. cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
  37. .call(() => {
  38. console.log("AAAAAA");
  39. })
  40. .start();
  41. this.labMoney.string = `${param.money.toFixed(2)}元`
  42. this.code = param.code
  43. this.labRedCode.string = `提现红包码:${this.code}`
  44. }
  45. OnExit() {
  46. this.node.active = false;
  47. }
  48. init(money, code) {
  49. this.labMoney.string = `${money.toFixed(2)}元`
  50. this.code = code
  51. this.labRedCode.string = `提现红包码:${this.code}`
  52. }
  53. /** 点击复制公众号 */
  54. clickCopyOfficial() {
  55. GameM.audioM.playEffect(AUDIO_TYPE.button)
  56. AdM.setClipboard(this.officialStr)
  57. }
  58. /** 点击教程 */
  59. clickTeach() {
  60. GameM.audioM.playEffect(AUDIO_TYPE.button)
  61. if (this.coolTime) {
  62. return
  63. }
  64. this.coolTime = true
  65. GameM.commonData.teachVideoType = 1;
  66. console.log('clickTeach')
  67. let temp = cc.loader.getRes('prefabs/VideoNode')
  68. this.videoNode = cc.instantiate(temp)
  69. this.videoNode.getChildByName('video').on("completed", this.onCompleted, this)
  70. this.node.addChild(this.videoNode)
  71. }
  72. onCompleted() {
  73. this.videoNode.getChildByName('video').off("completed", this.onCompleted, this)
  74. this.videoNode.destroy()
  75. GameM.audioM.setResumeMusic()
  76. GameM.audioM.setTempEffect(true)
  77. this.coolTime = false
  78. }
  79. /** 点击复制红包码 */
  80. clickCopyRedCode() {
  81. GameM.audioM.playEffect(AUDIO_TYPE.button)
  82. AdM.setClipboard(this.code)
  83. }
  84. /** 点击关闭 */
  85. clickClose() {
  86. GameM.audioM.setResumeMusic()
  87. GameM.audioM.setTempEffect(true)
  88. GameM.audioM.playEffect(AUDIO_TYPE.button)
  89. this.OnExit();
  90. //this.hideEff()
  91. }
  92. hideEff() {
  93. if (UiM.Instance.cashNode) {
  94. let pos = UiM.Instance.cashNode.getComponent(CashOut).labRedCode.position
  95. let addy = (cc.winSize.height - 1334) / 2
  96. pos.y += addy
  97. cc.tween(this.parNode).to(0.2, { scale: 0, position: pos }).call(() => {
  98. UiM.Instance.offPanel(PANEL_NAME.OfficialNode)
  99. }).start();
  100. }
  101. else {
  102. UiM.Instance.offPanel(PANEL_NAME.OfficialNode)
  103. }
  104. }
  105. }