197 lines
5.5 KiB
JavaScript
197 lines
5.5 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'b221e524RJHIreW/2YcvFU5', 'cmp.mail.wnd');
|
||
|
|
// Scripts/mod/mail/cmp/cmp.mail.wnd.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
// @author: shiraho@syg.com(必填, 创建模块的人员)
|
||
|
|
// @description:
|
||
|
|
// 竖版邮件
|
||
|
|
// <br/>Create: new Date().toISOString()
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
|
||
|
|
var PathTool = require("pathtool");
|
||
|
|
var MailController = require("mail.mod");
|
||
|
|
var MailEvent = require("mail_event");
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var FxSVC = require("nx.fx.sv.expand");
|
||
|
|
var FxTogs = require("nx.fx.togs");
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
list: {
|
||
|
|
"default": null,
|
||
|
|
type: FxSVC
|
||
|
|
},
|
||
|
|
togs: {
|
||
|
|
"default": null,
|
||
|
|
type: FxTogs
|
||
|
|
},
|
||
|
|
view: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
delBtn: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
getBtn: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
cur_index: 1,
|
||
|
|
info_pre: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Prefab
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.ctrl = MailController.getInstance();
|
||
|
|
this.select_index = 0;
|
||
|
|
//刷新邮件
|
||
|
|
this.bindGEvent(MailEvent.UPDATE_ITEM, this.freshMial.bind(this));
|
||
|
|
//刷新公告
|
||
|
|
this.bindGEvent(MailEvent.UPDATE_NOTICE, this.freshMial.bind(this));
|
||
|
|
//读取公告
|
||
|
|
this.bindGEvent(MailEvent.READ_INFO_NOTICE, this.readOneNotice.bind(this));
|
||
|
|
//读取邮件
|
||
|
|
this.bindGEvent(MailEvent.OPEN_INFO_WIN, this.readOneMail.bind(this));
|
||
|
|
this.bindGEvent(MailEvent.FRESH_ITEM, this.setItemsStatus.bind(this));
|
||
|
|
this.togs.posTog = this.onTogMenu.bind(this);
|
||
|
|
this.togs.togTo(0);
|
||
|
|
},
|
||
|
|
freshMial: function freshMial() {
|
||
|
|
if (this.cur_index == 1) this.info_win.getComponent("cmp.mail.info").resetData();
|
||
|
|
this.selectedTabCallBack(this.cur_index);
|
||
|
|
},
|
||
|
|
freshNotice: function freshNotice(flag, data) {
|
||
|
|
if (this.cur_index == 2) this.info_win.getComponent("cmp.mail.info").resetData();
|
||
|
|
this.selectedTabCallBack(this.cur_index);
|
||
|
|
},
|
||
|
|
setItemsStatus: function setItemsStatus() {
|
||
|
|
var index = this.cur_index;
|
||
|
|
var list = [];
|
||
|
|
if (index == 1) {
|
||
|
|
var array = this.ctrl.getAllMailArray();
|
||
|
|
for (var i = 0; i < array.length; i++) {
|
||
|
|
list.push(array[i]);
|
||
|
|
}
|
||
|
|
} else if (index == 2) {
|
||
|
|
var array = this.ctrl.getNoticeArray();
|
||
|
|
for (var i = 0; i < array.length; i++) {
|
||
|
|
list.push(array[i]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.list.rebuild(list);
|
||
|
|
this.list.addFocus(this.select_index);
|
||
|
|
},
|
||
|
|
readOneNotice: function readOneNotice(id) {
|
||
|
|
var notice_msg = this.ctrl.getNoticeMessage(id);
|
||
|
|
if (notice_msg) {
|
||
|
|
this.info_win.getComponent("cmp.mail.info").setData(notice_msg);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
readOneMail: function readOneMail(data) {
|
||
|
|
//打开info界面
|
||
|
|
if (data) {
|
||
|
|
this.info_win.getComponent("cmp.mail.info").setData(data);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
start: function start() {},
|
||
|
|
onDisable: function onDisable() {
|
||
|
|
if (nx.bridge.prompt) {
|
||
|
|
nx.bridge.prompt.delPrompt(1);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// registerEvent: function () {
|
||
|
|
|
||
|
|
// //更新红点状态
|
||
|
|
// // if(this.red_status_event == null){
|
||
|
|
// // this.red_status_event = gcore.GlobalEvent.bind(MailEvent.UPDATEREDSTATUS, (function (bid, num) {
|
||
|
|
|
||
|
|
// // }).bind(this))
|
||
|
|
// // }
|
||
|
|
// },
|
||
|
|
|
||
|
|
selectedTabCallBack: function selectedTabCallBack(index) {
|
||
|
|
var _this = this;
|
||
|
|
this.cur_index = index;
|
||
|
|
var list = [];
|
||
|
|
if (index == 1) {
|
||
|
|
var array = this.ctrl.getAllMailArray();
|
||
|
|
for (var i = 0; i < array.length; i++) {
|
||
|
|
list.push(array[i]);
|
||
|
|
}
|
||
|
|
this.delBtn.active = true;
|
||
|
|
this.getBtn.active = true;
|
||
|
|
} else if (index == 2) {
|
||
|
|
var array = this.ctrl.getNoticeArray();
|
||
|
|
for (var i = 0; i < array.length; i++) {
|
||
|
|
list.push(array[i]);
|
||
|
|
}
|
||
|
|
this.delBtn.active = false;
|
||
|
|
this.getBtn.active = false;
|
||
|
|
}
|
||
|
|
this.list.rebuild(list);
|
||
|
|
if (list.length == 0) {
|
||
|
|
this.info_win.getComponent("cmp.mail.info").resetData();
|
||
|
|
this.info_win.active = false;
|
||
|
|
} else {
|
||
|
|
this.info_win.active = true;
|
||
|
|
this.scheduleOnce(function () {
|
||
|
|
_this.onFocusChanged({
|
||
|
|
index: 0,
|
||
|
|
mdata: list[0]
|
||
|
|
});
|
||
|
|
}, 0.5);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
touchDel: function touchDel() {
|
||
|
|
var list = this.ctrl.getHasReadNonRewardList();
|
||
|
|
this.ctrl.deletMailSend(list);
|
||
|
|
},
|
||
|
|
touchGet: function touchGet() {
|
||
|
|
this.ctrl.getAllGoods();
|
||
|
|
},
|
||
|
|
onOpenConfigs: function onOpenConfigs() {
|
||
|
|
this.info_win = cc.instantiate(this.info_pre);
|
||
|
|
this.info_win.setParent(this.view);
|
||
|
|
this.selectedTabCallBack(this.cur_index);
|
||
|
|
},
|
||
|
|
onPreClosed: function onPreClosed() {
|
||
|
|
this.list.rebuild([]);
|
||
|
|
},
|
||
|
|
onTogMenu: function onTogMenu(_index) {
|
||
|
|
this.info_win.getComponent("cmp.mail.info").resetData();
|
||
|
|
this.selectedTabCallBack(_index + 1);
|
||
|
|
},
|
||
|
|
// 选中切换
|
||
|
|
onFocusChanged: function onFocusChanged(_item) {
|
||
|
|
// 空
|
||
|
|
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 聚焦
|
||
|
|
this.list.cleanFocus();
|
||
|
|
this.list.addFocus(_item.index);
|
||
|
|
this.select_index = _item.index;
|
||
|
|
if (_item.mdata.status >= 0) {
|
||
|
|
//邮件
|
||
|
|
this.ctrl.requireMailItem(_item.mdata.id, _item.mdata.srv_id, this.info_win);
|
||
|
|
} else if (_item.mdata.flag >= 0) {
|
||
|
|
//公告
|
||
|
|
this.ctrl.readNotice(_item.mdata.id);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
touchClose: function touchClose() {
|
||
|
|
// if(this.info_win){
|
||
|
|
// this.info_win.deleteMe();
|
||
|
|
// }
|
||
|
|
this.ctrl.openMailUI(false);
|
||
|
|
} // update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|