134 lines
3.0 KiB
JavaScript
134 lines
3.0 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '8ae1eM4HF5KxZbbcrETdFd+', 'cmp.acts.foreshow.wnd');
|
|
// Scripts/mod/acts/cmps/cmp.acts.foreshow.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 活动预告
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
autoSecs: {
|
|
"default": 10
|
|
},
|
|
adPages: {
|
|
"default": null,
|
|
type: cc.PageView
|
|
},
|
|
tPage: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
var _this = this;
|
|
// 统计菜单项
|
|
this.menus = nx.bridge.acts.vget("foreshow");
|
|
if (nx.dt.arrEmpty(this.menus)) {
|
|
this.delayClose();
|
|
return;
|
|
}
|
|
|
|
// 清空
|
|
this.adPages.removeAllPages();
|
|
this.toLeft = true;
|
|
this.menus.forEach(function (ad) {
|
|
_this.addPage(ad);
|
|
});
|
|
|
|
// 自动轮播
|
|
this.unscheduleAllCallbacks();
|
|
this.schedule(function () {
|
|
_this.nextAd();
|
|
}, this.autoSecs);
|
|
},
|
|
// 添加广告图
|
|
addPage: function addPage(_ad) {
|
|
// 创建新页面
|
|
var page = cc.instantiate(this.tPage);
|
|
page.name = "" + _ad.id;
|
|
page.adinfo = _ad;
|
|
var path = cc.path.join("locals", nx.getLocLanguage(), "images/ads", _ad.img);
|
|
nx.gui.setSpriteFrame(page, "img", path);
|
|
|
|
// 加入PV
|
|
this.adPages.addPage(page);
|
|
},
|
|
// 下一张
|
|
nextAd: function nextAd(_dir) {
|
|
var total = this.adPages.getPages().length;
|
|
var cur = this.adPages.getCurrentPageIndex();
|
|
|
|
// 左移
|
|
if (this.toLeft) {
|
|
var next = cur + 1;
|
|
if (total > 1) {
|
|
if (next < total) {
|
|
this.adPages.scrollToPage(next);
|
|
return;
|
|
}
|
|
} else {
|
|
if (next <= total) {
|
|
this.adPages.scrollToPage(next);
|
|
return;
|
|
}
|
|
}
|
|
this.toLeft = false;
|
|
this.nextAd();
|
|
} else {
|
|
var _next = cur - 1;
|
|
if (_next >= 0) {
|
|
this.adPages.scrollToPage(_next);
|
|
return;
|
|
}
|
|
this.toLeft = true;
|
|
this.nextAd();
|
|
}
|
|
},
|
|
// 左切
|
|
onTouchLeft: function onTouchLeft() {
|
|
var cur = this.adPages.getCurrentPageIndex() - 1;
|
|
if (cur >= 0) {
|
|
this.adPages.scrollToPage(cur);
|
|
}
|
|
},
|
|
// 右切
|
|
onTouchRight: function onTouchRight() {
|
|
var total = this.adPages.getPages().length;
|
|
var cur = this.adPages.getCurrentPageIndex() + 1;
|
|
if (cur < total) {
|
|
this.adPages.scrollToPage(cur);
|
|
}
|
|
},
|
|
// 点击海报
|
|
onTouchBox: function onTouchBox() {
|
|
var cur = this.adPages.getCurrentPageIndex();
|
|
var info = this.menus[cur];
|
|
if (nx.dt.objEmpty(info)) {
|
|
return;
|
|
}
|
|
|
|
// 活动跳转
|
|
if (nx.dt.numPositive(info.camp_id, false)) {
|
|
nx.bridge.jumper.jump2ActPage(info.camp_id);
|
|
this.close();
|
|
return;
|
|
}
|
|
|
|
// 普通跳转
|
|
if (nx.dt.strNEmpty(info.link)) {
|
|
nx.bridge.cmd.doStr(info.link);
|
|
this.close();
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |