RedBagCode.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import MKSwitch from "../../../mk/MKSwitch";
  2. const { ccclass, property } = cc._decorator;
  3. /**
  4. * 红包码列表
  5. * @author 薛鸿潇
  6. */
  7. @ccclass
  8. export default class RedBagCode extends cc.Component {
  9. @property({ type: cc.ScrollView, displayName: '滚动视图' })
  10. private scroll_view: cc.ScrollView = null!;
  11. @property({ displayName: 'lbl暂无提现', type: cc.Label })
  12. private lbl_none: cc.Label = null;
  13. @property(cc.Prefab)
  14. videoPre: cc.Prefab = null;
  15. start() {
  16. gData.cashNormal.getRecord();
  17. // this.initList();
  18. mk.ad.showNative(4);
  19. }
  20. /**
  21. * 初始化滚动列表
  22. */
  23. private initList() {
  24. let list_data = gData.cashNormal.getListDataHavCode();
  25. this.scroll_view.node.emit('srollview-init', list_data)
  26. this.initNoneItem(list_data);
  27. }
  28. /**
  29. * 初始化无条目时的提示
  30. */
  31. private initNoneItem(list_data) {
  32. const count = list_data.length;
  33. if (count) {
  34. this.lbl_none.node.active = false;
  35. } else {
  36. this.lbl_none.node.active = true;
  37. }
  38. }
  39. coolTime = false
  40. videoNode = null
  41. /** 点击教程 */
  42. clickTeach() {
  43. mk.audio.playEffect('button');
  44. if (this.coolTime) {
  45. return
  46. }
  47. this.coolTime = true
  48. gData.redCodeData.teachVideoType = 1;
  49. this.videoNode = cc.instantiate(this.videoPre)
  50. this.videoNode.getChildByName('video').on("completed", this.onCompleted, this)
  51. this.node.addChild(this.videoNode)
  52. }
  53. onCompleted() {
  54. this.videoNode.getChildByName('video').off("completed", this.onCompleted, this)
  55. this.videoNode.destroy()
  56. mk.audio.setResumeMusic();
  57. this.coolTime = false
  58. }
  59. onClickClose() {
  60. mk.ad.destroyNativeAd();
  61. }
  62. update() {
  63. if (gData.cashNormal.update_list) {
  64. this.initList();
  65. }
  66. }
  67. lateUpdate() {
  68. gData.cashNormal.update_list = false;
  69. }
  70. }