| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- <template>
- <view class="container" :style="{ '--font-scale': fontScale }">
- <!-- 加载状态 -->
- <view class="loading-container" v-if="loading">
- <text class="loading-text">加载中...</text>
- </view>
- <template v-if="!loading">
- <!-- 儿童信息卡片 -->
- <view class="child-info-card">
- <view class="child-info-avatar" :class="'child-avatar-color-' + (memberId % 6)">
- <text class="child-avatar-text">{{ childName ? childName[0] : '?' }}</text>
- </view>
- <view class="child-info-body">
- <text class="child-info-name">{{ childName }}</text>
- <view class="child-info-stats">
- <text class="stat-item stat-points">⭐ {{ childInfo.totalPoints || 0 }} 分</text>
- <text class="stat-item stat-streak" v-if="childInfo.streakDays > 0">🔥 连续 {{ childInfo.streakDays }} 天</text>
- </view>
- <view class="child-info-progress" v-if="todayTasks.length > 0">
- <text class="progress-label">
- 今日任务 {{ completedCount }}/{{ todayTasks.length }} 完成
- </text>
- <view class="progress-bar-bg">
- <view class="progress-bar-fill" :style="{ width: taskProgressPercent + '%' }"></view>
- </view>
- </view>
- </view>
- </view>
- <!-- 操作区 -->
- <view class="action-section">
- <view class="section-title">快捷操作</view>
- <view class="action-grid">
- <view class="action-btn" @click="goToCreateTask">
- <view class="action-btn-icon create-icon">📝</view>
- <text class="action-btn-label">创建任务</text>
- </view>
- <view class="action-btn" @click="goToWishReview">
- <view class="action-btn-icon wish-icon">💝</view>
- <text class="action-btn-label">心愿审核</text>
- <text class="action-btn-badge" v-if="pendingWishCount > 0">{{ pendingWishCount }}</text>
- </view>
- <view class="action-btn" @click="goToGrowth">
- <view class="action-btn-icon growth-icon">📊</view>
- <text class="action-btn-label">成长记录</text>
- </view>
- <view class="action-btn" @click="goToCompletionStats">
- <view class="action-btn-icon stats-icon">📈</view>
- <text class="action-btn-label">完成分析</text>
- </view>
- </view>
- </view>
- <!-- 今日任务 -->
- <view class="tasks-section">
- <view class="section-title">今日任务</view>
- <view class="tasks-card" v-if="todayTasks.length > 0">
- <view
- class="task-item"
- v-for="task in todayTasks"
- :key="task.id"
- >
- <text class="task-status-icon">{{ task.status === 'completed' ? '✅' : '⏳' }}</text>
- <view class="task-info">
- <text class="task-title">{{ task.title }}</text>
- <text class="task-points" v-if="task.points">+{{ task.points }}CF</text>
- </view>
- </view>
- </view>
- <view class="empty-card" v-else>
- <text class="empty-icon">🎉</text>
- <text class="empty-text">今日暂无任务</text>
- </view>
- </view>
- <!-- 待处理 -->
- <view class="pending-section">
- <view class="section-title">待处理</view>
- <view class="pending-card" v-if="pendingReviewTasks.length > 0 || pendingWishes.length > 0">
- <view
- class="pending-item"
- v-for="task in pendingReviewTasks"
- :key="task.id"
- >
- <text class="pending-icon">📋</text>
- <text class="pending-desc">{{ task.title }}</text>
- <text class="pending-tag tag-review">待审核</text>
- </view>
- <view
- class="pending-item"
- v-for="wish in pendingWishes"
- :key="wish.id"
- >
- <text class="pending-icon">💝</text>
- <text class="pending-desc">{{ wish.title }}</text>
- <text class="pending-tag tag-wish">{{ wish.status === 'draft' ? '待定价' : '待审批' }}</text>
- </view>
- </view>
- <view class="empty-card" v-else>
- <text class="empty-icon">✅</text>
- <text class="empty-text">全部已处理</text>
- </view>
- </view>
- </template>
- </view>
- </template>
- <script>
- import { getChildren, getTodayTasks, getPendingReviewTasks, getPendingWishes } from '../../utils/api.js'
- import fontScaleMixin from '@/mixins/font-scale.js'
- export default {
- mixins: [fontScaleMixin],
- data() {
- return {
- loading: true,
- memberId: '',
- childName: '',
- childInfo: {},
- todayTasks: [],
- pendingReviewTasks: [],
- pendingWishes: []
- }
- },
- computed: {
- completedCount() {
- return this.todayTasks.filter(t => t.status === 'completed').length
- },
- taskProgressPercent() {
- if (this.todayTasks.length === 0) return 0
- return Math.round((this.completedCount / this.todayTasks.length) * 100)
- },
- pendingWishCount() {
- return this.pendingWishes.length
- }
- },
- onLoad(options) {
- this.memberId = options.memberId || ''
- this.childName = options.childName ? decodeURIComponent(options.childName) : '成员'
- this.loadChildData()
- },
- methods: {
- async loadChildData() {
- this.loading = true
- try {
- // 获取儿童信息
- const childrenRes = await getChildren()
- const children = childrenRes.data || []
- const matched = children.find(c => String(c.id) === String(this.memberId))
- if (matched) {
- this.childInfo = matched
- if (!this.childName || this.childName === '成员') {
- this.childName = matched.nickname || matched.name || '成员'
- }
- }
- // 并行加载今日任务和待处理
- const [tasksRes, reviewRes, wishRes] = await Promise.all([
- getTodayTasks(this.memberId),
- getPendingReviewTasks(),
- getPendingWishes()
- ])
- this.todayTasks = tasksRes.data || []
- // 过滤属于该儿童的待审核任务
- const allReviewTasks = reviewRes.data || []
- this.pendingReviewTasks = allReviewTasks.filter(t => {
- return String(t.memberId || t.assigneeId) === String(this.memberId)
- }).slice(0, 5)
- // 过滤属于该儿童的待处理心愿
- const allWishes = wishRes.data || []
- this.pendingWishes = allWishes.filter(w => String(w.memberId) === String(this.memberId)).slice(0, 5)
- } catch (e) {
- console.error('加载成员详情失败', e)
- uni.showToast({ title: '加载失败', icon: 'none' })
- } finally {
- this.loading = false
- }
- },
- goToCreateTask() {
- uni.navigateTo({
- url: '/pages/tasks/create-task?memberId=' + this.memberId
- })
- },
- goToWishReview() {
- uni.navigateTo({
- url: '/pages/parent/wishes/index?memberId=' + this.memberId
- })
- },
- goToGrowth() {
- uni.switchTab({ url: '/pages/growth-main/index' })
- },
- goToCompletionStats() {
- uni.navigateTo({
- url: '/pages/stats/completion-rate?memberId=' + this.memberId
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- // ===== 成员详情页专属色阶(flat 图表青绿 + 米白卡片;单页专用,约定见 uni.scss §14)=====
- $flat-bg: $flat-bg; // 页面米白底
- $flat-card: $flat-card; // 暖白卡片底
- $flat-line: $flat-line; // 暖分隔线
- $flat-ink: $flat-ink; // 主文字(深灰)
- $flat-muted: $flat-muted; // 次要文字(灰)
- $flat-muted-2: $flat-muted-2; // 辅助文字(中灰)
- $c-cd-orange: #FF7A2E; // 橙渐变终档
- $flat-teal: $flat-teal; // 青绿主色
- $flat-teal-deep: $flat-teal-deep; // 青绿深档
- $flat-green: $flat-green; // 绿浅档
- $flat-green-deep: $flat-green-deep; // 绿深档
- $c-cd-pink: #F093FB; // 粉紫渐变起
- $c-cd-red: #F5576C; // 红粉渐变终
- $c-cd-danger-bg: $status-danger-tint-5; // 警示浅红底
- .container {
- padding: $uni-space-page;
- background: $flat-bg;
- min-height: 100vh;
- }
- .loading-container {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 200rpx 0;
- }
- .loading-text {
- font-size: calc(28rpx * var(--font-scale, 1));
- color: $flat-muted;
- }
- /* 儿童信息卡片 */
- .child-info-card {
- display: flex;
- align-items: flex-start;
- background: $app-surface;
- border-radius: 24rpx;
- padding: 24rpx;
- margin-bottom: 32rpx;
- box-shadow: 0 4px 20px rgba(255, 140, 66, 0.08);
- }
- .child-info-avatar {
- width: 72rpx;
- height: 72rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- margin-right: 16rpx;
- }
- .child-avatar-text {
- font-size: calc(32rpx * var(--font-scale, 1));
- font-weight: 600;
- color: $app-surface;
- }
- .child-avatar-color-0 { background: linear-gradient(135deg, $dim-body, $c-cd-orange); }
- .child-avatar-color-1 { background: linear-gradient(135deg, $accent-indigo, $accent-indigo-deep); }
- .child-avatar-color-2 { background: linear-gradient(135deg, $flat-teal, $flat-teal-deep); }
- .child-avatar-color-3 { background: linear-gradient(135deg, $brand-primary, $brand-primary-light); }
- .child-avatar-color-4 { background: linear-gradient(135deg, $flat-green, $flat-green-deep); }
- .child-avatar-color-5 { background: linear-gradient(135deg, $c-cd-pink, $c-cd-red); }
- .child-info-body {
- flex: 1;
- min-width: 0;
- }
- .child-info-name {
- font-size: calc(36rpx * var(--font-scale, 1));
- font-weight: 700;
- color: $flat-ink;
- display: block;
- }
- .child-info-stats {
- display: flex;
- flex-wrap: wrap;
- gap: 12rpx;
- margin-top: 12rpx;
- }
- .stat-item {
- font-size: calc(24rpx * var(--font-scale, 1));
- font-weight: 500;
- }
- .stat-points { color: $dim-body; }
- .stat-dan { color: $accent-indigo; }
- .stat-streak { color: $brand-primary; }
- .child-info-progress {
- margin-top: 16rpx;
- }
- .progress-label {
- font-size: calc(22rpx * var(--font-scale, 1));
- color: $flat-muted-2;
- display: block;
- margin-bottom: 8rpx;
- }
- .progress-bar-bg {
- height: 10rpx;
- background: $flat-card;
- border-radius: 999rpx;
- overflow: hidden;
- }
- .progress-bar-fill {
- height: 100%;
- background: linear-gradient(90deg, $flat-teal, $flat-teal-deep);
- border-radius: 999rpx;
- transition: width 0.3s ease;
- }
- /* 区块标题 */
- .section-title {
- font-size: calc(30rpx * var(--font-scale, 1));
- font-weight: 600;
- color: $flat-ink;
- margin-bottom: 20rpx;
- }
- /* 操作区 */
- .action-section {
- margin-bottom: 40rpx;
- }
- .action-grid {
- display: flex;
- flex-wrap: wrap;
- }
- .action-btn {
- width: 50%;
- box-sizing: border-box;
- background: $app-surface;
- border-radius: 24rpx;
- padding: 24rpx 16rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-shadow: 0 4px 20px rgba(255, 140, 66, 0.08);
- position: relative;
- border: 8rpx solid $flat-bg;
- }
- .action-btn-icon {
- width: 72rpx;
- height: 72rpx;
- border-radius: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: calc(36rpx * var(--font-scale, 1));
- margin-bottom: 12rpx;
- }
- .create-icon { background: rgba(255, 140, 66, 0.15); }
- .wish-icon { background: rgba(255, 107, 107, 0.15); }
- .growth-icon { background: rgba(78, 205, 196, 0.15); }
- .stats-icon { background: rgba(255, 217, 61, 0.15); }
- .action-btn-label {
- font-size: calc(24rpx * var(--font-scale, 1));
- color: $flat-muted-2;
- font-weight: 500;
- }
- .action-btn-badge {
- position: absolute;
- top: 12rpx;
- right: 12rpx;
- background: $brand-primary;
- color: $app-surface;
- font-size: calc(20rpx * var(--font-scale, 1));
- min-width: 32rpx;
- height: 32rpx;
- line-height: 32rpx;
- text-align: center;
- border-radius: 16rpx;
- padding: 0 8rpx;
- }
- /* 今日任务 */
- .tasks-section {
- margin-bottom: 40rpx;
- }
- .tasks-card {
- background: $app-surface;
- border-radius: 24rpx;
- padding: 8rpx 24rpx;
- box-shadow: 0 4px 20px rgba(255, 140, 66, 0.08);
- }
- .task-item {
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid $flat-line;
- }
- .task-item:last-child {
- border-bottom: none;
- }
- .task-status-icon {
- font-size: calc(32rpx * var(--font-scale, 1));
- margin-right: 16rpx;
- }
- .task-info {
- flex: 1;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .task-title {
- font-size: calc(28rpx * var(--font-scale, 1));
- color: $flat-ink;
- }
- .task-points {
- font-size: calc(24rpx * var(--font-scale, 1));
- color: $dim-body;
- font-weight: 600;
- }
- .empty-card {
- background: $app-surface;
- border-radius: 24rpx;
- padding: 48rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-shadow: 0 4px 20px rgba(255, 140, 66, 0.08);
- }
- .empty-icon {
- font-size: calc(48rpx * var(--font-scale, 1));
- margin-bottom: 12rpx;
- }
- .empty-text {
- font-size: calc(28rpx * var(--font-scale, 1));
- color: $flat-muted;
- }
- /* 待处理 */
- .pending-section {
- margin-bottom: 48rpx;
- }
- .pending-card {
- background: $app-surface;
- border-radius: 24rpx;
- padding: 8rpx 24rpx;
- box-shadow: 0 4px 20px rgba(255, 140, 66, 0.08);
- }
- .pending-item {
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid $flat-line;
- }
- .pending-item:last-child {
- border-bottom: none;
- }
- .pending-icon {
- font-size: calc(32rpx * var(--font-scale, 1));
- margin-right: 16rpx;
- }
- .pending-desc {
- flex: 1;
- font-size: calc(28rpx * var(--font-scale, 1));
- color: $flat-ink;
- }
- .pending-tag {
- font-size: calc(22rpx * var(--font-scale, 1));
- padding: 4rpx 14rpx;
- border-radius: 24rpx;
- font-weight: 500;
- }
- .tag-review {
- background: $flat-card;
- color: $dim-body;
- }
- .tag-wish {
- background: $c-cd-danger-bg;
- color: $brand-primary;
- }
- </style>
|