feat: 祈福小助手万年历小程序第一期
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
const { calculateDailyFortune } = require('../../utils/core/index.js');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
hasBazi: false,
|
||||
fortune: null,
|
||||
scoreLevelText: ''
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadFortune();
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.loadFortune();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
loadFortune() {
|
||||
const bazi = wx.getStorageSync('lunar-user-bazi');
|
||||
if (!bazi) {
|
||||
this.setData({ hasBazi: false, fortune: null });
|
||||
return;
|
||||
}
|
||||
|
||||
const today = new Date();
|
||||
const fortune = calculateDailyFortune(bazi.eightChar, today);
|
||||
|
||||
const levelMap = {
|
||||
great: '大吉',
|
||||
good: '吉',
|
||||
fair: '平',
|
||||
poor: '凶',
|
||||
bad: '大凶'
|
||||
};
|
||||
|
||||
this.setData({
|
||||
hasBazi: true,
|
||||
fortune,
|
||||
scoreLevelText: levelMap[fortune.scoreLevel] || '平'
|
||||
});
|
||||
},
|
||||
|
||||
goBazi() {
|
||||
wx.switchTab({ url: '/pages/bazi/bazi' });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user