126 lines
3.7 KiB
JavaScript
126 lines
3.7 KiB
JavaScript
|
|
|
||
|
|
const TaskConst = require( "task_const" );
|
||
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// 任务状态
|
||
|
|
const TST = TaskConst.task_status;
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
nodName: {
|
||
|
|
default : null,
|
||
|
|
type : cc.Label,
|
||
|
|
},
|
||
|
|
|
||
|
|
nodFocus: {
|
||
|
|
default : null,
|
||
|
|
type : cc.Node,
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function(){
|
||
|
|
nx.gui.setActive( this, "on", false );
|
||
|
|
nx.gui.setActive( this, "off", true );
|
||
|
|
// this.bindGEvent( TaskEvent.UpdateTaskList,this.freshTask.bind( this) );
|
||
|
|
},
|
||
|
|
|
||
|
|
freshTask: function( _data ){
|
||
|
|
if( this.mdata ){
|
||
|
|
if( this.mdata.id == _data.id ){
|
||
|
|
this.mdata.finish = _data.finish;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 数据重置
|
||
|
|
setData: function( _data, _index ) {
|
||
|
|
this.index = _index;
|
||
|
|
this.mdata = _data;
|
||
|
|
// 刷新
|
||
|
|
this.freshBase();
|
||
|
|
// if( _index == 0 ){
|
||
|
|
// this.scheduleOnce( ()=>{
|
||
|
|
// this.onTouchfocus();
|
||
|
|
// }, 0.3 );
|
||
|
|
|
||
|
|
// }
|
||
|
|
// this.freshStatus();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
// 刷新基本信息
|
||
|
|
freshBase: function() {
|
||
|
|
|
||
|
|
|
||
|
|
// 设状态
|
||
|
|
if( this.mdata ){
|
||
|
|
// console.log( JSON.stringify( this.mdata) + "当前 的任务单个信息" );
|
||
|
|
let pro = "";
|
||
|
|
pro = this.mdata.type == 1 ? "" : this.mdata.progress[0].value + "/" + this.mdata.progress[0].target_val;
|
||
|
|
|
||
|
|
nx.gui.setString( this,"lock/txt", this.mdata.desc );
|
||
|
|
if( this.mdata.canshow ){
|
||
|
|
let color = this.mdata.finish == 1 || this.mdata.finish == 2 ? new cc.Color().fromHEX("#28a812") : new cc.Color().fromHEX("#ff1b1b") ;
|
||
|
|
// nx.gui.setColor( this,"on/progress", color );
|
||
|
|
// nx.gui.setColor( this,"off/progress", color );
|
||
|
|
nx.gui.setString( this,"on/txt", this.mdata.desc );
|
||
|
|
nx.gui.setString( this,"on/progress", "" );
|
||
|
|
nx.gui.setActive( this, "on/doing", this.mdata.finish == 0 && this.mdata.type == 1 );
|
||
|
|
nx.gui.setActive( this, "on/done", ( this.mdata.finish == 2 ) && this.mdata.type == 1 );
|
||
|
|
nx.gui.setActive( this, "on/get", ( this.mdata.finish == 1 ) && this.mdata.type == 1 );
|
||
|
|
nx.gui.setString( this,"off/txt", this.mdata.desc );
|
||
|
|
nx.gui.setString( this,"off/progress", "" );
|
||
|
|
nx.gui.setActive( this, "off/doing", this.mdata.finish == 0 && this.mdata.type == 1 );
|
||
|
|
nx.gui.setActive( this, "off/done", (this.mdata.finish == 2 ) && this.mdata.type == 1 );
|
||
|
|
nx.gui.setActive( this, "off/get", ( this.mdata.finish == 1 ) && this.mdata.type == 1 );
|
||
|
|
|
||
|
|
|
||
|
|
nx.gui.setActive( this, "on", false );
|
||
|
|
nx.gui.setActive( this, "off", true );
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setActive( this, "lock", !this.mdata.canshow );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
onTouchfocus: function(){
|
||
|
|
|
||
|
|
// console.log( "当前点击的对应的序号" + this.index );
|
||
|
|
// nx.gui.setActive( this, "on", true );
|
||
|
|
// nx.gui.setActive( this, "off", false );
|
||
|
|
let nodes = this.node.parent;
|
||
|
|
let chd = nodes.children;
|
||
|
|
let chdn = chd[this.index];
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
let nod = chd[i];
|
||
|
|
nx.gui.setActive( nod, "on", false );
|
||
|
|
nx.gui.setActive( nod, "off", true );
|
||
|
|
}
|
||
|
|
nx.gui.setActive( chdn, "on", true );
|
||
|
|
nx.gui.setActive( chdn, "off", false );
|
||
|
|
|
||
|
|
nx.bridge.vset( "TaskInfo", this.mdata );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchlock: function(){
|
||
|
|
|
||
|
|
nx.tbox( "Locked" );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
});
|