123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import SoundMgr from "../base/SoundMgr";
- import Tool from "../base/Tool";
- var baseLayer = require('BaseLayer');
- cc.Class({
- extends: baseLayer,
- properties: {
- labT: cc.Label,
- labTime: cc.Label,
- labJi: cc.Label,
- labY: cc.Label,
- itemPre: cc.Node,
- conNode: cc.Node,
- ruleNode: cc.Node,
- acNode: cc.Node,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- this.tData = [6, 30, 68, 98, 198, 328, 648];
- this.lerpTime = 20;
- this.curIndex = 0;
- this.acNode.getComponent('RechargeActivity').setType(2, this);
- this.daoshiji();
- this.schedule(this.daoshiji, 1, cc.macro.REPEAT_FOREVER);
- this.setData();
- },
- setData(){
- this.labT.string = `x${123}`;
- this.labTime.string = '';
- this.labJi.string = '204万';
- this.labY.string = this.tData[this.curIndex] + '元 立即激活';
- this.initItems();
- },
- initItems(){
- this.conNode.removeAllChildren();
- for(let i=0; i < 7; i++){
- let temp = cc.instantiate(this.itemPre);
- temp.setParent(this.conNode);
- temp.name = `${i}`;
- temp.active = true;
- temp.getChildByName('lab').getComponent(cc.Label).string = '1234';
- temp.getChildByName('labTitle').getComponent(cc.Label).string = '标题呀';
- temp.getChildByName('bar').getComponent(cc.Sprite).fillRange = 0.6;
- temp.getChildByName('labBar').getComponent(cc.Label).string = '12/88';
- let gonode = temp.getChildByName('btnGo');
- gonode.active = false;
- Tool.addBtnListener(gonode, this.node, 'ShangCardLayer', 'onClickGo', i);
- let getnode = temp.getChildByName('btnGet');
- getnode.active = true;
- Tool.addBtnListener(getnode, this.node, 'ShangCardLayer', 'onClickGet', i);
- let done = temp.getChildByName('done');
- done.active = false;
- }
- },
- onClickArrow(event, xx){
- if(xx == 'left'){
- this.curIndex -= 1;
- this.curIndex = this.curIndex <=0 ? 0 : this.curIndex;
- }else{
- this.curIndex += 1;
- this.curIndex = this.curIndex >= this.tData.length ? (this.tData.length -1) : this.curIndex;
- }
- this.setData();
- },
- daoshiji(){
- if(this.lerpTime <= 1){
- this.labTime.node.active = false;
- this.unschedule(this.daoshiji);
- return;
- }
- this.labTime.node.active = true;
- this.lerpTime -= 1;
- this.labTime.string = Tool.timesBySec2(this.lerpTime);
-
- },
- onClickGo(event, customEventData){
- SoundMgr.playClick();
- console.log('go: ', customEventData);
- },
- onClickGet(event, customEventData){
- SoundMgr.playClick();
- console.log('get: ', customEventData);
- },
- onClickJi(){
- SoundMgr.playClick();
- },
- onClickRule(){
- SoundMgr.playClick();
- this.ruleNode.active = !this.ruleNode.active;
- },
- });
|