"use strict"; cc._RF.push(module, '8d3bd7bMmpO/6WLN1z6po2e', 'cmp.plot.pictures.wnd'); // Scripts/mod/plot/cmps/cmp.plot.pictures.wnd.js "use strict"; /****************************************************************** * Copyright(C) 2019 - 2020 Nx Studio * * 引导 --- 图片流 * * ******************************************************************/ var 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 onOpenConfigs(_params) { var _this = this; var key = _params ? _params.id : ""; if (nx.dt.strEmpty(key)) { nx.error("$PlotPictures:\u5E2E\u52A9\u7F3A\u5931!"); this.delayClose(); return; } if (!nx.bridge.plot || !nx.bridge.plot.configs || !nx.bridge.plot.configs.pictures) { nx.error("$PlotPictures:\u5E2E\u52A9\u7F3A\u5931! " + key); this.delayClose(); return; } this.data = nx.bridge.plot.configs.pictures[key]; if (!this.data || nx.dt.arrEmpty(this.data.list)) { nx.error("$PlotPictures:\u914D\u7F6E\u7F3A\u5931! " + key); this.delayClose(); return; } // 构建页面 this.toLeft = true; this.adPages.removeAllPages(); this.data.list.forEach(function (pic) { _this.addPage(pic); }); this.setPage(0); }, // 添加广告图 addPage: function addPage(_pic) { var path = cc.path.join("locals", nx.getLocLanguage(), "images/tips", _pic); var page = cc.instantiate(this.tPage); nx.gui.setSpriteFrame(page, "img", path); this.adPages.addPage(page); }, // 设置当前页 setPage: function setPage(_index) { this.adPages.scrollToPage(_index); var limit = this.adPages.getPages().length - 1; this.btnLeft.active = _index > 0; this.btnRight.active = _index < limit; }, // 左切 onTouchLeft: function onTouchLeft() { var cur = this.adPages.getCurrentPageIndex() - 1; if (cur >= 0) { this.setPage(cur); } }, // 右切 onTouchRight: function onTouchRight() { var total = this.adPages.getPages().length; var cur = this.adPages.getCurrentPageIndex() + 1; if (cur < total) { this.setPage(cur); } } }); cc._RF.pop();