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' });
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "每日运势",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<view class="container">
|
||||
<!-- 无八字提示 -->
|
||||
<view class="card text-center" wx:if="{{!hasBazi}}">
|
||||
<text class="text-lg text-muted">请先排八字以查看每日运势</text>
|
||||
<view class="btn-primary mt-2" bindtap="goBazi">去排八字</view>
|
||||
</view>
|
||||
|
||||
<!-- 运势内容 -->
|
||||
<block wx:if="{{hasBazi && fortune}}">
|
||||
<!-- 总分卡片 -->
|
||||
<view class="card score-card">
|
||||
<view class="text-center">
|
||||
<text class="score-value">{{fortune.overallScore}}</text>
|
||||
<text class="score-level">{{scoreLevelText}}</text>
|
||||
</view>
|
||||
<view class="text-sm text-muted text-center mt-1">{{fortune.date}} {{fortune.lunarDate}}</view>
|
||||
</view>
|
||||
|
||||
<!-- 幸运元素 -->
|
||||
<view class="card">
|
||||
<view class="section-title">幸运元素</view>
|
||||
<view class="grid grid-cols-2 gap-2">
|
||||
<view class="info-item">
|
||||
<text class="text-xs text-muted">幸运色</text>
|
||||
<text class="text-base font-medium">{{fortune.luckyMeta.colors.join('、')}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="text-xs text-muted">幸运数字</text>
|
||||
<text class="text-base font-medium">{{fortune.luckyMeta.numbers.join('、')}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="text-xs text-muted">幸运方位</text>
|
||||
<text class="text-base font-medium">{{fortune.luckyMeta.direction}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="text-xs text-muted">五行</text>
|
||||
<text class="text-base font-medium">{{fortune.luckyMeta.element}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 四柱关系 -->
|
||||
<view class="card">
|
||||
<view class="section-title">四柱与今日关系</view>
|
||||
<view class="relation-list">
|
||||
<view class="relation-item" wx:for="{{fortune.pillarRelationships}}" wx:key="pillar">
|
||||
<view class="flex justify-between items-center">
|
||||
<text class="font-medium">{{item.pillarLabel}}</text>
|
||||
<text class="text-sm {{item.score >= 0 ? 'text-lucky' : 'text-unlucky'}}">{{item.score > 0 ? '+' : ''}}{{item.score}}</text>
|
||||
</view>
|
||||
<view class="text-sm text-muted mt-1">
|
||||
{{item.userGanzhi}} vs {{item.dayGanzhi}}
|
||||
</view>
|
||||
<view class="flex flex-wrap gap-1 mt-1">
|
||||
<text class="badge badge-outline" wx:if="{{item.stemTenStar}}">{{item.stemTenStar}}</text>
|
||||
<text class="badge badge-lucky" wx:if="{{item.stemCombine}}">天干合</text>
|
||||
<text class="badge badge-unlucky" wx:if="{{item.stemOpposite}}">天干冲</text>
|
||||
<text class="badge badge-lucky" wx:if="{{item.branchCombine}}">地支合</text>
|
||||
<text class="badge badge-unlucky" wx:if="{{item.branchOpposite}}">地支冲</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 建议 -->
|
||||
<view class="card">
|
||||
<view class="section-title">今日建议</view>
|
||||
<view class="suggestion-list">
|
||||
<view class="suggestion-item" wx:for="{{fortune.suggestions}}" wx:key="*this">
|
||||
<text class="text-base">{{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分项得分 -->
|
||||
<view class="card">
|
||||
<view class="section-title">分项运势</view>
|
||||
<view class="grid grid-cols-2 gap-2">
|
||||
<view class="info-item text-center">
|
||||
<text class="text-xs text-muted">爱情</text>
|
||||
<text class="text-xl font-bold {{fortune.categoryScores.love >= 0 ? 'text-lucky' : 'text-unlucky'}}">{{fortune.categoryScores.love}}</text>
|
||||
</view>
|
||||
<view class="info-item text-center">
|
||||
<text class="text-xs text-muted">事业</text>
|
||||
<text class="text-xl font-bold {{fortune.categoryScores.career >= 0 ? 'text-lucky' : 'text-unlucky'}}">{{fortune.categoryScores.career}}</text>
|
||||
</view>
|
||||
<view class="info-item text-center">
|
||||
<text class="text-xs text-muted">财运</text>
|
||||
<text class="text-xl font-bold {{fortune.categoryScores.wealth >= 0 ? 'text-lucky' : 'text-unlucky'}}">{{fortune.categoryScores.wealth}}</text>
|
||||
</view>
|
||||
<view class="info-item text-center">
|
||||
<text class="text-xs text-muted">健康</text>
|
||||
<text class="text-xl font-bold {{fortune.categoryScores.health >= 0 ? 'text-lucky' : 'text-unlucky'}}">{{fortune.categoryScores.health}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -0,0 +1,47 @@
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.score-card {
|
||||
background: linear-gradient(135deg, #C41E3A 0%, #8B1A2B 100%);
|
||||
color: #FFFFFF;
|
||||
border: none;
|
||||
padding: 40rpx 24rpx;
|
||||
}
|
||||
|
||||
.score-value {
|
||||
font-size: 80rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.score-level {
|
||||
font-size: 32rpx;
|
||||
margin-left: 16rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 16rpx;
|
||||
color: #C41E3A;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
padding: 16rpx;
|
||||
background: #FFFBF5;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.relation-item {
|
||||
padding: 16rpx;
|
||||
border-bottom: 1rpx solid #E8D5C4;
|
||||
}
|
||||
|
||||
.relation-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.suggestion-item {
|
||||
padding: 12rpx 0;
|
||||
}
|
||||
Reference in New Issue
Block a user