RedCode.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. this.coolTime = false
  28. this.labOfficial.string = `“${this.officialStr}”`
  29. this.labRed.string = `“${this.redCodeStr}”`
  30. }
  31. update() {
  32. if (gData.redCodeData.init_data) {
  33. this.init(gData.redCodeData.money, gData.redCodeData.code);
  34. }
  35. }
  36. lateUpdate() {
  37. gData.redCodeData.init_data = false;
  38. }
  39. init(money, code) {
  40. this.labMoney.string = `${money.toFixed(2)}元`
  41. this.code = code
  42. this.labRedCode.string = `提现红包码:${this.code}`
  43. }
  44. /** 点击复制公众号 */
  45. clickCopyOfficial() {
  46. mk.audio.playEffect('button');
  47. JsbSystem.setClipboard(this.officialStr)
  48. }
  49. /** 点击教程 */
  50. clickTeach() {
  51. mk.audio.playEffect('button');
  52. if (this.coolTime) {
  53. return
  54. }
  55. this.coolTime = true
  56. gData.redCodeData.teachVideoType = 1;
  57. console.log('clickTeach')
  58. this.videoNode = cc.instantiate(this.videoPre)
  59. this.videoNode.getChildByName('video').on("completed", this.onCompleted, this)
  60. this.node.addChild(this.videoNode)
  61. }
  62. onCompleted() {
  63. this.videoNode.getChildByName('video').off("completed", this.onCompleted, this)
  64. this.videoNode.destroy()
  65. mk.audio.setResumeMusic();
  66. this.coolTime = false
  67. }
  68. /** 点击复制红包码 */
  69. clickCopyRedCode() {
  70. mk.audio.playEffect("button");
  71. JsbSystem.setClipboard(this.code)
  72. }
  73. /** 点击关闭 */
  74. closeCallBack() {
  75. mk.audio.playEffect("button");
  76. mk.audio.setResumeMusic();
  77. }
  78. }