registrations.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="container">
  3. <!-- 活动标题 -->
  4. <view class="header">
  5. <text class="header-title">{{ activityTitle || '报名管理' }}</text>
  6. </view>
  7. <!-- 状态筛选 chips -->
  8. <scroll-view class="filter-scroll" scroll-x enable-flex>
  9. <view class="filter-chips">
  10. <view
  11. class="filter-chip"
  12. :class="{ active: currentFilter === filter.value }"
  13. v-for="filter in statusFilters"
  14. :key="filter.value"
  15. @click="onFilterChange(filter.value)"
  16. >
  17. <text class="filter-label">{{ filter.label }}</text>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. <!-- 报名列表 -->
  22. <view class="reg-list" v-if="registrations.length > 0">
  23. <view
  24. class="reg-card"
  25. v-for="row in registrations"
  26. :key="row.id"
  27. >
  28. <view class="reg-info">
  29. <view class="reg-name-row">
  30. <text class="reg-name">{{ row.registrantName || '未填写姓名' }}</text>
  31. <text class="reg-tag" :class="'reg-tag-' + row.status">{{ statusText(row.status) }}</text>
  32. </view>
  33. <text class="reg-meta" v-if="row.registrantPhone">联系电话:{{ row.registrantPhone }}</text>
  34. <text class="reg-meta">报名时间:{{ formatDateTime(row.registeredAt) }}</text>
  35. </view>
  36. <view class="reg-actions" v-if="row.status === 'pending'">
  37. <button class="btn-approve" @click="onApprove(row)">通过</button>
  38. <button class="btn-reject" @click="onReject(row)">拒绝</button>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 空状态 -->
  43. <view class="empty-state" v-else-if="!loading">
  44. <text class="empty-icon">📋</text>
  45. <text class="empty-title">暂无报名记录</text>
  46. <text class="empty-desc">当前状态下没有报名申请</text>
  47. </view>
  48. <!-- 加载状态 -->
  49. <view class="loading-state" v-if="loading">
  50. <view class="loading-spinner"></view>
  51. <text class="loading-text">加载中...</text>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import { adminActivityRegistrationList, adminApproveRegistration, adminRejectRegistration, getActivityDetail } from '@/utils/api.js'
  57. export default {
  58. data() {
  59. return {
  60. activityId: null,
  61. activityTitle: '',
  62. currentFilter: 'all',
  63. statusFilters: [
  64. { label: '全部', value: 'all' },
  65. { label: '待审核', value: 'pending' },
  66. { label: '已通过', value: 'approved' },
  67. { label: '已拒绝', value: 'rejected' }
  68. ],
  69. registrations: [],
  70. loading: false
  71. }
  72. },
  73. onLoad: function(options) {
  74. if (options && options.activityId) {
  75. this.activityId = options.activityId
  76. }
  77. if (options && options.title) {
  78. this.activityTitle = decodeURIComponent(options.title)
  79. }
  80. this.loadDetail()
  81. this.loadList()
  82. },
  83. methods: {
  84. loadDetail: function() {
  85. var self = this
  86. if (!this.activityId || this.activityTitle) return
  87. getActivityDetail(this.activityId).then(function(res) {
  88. if (res && res.code === 200 && res.data) {
  89. self.activityTitle = res.data.title || ''
  90. }
  91. }).catch(function() {})
  92. },
  93. loadList: function() {
  94. var self = this
  95. this.loading = true
  96. var params = {
  97. activityId: this.activityId,
  98. page: 1,
  99. size: 100
  100. }
  101. if (this.currentFilter !== 'all') {
  102. params.status = this.currentFilter
  103. }
  104. adminActivityRegistrationList(params).then(function(res) {
  105. self.loading = false
  106. if (res && res.code === 200 && res.data) {
  107. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  108. self.registrations = list
  109. } else {
  110. self.registrations = []
  111. }
  112. }).catch(function() {
  113. self.loading = false
  114. self.registrations = []
  115. })
  116. },
  117. onFilterChange: function(value) {
  118. this.currentFilter = value
  119. this.loadList()
  120. },
  121. onApprove: function(row) {
  122. var self = this
  123. uni.showModal({
  124. title: '提示',
  125. content: '确认通过该报名吗?',
  126. success: function(res) {
  127. if (res.confirm) {
  128. adminApproveRegistration({ registrationId: row.id, activityId: self.activityId }).then(function(r) {
  129. if (r && r.code === 200) {
  130. uni.showToast({ title: '已通过', icon: 'success' })
  131. self.loadList()
  132. } else {
  133. uni.showToast({ title: (r && r.message) || '操作失败', icon: 'none' })
  134. }
  135. }).catch(function() {
  136. uni.showToast({ title: '网络异常', icon: 'none' })
  137. })
  138. }
  139. }
  140. })
  141. },
  142. onReject: function(row) {
  143. var self = this
  144. uni.showModal({
  145. title: '提示',
  146. content: '确认拒绝该报名吗?',
  147. success: function(res) {
  148. if (res.confirm) {
  149. adminRejectRegistration({ registrationId: row.id, activityId: self.activityId }).then(function(r) {
  150. if (r && r.code === 200) {
  151. uni.showToast({ title: '已拒绝', icon: 'success' })
  152. self.loadList()
  153. } else {
  154. uni.showToast({ title: (r && r.message) || '操作失败', icon: 'none' })
  155. }
  156. }).catch(function() {
  157. uni.showToast({ title: '网络异常', icon: 'none' })
  158. })
  159. }
  160. }
  161. })
  162. },
  163. statusText: function(status) {
  164. var map = { pending: '待审核', approved: '已通过', rejected: '已拒绝', cancelled: '已取消' }
  165. return map[status] || status || '未知'
  166. },
  167. formatDateTime: function(v) {
  168. if (!v) return ''
  169. var s = String(v)
  170. if (s.indexOf('-') < 0 && s.indexOf('/') < 0) return s
  171. var d = new Date(s.replace(/-/g, '/'))
  172. if (isNaN(d.getTime())) return s
  173. var pad = function(n) { return n < 10 ? '0' + n : '' + n }
  174. return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes())
  175. }
  176. }
  177. }
  178. </script>
  179. <style scoped>
  180. .container {
  181. min-height: 100vh;
  182. background: #F5F5F5;
  183. display: flex;
  184. flex-direction: column;
  185. }
  186. .header {
  187. background: #1A0F00;
  188. padding: 20rpx 24rpx;
  189. text-align: center;
  190. }
  191. .header-title {
  192. color: #fff;
  193. font-size: 30rpx;
  194. font-weight: 600;
  195. overflow: hidden;
  196. text-overflow: ellipsis;
  197. white-space: nowrap;
  198. }
  199. .filter-scroll {
  200. padding: 20rpx 24rpx;
  201. background: #fff;
  202. }
  203. .filter-chips {
  204. display: flex;
  205. flex-direction: row;
  206. gap: 16rpx;
  207. }
  208. .filter-chip {
  209. padding: 12rpx 24rpx;
  210. border-radius: 16px;
  211. background: #fff;
  212. border: 1rpx solid #ddd;
  213. flex-shrink: 0;
  214. }
  215. .filter-chip.active {
  216. background: #FFF7ED;
  217. border-color: #F97316;
  218. }
  219. .filter-label {
  220. font-size: 24rpx;
  221. color: #666;
  222. }
  223. .filter-chip.active .filter-label {
  224. color: #F97316;
  225. font-weight: 500;
  226. }
  227. .reg-list {
  228. padding: 20rpx 24rpx;
  229. display: flex;
  230. flex-direction: column;
  231. gap: 20rpx;
  232. }
  233. .reg-card {
  234. background: #fff;
  235. border-radius: 12rpx;
  236. padding: 24rpx;
  237. display: flex;
  238. flex-direction: row;
  239. align-items: center;
  240. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
  241. }
  242. .reg-info {
  243. flex: 1;
  244. display: flex;
  245. flex-direction: column;
  246. }
  247. .reg-name-row {
  248. display: flex;
  249. flex-direction: row;
  250. align-items: center;
  251. }
  252. .reg-name {
  253. font-size: 30rpx;
  254. font-weight: 600;
  255. color: #333;
  256. }
  257. .reg-tag {
  258. margin-left: 16rpx;
  259. font-size: 20rpx;
  260. padding: 2rpx 12rpx;
  261. border-radius: 6rpx;
  262. }
  263. .reg-tag-pending {
  264. background: #FFF7ED;
  265. color: #F59E0B;
  266. }
  267. .reg-tag-approved {
  268. background: #F0FDF4;
  269. color: #10B981;
  270. }
  271. .reg-tag-rejected {
  272. background: #F5F5F5;
  273. color: #9CA3AF;
  274. }
  275. .reg-tag-cancelled {
  276. background: #F5F5F5;
  277. color: #9CA3AF;
  278. }
  279. .reg-meta {
  280. font-size: 24rpx;
  281. color: #999;
  282. margin-top: 8rpx;
  283. }
  284. .reg-actions {
  285. display: flex;
  286. flex-direction: row;
  287. gap: 16rpx;
  288. margin-left: 20rpx;
  289. flex-shrink: 0;
  290. }
  291. .btn-approve {
  292. padding: 8rpx 24rpx;
  293. font-size: 24rpx;
  294. color: #fff;
  295. background: linear-gradient(135deg, #F97316, #FB923C);
  296. border: none;
  297. border-radius: 20rpx;
  298. line-height: 1.5;
  299. }
  300. .btn-reject {
  301. padding: 8rpx 24rpx;
  302. font-size: 24rpx;
  303. color: #999;
  304. background: #fff;
  305. border: 1rpx solid #ddd;
  306. border-radius: 20rpx;
  307. line-height: 1.5;
  308. }
  309. .empty-state {
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. justify-content: center;
  314. padding: 120rpx 40rpx;
  315. }
  316. .empty-icon {
  317. font-size: 80rpx;
  318. margin-bottom: 20rpx;
  319. }
  320. .empty-title {
  321. font-size: 32rpx;
  322. font-weight: 600;
  323. color: #333;
  324. margin-bottom: 12rpx;
  325. }
  326. .empty-desc {
  327. font-size: 26rpx;
  328. color: #999;
  329. }
  330. .loading-state {
  331. display: flex;
  332. flex-direction: column;
  333. align-items: center;
  334. justify-content: center;
  335. padding: 80rpx 40rpx;
  336. }
  337. .loading-spinner {
  338. width: 60rpx;
  339. height: 60rpx;
  340. border: 4rpx solid #FDE68A;
  341. border-top-color: #F97316;
  342. border-radius: 50%;
  343. animation: spin 0.8s linear infinite;
  344. margin-bottom: 20rpx;
  345. }
  346. @keyframes spin {
  347. to { transform: rotate(360deg); }
  348. }
  349. .loading-text {
  350. font-size: 26rpx;
  351. color: #999;
  352. }
  353. </style>