| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <view class="action-section">
- <!-- 今日任务 -->
- <view class="section-card" v-if="todayTasks.length > 0">
- <view class="section-header">
- <text class="section-title">✅ 今日任务</text>
- </view>
- <view class="task-item" v-for="task in todayTasks" :key="task.id" @click="goTaskDetail(task)">
- <view class="task-status" :class="task.status === 'completed' ? 'task-done' : 'task-pending'"></view>
- <text class="task-name">{{ task.title || task.name }}</text>
- <text class="task-points">{{ task.points || task.coin || 0 }}分</text>
- </view>
- </view>
- <view class="section-card" v-else-if="!loading && memberId">
- <view class="empty-state">
- <text class="empty-text">今日暂无任务</text>
- <text class="empty-sub">去「行」维度页布置新任务吧</text>
- </view>
- </view>
- <!-- 打卡统计 -->
- <view class="section-card" v-if="checkinStats">
- <view class="section-header">
- <text class="section-title">📊 打卡统计</text>
- </view>
- <view class="stats-row">
- <view class="stat-item">
- <text class="stat-value">{{ checkinStats.totalDays || 0 }}</text>
- <text class="stat-label">累计天数</text>
- </view>
- <view class="stat-item">
- <text class="stat-value">{{ checkinStats.currentStreak || 0 }}</text>
- <text class="stat-label">连续打卡</text>
- </view>
- <view class="stat-item">
- <text class="stat-value">{{ checkinStats.thisMonth || 0 }}</text>
- <text class="stat-label">本月次数</text>
- </view>
- </view>
- </view>
- <!-- 近期活动 -->
- <view class="section-card" v-if="activityList.length > 0">
- <view class="section-header">
- <text class="section-title">🎪 近期活动</text>
- </view>
- <view class="activity-item" v-for="act in activityList" :key="act.id" @click="goActivityDetail(act)">
- <text class="activity-name">{{ act.title || act.name }}</text>
- <text class="activity-date">{{ formatDate(act.startTime || act.activityDate) }}</text>
- </view>
- </view>
- <!-- 非孩子成员提示 -->
- <view class="section-card" v-if="!memberId && !loading">
- <view class="empty-state">
- <text class="empty-text">该成员暂无行动数据</text>
- </view>
- </view>
- <!-- 加载中 -->
- <view class="loading" v-if="loading">加载中...</view>
- </view>
- </template>
- <script>
- import { getTodayTasksByCategory, getCheckinStats, getActivityList } from '../../utils/api.js'
- import { parseDate } from '../../utils/format.js'
- export default {
- props: {
- memberId: {
- type: [Number, String],
- default: null
- },
- memberType: {
- type: String,
- default: ''
- },
- memberInfo: {
- type: Object,
- default: null
- },
- sandboxData: {
- type: Object,
- default: null
- },
- energyMap: {
- type: Object,
- default: null
- }
- },
- data: function() {
- return {
- loading: true,
- todayTasks: [],
- checkinStats: null,
- activityList: []
- }
- },
- mounted: function() {
- if (this.memberId) {
- this.loadData()
- } else {
- this.loading = false
- }
- },
- methods: {
- loadData: function() {
- var self = this
- getTodayTasksByCategory(this.memberId, 'action').then(function(res) {
- if (res.code === 200 && res.data) {
- self.todayTasks = Array.isArray(res.data) ? res.data : (res.data.records || [])
- }
- }).catch(function(e) {
- console.log('加载今日任务失败', e)
- })
-
- getCheckinStats({ memberId: this.memberId }).then(function(res) {
- if (res.code === 200 && res.data) {
- self.checkinStats = res.data
- }
- }).catch(function(e) {
- console.log('加载打卡统计失败', e)
- })
-
- getActivityList({ page: 1, size: 3 }).then(function(res) {
- if (res.code === 200 && res.data) {
- self.activityList = Array.isArray(res.data) ? res.data : (res.data.records || [])
- }
- }).catch(function(e) {
- console.log('加载活动列表失败', e)
- })
-
- this.loading = false
- },
- formatDate: function(dateStr) {
- if (!dateStr) return ''
- var d = parseDate(dateStr)
- if (!d) return ''
- return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
- },
- goTaskDetail: function(task) {
- // TODO: task-detail 页面尚未实现,暂不跳转
- console.log('task-detail not implemented', task)
- },
- goActivityDetail: function(act) {
- if (!act || !act.id) return
- uni.navigateTo({
- url: '/pages/activity/activity-detail/activity-detail?id=' + act.id
- })
- }
- }
- }
- </script>
- <style scoped>
- .action-section {}
- .section-card {
- background: #fff;
- border-radius: 24rpx;
- padding: 24rpx;
- margin-bottom: 20rpx;
- box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
- }
- .section-header {
- margin-bottom: 16rpx;
- }
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .task-item {
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 14rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .task-status {
- width: 16rpx;
- height: 16rpx;
- border-radius: 50%;
- margin-right: 16rpx;
- }
- .task-done {
- background: #10B981;
- }
- .task-pending {
- background: #F59E0B;
- }
- .task-name {
- flex: 1;
- font-size: 28rpx;
- color: #333;
- }
- .task-points {
- font-size: 24rpx;
- color: #10B981;
- }
- .stats-row {
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- padding: 16rpx 0;
- }
- .stat-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .stat-value {
- font-size: 40rpx;
- font-weight: bold;
- color: #10B981;
- }
- .stat-label {
- font-size: 24rpx;
- color: #999;
- margin-top: 4rpx;
- }
- .activity-item {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- padding: 12rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .activity-name {
- font-size: 26rpx;
- color: #333;
- flex: 1;
- }
- .activity-date {
- font-size: 22rpx;
- color: #999;
- }
- .empty-state {
- padding: 30rpx 0;
- text-align: center;
- }
- .empty-text {
- font-size: 28rpx;
- color: #999;
- }
- .empty-sub {
- font-size: 24rpx;
- color: #ccc;
- margin-top: 8rpx;
- }
- .loading {
- text-align: center;
- padding: 40rpx;
- color: #999;
- }
- </style>
|