| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <template>
- <view class="review-page">
- <!-- Tab Bar -->
- <view class="tab-bar">
- <view class="tab-bar__item" :class="{ 'tab-bar__item--active': tab === 'pending' }" @click="switchTab('pending')">
- <text class="tab-bar__label">📋 待审核</text>
- <view class="tab-bar__badge" v-if="pendingCount > 0">
- <text class="tab-bar__badge-text">{{ pendingCount > 99 ? '99+' : pendingCount }}</text>
- </view>
- </view>
- <view class="tab-bar__item" :class="{ 'tab-bar__item--active': tab === 'history' }" @click="switchTab('history')">
- <text class="tab-bar__label">📜 审核历史</text>
- </view>
- </view>
- <!-- Loading State -->
- <BaseLoading :loading="loading" text="加载中..." />
- <!-- Task List -->
- <view class="task-list" v-if="!loading && taskList.length > 0">
- <view v-for="(task, index) in taskList" :key="task.id" class="task-list__item">
- <!-- Pending Tab - Review Cards with Actions -->
- <PlayfulCard v-if="tab === 'pending'" variant="flat" shadow="sm"
- :class="'animate-slide-up animate-stagger-' + ((index % 10) + 1)">
- <view class="card-body">
- <text class="card-title">{{ task.title }}</text>
- <text class="card-desc">{{ task.description }}</text>
- <view class="card-meta-row">
- <text class="card-provider">提供者: {{ task.creatorRole === 'parent' ? '家长' : '孩子' }}</text>
- <text class="card-points">⭐ +{{ task.points }}</text>
- </view>
- </view>
- <view slot="actions" class="card-actions">
- <PlayfulButton variant="success" size="sm" @click="handleApprove(task.id)">✓ 通过</PlayfulButton>
- <PlayfulButton variant="error" size="sm" @click="handleReject(task.id)">✗ 拒绝</PlayfulButton>
- </view>
- </PlayfulCard>
- <!-- History Tab - Review Cards with Status -->
- <PlayfulCard v-if="tab === 'history'" variant="flat" shadow="sm"
- :class="'animate-slide-up animate-stagger-' + ((index % 10) + 1)">
- <view class="card-body">
- <view class="card-header-row">
- <text class="card-title card-title--flex">{{ task.title }}</text>
- <BaseBadge v-if="task.status === 'approved'" variant="success" size="sm">✅ 已通过</BaseBadge>
- <BaseBadge v-if="task.status === 'rejected'" variant="error" size="sm">❌ 已拒绝</BaseBadge>
- </view>
- <text class="card-desc">{{ task.description }}</text>
- <view class="card-meta-row">
- <text class="card-provider">提供者: {{ task.creatorRole === 'parent' ? '家长' : '孩子' }}</text>
- <text class="card-points">⭐ +{{ task.points }}</text>
- </view>
- <text class="card-time" v-if="task.reviewTime">审核时间: {{ task.reviewTime }}</text>
- </view>
- </PlayfulCard>
- </view>
- </view>
- <!-- Empty States -->
- <BaseEmpty v-if="!loading && taskList.length === 0 && tab === 'pending'"
- icon="🎉"
- title="没有待审核的任务"
- description="家长可以休息一下啦~"
- />
- <BaseEmpty v-if="!loading && taskList.length === 0 && tab === 'history'"
- icon="📜"
- title="还没有审核记录"
- />
- </view>
- </template>
- <script>
- import { getPendingReviewTasks, approveTask, rejectTask, getTaskHistory } from '../../utils/api.js'
- import PlayfulCard from '../../components/PlayfulCard.vue'
- import PlayfulButton from '../../components/PlayfulButton.vue'
- import BaseBadge from '../../components/BaseBadge.vue'
- import BaseEmpty from '../../components/BaseEmpty.vue'
- import BaseLoading from '../../components/BaseLoading.vue'
- export default {
- components: {
- PlayfulCard,
- PlayfulButton,
- BaseBadge,
- BaseEmpty,
- BaseLoading
- },
- data() {
- return {
- tab: 'pending',
- taskList: [],
- pendingCount: 0,
- loading: false
- }
- },
- watch: {
- tab() {
- this.loadTasks()
- }
- },
- onShow() {
- this.loadTasks()
- },
- methods: {
- switchTab(tabName) {
- if (this.tab !== tabName) {
- this.tab = tabName
- }
- },
- async loadTasks() {
- this.loading = true
- try {
- if (this.tab === 'pending') {
- const res = await getPendingReviewTasks()
- this.taskList = res.data || []
- this.pendingCount = this.taskList.length
- } else {
- const res = await getTaskHistory()
- this.taskList = (res.data && res.data.records) || []
- }
- } catch (e) {
- console.error(e)
- } finally {
- this.loading = false
- }
- },
- async handleApprove(taskId) {
- try {
- await approveTask(taskId)
- uni.showToast({ title: '已通过', icon: 'success' })
- this.loadTasks()
- } catch (e) {
- uni.showToast({ title: '操作失败', icon: 'none' })
- }
- },
- async handleReject(taskId) {
- try {
- await rejectTask(taskId)
- uni.showToast({ title: '已拒绝', icon: 'success' })
- this.loadTasks()
- } catch (e) {
- uni.showToast({ title: '操作失败', icon: 'none' })
- }
- }
- }
- }
- </script>
- <style scoped>
- .review-page {
- min-height: 100vh;
- background: var(--bg, #F5F9FC);
- padding: 24rpx var(--page-padding, 32rpx);
- }
- /* ============================================================
- Tab Bar
- ============================================================ */
- .tab-bar {
- position: relative;
- display: flex;
- background: var(--surface, #FFFFFF);
- border-radius: var(--radius-md, 20rpx);
- padding: 8rpx;
- margin-bottom: 32rpx;
- box-shadow: var(--shadow-sm, 0 4rpx 12rpx rgba(91, 155, 213, 0.06));
- border: 1px solid var(--border-light, #E2E8F0);
- }
- .tab-bar__item {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 22rpx 16rpx;
- border-radius: var(--radius-sm, 12rpx);
- position: relative;
- z-index: 2;
- transition: all var(--transition-base, 0.25s ease);
- cursor: pointer;
- }
- .tab-bar__item:active {
- transform: scale(0.97);
- }
- .tab-bar__item--active {
- background: var(--bg, #F5F9FC);
- }
- .tab-bar__label {
- font-size: 28rpx;
- font-weight: 600;
- color: var(--text-secondary, #64748B);
- transition: color var(--transition-base, 0.25s ease);
- }
- .tab-bar__item--active .tab-bar__label {
- color: var(--color-primary, #5B9BD5);
- }
- .tab-bar__item--active::after {
- content: '';
- position: absolute;
- bottom: 6rpx;
- left: 50%;
- transform: translateX(-50%);
- width: 40%;
- height: 4rpx;
- background: var(--color-primary, #5B9BD5);
- border-radius: 4rpx;
- }
- .tab-bar__badge {
- background: var(--color-primary, #5B9BD5);
- border-radius: 999rpx;
- min-width: 36rpx;
- height: 36rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 8rpx;
- margin-left: 8rpx;
- box-shadow: 0 2rpx 8rpx rgba(91, 155, 213, 0.3);
- }
- .tab-bar__badge-text {
- font-size: 20rpx;
- font-weight: 700;
- color: #FFFFFF;
- line-height: 1;
- }
- /* ============================================================
- Task List
- ============================================================ */
- .task-list {
- display: flex;
- flex-direction: column;
- gap: 24rpx;
- padding-bottom: 32rpx;
- }
- /* ============================================================
- Card Body (inside PlayfulCard default slot)
- ============================================================ */
- .card-body {
- display: flex;
- flex-direction: column;
- gap: 12rpx;
- }
- .card-title {
- font-size: 30rpx;
- font-weight: 700;
- color: var(--text, #1E293B);
- line-height: 1.4;
- }
- .card-title--flex {
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .card-desc {
- font-size: 26rpx;
- color: var(--text-secondary, #64748B);
- line-height: 1.5;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .card-header-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 16rpx;
- }
- .card-meta-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 24rpx;
- }
- .card-provider {
- color: var(--text-secondary, #64748B);
- }
- .card-points {
- color: var(--color-primary, #5B9BD5);
- font-weight: 600;
- }
- .card-time {
- font-size: 22rpx;
- color: var(--muted, #94A3B8);
- margin-top: 4rpx;
- }
- /* ============================================================
- Card Actions
- ============================================================ */
- .card-actions {
- display: flex;
- gap: 16rpx;
- width: 100%;
- }
- </style>
- <style lang="scss">
- /* Non-scoped: style PlayfulButton inside actions slot (scoped deep selectors crash HBuilderX postcss) */
- .card-actions .playful-btn {
- flex: 1;
- }
- </style>
|