tasks-card.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <script setup lang="ts">
  2. import { Task } from '../../../core/libs/models'
  3. import { taskCenterBg } from '../../../core/libs/pngs'
  4. import { useRouter } from '../../../core/utils/router'
  5. import { usePermissions } from '@/composables/permissions'
  6. const { clickByPermission } = usePermissions()
  7. const router = useRouter()
  8. defineProps({
  9. customClass: {
  10. type: String,
  11. default: '',
  12. },
  13. items: {
  14. type: Array as PropType<(Task & { btnProps: any })[]>,
  15. default: () => [],
  16. },
  17. })
  18. const styles = ref({
  19. header: {
  20. width: '100%',
  21. height: '60px',
  22. background: `url(${taskCenterBg}) -9px -9px`,
  23. },
  24. content: {
  25. background: `url(${taskCenterBg}) -9px -69px no-repeat`,
  26. },
  27. main: {
  28. background: `url(${taskCenterBg}) -9px -9px`,
  29. },
  30. })
  31. const taskExtends = ref([
  32. {
  33. id: 1,
  34. action: () => router.push('/pages-sub/publish/moment/index?circleType=1'),
  35. completed: false,
  36. },
  37. ])
  38. const taskExtendsById = computed(() =>
  39. taskExtends.value.reduce((acc, item) => {
  40. acc[item.id] = item
  41. return acc
  42. }, {}),
  43. )
  44. onMounted(async () => {})
  45. </script>
  46. <template>
  47. <view class="relative w-full box-border">
  48. <view class="relative h-full mx--2.5 mb--6 mt--1 box-border">
  49. <wd-img :width="'100%'" :height="'100%'" :src="taskCenterBg" mode="widthFix"></wd-img>
  50. </view>
  51. <view class="absolute left-0 right-0 top-1 bottom-6 z-1 p-3.5">
  52. <view class="w-full h-full flex flex-col justify-between">
  53. <div class="text-start text-black text-lg font-normal font-['PingFang_SC'] leading-normal">
  54. 任务中心
  55. </div>
  56. <div class="flex-grow mt-4 overflow-auto">
  57. <template v-for="({ taskKey, taskValue, status, id, btnProps }, i) in items" :key="i">
  58. <div class="flex items-center my-6">
  59. <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
  60. {{ taskKey }}
  61. </div>
  62. <div
  63. v-if="Number(taskValue) !== 0"
  64. class="ml-1 text-[#dc753a] text-xs font-normal font-['PingFang_SC'] leading-normal"
  65. >
  66. +{{ taskValue }}积分
  67. </div>
  68. <div class="flex-1"></div>
  69. <wd-button
  70. type="info"
  71. plain
  72. size="small"
  73. :disabled="btnProps?.disabled"
  74. @click="clickByPermission('task', () => btnProps?.onClick())"
  75. >
  76. {{ btnProps?.content }}
  77. <!-- {{ taskExtendsById[id]?.completed ? '已完成' : '去完成' }} -->
  78. </wd-button>
  79. </div>
  80. </template>
  81. </div>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- <div>
  86. <div :style="styles.header">1</div>
  87. <div :style="styles.content" class="p-3.5">
  88. <template v-for="({ title, score }, i) in items" :key="i">
  89. <div class="flex items-center my-6">
  90. <div class="text-black/90 text-sm font-normal font-['PingFang_SC'] leading-normal">
  91. {{ title }}
  92. </div>
  93. <div class="ml-1 text-[#dc753a] text-xs font-normal font-['PingFang_SC'] leading-normal">
  94. +{{ score }}积分
  95. </div>
  96. <div class="flex-1"></div>
  97. <wd-button type="info" plain size="small">去完成</wd-button>
  98. </div>
  99. </template>
  100. </div>
  101. <div></div>
  102. </div> -->
  103. <!-- <div class="card" :style="styles.main">
  104. <div class="card-content">
  105. <h2>任务中心</h2>
  106. <ul>
  107. <li>每日发布圈子获取积分</li>
  108. <li>到店打卡获取积分</li>
  109. <li>到店打卡获取积分</li>
  110. <li>到店打卡获取积分</li>
  111. <li>到店打卡获取积分</li>
  112. <li>到店打卡获取积分</li>
  113. <li>到店打卡获取积分</li>
  114. <li>到店打卡获取积分</li>
  115. <li>到店打卡获取积分</li>
  116. <li>到店打卡获取积分</li>
  117. <li>到店打卡获取积分</li>
  118. <li>到店打卡获取积分</li>
  119. <li>到店打卡获取积分</li>
  120. <li>到店打卡获取积分</li>
  121. <li>到店打卡获取积分</li>
  122. </ul>
  123. </div>
  124. </div> -->
  125. </template>
  126. <style scoped>
  127. .card {
  128. box-sizing: border-box;
  129. display: flex;
  130. flex-direction: column;
  131. justify-content: flex-start;
  132. width: 100%;
  133. min-height: 200px;
  134. padding: 20px;
  135. /* background-image: url('your-image-path'); */
  136. /* 背景图片路径 */
  137. background-repeat: no-repeat;
  138. background-position: top center; /* 背景图片头部固定 */
  139. background-size: auto; /* 固定背景图片的宽度,不拉伸 */
  140. border-radius: 10px;
  141. }
  142. .card-content {
  143. flex-grow: 1;
  144. padding: 20px;
  145. background-color: rgba(255, 255, 255, 0.8); /* 半透明背景 */
  146. border-radius: 10px;
  147. }
  148. </style>