"use strict"; cc._RF.push(module, '76032i8TFhFZqL89lp5W3Is', 'cmp.act.training7.task'); // Scripts/mod/acts/training7/cmp.act.training7.task.js "use strict"; var ItemBase = require("nx.fx.sv.expand.item"); var ItemLay = require("cmp.common.itemlayout"); var Act7Mod = require("act.training7.mod"); cc.Class({ "extends": ItemBase, properties: { desc: { "default": null, type: cc.Label }, bar: { "default": null, type: cc.ProgressBar }, barNum: { "default": null, type: cc.Label }, hased: { "default": null, type: cc.Node }, get: { "default": null, type: cc.Node }, "goto": { "default": null, type: cc.Node }, items: { "default": null, type: ItemLay } }, // LIFE-CYCLE CALLBACKS: rebind: function rebind(_idx, _data, _key) { this.mdata = _data; this.data_key = _key; this.setData(_data); }, setData: function setData(data) { if (nx.dt.objEmpty(data)) return; var data_list = null; if (this.data_key == "data_growthtarget") { data_list = Act7Mod.getInstance().getWalfareGrowUpData(data.day - 1); this.mdata.type = 2; } else { data_list = Act7Mod.getInstance().getWalfareData(data.day); this.mdata.type = 1; } for (var i in data_list) { if (data.goal_id == data_list[i].goal_id) { this.goal_data = data_list[i]; this.mdata.index = Number(i); break; } } if (nx.dt.objEmpty(this.goal_data)) return; this.desc.string = this.goal_data.desc; //進度 this.bar.progress = data.progress[0].value / data.progress[0].target_val; this.barNum.string = cc.js.formatStr("%s/%s", data.progress[0].value, data.progress[0].target_val); this.updateStatus(); this.items.rebuild(this.goal_data.award1); }, updateStatus: function updateStatus() { this["goto"].active = this.mdata.status == 0; this.get.active = this.mdata.status == 1; this.hased.active = this.mdata.status == 2; // if(this.mdata.status == 1){ // Act7Mod.getInstance().openTip(Act7Mod.getInstance().tipKeys()[1],true); // }else{ // Act7Mod.getInstance().openTip(Act7Mod.getInstance().tipKeys()[1],false); // } }, onTouchGet: function onTouchGet() { if (nx.dt.objEmpty(this.mdata)) return; Act7Mod.getInstance().sender13602(this.mdata.type, this.mdata.day, this.mdata.goal_id, this.mdata.index); }, onTouchJump: function onTouchJump() { if (nx.dt.objEmpty(this.goal_data)) return; nx.bridge.jumper.jump2Window(this.goal_data.source_id); }, onDisable: function onDisable() { this.items.rebuild([]); } // update (dt) {}, }); cc._RF.pop();