894 lines
26 KiB
JavaScript
894 lines
26 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '337a78YivdLF4On17KYQS2a', 'cmp.shop.wnd');
|
||
|
|
// Scripts/mod/shop/cmp.shop.wnd.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var FxSVC = require("nx.fx.sv.expand");
|
||
|
|
var ShopController = require("mall_controller");
|
||
|
|
var MallEvent = require("mall_event");
|
||
|
|
var MallController = require("mall_controller");
|
||
|
|
var FxTogs = require("nx.fx.togs");
|
||
|
|
var PathTool = require("pathtool");
|
||
|
|
var BackPackController = require("backpack_controller");
|
||
|
|
var TipsController = require("tips_controller");
|
||
|
|
var MallConst = require("mall_const");
|
||
|
|
var FID = require("bridge.function.ids");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
var first = 6;
|
||
|
|
|
||
|
|
// 标签页对应关系
|
||
|
|
var TabPage = [{
|
||
|
|
key: "GodShop",
|
||
|
|
tab: MallConst.MallType.GodShop,
|
||
|
|
"goto": 0
|
||
|
|
}, {
|
||
|
|
key: "Recovery",
|
||
|
|
tab: MallConst.MallType.Recovery,
|
||
|
|
"goto": 1
|
||
|
|
}, {
|
||
|
|
key: "ScoreShop",
|
||
|
|
tab: MallConst.MallType.ScoreShop,
|
||
|
|
"goto": 2
|
||
|
|
}, {
|
||
|
|
key: "SkillShop",
|
||
|
|
tab: MallConst.MallType.SkillShop,
|
||
|
|
"goto": 3
|
||
|
|
}, {
|
||
|
|
key: "SummonShop",
|
||
|
|
tab: MallConst.MallType.SummonShop,
|
||
|
|
"goto": 4
|
||
|
|
}, {
|
||
|
|
key: "LimitTimeChange",
|
||
|
|
tab: MallConst.MallType.LimitTimeChange,
|
||
|
|
"goto": 5
|
||
|
|
}];
|
||
|
|
var VarietyShop = MallConst.MallType.VarietyShop;
|
||
|
|
|
||
|
|
// 标签页对应关系
|
||
|
|
var DifTabPage = [{
|
||
|
|
key: "ThemeShop",
|
||
|
|
tab: MallConst.MallType.ThemeShop,
|
||
|
|
"goto": 0,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "StepUpShop",
|
||
|
|
tab: MallConst.MallType.StepUpShop,
|
||
|
|
"goto": 1,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "EliteStore",
|
||
|
|
tab: MallConst.MallType.EliteStore,
|
||
|
|
"goto": 2,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "LimitStore",
|
||
|
|
tab: MallConst.MallType.LimitStore,
|
||
|
|
"goto": 3,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "LimitPrayStore",
|
||
|
|
tab: MallConst.MallType.LimitPrayStore,
|
||
|
|
"goto": 4,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "CollectCardStore",
|
||
|
|
tab: MallConst.MallType.CollectCardStore,
|
||
|
|
"goto": 5,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "LimitWingStore",
|
||
|
|
tab: MallConst.MallType.LimitWingsStore,
|
||
|
|
"goto": 6,
|
||
|
|
lock: FID.Shop
|
||
|
|
}, {
|
||
|
|
key: "ArenaShop",
|
||
|
|
tab: MallConst.MallType.ArenaShop,
|
||
|
|
"goto": 7,
|
||
|
|
lock: FID.ArenaShop
|
||
|
|
}, {
|
||
|
|
key: "FriendShop",
|
||
|
|
tab: MallConst.MallType.FriendShop,
|
||
|
|
"goto": 8,
|
||
|
|
lock: FID.PlanesShop
|
||
|
|
}, {
|
||
|
|
key: "UnionShop",
|
||
|
|
tab: MallConst.MallType.UnionShop,
|
||
|
|
"goto": 9,
|
||
|
|
lock: FID.GuildShop
|
||
|
|
}, {
|
||
|
|
key: "EliteShop",
|
||
|
|
tab: MallConst.MallType.EliteShop,
|
||
|
|
"goto": 10,
|
||
|
|
lock: FID.EliteShop
|
||
|
|
}, {
|
||
|
|
key: "Ladder",
|
||
|
|
tab: MallConst.MallType.Ladder,
|
||
|
|
"goto": 11,
|
||
|
|
lock: FID.CrossLadder
|
||
|
|
}, {
|
||
|
|
key: "CrosschampionShop",
|
||
|
|
tab: MallConst.MallType.CrosschampionShop,
|
||
|
|
"goto": 12,
|
||
|
|
lock: FID.ExchangeChamp
|
||
|
|
}, {
|
||
|
|
key: "CampFitShop",
|
||
|
|
tab: MallConst.MallType.CampFitShop,
|
||
|
|
"goto": 13,
|
||
|
|
lock: FID.CampFitShops
|
||
|
|
}];
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
svcshopLst: {
|
||
|
|
"default": null,
|
||
|
|
type: FxSVC,
|
||
|
|
displayName: "商城列表"
|
||
|
|
},
|
||
|
|
togMenu: {
|
||
|
|
"default": null,
|
||
|
|
type: FxTogs
|
||
|
|
},
|
||
|
|
nodEmpty: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodOp: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodTime: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodTop: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
togMenus: {
|
||
|
|
"default": null,
|
||
|
|
type: FxTogs
|
||
|
|
},
|
||
|
|
nodMat: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
nodVarietyShop: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.bindGEvent(MallEvent.Open_View_Event, this.freshShowLst.bind(this));
|
||
|
|
this.bindGEvent(MallEvent.Get_Buy_list, this.freshShowLst.bind(this));
|
||
|
|
this.bindGEvent(MallEvent.Buy_Success_Event, this.freshShopItem.bind(this));
|
||
|
|
this.bindGEvent(MallEvent.Buy_One_Success, this.freshShopItem.bind(this));
|
||
|
|
|
||
|
|
// Tog监听
|
||
|
|
this.togMenus.posTog = this.onTogMenus.bind(this);
|
||
|
|
// this.togMenus.togTo( 0 );
|
||
|
|
// this.activeMenus( 1 );
|
||
|
|
// Tog监听
|
||
|
|
this.togMenu.posTog = this.onTogMenu.bind(this);
|
||
|
|
},
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
||
|
|
this.freshTitles();
|
||
|
|
if (_params.fromOther) {
|
||
|
|
var from = _params.fromOther;
|
||
|
|
if (from.length < 2) {
|
||
|
|
var tab = from[0];
|
||
|
|
var _goto = 0;
|
||
|
|
TabPage.forEach(function (_tab) {
|
||
|
|
if (tab == _tab.tab) {
|
||
|
|
_goto = _tab["goto"];
|
||
|
|
}
|
||
|
|
});
|
||
|
|
this.togMenu.togTo(_goto);
|
||
|
|
this.activeMenu(_goto + 1);
|
||
|
|
} else {
|
||
|
|
var tab1 = from[0];
|
||
|
|
var tab2 = from[1];
|
||
|
|
var _goto2 = 0;
|
||
|
|
var goto2 = 0;
|
||
|
|
TabPage.forEach(function (_tab) {
|
||
|
|
if (tab1 == _tab.tab) {
|
||
|
|
_goto2 = _tab["goto"];
|
||
|
|
}
|
||
|
|
});
|
||
|
|
DifTabPage.forEach(function (_tab) {
|
||
|
|
if (tab2 == _tab.tab) {
|
||
|
|
goto2 = _tab["goto"];
|
||
|
|
}
|
||
|
|
});
|
||
|
|
this.togMenu.togTo(_goto2);
|
||
|
|
this.activeMenu(_goto2 + 1, true);
|
||
|
|
this.togMenus.togTo(goto2);
|
||
|
|
this.activeMenus(goto2 + 1, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
// console.log( "伙伴背包收到的数据" + JSON.stringify( _params ) );
|
||
|
|
} else {
|
||
|
|
this.togMenu.togTo(0);
|
||
|
|
this.activeMenu(1);
|
||
|
|
this.freshShop();
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过外部接口调用的参数
|
||
|
|
// this.svcshopLst.rebuild( [] );
|
||
|
|
// console.log( "商城数据相关" + JSON.stringify( _params ) );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:关闭前
|
||
|
|
onPreClosed: function onPreClosed() {
|
||
|
|
// this.svcschemeList.rebuild( [] );
|
||
|
|
this.svcshopLst.rebuild([]);
|
||
|
|
},
|
||
|
|
freshTitles: function freshTitles() {
|
||
|
|
// let cut = function( _str ){
|
||
|
|
// // if( _str )
|
||
|
|
// }
|
||
|
|
|
||
|
|
var cfg = game.configs.exchange_data.data_shop_list;
|
||
|
|
var chd = this.togMenu.node.children;
|
||
|
|
for (var i = 0; i < chd.length; i++) {
|
||
|
|
var item = chd[i];
|
||
|
|
var key = TabPage[i].tab;
|
||
|
|
var _title = cfg[key] ? cfg[key].name : "";
|
||
|
|
nx.gui.setString(item, "on/txt", _title);
|
||
|
|
nx.gui.setString(item, "off/txt", _title);
|
||
|
|
if (nx.dt.strNEmpty(cfg[key].end_time)) {
|
||
|
|
var time = cfg[key].end_time.split(",");
|
||
|
|
var needt = "";
|
||
|
|
for (var _i = 0; _i < time.length; _i++) {
|
||
|
|
var sht = time[_i];
|
||
|
|
if (_i == 0) {
|
||
|
|
needt += sht;
|
||
|
|
} else if (_i > 0 && _i <= 2) {
|
||
|
|
needt += "-" + sht;
|
||
|
|
} else if (_i == 3) {
|
||
|
|
needt += "\t" + sht;
|
||
|
|
} else {
|
||
|
|
needt += ":" + sht;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var endTime = new Date(needt);
|
||
|
|
var timestamp = endTime.getTime();
|
||
|
|
nx.gui.setActive(item, "", timestamp - cc.sys.now() >= 0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
||
|
|
var chds = this.togMenus.node.children;
|
||
|
|
for (var _i2 = 0; _i2 < chds.length; _i2++) {
|
||
|
|
var _item2 = chds[_i2];
|
||
|
|
var tab = DifTabPage[_i2];
|
||
|
|
if (tab) {
|
||
|
|
var _key2 = DifTabPage[_i2].tab;
|
||
|
|
if (_key2) {
|
||
|
|
var _title2 = cfg[_key2].name;
|
||
|
|
nx.gui.setString(_item2, "on/txt", _title2);
|
||
|
|
nx.gui.setString(_item2, "off/txt", _title2);
|
||
|
|
// let cmp = nx.gui.getComponent( item, "lock", "bridge.condition.locker" );
|
||
|
|
// if( cmp ){
|
||
|
|
// cmp.setCondition( tab.lock );
|
||
|
|
// }
|
||
|
|
// nx.gui.setActive( item, "", cfg[key].id == 55 ? false : true );
|
||
|
|
// nx.gui.setActive( item, "", cfg[key].id != 59 )
|
||
|
|
if (nx.dt.arrNEmpty(cfg[_key2].limit)) {
|
||
|
|
if (role_vo.lev < cfg[_key2].limit[0][1] && cfg[_key2].id == 17) {
|
||
|
|
// nx.gui.setString( item, "off/txt", "" );
|
||
|
|
|
||
|
|
// nx.gui.setActive( item, "lock", true );
|
||
|
|
// nx.gui.setActive( item, "", cfg[key].id == 55 ? false : true );
|
||
|
|
nx.gui.setActive(_item2, "lock", true);
|
||
|
|
} else {
|
||
|
|
nx.gui.setActive(_item2, "lock", false);
|
||
|
|
// nx.gui.setActive( item, "", cfg[key].id == 55 ? false : true );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
var title = cfg[VarietyShop].name;
|
||
|
|
nx.gui.setString(this.nodVarietyShop, "txt", title);
|
||
|
|
},
|
||
|
|
// 物品列表 读取的本地json 钻石
|
||
|
|
freshShop: function freshShop() {
|
||
|
|
var lst = this.dealCfg();
|
||
|
|
nx.gui.setActive(this.nodEmpty, "", nx.dt.arrEmpty(lst));
|
||
|
|
this.svcshopLst.rebuild(lst);
|
||
|
|
this.opfreshShopItems();
|
||
|
|
},
|
||
|
|
// 刷新按钮显示 处理刷新按钮所需要的材料 以及免费刷新的次数等信息, 以及赋予相关的方法
|
||
|
|
opfreshShopItems: function opfreshShopItems() {
|
||
|
|
var _this = this;
|
||
|
|
var self = this;
|
||
|
|
var efg = game.configs.exchange_data;
|
||
|
|
if (efg) {}
|
||
|
|
var rfsg = efg.data_shop_exchage_cost;
|
||
|
|
// let cfg = rfsg.soul_reset_cost;
|
||
|
|
var ecfg = efg.data_shop_list;
|
||
|
|
var iconMat = ecfg[this.shopType].item_bid;
|
||
|
|
var count = BackPackController.getInstance().getModel().getItemNumByBid(iconMat);
|
||
|
|
this.Mat = iconMat;
|
||
|
|
nx.gui.setString(this.nodMat, "txt", nx.dt.shortCount(count));
|
||
|
|
nx.bridge.setIconS(this.nodMat, "icon", iconMat); // 小图标
|
||
|
|
nx.gui.setActive(this.nodMat, "", this.shopType != 1 && iconMat != 3);
|
||
|
|
nx.gui.setActive(this.nodTop, "", this.shopType == 8 || this.shopType == 5 || this.shopType == 6 || this.shopType == 17 || this.shopType == 30 || this.shopType == 54 || this.shopType == 55 || this.shopType == 56 || this.shopType == 57 || this.shopType == 61 || this.shopType == 36 || this.shopType == 58 || this.shopType == 59 || this.shopType == 62);
|
||
|
|
var EC = TipsController.getInstance();
|
||
|
|
var MC = MallController.getInstance();
|
||
|
|
if (this.shopType == 2 || this.shopType == 9) {
|
||
|
|
var need = ecfg[this.shopType].cost_list[0][1];
|
||
|
|
var icon = ecfg[this.shopType].cost_list[0][0];
|
||
|
|
nx.gui.setString(this.nodOp, "cost/txt", nx.text.format("lab_mall_window_tip4", need));
|
||
|
|
var path = "";
|
||
|
|
path = PathTool.querySmallIconPath(icon);
|
||
|
|
nx.bridge.setIconS(this.nodOp, "cost/icon", icon); // 小图标
|
||
|
|
nx.gui.setActive(this.nodOp, "cost/icon", true);
|
||
|
|
var cfg = gdata("item_data", "data_unit1", icon);
|
||
|
|
if (this.shopType == 2) {
|
||
|
|
var txt = nx.text.format("lab_mall_window_tip3", String(icon), cfg.name, need);
|
||
|
|
this.cb = function () {
|
||
|
|
nx.mbox(txt, ['cancel', 'confirm'], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == "confirm") {
|
||
|
|
MC.sender13405(self.shopType);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
}
|
||
|
|
if (this.shopType == 9) {
|
||
|
|
if (this.freshData) {
|
||
|
|
var time = this.freshData.refresh_time;
|
||
|
|
var chance = this.freshData.free_count > 0 ? this.freshData.free_count : this.freshData.count;
|
||
|
|
var free_chance = this.freshData.free_count > 0 ? rfsg.skill_refresh_free.val : rfsg.skill_refresh_number.val;
|
||
|
|
var freshCount = this.freshData.free_count == 0 ? nx.text.getKey("Refresh Count") : nx.text.getKey("Free Refresh Count");
|
||
|
|
var need_txt = this.freshData.free_count > 0 ? nx.text.getKey("Free") : nx.text.format("lab_mall_window_tip4", need);
|
||
|
|
nx.gui.setActive(this.nodOp, "cost/icon", !this.freshData.free_count > 0);
|
||
|
|
nx.gui.setString(this.nodOp, "cost/txt", need_txt);
|
||
|
|
nx.gui.setActive(this.nodTime, "time", false);
|
||
|
|
nx.gui.setString(this.nodTime, "freshTimes/desc", freshCount);
|
||
|
|
nx.gui.setString(this.nodTime, "freshTimes/txt", chance + "/" + free_chance);
|
||
|
|
|
||
|
|
// nx.gui.setString( );
|
||
|
|
|
||
|
|
if (time > 0) {
|
||
|
|
this.setFreeCD(time);
|
||
|
|
}
|
||
|
|
if (this.freshData.free_count > 0) {
|
||
|
|
this.cb = function () {
|
||
|
|
MC.sender13405(_this.shopType);
|
||
|
|
};
|
||
|
|
} else {
|
||
|
|
var _txt = nx.text.format("lab_mall_window_tip3", String(icon), cfg.name, need);
|
||
|
|
this.cb = function () {
|
||
|
|
nx.mbox(_txt, ['cancel', 'confirm'], function (_key, _box) {
|
||
|
|
_box.close();
|
||
|
|
if (_key == "confirm") {
|
||
|
|
MC.sender13405(self.shopType);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 技能商城刷新相关
|
||
|
|
nx.gui.setActive(this.nodOp, "", this.shopType == 2 || this.shopType == 9);
|
||
|
|
nx.gui.setActive(this.nodOp.parent, "recycle", this.shopType == 2);
|
||
|
|
nx.gui.setActive(this.nodTime, "", this.shopType == 9);
|
||
|
|
},
|
||
|
|
// 刷新单个商品信息
|
||
|
|
freshShopItem: function freshShopItem(_shopitem) {
|
||
|
|
/*****
|
||
|
|
*{"code":1,"type":1,"eid":1013,"is_half":0,"ext":[{"key":1,"val":10}],"msg":""}
|
||
|
|
[13407]:{"code":1,"msg":"","order":5,"num":1,"type":2}
|
||
|
|
*/
|
||
|
|
|
||
|
|
var efg = game.configs.exchange_data;
|
||
|
|
// let cfg = rfsg.soul_reset_cost;
|
||
|
|
var ecfg = efg.data_shop_list;
|
||
|
|
var iconMat = ecfg[this.shopType].item_bid;
|
||
|
|
var count = BackPackController.getInstance().getModel().getItemNumByBid(iconMat);
|
||
|
|
nx.gui.setString(this.nodMat, "txt", nx.dt.shortCount(count));
|
||
|
|
nx.bridge.setIconS(this.nodMat, "icon", iconMat);
|
||
|
|
var lst = _shopitem;
|
||
|
|
var SC = ShopController.getInstance();
|
||
|
|
var model = SC.getModel();
|
||
|
|
var data_json = model.getAllDefault();
|
||
|
|
var data_ol = nx.dt.objClone(this.shoplst);
|
||
|
|
// console.log( "刷新商城信息wwww" + JSON.stringify( data_json ) );
|
||
|
|
var nodes = nx.gui.find(this.svcshopLst.bindSCV, "view/content").children;
|
||
|
|
// if( )
|
||
|
|
// for (let j = 0; j < lst.length; j++) {
|
||
|
|
// let item = lst[j];
|
||
|
|
for (var i = 0; i < nodes.length; i++) {
|
||
|
|
var sitem = nodes[i];
|
||
|
|
if (sitem) {
|
||
|
|
var cmp = sitem.svItem;
|
||
|
|
var datas = nx.dt.objClone(data_json[i]);
|
||
|
|
if (cmp) {
|
||
|
|
if (lst) {
|
||
|
|
if (lst.type == 1 || lst.type == 8 || lst.type == 5 || lst.type == 17 || lst.type == 30 || lst.type == 6 || lst.type == 55 || lst.type == 54 || lst.type == 56 || lst.type == 57 || lst.type == 36 || lst.type == 61 || lst.type == 58 || lst.type == 59 || lst.type == 62 || lst.type == 71) {
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (lst.type == 2 || lst.type == 9) {
|
||
|
|
if (cmp.mdata.order == lst.order) {
|
||
|
|
var _data2 = nx.dt.objClone(cmp.mdata);
|
||
|
|
if (lst.num > 0) {
|
||
|
|
_data2.has_buy = data_ol[i].has_buy + lst.num;
|
||
|
|
cmp.rebind(cmp.index, _data2);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onTouchBuy: function onTouchBuy(_item) {
|
||
|
|
var _this2 = this;
|
||
|
|
var EC = TipsController.getInstance();
|
||
|
|
var normal = function normal(_type) {
|
||
|
|
if (EC) {
|
||
|
|
var type = _type;
|
||
|
|
EC.openBuyPanel(true, _item.info, type, function (_data) {
|
||
|
|
MC.sender13402(_data.eid, _data.num);
|
||
|
|
EC.openBuyPanel(false);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
var MC = MallController.getInstance();
|
||
|
|
// 购买
|
||
|
|
var price = _item.info.discount > 0 ? _item.info.discount : _item.info.price;
|
||
|
|
var count = BackPackController.getInstance().getModel().getItemNumByBid(_item.info.pay_type);
|
||
|
|
var num = Math.floor(parseInt(count / price));
|
||
|
|
var expend_item_cfg = gdata("item_data", "data_unit1", _item.info.pay_type, false);
|
||
|
|
if (_item.mdata.pay_type == "gold" || _item.mdata.pay_type == "expedition_medal" || _item.mdata.pay_type == "arena_cent" || _item.mdata.pay_type == "elite_coin" || _item.mdata.pay_type == "sky_coin" || _item.mdata.pay_type == "elite_recruit_point" || _item.mdata.pay_type == "step_up_recruit_point" || _item.mdata.pay_type == "guild" || _item.mdata.pay_type == "cluster_guess_cent" || _item.mdata.pay_type == "recruit_3075_point" || _item.mdata.pay_type == "camp_arena_point" || _item.mdata.pay_type == "recruit_3076_point" || _item.mdata.pay_type == "star_card_point" || _item.mdata.pay_type == "sprite_party_point" || _item.mdata.pay_type == "80274") {
|
||
|
|
if (_item.info.can_buy > 0) {
|
||
|
|
nx.tbox(nx.text.getKey("lab_guildsecretarea_tips_15"));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_item.mdata.pay_type == "expedition_medal") {
|
||
|
|
if (num < 1) {
|
||
|
|
nx.tbox(nx.text.format(nx.text.getKey("lab_hero_break_window_tip1"), expend_item_cfg.name));
|
||
|
|
// TipsController.getInstance().showItemTips( parseInt( _item.info.pay_type ) );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if (count < price) {
|
||
|
|
nx.tbox(nx.text.format(nx.text.getKey("lab_hero_break_window_tip1"), expend_item_cfg.name));
|
||
|
|
// TipsController.getInstance().showItemTips( parseInt( _item.info.pay_type ) );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
normal(2);
|
||
|
|
} else {
|
||
|
|
if (_item.info.can_buy > 0) {
|
||
|
|
nx.tbox(nx.text.getKey("lab_guildsecretarea_tips_15"));
|
||
|
|
return;
|
||
|
|
} else {
|
||
|
|
if (_item.mdata.has_buy == 0) {
|
||
|
|
if (count < price) {
|
||
|
|
nx.tbox(nx.text.format(nx.text.getKey("lab_hero_break_window_tip1"), expend_item_cfg.name));
|
||
|
|
// TipsController.getInstance().showItemTips( parseInt( _item.info.pay_type ) );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (EC) {
|
||
|
|
var type = 4;
|
||
|
|
EC.openBuyPanel(true, _item.info, type, function (_data) {
|
||
|
|
MC.sender13407(_data.order, _this2.shopType, _data.buy_type, _data.num);
|
||
|
|
EC.openBuyPanel(false);
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onTouchBlackMarket: function onTouchBlackMarket() {
|
||
|
|
var MC = MallController.getInstance();
|
||
|
|
MC.sender13403(4);
|
||
|
|
},
|
||
|
|
// 商城切换
|
||
|
|
onTogMenu: function onTogMenu(_index) {
|
||
|
|
this.activeMenu(parseInt(_index) + 1);
|
||
|
|
},
|
||
|
|
// 商城切换
|
||
|
|
onTogMenus: function onTogMenus(_index) {
|
||
|
|
// if( parseInt( _index ) == 0 ){
|
||
|
|
// this.activeMenu( 3 );
|
||
|
|
// }else{
|
||
|
|
this.activeMenus(parseInt(_index) + 1);
|
||
|
|
// }
|
||
|
|
},
|
||
|
|
|
||
|
|
// 激活菜单
|
||
|
|
activeMenus: function activeMenus(_bagCode, isfirst) {
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
var SC = ShopController.getInstance();
|
||
|
|
// console.log( "商店切换s:", _bagCode );
|
||
|
|
switch (_bagCode) {
|
||
|
|
case 8:
|
||
|
|
{
|
||
|
|
this.shopType = 6;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 9:
|
||
|
|
{
|
||
|
|
this.shopType = 8;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 10:
|
||
|
|
{
|
||
|
|
this.shopType = 5;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 11:
|
||
|
|
{
|
||
|
|
this.shopType = 17;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 12:
|
||
|
|
{
|
||
|
|
this.shopType = 30;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 13:
|
||
|
|
{
|
||
|
|
this.shopType = 36;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 14:
|
||
|
|
{
|
||
|
|
this.shopType = 61;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 1:
|
||
|
|
{
|
||
|
|
this.shopType = 56;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
{
|
||
|
|
this.shopType = 54;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 3:
|
||
|
|
{
|
||
|
|
this.shopType = 55;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
{
|
||
|
|
this.shopType = 57;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 5:
|
||
|
|
{
|
||
|
|
this.shopType = 58;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 6:
|
||
|
|
{
|
||
|
|
this.shopType = 59;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 7:
|
||
|
|
{
|
||
|
|
this.shopType = 62;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
if (SC) {
|
||
|
|
SC.sender13401(this.shopType);
|
||
|
|
}
|
||
|
|
var cmp = nx.gui.getComponent(this.togMenus.node.parent.parent, "", cc.ScrollView);
|
||
|
|
if (cmp && this.shopType == 62) {
|
||
|
|
cmp.scrollToRight(0.01); // scrollTo
|
||
|
|
}
|
||
|
|
|
||
|
|
// this.scheduleOnce( ()=>{
|
||
|
|
// this.freshShop();
|
||
|
|
// }, 0.2 );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 激活菜单
|
||
|
|
activeMenu: function activeMenu(_bagCode, isfirst) {
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
var SC = ShopController.getInstance();
|
||
|
|
// console.log( "商店切换:", _bagCode );
|
||
|
|
if (this.curType == _bagCode) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.curType = _bagCode;
|
||
|
|
// this.shopType = _bagCode;
|
||
|
|
if (_bagCode == 1) {
|
||
|
|
this.shopType = 1;
|
||
|
|
if (SC) {
|
||
|
|
SC.sender13401(this.shopType);
|
||
|
|
}
|
||
|
|
|
||
|
|
// this.freshShop();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (_bagCode == 2) {
|
||
|
|
this.shopType = 2;
|
||
|
|
if (SC) {
|
||
|
|
SC.sender13403(this.shopType);
|
||
|
|
}
|
||
|
|
|
||
|
|
// this.freshShop();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (_bagCode == 4) {
|
||
|
|
this.shopType = 9;
|
||
|
|
if (SC) {
|
||
|
|
SC.sender13403(this.shopType);
|
||
|
|
}
|
||
|
|
// this.freshShop();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (_bagCode == 3) {
|
||
|
|
var chd = this.togMenus.node.children;
|
||
|
|
for (var i = 0; i < chd.length; i++) {
|
||
|
|
var nod = chd[i];
|
||
|
|
nx.gui.setActive(nod, "", i > first);
|
||
|
|
}
|
||
|
|
if (!isfirst) {
|
||
|
|
this.togMenus.togTo(first + 1);
|
||
|
|
this.onTogMenus(first + 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (_bagCode == 5) {
|
||
|
|
var _chd = this.togMenus.node.children;
|
||
|
|
for (var _i3 = 0; _i3 < _chd.length; _i3++) {
|
||
|
|
var _nod = _chd[_i3];
|
||
|
|
nx.gui.setActive(_nod, "", _i3 <= first);
|
||
|
|
}
|
||
|
|
this.togMenus.togTo(0);
|
||
|
|
this.onTogMenus(0);
|
||
|
|
}
|
||
|
|
if (_bagCode == 6) {
|
||
|
|
this.shopType = 71;
|
||
|
|
if (SC) {
|
||
|
|
SC.sender13401(this.shopType);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
freshShowLst: function freshShowLst(_lst) {
|
||
|
|
var MC = MallController.getInstance();
|
||
|
|
if (_lst.type == 4) {
|
||
|
|
this.blackMarket = _lst;
|
||
|
|
if (MC) {
|
||
|
|
MC.openVarietyStoreWindows(true, this.blackMarket);
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.shopType = _lst.type;
|
||
|
|
this.shoplst = _lst.item_list;
|
||
|
|
this.freshData = _lst;
|
||
|
|
this.freshShop();
|
||
|
|
},
|
||
|
|
onTouchFresh: function onTouchFresh() {
|
||
|
|
nx.dt.fnInvoke(this.cb);
|
||
|
|
},
|
||
|
|
// 根据点击的index取相关的数据配置
|
||
|
|
dealCfg: function dealCfg() {
|
||
|
|
var SC = ShopController.getInstance();
|
||
|
|
var model = SC.getModel();
|
||
|
|
// console.log( "刷新列表 商城" + JSON.stringify( model.getItemShopData() ) );
|
||
|
|
var lst = model.getItemShopData();
|
||
|
|
var pst = model.getPointShopData();
|
||
|
|
var gst = model.getGuildShopData();
|
||
|
|
var ast = model.getArenaShopData();
|
||
|
|
var rst = model.getRankShopData();
|
||
|
|
var tst = model.getThemeShoplst();
|
||
|
|
var ssst = model.getSsetShoplst();
|
||
|
|
var sst = model.getSetShoplst();
|
||
|
|
var ladst = model.getLadderShoplst();
|
||
|
|
var crosslst = model.getCrossChampionShoplst();
|
||
|
|
var partnerlst = model.getPartnerLst();
|
||
|
|
var campfightlst = model.getCampFightLst();
|
||
|
|
var praylst = model.getPrayLst();
|
||
|
|
var collectcardlst = model.getCollectCardStoreLst();
|
||
|
|
var wingslst = model.getWingsStoreLst();
|
||
|
|
var limitTimeEx = model.getLimitTimeEx();
|
||
|
|
// let sst =
|
||
|
|
var cfg = [];
|
||
|
|
switch (this.shopType) {
|
||
|
|
case 1:
|
||
|
|
{
|
||
|
|
cfg = lst;
|
||
|
|
this.svcshopLst.svcKey = "gold";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
{
|
||
|
|
cfg = this.shoplst;
|
||
|
|
this.svcshopLst.svcKey = "11";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 8:
|
||
|
|
{
|
||
|
|
cfg = pst;
|
||
|
|
this.svcshopLst.svcKey = "expedition_medal";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 5:
|
||
|
|
{
|
||
|
|
cfg = gst;
|
||
|
|
this.svcshopLst.svcKey = "guild";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 6:
|
||
|
|
{
|
||
|
|
cfg = ast;
|
||
|
|
this.svcshopLst.svcKey = "arena_cent";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 17:
|
||
|
|
{
|
||
|
|
cfg = rst;
|
||
|
|
this.svcshopLst.svcKey = "elite_coin";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 30:
|
||
|
|
{
|
||
|
|
cfg = ladst;
|
||
|
|
this.svcshopLst.svcKey = "sky_coin";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 36:
|
||
|
|
{
|
||
|
|
cfg = crosslst;
|
||
|
|
this.svcshopLst.svcKey = "cluster_guess_cent";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 9:
|
||
|
|
{
|
||
|
|
cfg = this.shoplst;
|
||
|
|
this.svcshopLst.svcKey = "10450";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 54:
|
||
|
|
{
|
||
|
|
cfg = sst;
|
||
|
|
this.svcshopLst.svcKey = "step_up_recruit_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 55:
|
||
|
|
{
|
||
|
|
cfg = ssst;
|
||
|
|
this.svcshopLst.svcKey = "elite_recruit_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 56:
|
||
|
|
{
|
||
|
|
cfg = tst;
|
||
|
|
this.svcshopLst.svcKey = "gold";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 57:
|
||
|
|
{
|
||
|
|
cfg = partnerlst;
|
||
|
|
this.svcshopLst.svcKey = "recruit_3075_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 61:
|
||
|
|
{
|
||
|
|
cfg = campfightlst;
|
||
|
|
this.svcshopLst.svcKey = "camp_arena_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 62:
|
||
|
|
{
|
||
|
|
cfg = wingslst;
|
||
|
|
this.svcshopLst.svcKey = "sprite_party_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 58:
|
||
|
|
{
|
||
|
|
cfg = praylst;
|
||
|
|
this.svcshopLst.svcKey = "recruit_3076_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 59:
|
||
|
|
{
|
||
|
|
cfg = collectcardlst;
|
||
|
|
this.svcshopLst.svcKey = "star_card_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
case 71:
|
||
|
|
{
|
||
|
|
cfg = limitTimeEx;
|
||
|
|
this.svcshopLst.svcKey = "star_card_point";
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
return cfg;
|
||
|
|
},
|
||
|
|
// 免费倒计时
|
||
|
|
setFreeCD: function setFreeCD(_dtFree) {
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
if (!nx.dt.numPositive(_dtFree, false)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this.nodTime, "time", true);
|
||
|
|
var self = this;
|
||
|
|
// let rate = game.configs.sprite_data.data_const.hatch_rate.val;
|
||
|
|
var tick = function tick() {
|
||
|
|
var interval = Utils.getTimeInterval(_dtFree);
|
||
|
|
// console.log( "当前的倒计时" + interval );
|
||
|
|
if (interval <= 0) {
|
||
|
|
self.unscheduleAllCallbacks();
|
||
|
|
nx.gui.setString(self.nodTime, "time/txt", "");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var time = Utils.changeIntevalToDate(interval);
|
||
|
|
var txt = time.H + ":" + time.M + ":" + time.S;
|
||
|
|
nx.gui.setString(self.nodTime, "time/txt", txt);
|
||
|
|
};
|
||
|
|
this.schedule(tick, 1, cc.macro.REPEAT_FOREVER);
|
||
|
|
tick();
|
||
|
|
},
|
||
|
|
onTouchAddMat: function onTouchAddMat() {
|
||
|
|
switch (this.shopType) {
|
||
|
|
case MallConst.MallType.Recovery:
|
||
|
|
{
|
||
|
|
nx.bridge.jumper.jump2Window(FID.Recycle);
|
||
|
|
}
|
||
|
|
;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onTouchIcon: function onTouchIcon() {
|
||
|
|
var TC = TipsController.getInstance();
|
||
|
|
if (TC) {
|
||
|
|
TC.showItemTips(this.Mat);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|