DimensionTasks.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="section" v-if="displayTasks && displayTasks.length > 0">
  3. <view class="section-header">
  4. <text class="section-title">📋 今日任务</text>
  5. <text class="section-more" @click="$emit('moreTasks')">全部 ›</text>
  6. </view>
  7. <view class="task-list">
  8. <view class="task-card" v-for="task in displayTasks" :key="task.id" @click="$emit('taskClick', task)">
  9. <view class="task-left">
  10. <view class="task-check" :class="{ 'checked': task.status === 'completed' }">
  11. <text class="task-check-icon" v-if="task.status === 'completed'">✓</text>
  12. </view>
  13. </view>
  14. <view class="task-content">
  15. <text class="task-name" :class="{ 'done': task.status === 'completed' }">{{ task.title }}</text>
  16. <view class="task-meta">
  17. <text class="task-points" v-if="task.points">+{{ task.points }}分</text>
  18. <text class="task-penalty" v-if="task.penalty">-{{ task.penalty }}分</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import api from '@/utils/api.js'
  27. export default {
  28. props: {
  29. tasks: { type: Array, default: function() { return [] } },
  30. memberId: { type: Number, default: null }
  31. },
  32. data: function() {
  33. return {
  34. tasksData: []
  35. }
  36. },
  37. computed: {
  38. displayTasks: function() {
  39. return this.tasksData.length > 0 ? this.tasksData : this.tasks
  40. }
  41. },
  42. created: function() {
  43. this.loadTasks()
  44. },
  45. methods: {
  46. loadTasks: function() {
  47. var self = this
  48. if (!self.memberId) return
  49. self.loading = true
  50. api.getTodayTasks(self.memberId).then(function(res) {
  51. self.loading = false
  52. self.tasksData = Array.isArray(res.data) ? res.data : (res.data.records || [])
  53. }).catch(function() {
  54. self.loading = false
  55. self.tasksData = []
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. .section {
  63. margin: 20rpx 20rpx;
  64. }
  65. .section-header {
  66. display: flex;
  67. justify-content: space-between;
  68. align-items: center;
  69. margin-bottom: 20rpx;
  70. }
  71. .section-title {
  72. font-size: 30rpx;
  73. font-weight: bold;
  74. color: #333;
  75. }
  76. .section-more {
  77. font-size: 24rpx;
  78. color: #999;
  79. }
  80. .task-list {
  81. display: flex;
  82. flex-direction: column;
  83. }
  84. .task-card {
  85. display: flex;
  86. flex-direction: row;
  87. align-items: center;
  88. background: #fff;
  89. border-radius: 16rpx;
  90. padding: 24rpx 20rpx;
  91. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  92. margin-bottom: 16rpx;
  93. }
  94. .task-card:active { opacity: 0.8; }
  95. .task-left {
  96. margin-right: 20rpx;
  97. }
  98. .task-check {
  99. width: 44rpx;
  100. height: 44rpx;
  101. border-radius: 50%;
  102. border: 3rpx solid #ddd;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. background: #f9f9f9;
  107. }
  108. .task-check.checked {
  109. background: #22C55E;
  110. border-color: #22C55E;
  111. }
  112. .task-check-icon {
  113. font-size: 24rpx;
  114. color: #fff;
  115. font-weight: bold;
  116. }
  117. .task-content {
  118. flex: 1;
  119. display: flex;
  120. flex-direction: row;
  121. justify-content: space-between;
  122. align-items: center;
  123. }
  124. .task-name {
  125. font-size: 28rpx;
  126. color: #333;
  127. }
  128. .task-name.done {
  129. text-decoration: line-through;
  130. color: #999;
  131. }
  132. .task-meta {
  133. display: flex;
  134. flex-direction: row;
  135. align-items: center;
  136. }
  137. .task-points {
  138. font-size: 24rpx;
  139. color: #22C55E;
  140. margin-right: 12rpx;
  141. }
  142. .task-penalty {
  143. font-size: 24rpx;
  144. color: #EF4444;
  145. }
  146. </style>