RedCode.ts 2.3 KB

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