58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
cc.Class({
|
|
extends: cc.Component,
|
|
properties: {
|
|
userkuang: cc.Node,
|
|
erciTanchuang: cc.Node,
|
|
onButtonJieMian: cc.Node
|
|
},
|
|
start: function () {
|
|
if (window.qg || window.qq) {
|
|
this.jiance();
|
|
} else {
|
|
this.node.active = false;
|
|
}
|
|
},
|
|
jiance: function () {
|
|
var e = cc.sys.localStorage.getItem("user");
|
|
console.log("item" + e);
|
|
if (undefined == e || null == e || 0 == e.length) {
|
|
console.log("新用户");
|
|
this.node.getChildByName("item").active = true;
|
|
} else {
|
|
console.log("老用户");
|
|
this.node.getChildByName("item").active = false;
|
|
}
|
|
},
|
|
onShow: function () {
|
|
this.node.getChildByName("item").active = true;
|
|
this.onButtonJieMian.getChildByName("btn_ty").active = false;
|
|
this.onButtonJieMian.getChildByName("btn_bty").active = false;
|
|
this.onButtonJieMian.getChildByName("btn_Close").active = true;
|
|
},
|
|
onBtnClickEvent: function (e) {
|
|
var o = e.target.name;
|
|
console.log("点击了");
|
|
switch (o) {
|
|
case "btn_ty":
|
|
cc.sys.localStorage.setItem("user", 1);
|
|
this.node.getChildByName("item").active = false;
|
|
break;
|
|
case "btn_bty2":
|
|
cc.game.end();
|
|
this.node.getChildByName("item").active = false;
|
|
break;
|
|
case "btn_bty":
|
|
if (window.qq) {
|
|
qq.exitMiniProgram();
|
|
} else {
|
|
this.erciTanchuang.active = true;
|
|
}
|
|
break;
|
|
case "btn_Close":
|
|
this.node.getChildByName("item").active = false;
|
|
break;
|
|
case "btn_queding":
|
|
this.erciTanchuang.active = false;
|
|
}
|
|
}
|
|
}); |