|
|
@@ -8,12 +8,12 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- Tab bar (4 tabs) -->
|
|
|
+ <!-- Tab bar (role-aware tabs) -->
|
|
|
<view class="tab-bar">
|
|
|
<view
|
|
|
class="tab-item"
|
|
|
:class="{ active: currentTab === tab.key }"
|
|
|
- v-for="tab in tabs"
|
|
|
+ v-for="tab in visibleTabs"
|
|
|
:key="tab.key"
|
|
|
@click="onTabChange(tab.key)"
|
|
|
>
|
|
|
@@ -63,7 +63,9 @@
|
|
|
<view class="card-info">
|
|
|
<text class="card-title">{{ act.title }}</text>
|
|
|
<text class="card-meta" v-if="act.registrantName">报名人:{{ act.registrantName }}</text>
|
|
|
- <text class="card-meta">{{ act.startTime }}</text>
|
|
|
+ <text class="card-meta">开始时间:{{ formatDateTime(act.startTime) }}</text>
|
|
|
+ <text class="card-meta" v-if="act.registrationDeadline">报名截止:{{ formatDateTime(act.registrationDeadline) }}</text>
|
|
|
+ <text class="card-desc" v-if="act.description">{{ briefDesc(act.description) }}</text>
|
|
|
<text class="card-meta" v-if="act.location">📍 {{ act.location }}</text>
|
|
|
<view class="card-bottom">
|
|
|
<text class="card-status" :class="'status-' + (act._cls || 'upcoming')">
|
|
|
@@ -135,8 +137,13 @@
|
|
|
mode="aspectFill"
|
|
|
/>
|
|
|
<view class="card-info">
|
|
|
- <text class="card-title">{{ act.title }}</text>
|
|
|
- <text class="card-meta">{{ act.startTime }}</text>
|
|
|
+ <view class="card-title-row">
|
|
|
+ <text class="card-title">{{ act.title }}</text>
|
|
|
+ <text class="card-reg-badge" v-if="act.registered">已报名</text>
|
|
|
+ </view>
|
|
|
+ <text class="card-meta">开始时间:{{ formatDateTime(act.startTime) }}</text>
|
|
|
+ <text class="card-meta" v-if="act.registrationDeadline">报名截止:{{ formatDateTime(act.registrationDeadline) }}</text>
|
|
|
+ <text class="card-desc" v-if="act.description">{{ briefDesc(act.description) }}</text>
|
|
|
<text class="card-meta" v-if="act.location">📍 {{ act.location }}</text>
|
|
|
<view class="card-bottom">
|
|
|
<text class="card-status status-published">进行中</text>
|
|
|
@@ -166,23 +173,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- Tab 3: history -->
|
|
|
+ <!-- Tab 3: history (admin only — ended activities management) -->
|
|
|
<view v-if="currentTab === 'history'">
|
|
|
- <!-- Filter chips (same as mine) -->
|
|
|
- <scroll-view class="filter-scroll" scroll-x enable-flex>
|
|
|
- <view class="filter-chips">
|
|
|
- <view
|
|
|
- class="filter-chip"
|
|
|
- :class="{ active: currentMineFilter === filter.value }"
|
|
|
- v-for="filter in mineFilters"
|
|
|
- :key="filter.value"
|
|
|
- @click="onMineFilterChange(filter.value)"
|
|
|
- >
|
|
|
- <text class="filter-label">{{ filter.label }}</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </scroll-view>
|
|
|
-
|
|
|
<!-- Activity cards -->
|
|
|
<view class="card-list" v-if="historyActivities.length > 0">
|
|
|
<view
|
|
|
@@ -198,12 +190,12 @@
|
|
|
/>
|
|
|
<view class="card-info">
|
|
|
<text class="card-title">{{ act.title }}</text>
|
|
|
- <text class="card-meta">{{ act.startTime }}</text>
|
|
|
- <text class="card-meta" v-if="act.location">📍 {{ act.location }}</text>
|
|
|
+ <text class="card-meta">开始时间:{{ formatDateTime(act.startTime) }}</text>
|
|
|
+ <text class="card-meta" v-if="act.registrationDeadline">报名截止:{{ formatDateTime(act.registrationDeadline) }}</text>
|
|
|
+ <text class="card-desc" v-if="act.description">{{ briefDesc(act.description) }}</text>
|
|
|
<view class="card-bottom">
|
|
|
<text class="card-status status-ended">已结束</text>
|
|
|
- <text class="card-price" v-if="act.price > 0">¥{{ formatPrice(act.price) }}</text>
|
|
|
- <text class="card-price free" v-else>免费</text>
|
|
|
+ <text class="manage-action-small" @click.stop="goRegistrations(act)">报名管理</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -212,8 +204,8 @@
|
|
|
<!-- Empty state for history -->
|
|
|
<view class="empty-state" v-else-if="!historyLoading">
|
|
|
<text class="empty-icon">📜</text>
|
|
|
- <text class="empty-title">暂无历史活动</text>
|
|
|
- <text class="empty-desc">参加过的活动会显示在这里</text>
|
|
|
+ <text class="empty-title">暂无已结束活动</text>
|
|
|
+ <text class="empty-desc">已结束的活动会显示在这里</text>
|
|
|
</view>
|
|
|
|
|
|
<!-- Loading state -->
|
|
|
@@ -276,7 +268,7 @@
|
|
|
/>
|
|
|
<view class="card-info">
|
|
|
<text class="card-title">{{ act.title }}</text>
|
|
|
- <text class="card-meta">{{ act.startTime }}</text>
|
|
|
+ <text class="card-meta">开始时间:{{ formatDateTime(act.startTime) }}</text>
|
|
|
<view class="card-bottom">
|
|
|
<text class="card-status" :class="'status-' + (act.status || 'draft')">
|
|
|
{{ statusLabel(act.status) }}
|
|
|
@@ -284,6 +276,7 @@
|
|
|
<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>
|
|
|
+ <text class="manage-action-small" v-if="act.status === 'published'" @click.stop="goRegistrations(act)">报名管理</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -304,29 +297,35 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getActivityList, getMyActivityRegistrations, activityCheckin, cancelActivityRegistration, adminListMyActivities } from '@/utils/api.js'
|
|
|
+import { getActivityList, getMyActivityRegistrations, activityCheckin, cancelActivityRegistration, adminListMyActivities, adminPublishActivity, adminEndActivity } 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))
|
|
|
+ },
|
|
|
+ visibleTabs: function() {
|
|
|
+ var base = [
|
|
|
+ { key: 'mine', label: '我的活动' },
|
|
|
+ { key: 'discover', label: '发现活动' }
|
|
|
+ ]
|
|
|
+ if (this.isAdmin) {
|
|
|
+ base.push({ key: 'history', label: '历史记录' })
|
|
|
+ base.push({ key: 'manage', label: '管理' })
|
|
|
+ }
|
|
|
+ return base
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- tabs: [
|
|
|
- { key: 'mine', label: '我的活动' },
|
|
|
- { key: 'discover', label: '发现活动' },
|
|
|
- { key: 'history', label: '历史记录' },
|
|
|
- { key: 'manage', label: '管理' }
|
|
|
- ],
|
|
|
currentTab: 'mine',
|
|
|
mineFilters: [
|
|
|
{ label: '全部', value: '' },
|
|
|
{ label: '待开始', value: 'upcoming' },
|
|
|
{ label: '待审核', value: 'pending' },
|
|
|
- { label: '已签到', value: 'checked_in' }
|
|
|
+ { label: '已通过', value: 'approved' },
|
|
|
+ { label: '已拒绝', value: 'rejected' }
|
|
|
],
|
|
|
dimensionFilters: [
|
|
|
{ label: '全部', value: '' },
|
|
|
@@ -358,7 +357,12 @@ export default {
|
|
|
},
|
|
|
onLoad: function(options) {
|
|
|
if (options && options.tab) {
|
|
|
- this.currentTab = options.tab
|
|
|
+ // 非管理员不能停留在 历史记录/管理 tab
|
|
|
+ if ((options.tab === 'history' || options.tab === 'manage') && !this.isAdmin) {
|
|
|
+ this.currentTab = 'mine'
|
|
|
+ } else {
|
|
|
+ this.currentTab = options.tab
|
|
|
+ }
|
|
|
this.loadData()
|
|
|
}
|
|
|
},
|
|
|
@@ -371,6 +375,10 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
onTabChange: function(key) {
|
|
|
+ // 非管理员不能进入 历史记录/管理 tab
|
|
|
+ if ((key === 'history' || key === 'manage') && !this.isAdmin) {
|
|
|
+ return
|
|
|
+ }
|
|
|
this.currentTab = key
|
|
|
this.hasMore = true
|
|
|
if (key === 'mine') {
|
|
|
@@ -399,7 +407,7 @@ export default {
|
|
|
loadManageData: function() {
|
|
|
var self = this
|
|
|
this.manageLoading = true
|
|
|
- adminListMyActivities({ page: 1, size: 100 }).then(function(res) {
|
|
|
+ adminListMyActivities({ page: 1, size: 100, mine: true }).then(function(res) {
|
|
|
self.manageLoading = false
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
var records = res.data.records || []
|
|
|
@@ -448,11 +456,19 @@ export default {
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
uni.showLoading({ title: '发布中...' })
|
|
|
- setTimeout(function() {
|
|
|
+ adminPublishActivity(id).then(function(r) {
|
|
|
+ uni.hideLoading()
|
|
|
+ if (r && r.code === 200) {
|
|
|
+ uni.showToast({ title: '发布成功', icon: 'success' })
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: (r && r.message) || '发布失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ self.loadManageData()
|
|
|
+ }).catch(function() {
|
|
|
uni.hideLoading()
|
|
|
- uni.showToast({ title: '发布成功', icon: 'success' })
|
|
|
+ uni.showToast({ title: '网络异常', icon: 'none' })
|
|
|
self.loadManageData()
|
|
|
- }, 500)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -465,11 +481,19 @@ export default {
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
uni.showLoading({ title: '操作中...' })
|
|
|
- setTimeout(function() {
|
|
|
+ adminEndActivity(id).then(function(r) {
|
|
|
+ uni.hideLoading()
|
|
|
+ if (r && r.code === 200) {
|
|
|
+ uni.showToast({ title: '操作成功', icon: 'success' })
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: (r && r.message) || '操作失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ self.loadManageData()
|
|
|
+ }).catch(function() {
|
|
|
uni.hideLoading()
|
|
|
- uni.showToast({ title: '操作成功', icon: 'success' })
|
|
|
+ uni.showToast({ title: '网络异常', icon: 'none' })
|
|
|
self.loadManageData()
|
|
|
- }, 500)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -532,15 +556,14 @@ export default {
|
|
|
}
|
|
|
this.mineLoading = true
|
|
|
var childId = uni.getStorageSync('currentChildId')
|
|
|
- if (!childId) {
|
|
|
- this.mineLoading = false
|
|
|
- return
|
|
|
- }
|
|
|
var params = {
|
|
|
- childId: childId,
|
|
|
page: this.minePage,
|
|
|
size: this.pageSize
|
|
|
}
|
|
|
+ if (childId) {
|
|
|
+ params.childId = childId
|
|
|
+ }
|
|
|
+ // 仅将后端可识别的状态传给接口;'upcoming' 为前端客户端过滤
|
|
|
if (this.currentMineFilter && this.currentMineFilter !== 'upcoming') {
|
|
|
params.status = this.currentMineFilter
|
|
|
}
|
|
|
@@ -553,8 +576,8 @@ export default {
|
|
|
var filtered = []
|
|
|
for (var i = 0; i < records.length; i++) {
|
|
|
var act = records[i]
|
|
|
- if (act.startTime) {
|
|
|
- var startTime = new Date(act.startTime.replace(/-/g, '/'))
|
|
|
+ if (act.activityStartTime) {
|
|
|
+ var startTime = new Date(act.activityStartTime.replace(/-/g, '/'))
|
|
|
if (startTime > now && act.status === 'approved') {
|
|
|
filtered.push(act)
|
|
|
}
|
|
|
@@ -563,6 +586,7 @@ export default {
|
|
|
records = filtered
|
|
|
}
|
|
|
for (var di = 0; di < records.length; di++) {
|
|
|
+ self.normalizeRegistration(records[di])
|
|
|
self.decorateActivity(records[di])
|
|
|
}
|
|
|
if (refresh) {
|
|
|
@@ -612,37 +636,20 @@ export default {
|
|
|
this.historyActivities = []
|
|
|
}
|
|
|
this.historyLoading = true
|
|
|
- var childId = uni.getStorageSync('currentChildId')
|
|
|
- if (!childId) {
|
|
|
- this.historyLoading = false
|
|
|
- return
|
|
|
- }
|
|
|
+ // 历史记录 tab:活动管理员查看已结束活动(用于管理)
|
|
|
var params = {
|
|
|
- childId: childId,
|
|
|
+ status: 'ended',
|
|
|
page: this.historyPage,
|
|
|
size: this.pageSize
|
|
|
}
|
|
|
- getMyActivityRegistrations(params).then(function(res) {
|
|
|
+ getActivityList(params).then(function(res) {
|
|
|
self.historyLoading = false
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
var records = res.data.records || []
|
|
|
- var now = new Date()
|
|
|
- var ended = []
|
|
|
- for (var i = 0; i < records.length; i++) {
|
|
|
- var act = records[i]
|
|
|
- if (act.endTime) {
|
|
|
- var endTime = new Date(act.endTime.replace(/-/g, '/'))
|
|
|
- if (endTime < now || act.status === 'cancelled' || act.status === 'rejected') {
|
|
|
- ended.push(act)
|
|
|
- }
|
|
|
- } else {
|
|
|
- ended.push(act)
|
|
|
- }
|
|
|
- }
|
|
|
if (refresh) {
|
|
|
- self.historyActivities = ended
|
|
|
+ self.historyActivities = records
|
|
|
} else {
|
|
|
- self.historyActivities = self.historyActivities.concat(ended)
|
|
|
+ self.historyActivities = self.historyActivities.concat(records)
|
|
|
}
|
|
|
self.hasMore = records.length >= self.pageSize
|
|
|
}
|
|
|
@@ -653,6 +660,9 @@ export default {
|
|
|
goDetail: function(act) {
|
|
|
uni.navigateTo({ url: '/pages/activity/activity-detail/activity-detail?id=' + act.id })
|
|
|
},
|
|
|
+ goRegistrations: function(act) {
|
|
|
+ uni.navigateTo({ url: '/pages/activity/registrations?activityId=' + act.id + '&title=' + encodeURIComponent(act.title || '') })
|
|
|
+ },
|
|
|
switchToDiscover: function() {
|
|
|
this.currentTab = 'discover'
|
|
|
this.loadData()
|
|
|
@@ -660,6 +670,36 @@ export default {
|
|
|
formatPrice: function(price) {
|
|
|
return (price / 100).toFixed(2)
|
|
|
},
|
|
|
+ /** 将报名记录字段规范化为活动卡片字段(后端 my-registrations 返回 activity* 前缀字段) */
|
|
|
+ normalizeRegistration: function(rec) {
|
|
|
+ rec.id = rec.activityId
|
|
|
+ rec.title = rec.activityTitle
|
|
|
+ rec.coverImage = rec.activityCoverImage
|
|
|
+ rec.description = rec.activityDescription
|
|
|
+ rec.location = rec.activityLocation
|
|
|
+ rec.price = rec.activityPrice
|
|
|
+ rec.memberPrice = rec.activityMemberPrice
|
|
|
+ rec.startTime = rec.activityStartTime
|
|
|
+ rec.endTime = rec.activityEndTime
|
|
|
+ rec.registrationDeadline = rec.activityRegistrationDeadline
|
|
|
+ rec.requireRegistration = rec.activityRequireRegistration
|
|
|
+ rec.activityStatus = rec.activityStatus
|
|
|
+ return rec
|
|
|
+ },
|
|
|
+ formatDateTime: function(v) {
|
|
|
+ if (!v) return ''
|
|
|
+ var s = String(v)
|
|
|
+ if (s.indexOf('-') < 0 && s.indexOf('/') < 0) return s
|
|
|
+ var d = new Date(s.replace(/-/g, '/'))
|
|
|
+ if (isNaN(d.getTime())) return s
|
|
|
+ var pad = function(n) { return n < 10 ? '0' + n : '' + n }
|
|
|
+ return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes())
|
|
|
+ },
|
|
|
+ briefDesc: function(v) {
|
|
|
+ if (!v) return ''
|
|
|
+ var s = String(v).replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim()
|
|
|
+ return s.length > 36 ? s.substring(0, 36) + '...' : s
|
|
|
+ },
|
|
|
decorateActivity: function(act) {
|
|
|
if (act.status) {
|
|
|
act._cls = act.status
|
|
|
@@ -681,7 +721,8 @@ export default {
|
|
|
},
|
|
|
onCheckin: function(act) {
|
|
|
var self = this
|
|
|
- var childId = uni.getStorageSync('currentChildId')
|
|
|
+ // 优先使用全局当前孩子;为空时回退到报名记录上的 childId(家长自身视角也可签到)
|
|
|
+ var childId = uni.getStorageSync('currentChildId') || act.childId
|
|
|
if (!childId) {
|
|
|
uni.showToast({ title: '请先选择孩子身份', icon: 'none' })
|
|
|
return
|
|
|
@@ -704,7 +745,8 @@ export default {
|
|
|
content: '确定要取消报名吗?',
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
- var childId = uni.getStorageSync('currentChildId')
|
|
|
+ // 优先使用全局当前孩子;为空时回退到报名记录上的 childId
|
|
|
+ var childId = uni.getStorageSync('currentChildId') || act.childId
|
|
|
if (!childId) {
|
|
|
uni.showToast({ title: '请先选择孩子身份', icon: 'none' })
|
|
|
return
|
|
|
@@ -854,6 +896,38 @@ export default {
|
|
|
white-space: nowrap;
|
|
|
}
|
|
|
|
|
|
+.card-title-row {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.card-title-row .card-title {
|
|
|
+ flex: 1;
|
|
|
+ margin-right: 12rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.card-reg-badge {
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: 20rpx;
|
|
|
+ color: #F97316;
|
|
|
+ background: #FFF7ED;
|
|
|
+ border: 1rpx solid #F97316;
|
|
|
+ padding: 2rpx 12rpx;
|
|
|
+ border-radius: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.card-desc {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #888;
|
|
|
+ margin-top: 8rpx;
|
|
|
+ line-height: 1.5;
|
|
|
+ display: -webkit-box;
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+
|
|
|
.card-meta {
|
|
|
font-size: 24rpx;
|
|
|
color: #999;
|