task-card.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <script setup lang="ts">
  2. import { storeToRefs } from 'pinia'
  3. import { taskReceive } from '../../../../core/libs/requests'
  4. import { useUserStore } from '../../../../store'
  5. import Card from '@designer-hub/app/src/components/card.vue'
  6. import dayjs from 'dayjs'
  7. import { useTask } from '../../../../composables/task'
  8. const props = withDefaults(defineProps<{ options: any }>(), { options: () => ({}) })
  9. const userStore = useUserStore()
  10. const { userInfo } = storeToRefs(userStore)
  11. const { types } = useTask()
  12. const status = ref({
  13. 1: {
  14. title: '未开始',
  15. bg: 'bg-[#f04c47]',
  16. bgClass: 'bg-[#f04c47]',
  17. },
  18. 2: { title: '进行中', bg: '', bgClass: 'bg-[#2357e9]' },
  19. 3: { title: '已撤回', bg: '', bgClass: 'bg-[#f04c47]' },
  20. 4: { title: '已完成', bg: '', bgClass: 'bg-[#f04c47]' },
  21. 5: { title: '未完成', bg: '', bgClass: 'bg-[#abacaf]' },
  22. 6: { title: '待确认', bg: '', bgClass: 'bg-[#f04c47]' },
  23. })
  24. const acceptingOrders = async (item) => {
  25. uni.showLoading()
  26. const res = await taskReceive({ brokerId: userInfo.value.userId, taskId: item.id, orders: true })
  27. uni.hideLoading()
  28. // initData()
  29. }
  30. const acceptingNoOrders = async (item) => {
  31. uni.showLoading()
  32. const res = await taskReceive({ brokerId: userInfo.value.userId, taskId: item.id, orders: false })
  33. uni.hideLoading()
  34. // initData()
  35. }
  36. const toDetail = () =>
  37. uni.navigateTo({ url: `/pages/home/tasks/detail/index?taskId=${props.options.id}` })
  38. </script>
  39. <template>
  40. <Card
  41. :custom-class="`${types[options.taskType].bgClass} p-0`"
  42. style="padding: 0"
  43. @click="toDetail"
  44. >
  45. <div class="flex p-4 items-center">
  46. <div
  47. :class="`${status[options.status].bgClass} w-[47px] h-[23px] px-1 rounded border justify-center items-center gap-2.5 inline-flex`"
  48. >
  49. <div class="text-right text-white text-xs font-normal font-['PingFang_SC'] leading-tight">
  50. {{ status[options.status].title }}
  51. </div>
  52. </div>
  53. <div class="mx-2.5 text-black/90 text-lg font-normal font-['PingFang_SC'] leading-none">
  54. {{ types[options.taskType].title }}
  55. </div>
  56. <div class="flex-1"></div>
  57. <div class="mx-1.5 text-black/40 text-xs font-normal font-['PingFang_SC'] leading-none">
  58. 奖励积分
  59. </div>
  60. <div class="text-[#ff2e2e] text-[22px] font-medium font-['DIN'] leading-none">
  61. {{ options.pointsReward }}
  62. </div>
  63. </div>
  64. <div class="flex flex-col gap-4 bg-white p-5 rounded-2xl">
  65. <div>
  66. <span class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">
  67. 任务名称:
  68. </span>
  69. <span class="text-black/60 text-sm font-normal font-['PingFang_SC'] leading-none">
  70. {{ options.name }}
  71. </span>
  72. </div>
  73. <div>
  74. <span class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">
  75. 发起方:
  76. </span>
  77. <span class="text-black/60 text-sm font-normal font-['PingFang_SC'] leading-none">
  78. {{ options.bearerName }}
  79. </span>
  80. </div>
  81. <div>
  82. <span class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-none">
  83. 任务时间:
  84. </span>
  85. <span class="text-black/60 text-sm font-normal font-['PingFang_SC'] leading-none">
  86. {{ dayjs(options.startTime).format('YYYY/MM/DD') }}-{{
  87. dayjs(options.endTime).format('YYYY/MM/DD')
  88. }}
  89. </span>
  90. </div>
  91. <div class="flex items-center border-t border-t-solid border-t-[#efefef] pt-1.5">
  92. <div class="text-black/90 text-sm font-normal font-['PingFang SC']">
  93. 目标 {{ options.storeQuantity }}
  94. </div>
  95. <template v-if="!options.receive">
  96. <div class="flex-1"></div>
  97. <div class="text-black/90 text-sm font-normal font-['PingFang SC']">
  98. 个人完成
  99. <span style="color: #2357e9">{{ options.personalCompletedNum }}</span>
  100. </div>
  101. <div class="flex-1"></div>
  102. <div class="text-black/90 text-sm font-normal font-['PingFang SC']">
  103. 累计完成
  104. <span style="color: #f1981b">{{ options.completedNum }}</span>
  105. </div>
  106. </template>
  107. <template v-else>
  108. <div class="flex-1"></div>
  109. <div
  110. v-if="options.receive"
  111. class="mr-[16px] w-[68px] h-7 px-2.5 py-[3px] rounded-[30px] border border-[#fe5053] justify-center items-center gap-2.5 inline-flex"
  112. style="border: 1px solid #fe5053"
  113. @click.stop="acceptingNoOrders(options)"
  114. >
  115. <div class="w-9 text-[#ff2d2d] text-xs font-normal font-['PingFang SC']">不接单</div>
  116. </div>
  117. <div
  118. v-if="options.receive"
  119. @click.stop="acceptingOrders(options)"
  120. class="w-[68px] h-7 px-2.5 py-[3px] bg-[#2357e9] rounded-[30px] justify-center items-center gap-2.5 inline-flex"
  121. >
  122. <div class="text-white text-xs font-normal font-['PingFang SC']">接单</div>
  123. </div>
  124. </template>
  125. </div>
  126. </div>
  127. </Card>
  128. </template>