244 lines
7.1 KiB
JavaScript
244 lines
7.1 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'b97d9TdONJKjZbp53rr1p3g', 'cmp.mail.info');
|
||
|
|
// Scripts/mod/mail/cmp/cmp.mail.info.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
// @author: shiraho@syg.com(必填, 创建模块的人员)
|
||
|
|
// @description:
|
||
|
|
// 竖版邮件/公告详情
|
||
|
|
// <br/>Create: new Date().toISOString()
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
|
||
|
|
var PathTool = require("pathtool");
|
||
|
|
var TimeTool = require("timetool");
|
||
|
|
var MailController = require("mail.mod");
|
||
|
|
var MailEvent = require("mail_event");
|
||
|
|
var ItemLay = require("cmp.common.itemlayout");
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {
|
||
|
|
title: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
time: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
list: {
|
||
|
|
"default": null,
|
||
|
|
type: ItemLay
|
||
|
|
},
|
||
|
|
// icon:{
|
||
|
|
// default:null,
|
||
|
|
// type:cc.Sprite
|
||
|
|
// },
|
||
|
|
content: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.RichText
|
||
|
|
},
|
||
|
|
youxiao: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
goods_container: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
goods_scroll_content: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
btn_get: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
btn_delete: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
// goods_list : []
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
var _this = this;
|
||
|
|
this.ctrl = MailController.getInstance();
|
||
|
|
if (this.get_item_assets == null) {
|
||
|
|
this.get_item_assets = gcore.GlobalEvent.bind(MailEvent.GET_ITEM_ASSETS, function (key) {
|
||
|
|
if (_this.data) {
|
||
|
|
var item_key = Utils.getNorKey(_this.data.id || 0, _this.data.srv_id || "");
|
||
|
|
if (key == item_key) {
|
||
|
|
_this.removeAsset(key);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
start: function start() {},
|
||
|
|
//必要添加的数据传入方法
|
||
|
|
setData: function setData(data) {
|
||
|
|
this.data = data;
|
||
|
|
var str2 = data.content;
|
||
|
|
if (nx.dt.strNEmpty(data.content)) {
|
||
|
|
str2 = str2.replace(/</g, "<");
|
||
|
|
str2 = str2.replace(/>/g, ">");
|
||
|
|
str2 = str2.replace(/'/g, "'");
|
||
|
|
str2 = str2.replace(/"/g, '"');
|
||
|
|
str2 = StringUtil.parseStr(str2).string;
|
||
|
|
}
|
||
|
|
|
||
|
|
// var color = game.configs.color_data.data_color16[ 58 ];
|
||
|
|
//特殊符号处理^
|
||
|
|
var new_msg = null;
|
||
|
|
if (str2 && str2.indexOf("^") != -1) {
|
||
|
|
var arr = str2.split("^");
|
||
|
|
for (var i = 0; i < arr.length; i++) {
|
||
|
|
var cfg = gitemdata(arr[i]);
|
||
|
|
if (cfg) {
|
||
|
|
arr[i] = cfg.name;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
new_msg = arr.join("");
|
||
|
|
} else {
|
||
|
|
new_msg = str2;
|
||
|
|
}
|
||
|
|
this.content.string = new_msg;
|
||
|
|
this.list.rebuild([]);
|
||
|
|
if (data.status != null) {
|
||
|
|
var str = data.subject;
|
||
|
|
if (str.length >= 18) {
|
||
|
|
str = str.substring(0, 15) + "...";
|
||
|
|
}
|
||
|
|
this.title.string = str;
|
||
|
|
this.time.active = true;
|
||
|
|
this.youxiao.active = true;
|
||
|
|
if (data.assets && data.items) {
|
||
|
|
if (Utils.getArrLen(data.assets) > 0 || Utils.getArrLen(data.items) > 0 && data.type == 1) {
|
||
|
|
this.changeButtonStatus(true);
|
||
|
|
this.goods_container.active = true;
|
||
|
|
this.createGoodsList();
|
||
|
|
} else if (Utils.getArrLen(data.assets) <= 0 || Utils.getArrLen(data.items) <= 0 && data.type == 1) {
|
||
|
|
this.changeButtonStatus(false);
|
||
|
|
this.goods_container.active = false;
|
||
|
|
} else {
|
||
|
|
this.btn_get.active = false;
|
||
|
|
this.btn_delete.active = false;
|
||
|
|
this.goods_container.active = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// var show_time = TimeTool.getDayOrHour( client.socket.getTime() - this.data.send_time );
|
||
|
|
// if( show_time != null ) {
|
||
|
|
// this.time.string = show_time;
|
||
|
|
// } else {
|
||
|
|
// this.time.string = "";
|
||
|
|
// }
|
||
|
|
|
||
|
|
var show_time2 = TimeTool.getDayOrHour(data.time_out - client.socket.getTime());
|
||
|
|
if (show_time2 != null) {
|
||
|
|
this.youxiao.string = nx.text.getKey("MailLimitTime") + show_time2;
|
||
|
|
} else {
|
||
|
|
this.youxiao.string = "";
|
||
|
|
}
|
||
|
|
|
||
|
|
// this.changeIcon( data.status );
|
||
|
|
this.ctrl.read(data.id, data.srv_id);
|
||
|
|
} else if (data.flag != null) {
|
||
|
|
var _str = data.title;
|
||
|
|
if (_str.length >= 18) {
|
||
|
|
_str = _str.substring(0, 15) + "...";
|
||
|
|
}
|
||
|
|
this.title.string = _str;
|
||
|
|
this.btn_get.active = false;
|
||
|
|
this.btn_delete.active = false;
|
||
|
|
this.goods_container.active = false;
|
||
|
|
this.time.active = false;
|
||
|
|
this.youxiao.active = false;
|
||
|
|
// this.changeIcon( data.flag );
|
||
|
|
// this.ctrl.readNotice( data.id );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
resetData: function resetData() {
|
||
|
|
this.list.rebuild([]);
|
||
|
|
this.title.string = "";
|
||
|
|
this.content.string = "";
|
||
|
|
this.btn_get.active = false;
|
||
|
|
this.btn_delete.active = false;
|
||
|
|
this.goods_container.active = false;
|
||
|
|
this.time.active = false;
|
||
|
|
this.youxiao.active = false;
|
||
|
|
},
|
||
|
|
removeAsset: function removeAsset() {
|
||
|
|
this.list.rebuild([]);
|
||
|
|
this.goods_container.active = false;
|
||
|
|
this.data.assets = {};
|
||
|
|
this.data.status = 2;
|
||
|
|
this.data.items = {};
|
||
|
|
// this.changeIcon( this.data.status );
|
||
|
|
this.changeButtonStatus(false);
|
||
|
|
},
|
||
|
|
createGoodsList: function createGoodsList() {
|
||
|
|
if (this.data.status == 2) {
|
||
|
|
//领了的就不创建了
|
||
|
|
this.list.rebuild([]);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var list = [];
|
||
|
|
var show_list = [];
|
||
|
|
for (var k in this.data.assets) {
|
||
|
|
var v = this.data.assets[k];
|
||
|
|
if (nx.dt.objClone(Utils.getItemConfig(v.label || v.base_id)).id != null) show_list.push(this.data.assets[k]);
|
||
|
|
}
|
||
|
|
for (var k in this.data.items) {
|
||
|
|
var v = this.data.items[k];
|
||
|
|
if (nx.dt.objClone(Utils.getItemConfig(v.label || v.base_id)).id != null) show_list.push(this.data.items[k]);
|
||
|
|
}
|
||
|
|
for (var i in show_list) {
|
||
|
|
var v = show_list[i];
|
||
|
|
var real = {};
|
||
|
|
real.id = v.label || v.base_id;
|
||
|
|
real.num = v.val || v.quantity;
|
||
|
|
list.push(real);
|
||
|
|
}
|
||
|
|
this.list.rebuild(list);
|
||
|
|
},
|
||
|
|
changeButtonStatus: function changeButtonStatus(status) {
|
||
|
|
this.btn_get.active = status;
|
||
|
|
this.btn_delete.active = !status;
|
||
|
|
},
|
||
|
|
changeIcon: function changeIcon(status) {
|
||
|
|
|
||
|
|
// const icon = ( status == 0 ) ? "mail_2" : "mail_3";
|
||
|
|
// nx.gui.setAtlasFrame( this.icon, "", "uiRes/mods/mail/mail/" + icon );
|
||
|
|
},
|
||
|
|
touchGet: function touchGet() {
|
||
|
|
if (!this.data || !this.data.assets || !this.data.items) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (Utils.getArrLen(this.data.assets) > 0 || Utils.getArrLen(this.data.items) > 0 && this.data.type == 1) {
|
||
|
|
this.ctrl.getGoods(this.data.id, this.data.srv_id);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
touchDel: function touchDel() {
|
||
|
|
if (!this.data || !this.data.assets || !this.data.items) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (Utils.getArrLen(this.data.assets) <= 0 || Utils.getArrLen(this.data.items) <= 0 && this.data.type == 1) {
|
||
|
|
var ids = [{
|
||
|
|
id: this.data.id,
|
||
|
|
srv_id: this.data.srv_id
|
||
|
|
}];
|
||
|
|
this.ctrl.deletMailSend(ids);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onDestroy: function onDestroy() {
|
||
|
|
if (this.get_item_assets) {
|
||
|
|
gcore.GlobalEvent.unbind(this.get_item_assets);
|
||
|
|
this.get_item_assets = null;
|
||
|
|
}
|
||
|
|
} // update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|