mirror of
https://github.com/ChuXunYu/warOfCoins.git
synced 2026-01-31 00:21:26 +00:00
199 lines
7.7 KiB
JavaScript
199 lines
7.7 KiB
JavaScript
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
crisisEvents: []
|
|
},
|
|
|
|
onLoad: function() {
|
|
const that = this;
|
|
// 加载危机事件数据
|
|
wx.getFileSystemManager().readFile({
|
|
filePath: `${wx.env.USER_DATA_PATH}/data/crisisEvents.json`,
|
|
encoding: 'utf-8',
|
|
success: res => {
|
|
try {
|
|
const data = JSON.parse(res.data);
|
|
that.setData({
|
|
crisisEvents: data
|
|
});
|
|
} catch (e) {
|
|
console.error('解析危机事件数据失败', e);
|
|
// 如果读取本地失败,则使用示例数据
|
|
that.setData({
|
|
crisisEvents: [
|
|
{
|
|
id: 'fake_currency_1',
|
|
type: 'fakeCurrency',
|
|
title: '伪币冲击:初级',
|
|
description: '敌方在根据地周边地区投放少量伪造边币,市场上开始出现伪币流通现象',
|
|
level: 1,
|
|
impact: '市场信心轻微下降,边币贬值风险较小'
|
|
},
|
|
{
|
|
id: 'fake_currency_2',
|
|
type: 'fakeCurrency',
|
|
title: '伪币冲击:中级',
|
|
description: '敌方增加伪造边币投放力度,市场上伪币数量明显增加,造成一定混乱',
|
|
level: 2,
|
|
impact: '市场交易受阻,边币信任度下降,贸易活动减少'
|
|
},
|
|
{
|
|
id: 'fake_currency_3',
|
|
type: 'fakeCurrency',
|
|
title: '伪币冲击:高级',
|
|
description: '敌方大规模投放高仿真度伪币,市场已难以分辨真伪,货币混乱严重',
|
|
level: 3,
|
|
impact: '边币严重贬值,市场恐慌,经济活动受到重创'
|
|
},
|
|
{
|
|
id: 'shortage_1',
|
|
type: 'shortage',
|
|
title: '物资短缺:初级',
|
|
description: '部分生活必需品供应不足,市场价格开始上涨',
|
|
level: 1,
|
|
impact: '物价小幅上涨,边币购买力略有下降'
|
|
},
|
|
{
|
|
id: 'shortage_2',
|
|
type: 'shortage',
|
|
title: '物资短缺:中级',
|
|
description: '多种生活必需品严重短缺,黑市交易开始活跃',
|
|
level: 2,
|
|
impact: '物价大幅上涨,边币购买力明显下降,民众不满情绪增加'
|
|
},
|
|
{
|
|
id: 'shortage_3',
|
|
type: 'shortage',
|
|
title: '物资短缺:高级',
|
|
description: '根据地被敌军封锁,几乎所有物资都极度匮乏',
|
|
level: 3,
|
|
impact: '物价飞涨,边币几近崩溃,根据地经济面临瘫痪'
|
|
},
|
|
{
|
|
id: 'exchange_1',
|
|
type: 'exchange',
|
|
title: '汇率波动:初级',
|
|
description: '边币对法币汇率小幅波动,交易活动受到轻微影响',
|
|
level: 1,
|
|
impact: '边币信心略有动摇,边区与外界贸易略受影响'
|
|
},
|
|
{
|
|
id: 'exchange_2',
|
|
type: 'exchange',
|
|
title: '汇率波动:中级',
|
|
description: '边币对法币汇率大幅下跌,边区与外界贸易受阻',
|
|
level: 2,
|
|
impact: '边币信心受挫,边区经济受到较大冲击'
|
|
},
|
|
{
|
|
id: 'exchange_3',
|
|
type: 'exchange',
|
|
title: '汇率波动:高级',
|
|
description: '边币对法币汇率暴跌,边区与外界经济联系几乎中断',
|
|
level: 3,
|
|
impact: '边币信心崩溃,边区经济面临严重危机'
|
|
}
|
|
]
|
|
});
|
|
}
|
|
},
|
|
fail: () => {
|
|
console.log('读取本地文件失败,使用示例数据');
|
|
// 使用示例数据
|
|
that.setData({
|
|
crisisEvents: [
|
|
{
|
|
id: 'fake_currency_1',
|
|
type: 'fakeCurrency',
|
|
title: '伪币冲击:初级',
|
|
description: '敌方在根据地周边地区投放少量伪造边币,市场上开始出现伪币流通现象',
|
|
level: 1,
|
|
impact: '市场信心轻微下降,边币贬值风险较小'
|
|
},
|
|
{
|
|
id: 'fake_currency_2',
|
|
type: 'fakeCurrency',
|
|
title: '伪币冲击:中级',
|
|
description: '敌方增加伪造边币投放力度,市场上伪币数量明显增加,造成一定混乱',
|
|
level: 2,
|
|
impact: '市场交易受阻,边币信任度下降,贸易活动减少'
|
|
},
|
|
{
|
|
id: 'fake_currency_3',
|
|
type: 'fakeCurrency',
|
|
title: '伪币冲击:高级',
|
|
description: '敌方大规模投放高仿真度伪币,市场已难以分辨真伪,货币混乱严重',
|
|
level: 3,
|
|
impact: '边币严重贬值,市场恐慌,经济活动受到重创'
|
|
},
|
|
{
|
|
id: 'shortage_1',
|
|
type: 'shortage',
|
|
title: '物资短缺:初级',
|
|
description: '部分生活必需品供应不足,市场价格开始上涨',
|
|
level: 1,
|
|
impact: '物价小幅上涨,边币购买力略有下降'
|
|
},
|
|
{
|
|
id: 'shortage_2',
|
|
type: 'shortage',
|
|
title: '物资短缺:中级',
|
|
description: '多种生活必需品严重短缺,黑市交易开始活跃',
|
|
level: 2,
|
|
impact: '物价大幅上涨,边币购买力明显下降,民众不满情绪增加'
|
|
},
|
|
{
|
|
id: 'shortage_3',
|
|
type: 'shortage',
|
|
title: '物资短缺:高级',
|
|
description: '根据地被敌军封锁,几乎所有物资都极度匮乏',
|
|
level: 3,
|
|
impact: '物价飞涨,边币几近崩溃,根据地经济面临瘫痪'
|
|
},
|
|
{
|
|
id: 'exchange_1',
|
|
type: 'exchange',
|
|
title: '汇率波动:初级',
|
|
description: '边币对法币汇率小幅波动,交易活动受到轻微影响',
|
|
level: 1,
|
|
impact: '边币信心略有动摇,边区与外界贸易略受影响'
|
|
},
|
|
{
|
|
id: 'exchange_2',
|
|
type: 'exchange',
|
|
title: '汇率波动:中级',
|
|
description: '边币对法币汇率大幅下跌,边区与外界贸易受阻',
|
|
level: 2,
|
|
impact: '边币信心受挫,边区经济受到较大冲击'
|
|
},
|
|
{
|
|
id: 'exchange_3',
|
|
type: 'exchange',
|
|
title: '汇率波动:高级',
|
|
description: '边币对法币汇率暴跌,边区与外界经济联系几乎中断',
|
|
level: 3,
|
|
impact: '边币信心崩溃,边区经济面临严重危机'
|
|
}
|
|
]
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
handleEventSelect: function(e) {
|
|
const eventId = e.currentTarget.dataset.id;
|
|
const selectedEvent = this.data.crisisEvents.find(item => item.id === eventId);
|
|
|
|
if (selectedEvent) {
|
|
// 将选中事件保存到全局数据
|
|
const app = getApp();
|
|
app.globalData.selectedEvent = selectedEvent;
|
|
|
|
// 跳转到策略选择页面
|
|
wx.navigateTo({
|
|
url: '/pages/strategy/strategy'
|
|
});
|
|
}
|
|
}
|
|
})
|