Files
fc/dev/project/library/imports/ca/caaa04d4-7c38-4a57-a7c7-00703d0ed398.js
T
2026-05-24 10:21:26 +08:00

170 lines
4.9 KiB
JavaScript

"use strict";
cc._RF.push(module, 'caaa0TUfDhKV6fHAHA9DtOY', 'cmp.mail.test.wnd');
// Scripts/mod/mail/cmp/cmp.mail.test.wnd.js
"use strict";
var BridgeWindow = require("bridge.window");
var FxTogs = require("nx.fx.togs");
var SvcList = require("nx.fx.sv.expand");
var mod = require("mail.mod");
var MailEvent = require("mail_event");
cc.Class({
"extends": BridgeWindow,
properties: {
nodTog: {
"default": null,
type: FxTogs
},
nodCnt: {
"default": null,
type: SvcList
},
nodInfo: {
"default": null,
type: cc.Node
}
},
onLoad: function onLoad() {
this.mod = mod.getInstance();
if (!this.mod) {
this.delayClose();
}
this.select_index = 0;
// //刷新邮件
this.bindGEvent(MailEvent.UPDATE_ITEM, this.freshMailList.bind(this));
// //刷新公告
this.bindGEvent(MailEvent.UPDATE_NOTICE, this.freshMailList.bind(this));
// //读取公告
this.bindGEvent(MailEvent.READ_INFO_NOTICE, this.showNoticeInfo.bind(this));
// //读取邮件
this.bindGEvent(MailEvent.OPEN_INFO_WIN, this.showMailInfo.bind(this));
this.bindGEvent(MailEvent.FRESH_ITEM, this.dealMailStatus.bind(this));
},
onOpenConfigs: function onOpenConfigs(_param) {
this.nodTog.posTog = this.onTogMenu.bind(this);
this.nodTog.togTo(0);
this.onTogMenu(0);
},
onPreClosed: function onPreClosed() {
this.nodCnt.rebuild([]);
},
onTogMenu: function onTogMenu(_idx) {
var _this = this;
var id = parseInt(_idx);
this.choice = id;
var mails = id == 0 ? this.mod.getAllMailArray() : this.mod.getNoticeArray();
nx.gui.setActive(this.nodInfo, "", id == 1 ? nx.dt.arrNEmpty(mails) : nx.dt.arrNEmpty(mails));
nx.gui.setActive(this.nodCnt.node, "lay", id == 1 ? nx.dt.arrNEmpty(mails) : true);
var cmp = nx.gui.getComponent(this.nodCnt.node, "scrollCon", cc.ScrollView);
if (cmp) {
cmp.scrollToTop(0.01);
}
this.nodCnt.rebuild(mails);
var chd = nx.gui.find(this.nodCnt.bindSCV, "mask/content").children;
this.scheduleOnce(function () {
_this.nodCnt.addFocus(0);
if (chd[0]) {
chd[0].svItem ? _this.onFocusChange(chd[0].svItem) : _this.onFocusChange({});
}
}, 0.1);
// this.dealOp();
},
onFocusChange: function onFocusChange(_item) {
// 空
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
return;
}
var chd = nx.gui.find(this.nodCnt.bindSCV, "mask/content").children;
// this.list.cleanFocus();
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
if (nod.svItem) {
if (i == _item.index) {
nod.svItem.onFocus();
// break;
} else {
nod.svItem.outFocus();
}
}
}
// 聚焦
// this.list.cleanFocus();
// this.list.addFocus( _item.index );
this.select_index = _item.index;
if (_item.mdata.status >= 0) {
//邮件
this.mod.requireMailItem(_item.mdata.id, _item.mdata.srv_id, this.info_win);
} else if (_item.mdata.flag >= 0) {
//公告
this.mod.readNotice(_item.mdata.id);
}
},
showMailInfo: function showMailInfo(_data) {
this.readMail = _data;
var cmp = nx.gui.getComponent(this.nodInfo, "", "cmp.mail.info");
if (cmp) {
cmp.setData(_data);
}
nx.gui.setActive(this.nodInfo, "", true);
// this.dealMailStatus();
},
dealMailStatus: function dealMailStatus() {
var _this2 = this;
var chd = nx.gui.find(this.nodCnt.bindSCV, "mask/content").children;
// this.list.cleanFocus();
var mails = this.choice == 0 ? this.mod.getAllMailArray() : this.mod.getNoticeArray();
var change = {};
mails.forEach(function (_mail) {
if (_mail.id == _this2.readMail.id) {
change = _mail;
}
});
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
if (nod.svItem && nx.dt.objNEmpty(change)) {
if (change.id == nod.svItem.mdata.id) {
nod.svItem.rebind(i, change);
// break;
}
}
}
// this.dealOp();
},
freshMailList: function freshMailList() {
this.onTogMenu(this.choice);
},
touchGetAll: function touchGetAll() {
this.mod.getAllGoods();
},
touchDel: function touchDel() {
var mails = this.choice == 0 ? this.mod.getAllMailArray() : this.mod.getNoticeArray();
var readMails = [];
mails.forEach(function (_mail) {
if (_mail.status == 2 || _mail.status == 1 && nx.dt.arrEmpty(_mail.assets)) {
readMails.push(_mail);
}
});
if (nx.dt.arrNEmpty(readMails)) {
var list = this.mod.getHasReadNonRewardList();
this.mod.deletMailSend(list);
} else {
nx.tbox("NoneMailDel");
}
},
showNoticeInfo: function showNoticeInfo(_id) {
var notice_msg = this.mod.getNoticeMessage(_id);
if (notice_msg) {
this.nodInfo.getComponent("cmp.mail.info").setData(notice_msg);
}
}
});
cc._RF.pop();