RedBagCode.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const { ccclass, property } = cc._decorator;
  2. /**
  3. * 红包码列表
  4. * @author 薛鸿潇
  5. */
  6. @ccclass
  7. export default class RedBagCode extends cc.Component {
  8. @property({ type: cc.ScrollView, displayName: '滚动视图' })
  9. private scroll_view: cc.ScrollView = null!;
  10. @property({ displayName: 'lbl暂无提现', type: cc.Label })
  11. private lbl_none: cc.Label = null;
  12. @property(cc.Prefab)
  13. videoPre: cc.Prefab = null;
  14. start() {
  15. gData.cashNormal.getRecord();
  16. // this.initList();
  17. mk.ad.showNative(4);
  18. }
  19. /**
  20. * 初始化滚动列表
  21. */
  22. private initList() {
  23. let list_data = gData.cashNormal.getListDataHavCode();
  24. this.scroll_view.node.emit('srollview-init', list_data)
  25. this.initNoneItem(list_data);
  26. }
  27. /**
  28. * 初始化无条目时的提示
  29. */
  30. private initNoneItem(list_data) {
  31. const count = list_data.length;
  32. if (count) {
  33. this.lbl_none.node.active = false;
  34. } else {
  35. this.lbl_none.node.active = true;
  36. }
  37. }
  38. coolTime = false
  39. videoNode = null
  40. /** 点击教程 */
  41. clickTeach() {
  42. mk.audio.playEffect('button');
  43. if (this.coolTime) {
  44. return
  45. }
  46. this.coolTime = true
  47. gData.redCodeData.teachVideoType = 1;
  48. console.log('clickTeach')
  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. }