78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 图鉴收集任务总奖励
|
|
*
|
|
******************************************************************/
|
|
|
|
const ModLibrary = require( "library.mod" );
|
|
|
|
cc.Class({
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
},
|
|
|
|
// 重建
|
|
rebuild: function( _data ) {
|
|
|
|
this.info = _data;
|
|
if( nx.dt.objEmpty( this.info ) ) {
|
|
return;
|
|
}
|
|
|
|
// 标题
|
|
nx.gui.setString( this, "txt", nx.text.getKey( _data.reward_desc ) );
|
|
|
|
// 状态更新
|
|
this.updateState( _data.statu );
|
|
},
|
|
|
|
// 状态更新
|
|
updateState: function( _statu ) {
|
|
|
|
// 领取状态
|
|
nx.gui.setActive( this, "got", _statu == 2 );
|
|
nx.gui.setActive( this, "get", _statu == 1 );
|
|
|
|
// 置灰
|
|
let mat = cc.Material.getBuiltinMaterial( ( _statu == 0 ) ? '2d-gray-sprite' : '2d-sprite' );
|
|
let bg = nx.gui.getComponent( this, "", cc.Sprite );
|
|
let icon = nx.gui.getComponent( this, "icon", cc.Sprite );
|
|
bg.setMaterial( 0, mat );
|
|
icon.setMaterial( 0, mat );
|
|
|
|
},
|
|
|
|
// 点击领取
|
|
onTouchGet: function() {
|
|
|
|
let library = ModLibrary.getInstance();
|
|
library.reqGroupReward( this.info.id, ( _ret, _data ) => {
|
|
|
|
if( !_ret ) {
|
|
nx.tbox( _data );
|
|
return;
|
|
}
|
|
|
|
this.updateState( 2 );
|
|
} );
|
|
},
|
|
|
|
// 点击预览
|
|
onTouchPreview: function() {
|
|
|
|
let list = this.info ? this.info.reward : [];
|
|
if( nx.dt.arrEmpty( list ) ) {
|
|
return;
|
|
}
|
|
|
|
nx.bridge.createPanel( "PopItemsPreview", {
|
|
tip: "PreviewReward",
|
|
items: list
|
|
} );
|
|
|
|
},
|
|
|
|
});
|