Files

94 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
* Copyright(C) 2019 - 2020 Nx Studio
*
* 引导 --- 图片流
*
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
cc.Class( {
extends: BridgeWindow,
properties: {
adPages: { default: null, type: cc.PageView },
tPage: { default: null, type: cc.Node },
btnLeft: { default: null, type: cc.Node },
btnRight: { default: null, type: cc.Node },
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
let key = _params ? _params.id : "";
if( nx.dt.strEmpty( key ) ) {
nx.error( `$PlotPictures:帮助缺失!` );
this.delayClose();
return;
}
if( !nx.bridge.plot ||
!nx.bridge.plot.configs ||
!nx.bridge.plot.configs.pictures ) {
nx.error( `$PlotPictures:帮助缺失! ${ key }` );
this.delayClose();
return;
}
this.data = nx.bridge.plot.configs.pictures[ key ];
if( !this.data || nx.dt.arrEmpty( this.data.list ) ) {
nx.error( `$PlotPictures:配置缺失! ${ key }` );
this.delayClose();
return;
}
// 构建页面
this.toLeft = true;
this.adPages.removeAllPages();
this.data.list.forEach( pic => {
this.addPage( pic );
} );
this.setPage( 0 );
},
// 添加广告图
addPage: function( _pic ) {
let path = cc.path.join( "locals", nx.getLocLanguage(), "images/tips", _pic );
let page = cc.instantiate( this.tPage );
nx.gui.setSpriteFrame( page, "img", path );
this.adPages.addPage( page );
},
// 设置当前页
setPage: function( _index ) {
this.adPages.scrollToPage( _index );
let limit = this.adPages.getPages().length - 1;
this.btnLeft.active = ( _index > 0 );
this.btnRight.active = ( _index < limit );
},
// 左切
onTouchLeft: function() {
let cur = this.adPages.getCurrentPageIndex() - 1;
if( cur >= 0 ) {
this.setPage( cur );
}
},
// 右切
onTouchRight: function() {
let total = this.adPages.getPages().length;
let cur = this.adPages.getCurrentPageIndex() + 1;
if( cur < total ) {
this.setPage( cur );
}
},
} );