RedCode.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import JsbSystem from "../../../mk/system/JsbSystem";
  2. /**
  3. * @description 公众号提现
  4. * @author kaka
  5. */
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class RedCode extends cc.Component {
  9. @property(cc.Label)
  10. labOfficial: cc.Label = null;
  11. @property(cc.Label)
  12. labRed: cc.Label = null;
  13. @property(cc.Label)
  14. labMoney: cc.Label = null;
  15. @property(cc.Label)
  16. labRedCode: cc.Label = null;
  17. @property(cc.Node)
  18. parNode: cc.Node = null;
  19. @property(cc.Prefab)
  20. videoPre: cc.Prefab = null;
  21. videoNode = null
  22. officialStr = "白羊游戏社"
  23. redCodeStr = "领红包"
  24. code = ""
  25. coolTime = false
  26. start() {
  27. mk.ad.showNative(4);
  28. this.coolTime = false
  29. this.labOfficial.string = `“${this.officialStr}”`
  30. this.labRed.string = `“${this.redCodeStr}”`
  31. }
  32. update() {
  33. if (gData.redCodeData.init_data) {
  34. this.init(gData.redCodeData.money, gData.redCodeData.code);
  35. }
  36. }
  37. lateUpdate() {
  38. gData.redCodeData.init_data = false;
  39. }
  40. init(money, code) {
  41. this.labMoney.string = `${money.toFixed(2)}元`
  42. this.code = code
  43. this.labRedCode.string = `提现红包码:${this.code}`
  44. }
  45. /** 点击复制公众号 */
  46. clickCopyOfficial() {
  47. mk.audio.playEffect('button');
  48. JsbSystem.setClipboard(this.officialStr)
  49. }
  50. /** 点击教程 */
  51. clickTeach() {
  52. mk.audio.playEffect('button');
  53. if (this.coolTime) {
  54. return
  55. }
  56. this.coolTime = true
  57. gData.redCodeData.teachVideoType = 1;
  58. console.log('clickTeach')
  59. this.videoNode = cc.instantiate(this.videoPre)
  60. this.videoNode.getChildByName('video').on("completed", this.onCompleted, this)
  61. this.node.addChild(this.videoNode)
  62. }
  63. onCompleted() {
  64. this.videoNode.getChildByName('video').off("completed", this.onCompleted, this)
  65. this.videoNode.destroy()
  66. mk.audio.setResumeMusic();
  67. this.coolTime = false
  68. }
  69. /** 点击复制红包码 */
  70. clickCopyRedCode() {
  71. mk.audio.playEffect("button");
  72. JsbSystem.setClipboard(this.code)
  73. }
  74. /** 点击关闭 */
  75. closeCallBack() {
  76. mk.audio.playEffect("button");
  77. mk.audio.setResumeMusic();
  78. }
  79. onClickClose() {
  80. mk.ad.destroyNativeAd();
  81. }
  82. }