OfficialNode.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import AdM from "../manager/AdM";
  2. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  3. import UiM, { PANEL_NAME } from "../manager/UiM";
  4. import { Utils } from "../utils/Utils";
  5. import CashOut from "./CashOut";
  6. /** 公众号提现
  7. * @author kaka
  8. * @date 2020-12-11
  9. */
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class OfficialNode extends cc.Component {
  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. init(money, code) {
  34. this.labMoney.string = `${money.toFixed(2)}元`
  35. this.code = code
  36. this.labRedCode.string = `提现红包码:${this.code}`
  37. }
  38. /** 点击复制公众号 */
  39. clickCopyOfficial() {
  40. GameM.audioM.playEffect(AUDIO_TYPE.button)
  41. AdM.setClipboard(this.officialStr)
  42. }
  43. /** 点击教程 */
  44. async clickTeach() {
  45. GameM.audioM.playEffect(AUDIO_TYPE.button)
  46. if (this.coolTime) {
  47. return
  48. }
  49. this.coolTime = true
  50. GameM.commonData.teachVideoType = 1;
  51. console.log('clickTeach')
  52. let temp = await Utils.loadResPromise('prefabs/VideoNode')
  53. this.videoNode = cc.instantiate(temp)
  54. this.videoNode.getChildByName('video').on("completed", this.onCompleted, this)
  55. this.node.addChild(this.videoNode)
  56. }
  57. onCompleted() {
  58. this.videoNode.getChildByName('video').off("completed", this.onCompleted, this)
  59. this.videoNode.destroy()
  60. GameM.audioM.setResumeMusic()
  61. GameM.audioM.setTempEffect(true)
  62. this.coolTime = false
  63. }
  64. /** 点击复制红包码 */
  65. clickCopyRedCode() {
  66. GameM.audioM.playEffect(AUDIO_TYPE.button)
  67. AdM.setClipboard(this.code)
  68. }
  69. /** 点击关闭 */
  70. clickClose() {
  71. GameM.audioM.setResumeMusic()
  72. GameM.audioM.setTempEffect(true)
  73. GameM.audioM.playEffect(AUDIO_TYPE.button)
  74. this.hideEff()
  75. }
  76. hideEff() {
  77. if (UiM.Instance.cashNode) {
  78. let pos = UiM.Instance.cashNode.getComponent(CashOut).labRedCode.position
  79. let addy = (cc.winSize.height - 1334) / 2
  80. pos.y += addy
  81. cc.tween(this.parNode).to(0.2, { scale: 0, position: pos }).call(() => {
  82. UiM.Instance.offPanel(PANEL_NAME.OfficialNode)
  83. }).start();
  84. }
  85. else {
  86. UiM.Instance.offPanel(PANEL_NAME.OfficialNode)
  87. }
  88. }
  89. }