var List = require("List"); import SoundMgr from "../base/SoundMgr"; import UIMgr from "../base/UIMgr"; cc.Class({ extends: cc.Component, properties: { conNode: cc.Node, unList: List, readList: List, unRead: cc.Node, read: cc.Node, noMail: cc.Node, desNode: cc.Node, getNode: cc.Node, delNode: cc.Node, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.adaptor(); }, start () { this.initData(); }, showMail(hallSceneJs){ this.hallSceneJs = hallSceneJs; this.node.active = true; }, initData(){ this.itemOffData = []; //未读 this.itemOnData = []; //已读 for(let i=0; i < 10; i++){ this.itemOffData.push(i); this.itemOnData.push(i*10); } this.unList.numItems = this.itemOffData.length; this.readList.numItems = this.itemOnData.length; this.onClickOnOff(-1,1); }, onClickOnOff(event, bOff){ bOff = bOff == 1; this.unRead.active = bOff; this.unList.node.active = bOff; this.read.active = !bOff; this.readList.node.active = !bOff; this.delNode.active = !bOff; if(this.unRead.active){ this.noMail.active = this.itemOffData.length == 0; } if(this.read.active){ this.noMail.active = this.itemOnData.length == 0; } }, unListRender(item, idx){ item.active = true; item.getComponent('ListItem').setInfo(this, this.itemOffData[idx]); }, readListRender(item, idx){ item.active = true; item.getComponent('ListItem').setInfo(this, this.itemOnData[idx]); }, delUnRead(idx){ let self = this; let func = function(idx){ if (idx != null) { self.itemOffData.splice(idx, 1); self.unList.numItems = self.itemOffData.length; } } self.unList.aniDelItem(idx, func); }, delAllRead(idx){ let self = this; let func = function(idx){ if (idx != null) { self.itemOnData.splice(0, self.itemOnData.length); self.readList.numItems = self.itemOnData.length; self.noMail.active = self.itemOnData.length == 0; } } self.readList.aniDelItem(idx, func); this.delNode.getChildByName('mask').active = true; }, onClickDel(){ SoundMgr.playClick(); this.delAllRead(-1); }, adaptor(){ let desPos = this.desNode.convertToWorldSpaceAR(cc.v2(0,0)); let lerp = (desPos.y -320) * 2; this.conNode.setContentSize(this.conNode.width, this.conNode.height + lerp); this.unList.node.setContentSize(this.unList.node.width, this.unList.node.height + lerp); let view1 = this.unList.node.getChildByName('view'); view1.setContentSize(view1.width, view1.height + lerp); this.readList.node.setContentSize(this.readList.node.width, this.readList.node.height + lerp); let view2 = this.readList.node.getChildByName('view'); view2.setContentSize(view2.width, view2.height + lerp); }, onClickLook(idx){ this.delUnRead(idx); UIMgr.openUI('prefabs/MailTipLayer', (pf)=>{ // pf.getComponent('MailTipLayer').closeCb(()=>{ // this.delUnRead(idx); // }); }); }, onClose(){ SoundMgr.playClick(); this.node.active = false; this.hallSceneJs.showHides(true); }, });