import { ui } from "./../../ui/layaMaxUI"
import Global from "../Global"
import Const from "../Const"
import GameView from "./GameView"
export default class HomeView extends ui.HomeViewUI {
isGameDataLoaded
navigator
guide
settingIconRolling
static instance
constructor() {
if(Laya.Browser.onMiniGame)
{
Laya.Browser.window.wx.showShareMenu();
Laya.Browser.window.wx.onShareAppMessage(function(){
return{title:"听说这游戏只有不到1%的人能通过第一关!",imageUrl:"res/texture/home/we.jpeg"}
});
}
super()
var t = this
return t.isGameDataLoaded = !1, t.guide = !1, t.settingIconRolling = !1, console.log("HomeView constructor()"),
HomeView.instance = t, GameView.openInstance(), t;
}
static openInstance() {
this.instance ? this.instance.onOpened() : Laya.Scene.open(Const.URL_HomeView, !1);
}
onOpened() {
console.log("HomeView onOpened()")
if (this.isGameDataLoaded) {
if (GameView.instance) {
GameView.instance.showDiamond()
//GameView.instance.hideNavigator()'
}
// // 广告
// n.randomShowBanner(!0)
//互推导航
// if (Global.config.allow_navigator) {
// if (this.navigator) {
// this.navigator.loadHomeIconInfoList();
// }
// else {
// this.navigator = new u.default(r.default)
// this.navigator.createHomeIcons(this.homeIconBox, this, ["home_icon_1", "home_icon_2", "home_icon_3", "home_icon_4", "home_icon_5", "home_icon_6", "home_icon_7", "home_icon_8", "home_icon_9", "home_icon_10"])
// this.navigator.createDrawer(this.drawerBox, "game_drawer")
// this.navigator.createMoreGame(this.moreGameBox, this.moreGameOpenButtonBox, "game_more")
// }
}
this.visible = !0;
}
onEnable()
{
console.log("HomeView onEnable()")
this.bindButtons()
this.versionLabel.changeText("v" + Const.VERSION)
if (Laya.Browser.onMiniGame) {
// this.initWeixin();
//Laya.Stat.show();
this.onGameDataLoaded();
} else {
//Laya.Stat.show();
this.onGameDataLoaded();
}
}
bindButtons() {
var e = this;
// 开始游戏
this.startButton.on(Laya.Event.CLICK, this, function() {
if (GameView.instance) {
// Laya.Browser.onMiniGame && r.default.traceEvent("Click_Startgame")
e.hide()
GameView.openInstance()
GameView.instance.loadCurrentLevelMission()
}
}
)
// this.settingButton.on(Laya.Event.CLICK, this, function() {
// e.vibrateOff.visible || e.vibrateOn.visible ? e.hideSettings() : e.showSettings();
// })
// this.soundOn.on(Laya.Event.CLICK, this, function() {
// e.soundOn.visible = !1, e.soundOff.visible = !0, l.default.gameData.soundEnabled = !1,
// e.updateGameData();
// })
// this.soundOff.on(Laya.Event.CLICK, this, function() {
// e.soundOn.visible = !0, e.soundOff.visible = !1, l.default.gameData.soundEnabled = !0,
// e.updateGameData();
// })
// this.vibrateOn.on(Laya.Event.CLICK, this, function() {
// e.vibrateOn.visible = !1, e.vibrateOff.visible = !0, l.default.gameData.vibrateEnable = !1,
// e.updateGameData();
// })
// this.vibrateOff.on(Laya.Event.CLICK, this, function() {
// e.vibrateOn.visible = !0, e.vibrateOff.visible = !1, l.default.gameData.vibrateEnable = !0,
// e.updateGameData();
// });
}
hide() {
// n.hideCurrentBanner()
this.visible = !1
}
// // 微信分享设置
// initWeixin() {
// s.default.showShareMenu({
// withShareTicket: !0
// })
// s.default.onShareAppMessage(function() {
// var e = r.default.createShareOptions({
// pos: "ShareAppButton"
// });
// return {
// title: e.title,
// imageUrl: e.imageUrl,
// query: e.query
// };
// })
// r.default.init({
// host: "ws.lesscool.cn",
// version: o.VERSION,
// appid: 1078,
// secret: "e7abfe9df676d9d377ae2ee7e907516a",
// share: {
// title: "全民欢乐,天天游戏!",
// image: "http://oss.lesscool.cn/fcdh/96d172496dbafa4ab9c8335a7133476c.png"
// }
// })
// this.loginWs();
// }
// // 微信登录
// loginWs() {
// r.default.traceEvent("WS_LOGINING")
// s.default.showLoading({
// title: "登录中",
// mask: !0
// })
// r.default.onLoginComplete(this.onLoginComplete.bind(this))
// r.default.login();
// }
onGameDataLoaded() {
console.log("onGameDataLoaded", Global.gameData)
this.isGameDataLoaded = !0
this.onOpened()
// c.default.instance && c.default.instance.loadCurrentLevelMission()
// 广告
// n.loadInterAd()
this.startButton.visible = !0;
}
updateGameData(e = !1) {
Global.gameData.updateTimestamp = Date.now()
e && console.log("updateGameData", Global.gameData)
// Laya.Browser.onMiniGame && r.default.setAllData(l.default.gameData, e);
}
}