73 lines
2.0 KiB
JavaScript
73 lines
2.0 KiB
JavaScript
cc.Class({
|
|
extends: cc.Component,
|
|
properties: {
|
|
showPic: cc.Sprite
|
|
},
|
|
onLoad: function () {
|
|
this.showID = 0;
|
|
this.changeTime = 0;
|
|
if ((window.swan || window.tt) && window.GameConfig.iconList && window.GameConfig.packageList) {
|
|
if (window.GameConfig.packageList.length <= 0 || window.GameConfig.packageList.length <= 0) {
|
|
this.node.active = false;
|
|
} else {
|
|
this.showIcon();
|
|
}
|
|
} else {
|
|
this.node.active = false;
|
|
}
|
|
},
|
|
showIcon: function () {
|
|
window.swan && cc.loader.load(window.GameConfig.iconList[this.showID], function (e, o) {
|
|
e || (this.showPic.spriteFrame = new cc.SpriteFrame(o));
|
|
}.bind(this));
|
|
},
|
|
touchIconCallBack: function () {
|
|
if (window.tt) {
|
|
"ios" === window.tt.getSystemInfoSync().platform && window.tt.showToast({
|
|
title: " iOS不支持此功能"
|
|
});
|
|
window.tt.showMoreGamesModal({
|
|
appLaunchOptions: [{
|
|
appId: "",
|
|
query: "foo=bar&baz=qux",
|
|
extraData: {}
|
|
}],
|
|
success: function (e) {},
|
|
fail: function (e) {}
|
|
});
|
|
} else if (window.qg) {
|
|
window.qg.navigateToMiniGame({
|
|
pkgName: window.GameConfig.packageList[this.showID],
|
|
path: "?page=pageB",
|
|
extraData: {
|
|
from: "脑洞侦探"
|
|
},
|
|
success: function () {},
|
|
fail: function (e) {
|
|
console.log(JSON.stringify(e));
|
|
}
|
|
});
|
|
} else {
|
|
window.swan && window.swan.navigateToMiniProgram({
|
|
appKey: window.GameConfig.packageList[this.showID],
|
|
path: "/path/page/0",
|
|
extraData: {
|
|
from: "脑洞侦探"
|
|
},
|
|
success: function () {},
|
|
fail: function (e) {
|
|
console.log(JSON.stringify(e));
|
|
}
|
|
});
|
|
}
|
|
},
|
|
update: function (e) {
|
|
this.changeTime += e;
|
|
if (this.changeTime >= 3) {
|
|
this.changeTime = 0;
|
|
this.showID += 1;
|
|
this.showID >= window.GameConfig.iconList.length && (this.showID = 0);
|
|
this.showIcon();
|
|
}
|
|
}
|
|
}); |