gratitude.durian.xpcool.com/wechat-miniprogram/pages/index/index.js
2026-08-14 18:01:45 +08:00

64 lines
1.0 KiB
JavaScript

// pages/index/index.js - 主菜单页面
const app = getApp();
Page({
data: {
maxScore: 0,
maxCombo: 0,
currentLevel: 1,
hasSaveData: false
},
onLoad() {
// 加载存档数据
this.loadSaveData();
},
onShow() {
// 每次显示页面时刷新数据
this.loadSaveData();
},
/**
* 加载存档数据
*/
loadSaveData() {
const gameData = app.gameData;
this.setData({
maxScore: gameData.totalScore || 0,
maxCombo: gameData.maxCombo || 0,
currentLevel: gameData.currentLevel || 1,
hasSaveData: gameData.totalScore > 0 || gameData.currentLevel > 1
});
},
/**
* 开始新游戏
*/
startGame() {
wx.navigateTo({
url: '/pages/game/index'
});
},
/**
* 继续游戏
*/
continueGame() {
wx.navigateTo({
url: '/pages/game/index'
});
},
/**
* 打开图鉴(待实现)
*/
openCollection() {
wx.showToast({
title: '图鉴功能开发中',
icon: 'none'
});
}
});