123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { _decorator, Component, Label, Node } from 'cc';
- import { BaseView } from '../../../framework/layer/BaseView';
- import { MailItem } from './MailItem';
- import { StringUtil } from '../../../framework/util/StringUtil';
- import { MailData } from '../../data/MailData';
- import { GlobalConf } from '../../config/GlobalConf';
- import List from '../../../framework/list/List';
- import { Framework } from '../../../framework/Framework';
- const { ccclass, property } = _decorator;
- @ccclass('MailMain')
- export class MailMain extends BaseView {
- @property({ type: Label, tooltip: "关闭提示" })
- closeTips: Label = null;
- @property({ type: Label, tooltip: "标题" })
- titlteTx: Label = null;
- @property({ type: Label, tooltip: "邮件数文字" })
- numTx: Label = null;
- @property({ type: List, tooltip: "滑动容器" })
- sv: List = null;
- @property({ type: Node, tooltip: "为空提示节点" })
- noneNode: Node = null;
- @property({ type: Label, tooltip: "为空提示文字" })
- noneTx: Label = null;
- @property({ type: Node, tooltip: "一键删除按钮" })
- delAutoBtn: Node = null;
- @property({ type: Label, tooltip: "一键删除按钮文字" })
- delAutoBtnTx: Label = null;
- @property({ type: Node, tooltip: "一键领取按钮" })
- getAutoBtn: Node = null;
- @property({ type: Label, tooltip: "一键领取按钮文字" })
- getAutoBtnTx: Label = null;
- private _mailList = [];
- private _nowMailId: number = 0;
- onLoad() {
- super.onLoad();
- this.closeTips.string = StringUtil.getLanguageData('点击空白关闭');
- this.titlteTx.string = StringUtil.getLanguageData('邮件');
- this.noneTx.string = StringUtil.getLanguageData('当前空空如也哦~');
- this.delAutoBtnTx.string = StringUtil.getLanguageData('一键删除');
- this.getAutoBtnTx.string = StringUtil.getLanguageData('一键领取');
- }
- onDestroy() {
- super.onDestroy();
- }
- onOpen() {
- this.updateMainPanel();
- this.updateMailNum();
- }
- onClose() {
- }
- onShow() {
- }
- onHide() {
- }
- private onTouchButton(event: Event, customStr) {
- let target: any = event.target;
- if (target.name == 'mask') {
- Framework.layer.close(this);
- } else if (target.name == 'auto_del_btn') {
- } else if (target.name == 'auto_get_btn') {
- }
- }
- onEventList(item, idx) {
- item.getComponent(MailItem).refreshItem(this._mailList[idx]);
- }
- private updateMainPanel() {
- this._mailList = MailData.orderMail();
- this._nowMailId = this._mailList.length > 0 ? this._mailList[0].id : 0;
- if (this._mailList.length == 0) {
- this.noneNode.active = true;
- this.delAutoBtn.active = false;
- this.getAutoBtn.active = false;
- this.numTx.node.active = false;
- } else {
- this.noneNode.active = false;
- this.delAutoBtn.active = true;
- this.getAutoBtn.active = true;
- this.numTx.node.active = true;
- }
- this.sv.numItems = this._mailList.length;
- }
- private updateMailNum() {
- this.numTx.string = `${StringUtil.getLanguageData('邮件数: ')}${this._mailList.length}/${GlobalConf.data.MailMaxCount.Value}`;
- }
- }
|