unLock_view.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { _decorator, Component, Label, Node, Animation } from 'cc';
  2. import { base_ui } from '../fw/base_ui';
  3. import { userDataManager } from '../manager/userDataManager';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('unLock_view')
  6. export class unLock_view extends base_ui {
  7. @property(Node) btn_close:Node = null
  8. @property(Node) btn_look_video:Node = null
  9. @property(Node) lab_look_video:Node = null
  10. private max_count:number = 3
  11. private m_lookVideo_finish_cb = null
  12. start() {
  13. this.onButtonListen(this.btn_close, ()=>{
  14. this.stopBtnLookVideoAni()
  15. this.closeSelf()
  16. })
  17. let count = 0
  18. this.onButtonListen(this.btn_look_video, ()=>{
  19. if(count>=this.max_count) {
  20. return
  21. }
  22. count++
  23. this.lab_look_video.getComponent(Label).string = '看视频' + count + '/' + this.max_count
  24. if(count==this.max_count) {
  25. if(this.m_lookVideo_finish_cb) {
  26. let cur_time = new Date().getTime()
  27. userDataManager.saveUserFreeAdsData(cur_time)
  28. this.m_lookVideo_finish_cb(this)
  29. }
  30. }
  31. })
  32. this.playBtnLookVideoAni()
  33. }
  34. initView(lookVideo_finish_cb) {
  35. this.m_lookVideo_finish_cb = lookVideo_finish_cb
  36. }
  37. closeSelf() {
  38. this.close()
  39. }
  40. private playBtnLookVideoAni() {
  41. this.btn_look_video.getComponent(Animation).play()
  42. }
  43. private stopBtnLookVideoAni() {
  44. this.btn_look_video.getComponent(Animation).stop()
  45. }
  46. }