import { _decorator, Component, Label, Node, Animation } from 'cc'; import { base_ui } from '../fw/base_ui'; import { userDataManager } from '../manager/userDataManager'; const { ccclass, property } = _decorator; @ccclass('unLock_view') export class unLock_view extends base_ui { @property(Node) btn_close:Node = null @property(Node) btn_look_video:Node = null @property(Node) lab_look_video:Node = null private max_count:number = 3 private m_lookVideo_finish_cb = null start() { this.onButtonListen(this.btn_close, ()=>{ this.stopBtnLookVideoAni() this.closeSelf() }) let count = 0 this.onButtonListen(this.btn_look_video, ()=>{ if(count>=this.max_count) { return } count++ this.lab_look_video.getComponent(Label).string = '看视频' + count + '/' + this.max_count if(count==this.max_count) { if(this.m_lookVideo_finish_cb) { let cur_time = new Date().getTime() userDataManager.saveUserFreeAdsData(cur_time) this.m_lookVideo_finish_cb(this) } } }) this.playBtnLookVideoAni() } initView(lookVideo_finish_cb) { this.m_lookVideo_finish_cb = lookVideo_finish_cb } closeSelf() { this.close() } private playBtnLookVideoAni() { this.btn_look_video.getComponent(Animation).play() } private stopBtnLookVideoAni() { this.btn_look_video.getComponent(Animation).stop() } }