842 lines
29 KiB
JavaScript
842 lines
29 KiB
JavaScript
const BridgeWindow = require( "bridge.window" );
|
|
const FxSVC = require( "nx.fx.sv.expand" );
|
|
const ShopController = require( "mall_controller" );
|
|
const MallEvent = require( "mall_event" );
|
|
const MallController = require("mall_controller");
|
|
const FxTogs = require( "nx.fx.togs" );
|
|
const PathTool = require( "pathtool" );
|
|
const BackPackController = require( "backpack_controller" );
|
|
const TipsController = require( "tips_controller" );
|
|
const MallConst = require( "mall_const" );
|
|
const FID = require( "bridge.function.ids" );
|
|
const RoleController = require("role_controller");
|
|
const first = 6;
|
|
|
|
// 标签页对应关系
|
|
const 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 },
|
|
];
|
|
|
|
const VarietyShop = MallConst.MallType.VarietyShop;
|
|
|
|
// 标签页对应关系
|
|
const 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() {
|
|
|
|
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( _params ) {
|
|
|
|
this.freshTitles();
|
|
if( _params.fromOther ){
|
|
let from = _params.fromOther;
|
|
if( from.length < 2 ){
|
|
|
|
let tab = from[0];
|
|
let goto = 0;
|
|
TabPage.forEach( _tab => {
|
|
if( tab == _tab.tab ){
|
|
goto = _tab.goto;
|
|
}
|
|
} )
|
|
this.togMenu.togTo( goto );
|
|
this.activeMenu( goto + 1 );
|
|
|
|
}else{
|
|
let tab1 = from[0];
|
|
let tab2 = from[1];
|
|
let goto = 0;
|
|
let goto2 = 0;
|
|
TabPage.forEach( _tab => {
|
|
if( tab1 == _tab.tab ){
|
|
goto = _tab.goto;
|
|
}
|
|
} )
|
|
DifTabPage.forEach( _tab => {
|
|
if( tab2 == _tab.tab ){
|
|
goto2 = _tab.goto;
|
|
}
|
|
} )
|
|
this.togMenu.togTo( goto );
|
|
this.activeMenu( ( goto + 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() {
|
|
|
|
// this.svcschemeList.rebuild( [] );
|
|
this.svcshopLst.rebuild( [] );
|
|
|
|
},
|
|
|
|
freshTitles: function(){
|
|
|
|
// let cut = function( _str ){
|
|
// // if( _str )
|
|
// }
|
|
|
|
let cfg = game.configs.exchange_data.data_shop_list;
|
|
let chd = this.togMenu.node.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let item = chd[i];
|
|
let key = TabPage[i].tab;
|
|
let 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 ) ){
|
|
let time = cfg[key].end_time.split( "," );
|
|
let needt = "";
|
|
for (let i = 0; i < time.length; i++) {
|
|
let 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;
|
|
}
|
|
}
|
|
|
|
let endTime = new Date( needt );
|
|
let timestamp = endTime.getTime();
|
|
|
|
nx.gui.setActive( item, "", timestamp - cc.sys.now() >= 0 );
|
|
}
|
|
|
|
}
|
|
let role_vo = RoleController.getInstance().getRoleVo();
|
|
let chds = this.togMenus.node.children;
|
|
for (let i = 0; i < chds.length; i++) {
|
|
let item = chds[i];
|
|
let tab = DifTabPage[i];
|
|
if( tab ){
|
|
let key = DifTabPage[i].tab;
|
|
if( key ){
|
|
let title = cfg[key].name;
|
|
nx.gui.setString( item, "on/txt", title );
|
|
nx.gui.setString( item, "off/txt", title );
|
|
// 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[key].limit ) ){
|
|
if( role_vo.lev < cfg[key].limit[0][1] && ( cfg[key].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( item, "lock", true );
|
|
}else{
|
|
nx.gui.setActive( item, "lock", false );
|
|
// nx.gui.setActive( item, "", cfg[key].id == 55 ? false : true );
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
let title = cfg[VarietyShop].name;
|
|
nx.gui.setString( this.nodVarietyShop, "txt", title );
|
|
},
|
|
|
|
// 物品列表 读取的本地json 钻石
|
|
freshShop: function(){
|
|
|
|
let lst = this.dealCfg();
|
|
nx.gui.setActive( this.nodEmpty, "", nx.dt.arrEmpty( lst ) );
|
|
this.svcshopLst.rebuild( lst );
|
|
|
|
|
|
this.opfreshShopItems();
|
|
|
|
|
|
},
|
|
|
|
// 刷新按钮显示 处理刷新按钮所需要的材料 以及免费刷新的次数等信息, 以及赋予相关的方法
|
|
opfreshShopItems: function(){
|
|
|
|
let self = this;
|
|
let efg = game.configs.exchange_data;
|
|
if( efg ){
|
|
|
|
}
|
|
let rfsg = efg.data_shop_exchage_cost;
|
|
// let cfg = rfsg.soul_reset_cost;
|
|
let ecfg = efg.data_shop_list;
|
|
|
|
let iconMat = ecfg[this.shopType].item_bid;
|
|
|
|
let 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
|
|
);
|
|
let EC = TipsController.getInstance();
|
|
let MC = MallController.getInstance();
|
|
if( this.shopType == 2 || this.shopType == 9 ){
|
|
|
|
let need = ecfg[this.shopType].cost_list[0][1];
|
|
let icon = ecfg[this.shopType].cost_list[0][0];
|
|
|
|
nx.gui.setString( this.nodOp, "cost/txt", nx.text.format( "lab_mall_window_tip4", need ) );
|
|
let path = "";
|
|
path = PathTool.querySmallIconPath( icon );
|
|
nx.bridge.setIconS( this.nodOp, "cost/icon", icon );// 小图标
|
|
nx.gui.setActive( this.nodOp, "cost/icon", true );
|
|
|
|
let cfg = gdata( "item_data", "data_unit1", icon );
|
|
if( this.shopType == 2 ){
|
|
|
|
let txt = nx.text.format( "lab_mall_window_tip3", String( icon ), cfg.name, need );
|
|
this.cb = ()=>{
|
|
|
|
nx.mbox( txt, [ 'cancel', 'confirm' ], ( _key, _box ) => {
|
|
_box.close();
|
|
if( _key == "confirm" ) {
|
|
MC.sender13405( self.shopType );
|
|
}
|
|
} );
|
|
|
|
|
|
}
|
|
}
|
|
if( this.shopType == 9 ){
|
|
|
|
if( this.freshData ){
|
|
|
|
let time = this.freshData.refresh_time;
|
|
let chance = this.freshData.free_count > 0 ? this.freshData.free_count : this.freshData.count ;
|
|
let free_chance = this.freshData.free_count > 0 ? rfsg.skill_refresh_free.val : rfsg.skill_refresh_number.val;
|
|
let freshCount = this.freshData.free_count == 0 ? nx.text.getKey( "Refresh Count" ) : nx.text.getKey( "Free Refresh Count" );
|
|
let 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 = ()=>{
|
|
MC.sender13405( this.shopType );
|
|
};
|
|
}else{
|
|
let txt = nx.text.format( "lab_mall_window_tip3", String( icon ), cfg.name, need );
|
|
this.cb = ()=>{
|
|
|
|
nx.mbox( txt, [ 'cancel', 'confirm' ], ( _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( _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}
|
|
*/
|
|
|
|
let efg = game.configs.exchange_data;
|
|
// let cfg = rfsg.soul_reset_cost;
|
|
let ecfg = efg.data_shop_list;
|
|
|
|
let iconMat = ecfg[this.shopType].item_bid;
|
|
let count = BackPackController.getInstance().getModel().getItemNumByBid( iconMat );
|
|
nx.gui.setString( this.nodMat, "txt", nx.dt.shortCount( count ) );
|
|
nx.bridge.setIconS( this.nodMat, "icon", iconMat );
|
|
let lst = _shopitem ;
|
|
let SC = ShopController.getInstance();
|
|
let model = SC.getModel();
|
|
let data_json = model.getAllDefault();
|
|
let data_ol = nx.dt.objClone( this.shoplst );
|
|
// console.log( "刷新商城信息wwww" + JSON.stringify( data_json ) );
|
|
let nodes = nx.gui.find( this.svcshopLst.bindSCV, "view/content" ).children;
|
|
// if( )
|
|
// for (let j = 0; j < lst.length; j++) {
|
|
// let item = lst[j];
|
|
for (let i = 0; i < nodes.length; i++) {
|
|
|
|
let sitem = nodes[i];
|
|
if( sitem ){
|
|
let cmp = sitem.svItem;
|
|
let 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 ){
|
|
let 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 ){
|
|
let data = nx.dt.objClone( cmp.mdata );
|
|
if( lst.num > 0 ){
|
|
data.has_buy = data_ol[i].has_buy + lst.num;
|
|
cmp.rebind( cmp.index, data );
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onTouchBuy: function( _item ){
|
|
|
|
let EC = TipsController.getInstance();
|
|
|
|
let normal = function( _type ){
|
|
if( EC ){
|
|
let type = _type;
|
|
EC.openBuyPanel( true, _item.info, type, _data => {
|
|
MC.sender13402( _data.eid, _data.num );
|
|
EC.openBuyPanel( false );
|
|
} );
|
|
|
|
}
|
|
}
|
|
|
|
let MC = MallController.getInstance();
|
|
// 购买
|
|
let price = _item.info.discount > 0 ? _item.info.discount : _item.info.price ;
|
|
let count = BackPackController.getInstance().getModel().getItemNumByBid( _item.info.pay_type ) ;
|
|
let num = Math.floor(parseInt( count / price ));
|
|
let 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 ){
|
|
let type = 4;
|
|
|
|
EC.openBuyPanel( true, _item.info, type, _data => {
|
|
MC.sender13407( _data.order, this.shopType, _data.buy_type, _data.num );
|
|
EC.openBuyPanel( false );
|
|
} );
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
onTouchBlackMarket: function(){
|
|
|
|
let MC = MallController.getInstance();
|
|
MC.sender13403( 4 );
|
|
|
|
},
|
|
|
|
// 商城切换
|
|
onTogMenu: function( _index ) {
|
|
this.activeMenu( parseInt( _index ) + 1 );
|
|
},
|
|
|
|
// 商城切换
|
|
onTogMenus: function( _index ) {
|
|
// if( parseInt( _index ) == 0 ){
|
|
// this.activeMenu( 3 );
|
|
// }else{
|
|
this.activeMenus( parseInt( _index ) + 1 );
|
|
// }
|
|
|
|
},
|
|
|
|
|
|
// 激活菜单
|
|
activeMenus: function( _bagCode, isfirst ) {
|
|
|
|
this.unscheduleAllCallbacks();
|
|
let 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 );
|
|
}
|
|
let 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( _bagCode, isfirst ) {
|
|
|
|
this.unscheduleAllCallbacks();
|
|
let 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 ){
|
|
|
|
|
|
let chd = this.togMenus.node.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
nx.gui.setActive( nod, "", i > first );
|
|
}
|
|
if( !isfirst ){
|
|
this.togMenus.togTo( first + 1 );
|
|
this.onTogMenus( first + 1 );
|
|
}
|
|
|
|
}
|
|
|
|
if ( _bagCode == 5 ){
|
|
|
|
let chd = this.togMenus.node.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let nod = chd[i];
|
|
nx.gui.setActive( nod, "", i <= first );
|
|
}
|
|
|
|
this.togMenus.togTo( 0 );
|
|
this.onTogMenus( 0 );
|
|
}
|
|
|
|
if ( _bagCode == 6 ){
|
|
|
|
this.shopType = 71;
|
|
if( SC ){
|
|
SC.sender13401( this.shopType );
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
freshShowLst: function( _lst ){
|
|
|
|
let 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(){
|
|
nx.dt.fnInvoke( this.cb );
|
|
},
|
|
|
|
|
|
// 根据点击的index取相关的数据配置
|
|
dealCfg: function(){
|
|
|
|
let SC = ShopController.getInstance();
|
|
let model = SC.getModel();
|
|
// console.log( "刷新列表 商城" + JSON.stringify( model.getItemShopData() ) );
|
|
let lst = model.getItemShopData();
|
|
let pst = model.getPointShopData();
|
|
let gst = model.getGuildShopData();
|
|
let ast = model.getArenaShopData();
|
|
let rst = model.getRankShopData();
|
|
let tst = model.getThemeShoplst();
|
|
let ssst = model.getSsetShoplst();
|
|
let sst = model.getSetShoplst();
|
|
let ladst = model.getLadderShoplst();
|
|
let crosslst = model.getCrossChampionShoplst();
|
|
let partnerlst = model.getPartnerLst();
|
|
let campfightlst = model.getCampFightLst();
|
|
let praylst = model.getPrayLst();
|
|
let collectcardlst = model.getCollectCardStoreLst();
|
|
let wingslst = model.getWingsStoreLst();
|
|
|
|
let limitTimeEx = model.getLimitTimeEx();
|
|
// let sst =
|
|
let 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( _dtFree ) {
|
|
|
|
this.unscheduleAllCallbacks();
|
|
|
|
if( !nx.dt.numPositive( _dtFree, false ) ) {
|
|
return;
|
|
}
|
|
nx.gui.setActive( this.nodTime, "time", true );
|
|
let self = this;
|
|
// let rate = game.configs.sprite_data.data_const.hatch_rate.val;
|
|
let tick = function() {
|
|
let interval = Utils.getTimeInterval( _dtFree );
|
|
// console.log( "当前的倒计时" + interval );
|
|
if( interval <= 0 ) {
|
|
self.unscheduleAllCallbacks();
|
|
nx.gui.setString( self.nodTime, "time/txt", "" );
|
|
return;
|
|
}
|
|
|
|
let time = Utils.changeIntevalToDate( interval );
|
|
let 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(){
|
|
|
|
switch( this.shopType ){
|
|
case MallConst.MallType.Recovery: { nx.bridge.jumper.jump2Window( FID.Recycle ) }; break;
|
|
}
|
|
|
|
},
|
|
|
|
onTouchIcon: function(){
|
|
|
|
const TC = TipsController.getInstance();
|
|
if ( TC ) {
|
|
TC.showItemTips( this.Mat );
|
|
}
|
|
},
|
|
|
|
});
|