review.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="review-page">
  3. <!-- Tab Bar -->
  4. <view class="tab-bar">
  5. <view class="tab-bar__item" :class="{ 'tab-bar__item--active': tab === 'pending' }" @click="switchTab('pending')">
  6. <text class="tab-bar__label">📋 待审核</text>
  7. <view class="tab-bar__badge" v-if="pendingCount > 0">
  8. <text class="tab-bar__badge-text">{{ pendingCount > 99 ? '99+' : pendingCount }}</text>
  9. </view>
  10. </view>
  11. <view class="tab-bar__item" :class="{ 'tab-bar__item--active': tab === 'history' }" @click="switchTab('history')">
  12. <text class="tab-bar__label">📜 审核历史</text>
  13. </view>
  14. </view>
  15. <!-- Loading State -->
  16. <BaseLoading :loading="loading" text="加载中..." />
  17. <!-- Task List -->
  18. <view class="task-list" v-if="!loading && taskList.length > 0">
  19. <view v-for="(task, index) in taskList" :key="task.id" class="task-list__item">
  20. <!-- Pending Tab - Review Cards with Actions -->
  21. <PlayfulCard v-if="tab === 'pending'" variant="flat" shadow="sm"
  22. :class="'animate-slide-up animate-stagger-' + ((index % 10) + 1)">
  23. <view class="card-body">
  24. <text class="card-title">{{ task.title }}</text>
  25. <text class="card-desc">{{ task.description }}</text>
  26. <view class="card-meta-row">
  27. <text class="card-provider">提供者: {{ task.creatorRole === 'parent' ? '家长' : '孩子' }}</text>
  28. <text class="card-points">⭐ +{{ task.points }}</text>
  29. </view>
  30. </view>
  31. <view slot="actions" class="card-actions">
  32. <PlayfulButton variant="success" size="sm" @click="handleApprove(task.id)">✓ 通过</PlayfulButton>
  33. <PlayfulButton variant="error" size="sm" @click="handleReject(task.id)">✗ 拒绝</PlayfulButton>
  34. </view>
  35. </PlayfulCard>
  36. <!-- History Tab - Review Cards with Status -->
  37. <PlayfulCard v-if="tab === 'history'" variant="flat" shadow="sm"
  38. :class="'animate-slide-up animate-stagger-' + ((index % 10) + 1)">
  39. <view class="card-body">
  40. <view class="card-header-row">
  41. <text class="card-title card-title--flex">{{ task.title }}</text>
  42. <BaseBadge v-if="task.status === 'approved'" variant="success" size="sm">✅ 已通过</BaseBadge>
  43. <BaseBadge v-if="task.status === 'rejected'" variant="error" size="sm">❌ 已拒绝</BaseBadge>
  44. </view>
  45. <text class="card-desc">{{ task.description }}</text>
  46. <view class="card-meta-row">
  47. <text class="card-provider">提供者: {{ task.creatorRole === 'parent' ? '家长' : '孩子' }}</text>
  48. <text class="card-points">⭐ +{{ task.points }}</text>
  49. </view>
  50. <text class="card-time" v-if="task.reviewTime">审核时间: {{ task.reviewTime }}</text>
  51. </view>
  52. </PlayfulCard>
  53. </view>
  54. </view>
  55. <!-- Empty States -->
  56. <BaseEmpty v-if="!loading && taskList.length === 0 && tab === 'pending'"
  57. icon="🎉"
  58. title="没有待审核的任务"
  59. description="家长可以休息一下啦~"
  60. />
  61. <BaseEmpty v-if="!loading && taskList.length === 0 && tab === 'history'"
  62. icon="📜"
  63. title="还没有审核记录"
  64. />
  65. </view>
  66. </template>
  67. <script>
  68. import { getPendingReviewTasks, approveTask, rejectTask, getTaskHistory } from '../../utils/api.js'
  69. import PlayfulCard from '../../components/PlayfulCard.vue'
  70. import PlayfulButton from '../../components/PlayfulButton.vue'
  71. import BaseBadge from '../../components/BaseBadge.vue'
  72. import BaseEmpty from '../../components/BaseEmpty.vue'
  73. import BaseLoading from '../../components/BaseLoading.vue'
  74. export default {
  75. components: {
  76. PlayfulCard,
  77. PlayfulButton,
  78. BaseBadge,
  79. BaseEmpty,
  80. BaseLoading
  81. },
  82. data() {
  83. return {
  84. tab: 'pending',
  85. taskList: [],
  86. pendingCount: 0,
  87. loading: false
  88. }
  89. },
  90. watch: {
  91. tab() {
  92. this.loadTasks()
  93. }
  94. },
  95. onShow() {
  96. this.loadTasks()
  97. },
  98. methods: {
  99. switchTab(tabName) {
  100. if (this.tab !== tabName) {
  101. this.tab = tabName
  102. }
  103. },
  104. async loadTasks() {
  105. this.loading = true
  106. try {
  107. if (this.tab === 'pending') {
  108. const res = await getPendingReviewTasks()
  109. this.taskList = res.data || []
  110. this.pendingCount = this.taskList.length
  111. } else {
  112. const res = await getTaskHistory()
  113. this.taskList = (res.data && res.data.records) || []
  114. }
  115. } catch (e) {
  116. console.error(e)
  117. } finally {
  118. this.loading = false
  119. }
  120. },
  121. async handleApprove(taskId) {
  122. try {
  123. await approveTask(taskId)
  124. uni.showToast({ title: '已通过', icon: 'success' })
  125. this.loadTasks()
  126. } catch (e) {
  127. uni.showToast({ title: '操作失败', icon: 'none' })
  128. }
  129. },
  130. async handleReject(taskId) {
  131. try {
  132. await rejectTask(taskId)
  133. uni.showToast({ title: '已拒绝', icon: 'success' })
  134. this.loadTasks()
  135. } catch (e) {
  136. uni.showToast({ title: '操作失败', icon: 'none' })
  137. }
  138. }
  139. }
  140. }
  141. </script>
  142. <style scoped>
  143. .review-page {
  144. min-height: 100vh;
  145. background: var(--bg, #F5F9FC);
  146. padding: 24rpx var(--page-padding, 32rpx);
  147. }
  148. /* ============================================================
  149. Tab Bar
  150. ============================================================ */
  151. .tab-bar {
  152. position: relative;
  153. display: flex;
  154. background: var(--surface, #FFFFFF);
  155. border-radius: var(--radius-md, 20rpx);
  156. padding: 8rpx;
  157. margin-bottom: 32rpx;
  158. box-shadow: var(--shadow-sm, 0 4rpx 12rpx rgba(91, 155, 213, 0.06));
  159. border: 1px solid var(--border-light, #E2E8F0);
  160. }
  161. .tab-bar__item {
  162. flex: 1;
  163. display: flex;
  164. align-items: center;
  165. justify-content: center;
  166. padding: 22rpx 16rpx;
  167. border-radius: var(--radius-sm, 12rpx);
  168. position: relative;
  169. z-index: 2;
  170. transition: all var(--transition-base, 0.25s ease);
  171. cursor: pointer;
  172. }
  173. .tab-bar__item:active {
  174. transform: scale(0.97);
  175. }
  176. .tab-bar__item--active {
  177. background: var(--bg, #F5F9FC);
  178. }
  179. .tab-bar__label {
  180. font-size: 28rpx;
  181. font-weight: 600;
  182. color: var(--text-secondary, #64748B);
  183. transition: color var(--transition-base, 0.25s ease);
  184. }
  185. .tab-bar__item--active .tab-bar__label {
  186. color: var(--color-primary, #5B9BD5);
  187. }
  188. .tab-bar__item--active::after {
  189. content: '';
  190. position: absolute;
  191. bottom: 6rpx;
  192. left: 50%;
  193. transform: translateX(-50%);
  194. width: 40%;
  195. height: 4rpx;
  196. background: var(--color-primary, #5B9BD5);
  197. border-radius: 4rpx;
  198. }
  199. .tab-bar__badge {
  200. background: var(--color-primary, #5B9BD5);
  201. border-radius: 999rpx;
  202. min-width: 36rpx;
  203. height: 36rpx;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. padding: 0 8rpx;
  208. margin-left: 8rpx;
  209. box-shadow: 0 2rpx 8rpx rgba(91, 155, 213, 0.3);
  210. }
  211. .tab-bar__badge-text {
  212. font-size: 20rpx;
  213. font-weight: 700;
  214. color: #FFFFFF;
  215. line-height: 1;
  216. }
  217. /* ============================================================
  218. Task List
  219. ============================================================ */
  220. .task-list {
  221. display: flex;
  222. flex-direction: column;
  223. gap: 24rpx;
  224. padding-bottom: 32rpx;
  225. }
  226. /* ============================================================
  227. Card Body (inside PlayfulCard default slot)
  228. ============================================================ */
  229. .card-body {
  230. display: flex;
  231. flex-direction: column;
  232. gap: 12rpx;
  233. }
  234. .card-title {
  235. font-size: 30rpx;
  236. font-weight: 700;
  237. color: var(--text, #1E293B);
  238. line-height: 1.4;
  239. }
  240. .card-title--flex {
  241. flex: 1;
  242. min-width: 0;
  243. overflow: hidden;
  244. text-overflow: ellipsis;
  245. white-space: nowrap;
  246. }
  247. .card-desc {
  248. font-size: 26rpx;
  249. color: var(--text-secondary, #64748B);
  250. line-height: 1.5;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. .card-header-row {
  256. display: flex;
  257. align-items: center;
  258. justify-content: space-between;
  259. gap: 16rpx;
  260. }
  261. .card-meta-row {
  262. display: flex;
  263. align-items: center;
  264. justify-content: space-between;
  265. font-size: 24rpx;
  266. }
  267. .card-provider {
  268. color: var(--text-secondary, #64748B);
  269. }
  270. .card-points {
  271. color: var(--color-primary, #5B9BD5);
  272. font-weight: 600;
  273. }
  274. .card-time {
  275. font-size: 22rpx;
  276. color: var(--muted, #94A3B8);
  277. margin-top: 4rpx;
  278. }
  279. /* ============================================================
  280. Card Actions
  281. ============================================================ */
  282. .card-actions {
  283. display: flex;
  284. gap: 16rpx;
  285. width: 100%;
  286. }
  287. </style>
  288. <style lang="scss">
  289. /* Non-scoped: style PlayfulButton inside actions slot (scoped deep selectors crash HBuilderX postcss) */
  290. .card-actions .playful-btn {
  291. flex: 1;
  292. }
  293. </style>