review.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view class="review-page" :style="{ '--font-scale': fontScale }">
  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. import fontScaleMixin from '@/mixins/font-scale.js'
  75. export default {
  76. mixins: [fontScaleMixin],
  77. components: {
  78. PlayfulCard,
  79. PlayfulButton,
  80. BaseBadge,
  81. BaseEmpty,
  82. BaseLoading
  83. },
  84. data() {
  85. return {
  86. tab: 'pending',
  87. taskList: [],
  88. pendingCount: 0,
  89. loading: false
  90. }
  91. },
  92. watch: {
  93. tab() {
  94. this.loadTasks()
  95. }
  96. },
  97. onShow() {
  98. this.loadTasks()
  99. },
  100. methods: {
  101. switchTab(tabName) {
  102. if (this.tab !== tabName) {
  103. this.tab = tabName
  104. }
  105. },
  106. async loadTasks() {
  107. this.loading = true
  108. try {
  109. if (this.tab === 'pending') {
  110. const res = await getPendingReviewTasks()
  111. this.taskList = res.data || []
  112. this.pendingCount = this.taskList.length
  113. } else {
  114. const res = await getTaskHistory()
  115. this.taskList = (res.data && res.data.records) || []
  116. }
  117. } catch (e) {
  118. console.error(e)
  119. } finally {
  120. this.loading = false
  121. }
  122. },
  123. async handleApprove(taskId) {
  124. try {
  125. await approveTask(taskId)
  126. uni.showToast({ title: '已通过', icon: 'success' })
  127. this.loadTasks()
  128. } catch (e) {
  129. uni.showToast({ title: '操作失败', icon: 'none' })
  130. }
  131. },
  132. async handleReject(taskId) {
  133. try {
  134. await rejectTask(taskId)
  135. uni.showToast({ title: '已拒绝', icon: 'success' })
  136. this.loadTasks()
  137. } catch (e) {
  138. uni.showToast({ title: '操作失败', icon: 'none' })
  139. }
  140. }
  141. }
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .review-page {
  146. min-height: 100vh;
  147. background: var(--bg, $uni-bg-color);
  148. padding: 24rpx var(--page-padding, 32rpx);
  149. }
  150. /* ============================================================
  151. Tab Bar
  152. ============================================================ */
  153. .tab-bar {
  154. position: relative;
  155. display: flex;
  156. background: var(--surface, $app-surface);
  157. border-radius: var(--radius-md, 20rpx);
  158. padding: 8rpx;
  159. margin-bottom: 32rpx;
  160. box-shadow: var(--shadow-sm, 0 4rpx 12rpx rgba(249,115,22,0.06));
  161. border: 1px solid var(--border-light, $uni-border-color-light);
  162. }
  163. .tab-bar__item {
  164. flex: 1;
  165. display: flex;
  166. align-items: center;
  167. justify-content: center;
  168. padding: 22rpx 16rpx;
  169. border-radius: var(--radius-sm, 12rpx);
  170. position: relative;
  171. z-index: 2;
  172. transition: transform var(--transition-base, 0.25s ease);
  173. cursor: pointer;
  174. }
  175. .tab-bar__item:active {
  176. transform: scale(0.97);
  177. }
  178. .tab-bar__item--active {
  179. background: var(--bg, $uni-bg-color);
  180. }
  181. .tab-bar__label {
  182. font-size: calc(28rpx * var(--font-scale, 1));
  183. font-weight: 600;
  184. color: var(--text-secondary, $uni-text-color-secondary);
  185. transition: color var(--transition-base, 0.25s ease);
  186. }
  187. .tab-bar__item--active .tab-bar__label {
  188. color: var(--color-primary, $brand-primary);
  189. }
  190. .tab-bar__item--active::after {
  191. content: '';
  192. position: absolute;
  193. bottom: 6rpx;
  194. left: 50%;
  195. transform: translateX(-50%);
  196. width: 40%;
  197. height: 4rpx;
  198. background: var(--color-primary, $brand-primary);
  199. border-radius: 8rpx;
  200. }
  201. .tab-bar__badge {
  202. background: var(--color-primary, $brand-primary);
  203. border-radius: 999rpx;
  204. min-width: 36rpx;
  205. height: 36rpx;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. padding: 0 8rpx;
  210. margin-left: 8rpx;
  211. box-shadow: 0 2rpx 8rpx rgba(249,115,22,0.3);
  212. }
  213. .tab-bar__badge-text {
  214. font-size: calc(20rpx * var(--font-scale, 1));
  215. font-weight: 700;
  216. color: $app-surface;
  217. line-height: 1;
  218. }
  219. /* ============================================================
  220. Task List
  221. ============================================================ */
  222. .task-list {
  223. display: flex;
  224. flex-direction: column;
  225. gap: 24rpx;
  226. padding-bottom: 32rpx;
  227. }
  228. /* ============================================================
  229. Card Body (inside PlayfulCard default slot)
  230. ============================================================ */
  231. .card-body {
  232. display: flex;
  233. flex-direction: column;
  234. gap: 12rpx;
  235. }
  236. .card-title {
  237. font-size: calc(30rpx * var(--font-scale, 1));
  238. font-weight: 700;
  239. color: var(--text, $uni-text-color);
  240. line-height: 1.4;
  241. }
  242. .card-title--flex {
  243. flex: 1;
  244. min-width: 0;
  245. overflow: hidden;
  246. text-overflow: ellipsis;
  247. white-space: nowrap;
  248. }
  249. .card-desc {
  250. font-size: calc(26rpx * var(--font-scale, 1));
  251. color: var(--text-secondary, $uni-text-color-secondary);
  252. line-height: 1.5;
  253. overflow: hidden;
  254. text-overflow: ellipsis;
  255. white-space: nowrap;
  256. }
  257. .card-header-row {
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. gap: 16rpx;
  262. }
  263. .card-meta-row {
  264. display: flex;
  265. align-items: center;
  266. justify-content: space-between;
  267. font-size: calc(24rpx * var(--font-scale, 1));
  268. }
  269. .card-provider {
  270. color: var(--text-secondary, $uni-text-color-secondary);
  271. }
  272. .card-points {
  273. color: var(--color-primary, $brand-primary);
  274. font-weight: 600;
  275. }
  276. .card-time {
  277. font-size: calc(22rpx * var(--font-scale, 1));
  278. color: var(--muted, $app-text-subtle);
  279. margin-top: 4rpx;
  280. }
  281. /* ============================================================
  282. Card Actions
  283. ============================================================ */
  284. .card-actions {
  285. display: flex;
  286. gap: 16rpx;
  287. width: 100%;
  288. }
  289. </style>
  290. <style lang="scss">
  291. /* Non-scoped: style PlayfulButton inside actions slot (scoped deep selectors crash HBuilderX postcss) */
  292. .card-actions .playful-btn {
  293. flex: 1;
  294. }
  295. </style>