135 lines
3.3 KiB
JavaScript
135 lines
3.3 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '6bd0fbxa1VHJrrpwFFAff7c', 'cmp.act.limit.shop');
|
|
// Scripts/mod/acts/limitShop/cmp/cmp.act.limit.shop.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 限购商城
|
|
*
|
|
******************************************************************/
|
|
|
|
var ActPage = require("act.page.base");
|
|
var ActLimitShop = require("act.limit.shop.mod");
|
|
cc.Class({
|
|
"extends": ActPage,
|
|
properties: {
|
|
nodPanel: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodHead: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
lstProd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodDate: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 初始化
|
|
build: function build(_data) {
|
|
this._super(_data);
|
|
|
|
// 置空
|
|
var MOD = ActLimitShop.getInstance();
|
|
if (!MOD || nx.dt.objEmpty(this.data)) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// 配置查询
|
|
this.configs = MOD.queryConfigs(this.data.camp_id);
|
|
if (!this.configs) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// 基本信息
|
|
this.freshBasic();
|
|
},
|
|
// 显示
|
|
onEnable: function onEnable() {
|
|
var _this = this;
|
|
var MOD = ActLimitShop.getInstance();
|
|
if (!MOD || nx.dt.objEmpty(this.data)) {
|
|
return;
|
|
}
|
|
MOD.reqBaseData(this.data.camp_id, function (_ret, _data) {
|
|
if (_ret) {
|
|
_this.freshDate(_data.remain_sec);
|
|
_this.freshProducts(_data.aim_list);
|
|
}
|
|
});
|
|
},
|
|
// 销毁
|
|
onDisable: function onDisable() {},
|
|
// 置空
|
|
setEmpty: function setEmpty() {
|
|
nx.gui.setActive(this, "right", false);
|
|
},
|
|
// 基本信息
|
|
freshBasic: function freshBasic() {
|
|
// 置空
|
|
if (!this.configs || nx.dt.objEmpty(this.data)) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
nx.gui.setActive(this, "right", true);
|
|
|
|
// 背景刷新
|
|
var path = cc.path.join("resDB/bigs", this.configs.bg || "bg005");
|
|
nx.gui.setSpriteFrame(this, "bg", path);
|
|
|
|
// 面板
|
|
path = cc.path.join("prefab/acts/limitShop/panels", this.configs.dialog_bg);
|
|
nx.gui.setSpriteFrame(this.nodPanel, "body", path);
|
|
|
|
// 商店头部
|
|
var head = cc.path.join("locals/{lang}/images/limitshop", this.configs.title);
|
|
nx.gui.setSpriteFrame(this.nodHead, "", nx.res.fmtPath(head));
|
|
},
|
|
// 刷新活动日期
|
|
freshDate: function freshDate(_secs) {
|
|
var time = nx.bridge.time.toNeedSeconds(_secs);
|
|
nx.gui.setString(this.nodDate, "txt", time);
|
|
},
|
|
// 商品刷新
|
|
freshProducts: function freshProducts(_lst) {
|
|
// 空
|
|
if (nx.dt.arrEmpty(_lst)) {
|
|
nx.gui.setActive(this.lstProd, "", false);
|
|
return;
|
|
}
|
|
|
|
// 重建
|
|
nx.gui.setActive(this.lstProd, "", true);
|
|
var root = nx.gui.find(this.lstProd, "view/content");
|
|
nx.gui.gocChildren(root, "", _lst.length, root.children[0]);
|
|
for (var i = 0; i < _lst.length; ++i) {
|
|
var cmp = nx.gui.getComponent(root.children[i], "", "cmp.act.limit.item");
|
|
cmp.setData(_lst[i], this.configs.item_bg);
|
|
}
|
|
},
|
|
// 商品事件
|
|
onProductEvent: function onProductEvent(_data) {
|
|
var MOD = ActLimitShop.getInstance();
|
|
if (!MOD || !this.data || !_data || _data.diamond != true) {
|
|
return;
|
|
}
|
|
|
|
// 钻石类购买
|
|
MOD.reqBuyDiamondProdcut(this.data.camp_id, _data.num, function (_ret) {
|
|
if (_ret) {
|
|
nx.dt.fnInvoke(_data.cb, true);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |