|
|
@@ -1,11 +1,14 @@
|
|
|
<template>
|
|
|
<view class="activity-container">
|
|
|
- <!-- Nav bar with title "活动中心" -->
|
|
|
+ <!-- Nav bar with title "活动中心" and admin "+" button -->
|
|
|
<view class="nav-bar">
|
|
|
<text class="nav-title">活动中心</text>
|
|
|
+ <view class="nav-add-btn" v-if="isAdmin" @click="goCreate">
|
|
|
+ <text class="nav-add-icon">+</text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- Tab bar (3 tabs) -->
|
|
|
+ <!-- Tab bar (4 tabs) -->
|
|
|
<view class="tab-bar">
|
|
|
<view
|
|
|
class="tab-item"
|
|
|
@@ -223,20 +226,99 @@
|
|
|
<text class="load-more-text">没有更多了</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <!-- Tab 4: manage (admin only) -->
|
|
|
+ <view v-if="currentTab === 'manage' && isAdmin">
|
|
|
+ <!-- Manage overview stats -->
|
|
|
+ <view class="manage-overview">
|
|
|
+ <view class="manage-stat-card">
|
|
|
+ <text class="manage-stat-num">{{ manageStats.total }}</text>
|
|
|
+ <text class="manage-stat-label">全部活动</text>
|
|
|
+ </view>
|
|
|
+ <view class="manage-stat-card">
|
|
|
+ <text class="manage-stat-num manage-published">{{ manageStats.published }}</text>
|
|
|
+ <text class="manage-stat-label">已发布</text>
|
|
|
+ </view>
|
|
|
+ <view class="manage-stat-card">
|
|
|
+ <text class="manage-stat-num manage-draft">{{ manageStats.draft }}</text>
|
|
|
+ <text class="manage-stat-label">草稿</text>
|
|
|
+ </view>
|
|
|
+ <view class="manage-stat-card">
|
|
|
+ <text class="manage-stat-num manage-ended">{{ manageStats.ended }}</text>
|
|
|
+ <text class="manage-stat-label">已结束</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- Quick actions -->
|
|
|
+ <view class="manage-actions">
|
|
|
+ <view class="manage-action-btn" @click="goCreate">
|
|
|
+ <text class="manage-action-icon">+</text>
|
|
|
+ <text class="manage-action-text">创建活动</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- My managed activities list -->
|
|
|
+ <view class="manage-section-title">
|
|
|
+ <text>我的活动管理</text>
|
|
|
+ </view>
|
|
|
+ <view class="card-list" v-if="manageActivities.length > 0">
|
|
|
+ <view
|
|
|
+ class="activity-card"
|
|
|
+ v-for="act in manageActivities"
|
|
|
+ :key="act.id"
|
|
|
+ @click="goEdit(act)"
|
|
|
+ >
|
|
|
+ <image
|
|
|
+ class="card-cover"
|
|
|
+ :src="act.coverImage || '/static/default-activity.png'"
|
|
|
+ mode="aspectFill"
|
|
|
+ />
|
|
|
+ <view class="card-info">
|
|
|
+ <text class="card-title">{{ act.title }}</text>
|
|
|
+ <text class="card-meta">{{ act.startTime }}</text>
|
|
|
+ <view class="card-bottom">
|
|
|
+ <text class="card-status" :class="'status-' + (act.status || 'draft')">
|
|
|
+ {{ statusLabel(act.status) }}
|
|
|
+ </text>
|
|
|
+ <view class="manage-action-group">
|
|
|
+ <text class="manage-action-small" v-if="act.status === 'draft'" @click.stop="doPublish(act.id)">发布</text>
|
|
|
+ <text class="manage-action-small" v-if="act.status === 'published'" @click.stop="doEnd(act.id)">结束</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="empty-state" v-else-if="!manageLoading">
|
|
|
+ <text class="empty-icon">📊</text>
|
|
|
+ <text class="empty-title">暂无管理的活动</text>
|
|
|
+ <text class="empty-desc">点击上方「创建活动」开始</text>
|
|
|
+ </view>
|
|
|
+ <view class="loading-state" v-if="manageLoading">
|
|
|
+ <view class="loading-spinner"></view>
|
|
|
+ <text class="loading-text">加载中...</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getActivityList, getMyActivityRegistrations, activityCheckin, cancelActivityRegistration } from '@/utils/api.js'
|
|
|
+import { getActivityList, getMyActivityRegistrations, activityCheckin, cancelActivityRegistration, adminListMyActivities } from '@/utils/api.js'
|
|
|
|
|
|
export default {
|
|
|
+ computed: {
|
|
|
+ isAdmin: function() {
|
|
|
+ var userInfo = uni.getStorageSync('userInfo')
|
|
|
+ return userInfo && (userInfo.role === 'admin' || userInfo.role === 'activity_admin' || (userInfo.roles && userInfo.roles.indexOf('activity_admin') >= 0))
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
tabs: [
|
|
|
{ key: 'mine', label: '我的活动' },
|
|
|
{ key: 'discover', label: '发现活动' },
|
|
|
- { key: 'history', label: '历史记录' }
|
|
|
+ { key: 'history', label: '历史记录' },
|
|
|
+ { key: 'manage', label: '管理' }
|
|
|
],
|
|
|
currentTab: 'mine',
|
|
|
mineFilters: [
|
|
|
@@ -266,7 +348,11 @@ export default {
|
|
|
historyPage: 1,
|
|
|
pageSize: 10,
|
|
|
hasMore: true,
|
|
|
- isRefreshing: false
|
|
|
+ isRefreshing: false,
|
|
|
+ // Manage tab data
|
|
|
+ manageLoading: false,
|
|
|
+ manageStats: { total: 0, published: 0, draft: 0, ended: 0 },
|
|
|
+ manageActivities: []
|
|
|
}
|
|
|
},
|
|
|
onLoad: function(options) {
|
|
|
@@ -278,6 +364,8 @@ export default {
|
|
|
onShow: function() {
|
|
|
if (this.currentTab === 'mine') {
|
|
|
this.loadMyActivities(true)
|
|
|
+ } else if (this.currentTab === 'manage') {
|
|
|
+ this.loadManageData()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -293,6 +381,8 @@ export default {
|
|
|
} else if (key === 'history') {
|
|
|
this.historyPage = 1
|
|
|
this.historyActivities = []
|
|
|
+ } else if (key === 'manage') {
|
|
|
+ this.loadManageData()
|
|
|
}
|
|
|
this.loadData()
|
|
|
},
|
|
|
@@ -305,6 +395,134 @@ export default {
|
|
|
this.loadHistoryActivities()
|
|
|
}
|
|
|
},
|
|
|
+ loadManageData: function() {
|
|
|
+ var self = this
|
|
|
+ this.manageLoading = true
|
|
|
+ adminListMyActivities({ page: 1, size: 100 }).then(function(res) {
|
|
|
+ self.manageLoading = false
|
|
|
+ if (res && res.code === 200 && res.data) {
|
|
|
+ var records = res.data.records || []
|
|
|
+ self.manageActivities = records.slice(0, 20)
|
|
|
+ var total = records.length
|
|
|
+ var published = 0
|
|
|
+ var draft = 0
|
|
|
+ var ended = 0
|
|
|
+ for (var i = 0; i < records.length; i++) {
|
|
|
+ var s = records[i].status
|
|
|
+ if (s === 'published') published++
|
|
|
+ else if (s === 'draft') draft++
|
|
|
+ else if (s === 'ended' || s === 'cancelled') ended++
|
|
|
+ }
|
|
|
+ self.manageStats = { total: total, published: published, draft: draft, ended: ended }
|
|
|
+ } else {
|
|
|
+ self.manageActivities = []
|
|
|
+ self.manageStats = { total: 0, published: 0, draft: 0, ended: 0 }
|
|
|
+ }
|
|
|
+ }).catch(function() {
|
|
|
+ self.manageLoading = false
|
|
|
+ self.manageActivities = []
|
|
|
+ self.manageStats = { total: 0, published: 0, draft: 0, ended: 0 }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ goCreate: function() {
|
|
|
+ uni.navigateTo({ url: '/pages/activity/create' })
|
|
|
+ },
|
|
|
+ goEdit: function(act) {
|
|
|
+ uni.navigateTo({ url: '/pages/activity/create?id=' + act.id })
|
|
|
+ },
|
|
|
+ statusLabel: function(status) {
|
|
|
+ var map = {
|
|
|
+ draft: '草稿',
|
|
|
+ published: '进行中',
|
|
|
+ ended: '已结束',
|
|
|
+ cancelled: '已取消'
|
|
|
+ }
|
|
|
+ return map[status] || status
|
|
|
+ },
|
|
|
+ doPublish: function(id) {
|
|
|
+ var self = this
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确认发布此活动吗?发布后将对外可见。',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.showLoading({ title: '发布中...' })
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '发布成功', icon: 'success' })
|
|
|
+ self.loadManageData()
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ doEnd: function(id) {
|
|
|
+ var self = this
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确认结束此活动吗?结束后不再接受新参与者。',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.showLoading({ title: '操作中...' })
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '操作成功', icon: 'success' })
|
|
|
+ self.loadManageData()
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onMineFilterChange: function(value) {
|
|
|
+ this.currentMineFilter = value
|
|
|
+ this.minePage = 1
|
|
|
+ this.myActivities = []
|
|
|
+ this.hasMore = true
|
|
|
+ if (this.currentTab === 'mine') {
|
|
|
+ this.loadMyActivities()
|
|
|
+ } else if (this.currentTab === 'history') {
|
|
|
+ this.loadHistoryActivities()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onDimensionChange: function(value) {
|
|
|
+ this.currentDimension = value
|
|
|
+ this.discoverPage = 1
|
|
|
+ this.discoverActivities = []
|
|
|
+ this.hasMore = true
|
|
|
+ this.loadDiscoverActivities()
|
|
|
+ },
|
|
|
+ onLoadMore: function() {
|
|
|
+ if (!this.hasMore) return
|
|
|
+ if (this.currentTab === 'mine' && !this.mineLoading) {
|
|
|
+ this.minePage++
|
|
|
+ this.loadMyActivities()
|
|
|
+ } else if (this.currentTab === 'discover' && !this.discoverLoading) {
|
|
|
+ this.discoverPage++
|
|
|
+ this.loadDiscoverActivities()
|
|
|
+ } else if (this.currentTab === 'history' && !this.historyLoading) {
|
|
|
+ this.historyPage++
|
|
|
+ this.loadHistoryActivities()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onRefresh: function() {
|
|
|
+ var self = this
|
|
|
+ this.isRefreshing = true
|
|
|
+ if (this.currentTab === 'mine') {
|
|
|
+ this.loadMyActivities(true).finally(function() {
|
|
|
+ self.isRefreshing = false
|
|
|
+ })
|
|
|
+ } else if (this.currentTab === 'discover') {
|
|
|
+ this.loadDiscoverActivities(true).finally(function() {
|
|
|
+ self.isRefreshing = false
|
|
|
+ })
|
|
|
+ } else if (this.currentTab === 'history') {
|
|
|
+ this.loadHistoryActivities(true).finally(function() {
|
|
|
+ self.isRefreshing = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.isRefreshing = false
|
|
|
+ }
|
|
|
+ },
|
|
|
loadMyActivities: function(refresh) {
|
|
|
var self = this
|
|
|
if (refresh) {
|
|
|
@@ -431,56 +649,6 @@ export default {
|
|
|
self.historyLoading = false
|
|
|
})
|
|
|
},
|
|
|
- onMineFilterChange: function(value) {
|
|
|
- this.currentMineFilter = value
|
|
|
- this.minePage = 1
|
|
|
- this.myActivities = []
|
|
|
- this.hasMore = true
|
|
|
- if (this.currentTab === 'mine') {
|
|
|
- this.loadMyActivities()
|
|
|
- } else if (this.currentTab === 'history') {
|
|
|
- this.loadHistoryActivities()
|
|
|
- }
|
|
|
- },
|
|
|
- onDimensionChange: function(value) {
|
|
|
- this.currentDimension = value
|
|
|
- this.discoverPage = 1
|
|
|
- this.discoverActivities = []
|
|
|
- this.hasMore = true
|
|
|
- this.loadDiscoverActivities()
|
|
|
- },
|
|
|
- onLoadMore: function() {
|
|
|
- if (!this.hasMore) return
|
|
|
- if (this.currentTab === 'mine' && !this.mineLoading) {
|
|
|
- this.minePage++
|
|
|
- this.loadMyActivities()
|
|
|
- } else if (this.currentTab === 'discover' && !this.discoverLoading) {
|
|
|
- this.discoverPage++
|
|
|
- this.loadDiscoverActivities()
|
|
|
- } else if (this.currentTab === 'history' && !this.historyLoading) {
|
|
|
- this.historyPage++
|
|
|
- this.loadHistoryActivities()
|
|
|
- }
|
|
|
- },
|
|
|
- onRefresh: function() {
|
|
|
- var self = this
|
|
|
- this.isRefreshing = true
|
|
|
- if (this.currentTab === 'mine') {
|
|
|
- this.loadMyActivities(true).finally(function() {
|
|
|
- self.isRefreshing = false
|
|
|
- })
|
|
|
- } else if (this.currentTab === 'discover') {
|
|
|
- this.loadDiscoverActivities(true).finally(function() {
|
|
|
- self.isRefreshing = false
|
|
|
- })
|
|
|
- } else if (this.currentTab === 'history') {
|
|
|
- this.loadHistoryActivities(true).finally(function() {
|
|
|
- self.isRefreshing = false
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.isRefreshing = false
|
|
|
- }
|
|
|
- },
|
|
|
goDetail: function(act) {
|
|
|
uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
|
|
|
},
|
|
|
@@ -488,41 +656,9 @@ export default {
|
|
|
this.currentTab = 'discover'
|
|
|
this.loadData()
|
|
|
},
|
|
|
- getStatusClass: function(act) {
|
|
|
- if (!act.status) {
|
|
|
- if (act.endTime) {
|
|
|
- var endTime = new Date(act.endTime.replace(/-/g, '/'))
|
|
|
- if (endTime < new Date()) {
|
|
|
- return 'status-ended'
|
|
|
- }
|
|
|
- }
|
|
|
- return 'status-upcoming'
|
|
|
- }
|
|
|
- return 'status-' + act.status
|
|
|
- },
|
|
|
- getStatusText: function(act) {
|
|
|
- var statusMap = {
|
|
|
- pending: '待审核',
|
|
|
- approved: '报名成功',
|
|
|
- rejected: '已拒绝',
|
|
|
- cancelled: '已取消',
|
|
|
- checked_in: '已签到'
|
|
|
- }
|
|
|
- if (!act.status) {
|
|
|
- if (act.endTime) {
|
|
|
- var endTime = new Date(act.endTime.replace(/-/g, '/'))
|
|
|
- if (endTime < new Date()) {
|
|
|
- return '已结束'
|
|
|
- }
|
|
|
- }
|
|
|
- return '待开始'
|
|
|
- }
|
|
|
- return statusMap[act.status] || act.status
|
|
|
- },
|
|
|
formatPrice: function(price) {
|
|
|
return (price / 100).toFixed(2)
|
|
|
},
|
|
|
- // Pre-compute display properties for WXML compatibility (no method calls in :class)
|
|
|
decorateActivity: function(act) {
|
|
|
if (act.status) {
|
|
|
act._cls = act.status
|
|
|
@@ -778,6 +914,11 @@ export default {
|
|
|
color: #22C55E;
|
|
|
}
|
|
|
|
|
|
+.status-draft {
|
|
|
+ background: #FFF7ED;
|
|
|
+ color: #F97316;
|
|
|
+}
|
|
|
+
|
|
|
.card-price {
|
|
|
font-size: 28rpx;
|
|
|
color: #F97316;
|
|
|
@@ -886,4 +1027,128 @@ export default {
|
|
|
font-size: 24rpx;
|
|
|
color: #999;
|
|
|
}
|
|
|
+
|
|
|
+/* Nav add button */
|
|
|
+.nav-add-btn {
|
|
|
+ position: absolute;
|
|
|
+ right: 24rpx;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ width: 56rpx;
|
|
|
+ height: 56rpx;
|
|
|
+ background: rgba(255, 255, 255, 0.15);
|
|
|
+ border-radius: 50%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+.nav-add-icon {
|
|
|
+ color: #fff;
|
|
|
+ font-size: 36rpx;
|
|
|
+ font-weight: 300;
|
|
|
+ line-height: 1;
|
|
|
+}
|
|
|
+
|
|
|
+/* Manage overview stats */
|
|
|
+.manage-overview {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ padding: 24rpx;
|
|
|
+ gap: 16rpx;
|
|
|
+ background: #fff;
|
|
|
+ margin: 24rpx 24rpx 0;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
|
|
+}
|
|
|
+
|
|
|
+.manage-stat-card {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ padding: 16rpx 0;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-stat-num {
|
|
|
+ font-size: 40rpx;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #333;
|
|
|
+ line-height: 1.2;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-published {
|
|
|
+ color: #22C55E;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-draft {
|
|
|
+ color: #F97316;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-ended {
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-stat-label {
|
|
|
+ font-size: 22rpx;
|
|
|
+ color: #999;
|
|
|
+ margin-top: 8rpx;
|
|
|
+}
|
|
|
+
|
|
|
+/* Quick action button */
|
|
|
+.manage-actions {
|
|
|
+ padding: 24rpx 24rpx 0;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-action-btn {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ gap: 12rpx;
|
|
|
+ padding: 24rpx 0;
|
|
|
+ background: linear-gradient(135deg, #F97316, #FB923C);
|
|
|
+ border-radius: 12rpx;
|
|
|
+ margin: 0 24rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-action-icon {
|
|
|
+ color: #fff;
|
|
|
+ font-size: 36rpx;
|
|
|
+ font-weight: 300;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-action-text {
|
|
|
+ color: #fff;
|
|
|
+ font-size: 28rpx;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+/* Section title */
|
|
|
+.manage-section-title {
|
|
|
+ padding: 24rpx 24rpx 12rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-section-title text {
|
|
|
+ font-size: 28rpx;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #333;
|
|
|
+}
|
|
|
+
|
|
|
+/* Manage action group in card */
|
|
|
+.manage-action-group {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ gap: 16rpx;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.manage-action-small {
|
|
|
+ font-size: 22rpx;
|
|
|
+ padding: 4rpx 16rpx;
|
|
|
+ border-radius: 20rpx;
|
|
|
+ background: #F97316;
|
|
|
+ color: #fff;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
</style>
|