"use strict"; cc._RF.push(module, '31916KsmbNDb6XfLXb3VqJA', 'cmp.act.task.daily.page'); // Scripts/mod/acts/taskDaily/cmp.act.task.daily.page.js "use strict"; /****************************************************************** * * 日常任务模版 * ******************************************************************/ var ActPage = require("act.page.base"); var FxSVC = require("nx.fx.sv.expand"); var TipsController = require("tips_controller"); var BridgeItemBinder = require("bridge.binder.item.icon.count"); cc.Class({ "extends": ActPage, properties: { lstTask: { "default": null, type: FxSVC }, nodDate: { "default": null, type: cc.Node }, nodItem1: { "default": null, type: BridgeItemBinder }, nodItem2: { "default": null, type: BridgeItemBinder } }, // 初始化 build: function build(_data) { this._super(_data); // 活动监听 this.mod.vbind(this, [["dailyTasks", this.freshTask.bind(this)]]); var items = this.mod.queryItemsConfig(); if (items) { this.nodItem1.setID(items.item1); this.nodItem2.setID(items.item2); } }, onEnable: function onEnable() { // 更新一下 this.mod.reqBaseData(); // 刷新活动日期 var time = nx.bridge.time.toNeedTime(this.data.end_time); nx.gui.setString(this.nodDate, "txt", time); }, // 销毁 onDestroy: function onDestroy() { // 活动监听解除 if (this.mod) { this.mod.vunbind(this); } this._super(); }, // 任务刷新 freshTask: function freshTask(_task, _old, _init) { if (_init) return; // 空 var cfgs = this.mod.queryTaskCfgs(); if (nx.dt.arrEmpty(_task) || nx.dt.objEmpty(cfgs)) { this.lstTask.rebuild([]); return; } // 重建 this.tasks = []; for (var i = 0; i < _task.length; ++i) { var task = nx.dt.objClone(_task[i]); var info = cfgs[task.id]; task.day = info.day; task.title = info.title; task.desc = info.desc; task.progress = info.progress; task.award = info.award; task.jump_id = info.jump_id; task.mod = this.mod; this.tasks.push(task); } // 0:未完成 1:已完成 2:已提交 var PR = [2, 1, 3]; this.tasks.sort(function (a, b) { if (a.finish == b.finish) { return a.id - b.id; } return PR[a.finish] - PR[b.finish]; }); this.lstTask.rebuild(this.tasks); }, // 点击规则 onTouchRule: function onTouchRule() { var rule = this.mod ? this.mod.queryRule() : ""; if (nx.dt.strNEmpty(rule)) { var TC = TipsController.getInstance(); TC.showTextPanel("tip", rule); } }, // 点击商城 onTouchShop: function onTouchShop() { nx.bridge.jumper.jump2Window(474); } }); cc._RF.pop();