144 lines
4.3 KiB
JavaScript
144 lines
4.3 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'fae90QRwURND7R4xlCZuRLF', 'cmp.holy.pray.shop');
|
||
|
|
// Scripts/mod/pray/cmp/cmp.holy.pray.shop.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 战斗义肢 祈祷兑换商城
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var MallEvent = require("mall_event");
|
||
|
|
var MallController = require("mall_controller");
|
||
|
|
var MallConst = require("mall_const");
|
||
|
|
var FxSVC = require("nx.fx.sv.expand");
|
||
|
|
var FxTogs = require("nx.fx.togs");
|
||
|
|
var TipsController = require("tips_controller");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
svcShopLst: {
|
||
|
|
"default": null,
|
||
|
|
type: FxSVC,
|
||
|
|
displayName: "商城列表"
|
||
|
|
},
|
||
|
|
nodEmpty: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node,
|
||
|
|
displayName: "空显示"
|
||
|
|
},
|
||
|
|
nodPrayMenu: {
|
||
|
|
"default": null,
|
||
|
|
type: FxTogs,
|
||
|
|
displayName: "阵营切换"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.bindGEvent(MallEvent.Open_View_Event, this.freshShopList.bind(this));
|
||
|
|
this.bindGEvent(MallEvent.Buy_Success_Event, this.freshShopItem.bind(this));
|
||
|
|
this.nodPrayMenu.posTog = this.onTogPrayMenu.bind(this);
|
||
|
|
this.setTitle();
|
||
|
|
},
|
||
|
|
setTitle: function setTitle() {
|
||
|
|
var holyShop = game.configs.exchange_data.data_shop_exchage_suit;
|
||
|
|
var count = Object.keys(holyShop).length;
|
||
|
|
// let holyNod = nx.gui.find( this.nodPray, "view/menu" );
|
||
|
|
nx.gui.gocChildren(this.nodPrayMenu, "", count);
|
||
|
|
var top_titles = game.configs.partner_holy_eqm_data.data_suit_res_prefix;
|
||
|
|
var chdsuit = this.nodPrayMenu.node.children;
|
||
|
|
for (var s = 0; s < chdsuit.length; s++) {
|
||
|
|
var snod = chdsuit[s];
|
||
|
|
var title_show = top_titles[s + 1];
|
||
|
|
if (title_show) {
|
||
|
|
nx.gui.setString(snod, "on/txt", title_show.prefix);
|
||
|
|
nx.gui.setString(snod, "off/txt", title_show.prefix);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onTogPrayMenu: function onTogPrayMenu(_index) {
|
||
|
|
// if( parseInt( _index ) == 0 ){
|
||
|
|
// this.activeMenu( 3 );
|
||
|
|
// }else{
|
||
|
|
this.activePrayMenus(parseInt(_index));
|
||
|
|
// }
|
||
|
|
},
|
||
|
|
|
||
|
|
activePrayMenus: function activePrayMenus(_idx) {
|
||
|
|
this.nowSuit = _idx;
|
||
|
|
this.freshShopList();
|
||
|
|
},
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
||
|
|
this.nowSuit = 0;
|
||
|
|
this.score = _params.score;
|
||
|
|
this.nodPrayMenu.togTo(0);
|
||
|
|
var mall = MallController.getInstance().sender13401(MallConst.MallType.SuitShop);
|
||
|
|
|
||
|
|
// this.activePrayMenus( 0 );
|
||
|
|
},
|
||
|
|
|
||
|
|
freshShopList: function freshShopList(_shoplst) {
|
||
|
|
var _this = this;
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
var mall = MallController.getInstance().getModel();
|
||
|
|
var lst = mall.getHolyShoplst();
|
||
|
|
var showLst = lst[this.nowSuit];
|
||
|
|
// let list = [];
|
||
|
|
if (!showLst) {
|
||
|
|
nx.gui.setActive(this.nodEmpty, "", true);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
showLst.forEach(function (_lst) {
|
||
|
|
_lst.score = _this.score;
|
||
|
|
_lst.suit = _this.nowSuit;
|
||
|
|
});
|
||
|
|
this.scheduleOnce(function () {
|
||
|
|
_this.svcShopLst.rebuild(showLst);
|
||
|
|
}, 0.1);
|
||
|
|
nx.gui.setActive(this.nodEmpty, "", nx.dt.arrEmpty(showLst));
|
||
|
|
},
|
||
|
|
// 刷新单个商品信息
|
||
|
|
onTouchBuy: function onTouchBuy(_item) {
|
||
|
|
var role = RoleController.getInstance().getRoleVo();
|
||
|
|
if (role.lev < _item.info.level) {
|
||
|
|
nx.tbox(nx.text.format("BuyCondition", _item.info.level));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var EC = TipsController.getInstance();
|
||
|
|
var MC = MallController.getInstance();
|
||
|
|
if (EC) {
|
||
|
|
var type = MallConst.MallType.SuitShop;
|
||
|
|
EC.openBuyPanel(true, _item.info, type, function (_data) {
|
||
|
|
MC.sender13402(_data.eid, _data.num);
|
||
|
|
EC.openBuyPanel(false);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 刷新单个商品信息
|
||
|
|
freshShopItem: function freshShopItem(_shopitem) {
|
||
|
|
var lst = _shopitem;
|
||
|
|
var nodes = nx.gui.find(this.svcShopLst.bindSCV, "view/content").children;
|
||
|
|
for (var i = 0; i < nodes.length; i++) {
|
||
|
|
var sitem = nodes[i];
|
||
|
|
if (sitem) {
|
||
|
|
var cmp = sitem.svItem;
|
||
|
|
if (cmp) {
|
||
|
|
if (lst) {
|
||
|
|
if (cmp.mdata.id == lst.eid) {
|
||
|
|
var data = nx.dt.objClone(cmp.mdata);
|
||
|
|
data.has_buy = !nx.dt.arrEmpty(lst.ext) ? lst.ext[0].val : 0;
|
||
|
|
cmp.rebind(cmp.index, data);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|