Kaynağa Gözat

feat: 签到接口对接

liangan 1 hafta önce
ebeveyn
işleme
03d2543c3e
2 değiştirilmiş dosya ile 28 ekleme ve 17 silme
  1. 9 2
      src/api/mine.ts
  2. 19 15
      src/pages/missionCenter/missionCenter.vue

+ 9 - 2
src/api/mine.ts

@@ -45,6 +45,13 @@ export function addressDel(data: any) {
  * 七日签到列表
  * @returns
  */
-export function todayDetail() {
-  return http.post<any>(`/mall/user/sign/todayDetail`)
+export function todayDetail(data: any) {
+  return http.post<any>(`/mall/user/sign/todayDetail?${qs(data)}`)
+}
+/**
+ * 签到
+ * @returns
+ */
+export function clockIn(data: any) {
+  return http.post<any>(`/mall/user/sign/clockIn?${qs(data)}`)
 }

+ 19 - 15
src/pages/missionCenter/missionCenter.vue

@@ -10,12 +10,16 @@
 
 <script lang="ts" setup>
 import { ref } from 'vue'
-import { todayDetail } from '@/api/mine'
+import { clockIn, todayDetail } from '@/api/mine'
 import { toPage } from '@/utils/page'
 
 defineOptions({
   name: 'MissionCenter', // 任务中心
 })
+const userInfo = computed(() => {
+  return getUserInfoHook()
+})
+
 const dailyMission = [
   {
     name: 'Invite Friends Earn Cash',
@@ -39,23 +43,23 @@ const dailyMission = [
 // 当前签到天数
 const currentDay = ref(3)
 // 今日是否已签到
-const hasSignedToday = ref(false)
+const hasSignedToday = ref(true)
 
 // 签到方法
-function signIn() {
+async function signIn() {
   if (hasSignedToday.value)
     return
-  hasSignedToday.value = true
-  // 如果是新的一天,增加签到天数
-  if (currentDay.value < 7) {
-    currentDay.value++
+  const res = await clockIn({ uid: userInfo.value.userId })
+  if (res.code === '200') {
+    await getSignList()
   }
-  // 这里可以添加签到请求逻辑
 }
-
+const signList = ref<any[]>([])
 async function getSignList() {
-  const res = await todayDetail()
+  const res = await todayDetail({ uid: userInfo.value.userId })
   console.log(res)
+  signList.value = res.data.signList
+  hasSignedToday.value = res.data.today
 }
 onLoad(() => {
   getSignList()
@@ -72,18 +76,18 @@ onLoad(() => {
       </view>
       <!-- 七天签到日历 -->
       <view class="flex items-center justify-between">
-        <view v-for="(day, index) in 7" :key="index" class="flex flex-col items-center">
+        <view v-for="(day, index) in signList" :key="index" class="flex flex-col items-center">
           <view
             class="h-70rpx w-70rpx flex items-center justify-center rounded-full" :class="[
-              index < currentDay ? 'bg-#FF3778/30' : 'bg-gray-100',
+              day.status === 1 ? 'bg-#FF3778/30' : 'bg-gray-100',
             ]"
           >
-            <text class="text-24rpx" :class="[index < currentDay ? 'text-[var(--wot-color-theme)]' : 'text-#000/15']">
-              ৳5
+            <text class="text-24rpx" :class="[day.status === 1 ? 'text-[var(--wot-color-theme)]' : 'text-#000/15']">
+              ৳{{ day.value }}
             </text>
           </view>
           <view class="mt-8rpx text-20rpx text-gray-500">
-            {{ index + 1 }}D
+            {{ day.days }}D
           </view>
         </view>
       </view>