signIn.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <!-- 签到 -->
  2. <template>
  3. <div>
  4. <integralShow></integralShow>
  5. <div class="text-end signInRecord mt-3" @click="handleRecord">
  6. {{ $t('taskCenter.signInRecord') }}
  7. <v-icon>mdi-chevron-right</v-icon>
  8. </div>
  9. <div class="d-flex justify-center mt-3">
  10. <div v-for="(item, index) in configList" :key="'signInKey' + index" >
  11. <div
  12. class="borderRadius-5 mx-5 py-3 px-4"
  13. style="text-align: center;"
  14. :style="{'background-color': index < continuousDay ? '#10897ba8' : 'var(--color-f2f4f7)'}"
  15. >
  16. <!-- 图标 -->
  17. <div class="mt-1">
  18. <svg v-if="index < continuousDay" t="1719224910498" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="28939" width="36" height="36"><path d="M97.8944 511.7952c0 228.5568 185.1392 413.696 413.696 413.696s413.696-185.1392 413.696-413.696-185.1392-413.696-413.696-413.696c-109.7728 0-214.8352 43.6224-292.4544 121.2416-77.6192 77.4144-121.2416 182.6816-121.2416 292.4544z m0 0" fill="#FBE945" p-id="28940"></path><path d="M804.2496 219.3408L219.3408 804.4544c162.2016 158.1056 421.2736 156.4672 581.2224-3.6864 160.1536-160.1536 161.5872-419.2256 3.6864-581.4272z m0 0" fill="#F2D636" p-id="28941"></path><path d="M210.944 511.7952c0 121.6512 73.3184 231.2192 185.5488 277.9136 112.4352 46.4896 241.664 20.8896 327.68-65.1264s111.8208-215.4496 65.1264-327.68c-46.4896-112.4352-156.2624-185.5488-277.9136-185.5488-165.888-0.4096-300.4416 134.3488-300.4416 300.4416z m0 0" fill="#FBB11B" p-id="28942"></path><path d="M717.824 293.2736c-118.1696-112.0256-303.9232-109.568-419.0208 5.5296-115.0976 115.0976-117.5552 301.056-5.5296 419.0208l424.5504-424.5504z m0 0" fill="#FDC72F" p-id="28943"></path><path d="M709.8368 351.8464c-2.8672 9.8304-64.7168 61.44-94.0032 100.5568-29.2864 39.1168-67.584 106.9056-91.136 161.792-16.9984 39.7312-17.6128 45.056-35.84 54.8864-18.2272 9.8304-53.248 16.7936-60.2112 11.264-6.9632-5.5296-11.6736-36.0448-38.2976-80.896s-42.8032-48.5376-73.5232-70.0416c-14.336-9.8304 27.2384-33.9968 50.9952-38.0928 23.7568-4.3008 44.4416 10.0352 64.1024 30.9248 19.6608 20.8896 33.1776 49.5616 40.3456 50.9952 6.9632 1.4336 21.0944-46.4896 60.6208-103.2192 35.6352-50.9952 94.6176-115.9168 122.6752-124.3136 27.648-8.192 56.9344-3.6864 54.272 6.144z" fill="#FBE945" p-id="28944"></path><path d="M456.2944 554.8032c6.9632 10.0352 12.0832 17.8176 15.7696 18.432 5.9392 1.2288 16.9984-33.5872 44.8512-79.0528l151.552-151.552c23.1424-3.6864 43.8272 0.8192 41.3696 9.0112-2.8672 9.8304-64.7168 61.44-94.0032 100.5568-29.2864 39.1168-67.584 106.9056-91.136 161.792-16.9984 39.7312-17.6128 45.056-35.84 54.8864-18.2272 9.8304-53.248 16.7936-60.2112 11.264-6.144-4.9152-10.6496-29.9008-30.5152-67.1744l58.1632-58.1632z" fill="#F2D636" p-id="28945"></path></svg>
  19. <svg v-else t="1719224961216" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="29154" width="38" height="38"><path d="M98.0992 511.7952c0 228.5568 185.1392 413.696 413.696 413.696s413.696-185.1392 413.696-413.696-185.1392-413.696-413.696-413.696c-109.7728 0-214.8352 43.6224-292.4544 121.2416-77.6192 77.4144-121.2416 182.6816-121.2416 292.4544z m0 0" fill="#FBE945" p-id="29155"></path><path d="M804.2496 219.3408L219.3408 804.4544c162.2016 158.1056 421.2736 156.4672 581.2224-3.6864 160.1536-160.1536 161.792-419.2256 3.6864-581.4272z m0 0" fill="#F2D636" p-id="29156"></path><path d="M210.944 511.7952c0 121.6512 73.3184 231.2192 185.5488 277.9136 112.4352 46.4896 241.664 20.8896 327.68-65.1264s111.8208-215.4496 65.1264-327.68c-46.4896-112.4352-156.2624-185.5488-277.9136-185.5488C345.7024 210.944 210.944 345.7024 210.944 511.7952z m0 0" fill="#FBB11B" p-id="29157"></path><path d="M717.824 293.2736c-118.1696-112.0256-303.9232-109.568-419.0208 5.5296-115.0976 115.0976-117.5552 301.056-5.5296 419.0208l424.5504-424.5504z m0 0" fill="#FDC72F" p-id="29158"></path><path d="M648.3968 566.4768c23.7568 125.1328-22.9376 157.696-138.4448 97.8944-118.1696 64.3072-163.0208 32.5632-136.6016-93.3888-96.0512-85.4016-77.6192-137.4208 54.6816-156.0576 58.1632-116.3264 114.688-117.1456 170.1888-2.6624 131.2768 14.1312 148.0704 65.3312 50.176 154.2144z m0 0" fill="#F4EA2A" p-id="29159"></path><path d="M598.2208 412.2624c131.2768 14.1312 148.0704 65.1264 50.176 154.2144 23.7568 125.1328-22.9376 157.696-138.4448 97.8944-90.112 49.152-137.6256 42.1888-143.36-19.8656l231.6288-232.2432z m50.176 154.2144" fill="#F2D636" p-id="29160"></path></svg>
  20. </div>
  21. <div class="mt-2" :style="{'color': index < continuousDay ? '#fff' : 'var(--color-333)'}">
  22. <span class="font-12">+</span>
  23. <span>{{ item.point }}</span>
  24. </div>
  25. </div>
  26. <div class="mt-2 font-13" style="text-align: center;" :style="{'color': index < continuousDay ? '#10897b' : 'var(--color-333)'}">
  27. {{ `${index === todayNumber ? '今天' : '第' + item.day + '天'}` }}
  28. </div>
  29. </div>
  30. </div>
  31. <div class="mt-8" style="text-align: right;">
  32. <span v-if="continuousDay > 0" class="font-13 color-777 mr-3">
  33. 您已经连续签到
  34. <span class="mx-1" style="color: var(--v-primary-base); font-weight: 600;"> {{ continuousDay }} </span>
  35. 天,明天再来吧
  36. </span>
  37. <v-btn class="half-button" color="primary" size="small" :loading="signLoading" :disabled="todaySignIn" @click="handleSignIn">{{ todaySignIn ? '已签到' : '签到' }}</v-btn>
  38. </div>
  39. <!-- 签到记录 -->
  40. <!-- <v-navigation-drawer v-model="drawer" location="right" temporary width="600" class="drawer">
  41. <v-data-table
  42. :items="recordList"
  43. :headers="headers"
  44. disable-sort
  45. height="80vh"
  46. >
  47. <template #bottom></template>
  48. </v-data-table>
  49. <CtPagination
  50. v-if="total > 0"
  51. :total="total"
  52. :page="pageNo"
  53. :limit="pageSize"
  54. @handleChange="handleChangePage"
  55. ></CtPagination>
  56. </v-navigation-drawer> -->
  57. </div>
  58. </template>
  59. <script setup>
  60. defineOptions({name: 'personal-taskCenter-signIn'})
  61. import { ref } from 'vue'
  62. // import { timesTampChange } from '@/utils/date'
  63. import { useI18n } from '@/hooks/web/useI18n'
  64. import {
  65. getRewardSignInRecordSummary,
  66. getRewardSignInConfigList,
  67. createRewardSignInRecord,
  68. // getRewardSignInRecordPage
  69. } from '@/api/sign'
  70. import integralShow from '@/views/integral/components/integralShow.vue'
  71. import Snackbar from '@/plugins/snackbar'
  72. const { t } = useI18n()
  73. // 连续签到天数
  74. const continuousDay = ref(0)
  75. // 今天有无签到
  76. const todaySignIn = ref(false)
  77. // 规则列表
  78. const configList = ref([])
  79. const todayNumber = ref()
  80. const signLoading = ref(false)
  81. // 签到记录
  82. // const total = ref(0)
  83. // const drawer = ref(false)
  84. // const pageSize = ref(10)
  85. // const pageNo = ref(1)
  86. // const recordList = ref([])
  87. // const headers = [
  88. // { title: t('taskCenter.signInDays'), key: 'day' },
  89. // { title: t('taskCenter.points'), key: 'point' },
  90. // { title: t('taskCenter.createTime'), key: 'createTime', value: item => timesTampChange(item.createTime)}
  91. // ]
  92. // 获取签到规则列表
  93. const getConfigList = async () => {
  94. const data = await getRewardSignInConfigList()
  95. configList.value = data
  96. }
  97. getConfigList()
  98. // 获取个人签到统计
  99. const getSummary = async () => {
  100. const data = await getRewardSignInRecordSummary()
  101. if (!data) return
  102. continuousDay.value = data.continuousDay // 连续签到第n天
  103. todaySignIn.value = data.todaySignIn // 今天有无签到
  104. todayNumber.value = todaySignIn.value ? continuousDay.value - 1 : continuousDay.value
  105. }
  106. getSummary()
  107. // 签到
  108. const handleSignIn = async () => {
  109. signLoading.value = true
  110. await createRewardSignInRecord()
  111. setTimeout(async () => {
  112. await getSummary()
  113. Snackbar.success(t('taskCenter.signInSuccess'))
  114. signLoading.value = false
  115. }, 1000)
  116. }
  117. // 签到记录
  118. // const getRecordList = async () => {
  119. // const res = await getRewardSignInRecordPage(pageNo.value, pageSize.value)
  120. // recordList.value = res.list
  121. // total.value = res.total
  122. // }
  123. const handleRecord = () => {
  124. // drawer.value = true
  125. // pageNo.value = 1
  126. // recordList.value = []
  127. // getRecordList()
  128. window.open('/integral/pointsManagement')
  129. }
  130. // const handleChangePage = (e) => {
  131. // pageNo.value = e
  132. // getRecordList()
  133. // }
  134. </script>
  135. <style lang="scss" scoped>
  136. .color-333 { color: var(--color-333); }
  137. .color-fff { color: #fff; }
  138. .color-777 { color: var(--color-666); }
  139. .font-12 { font-size: 12px; }
  140. .font-13 { font-size: 13px; }
  141. .font-14 { font-size: 14; }
  142. .font-16 { font-size: 16px; }
  143. .borderRadius-5 { border-radius: 5px; }
  144. .signInRecord {
  145. font-size: 14px;
  146. color: var(--v-primary-base);
  147. cursor: pointer;
  148. }
  149. </style>