134 lines
2.9 KiB
JavaScript
134 lines
2.9 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '365e7ljhhpCiJaiRIju5475', 'cmp.personal.push.entry');
|
||
|
|
// Scripts/mod/acts/push/cmp.personal.push.entry.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 推送入口
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var BridgeComponent = require("bridge.component");
|
||
|
|
var NxSpine = require("nx.fx.spine");
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeComponent,
|
||
|
|
properties: {
|
||
|
|
box: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
spRole: {
|
||
|
|
"default": null,
|
||
|
|
type: NxSpine
|
||
|
|
},
|
||
|
|
words: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodCD: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 显示
|
||
|
|
onEnable: function onEnable() {
|
||
|
|
var _this = this;
|
||
|
|
this.box.active = false;
|
||
|
|
this.words.active = false;
|
||
|
|
|
||
|
|
// 视图绑定
|
||
|
|
nx.bridge.vbind(this, [["PPushGifts", this.onFreshGifts.bind(this)], ["PPushNews", this.onNewGifts.bind(this)]]);
|
||
|
|
|
||
|
|
// 倒计时
|
||
|
|
this.cdTick();
|
||
|
|
this.schedule(function () {
|
||
|
|
_this.cdTick();
|
||
|
|
}, 1);
|
||
|
|
},
|
||
|
|
// 关闭
|
||
|
|
onDisable: function onDisable() {
|
||
|
|
// 倒计时
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
|
||
|
|
// 视图监听解除
|
||
|
|
nx.bridge.vunbind(this);
|
||
|
|
},
|
||
|
|
// 礼包刷新
|
||
|
|
onFreshGifts: function onFreshGifts(_list) {
|
||
|
|
this.gifts = _list || [];
|
||
|
|
if (nx.dt.arrEmpty(_list)) {
|
||
|
|
this.box.active = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (this.box.active) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 显示
|
||
|
|
this.box.active = true;
|
||
|
|
this.spRole.action("piay2", true);
|
||
|
|
},
|
||
|
|
// 有新礼包
|
||
|
|
onNewGifts: function onNewGifts(_ids) {
|
||
|
|
// 不提示
|
||
|
|
var tmp = nx.storage.getNumber("PPHideTip", 0);
|
||
|
|
if (tmp == 1) {
|
||
|
|
this.words.active = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 新提示
|
||
|
|
this.newTip = nx.dt.arrNEmpty(_ids);
|
||
|
|
this.tipOpen();
|
||
|
|
|
||
|
|
// 直接弹出
|
||
|
|
if (this.newTip) {
|
||
|
|
nx.bridge.createPanel("WndPersonalPush", {
|
||
|
|
ids: _ids
|
||
|
|
});
|
||
|
|
nx.bridge.vset("PPushNews", []);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 提示
|
||
|
|
tipOpen: function tipOpen() {
|
||
|
|
if (!this.box.active || this.words.active) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (!this.newTip) {
|
||
|
|
this.words.active = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
var self = this;
|
||
|
|
this.words.active = true;
|
||
|
|
this.scheduleOnce(function () {
|
||
|
|
self.words.active = false;
|
||
|
|
self.scheduleOnce(function () {
|
||
|
|
self.tipOpen();
|
||
|
|
}, 10);
|
||
|
|
}, 5);
|
||
|
|
},
|
||
|
|
// 点击打开
|
||
|
|
onTouchOpen: function onTouchOpen() {
|
||
|
|
nx.bridge.createPanel("WndPersonalPush");
|
||
|
|
this.newTip = false;
|
||
|
|
this.words.active = false;
|
||
|
|
},
|
||
|
|
// 倒计时
|
||
|
|
cdTick: function cdTick() {
|
||
|
|
if (!this.nodCD) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var time = nx.bridge.vget("PPushCD");
|
||
|
|
if (!nx.dt.numPositive(time, false)) {
|
||
|
|
this.nodCD.active = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.nodCD.active = true;
|
||
|
|
var txt = nx.bridge.time.cdDate(time);
|
||
|
|
nx.gui.setString(this.nodCD, "txt", txt);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|