|
|
@@ -2,7 +2,7 @@ import { useState } from 'react'
|
|
|
import { View, Text, ScrollView, Swiper, SwiperItem, Image } from '@tarojs/components'
|
|
|
import Taro from '@tarojs/taro'
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
|
-import { publicAdvertisementClient, wechatCouponStockClient } from '@/api'
|
|
|
+import { publicAdvertisementClient, publicWechatCouponStockClient } from '@/api'
|
|
|
import { Button } from '@/components/ui/button'
|
|
|
import { Card, CardContent, CardHeader } from '@/components/ui/card'
|
|
|
import { cn } from '@/utils/cn'
|
|
|
@@ -17,7 +17,7 @@ type AdvertisementResponse = InferResponseType<typeof publicAdvertisementClient.
|
|
|
type Advertisement = AdvertisementResponse['data'][0]
|
|
|
|
|
|
// 使用RPC类型安全提取代金券批次响应类型
|
|
|
-type WechatCouponStockResponse = InferResponseType<typeof wechatCouponStockClient.$get, 200>
|
|
|
+type WechatCouponStockResponse = InferResponseType<typeof publicWechatCouponStockClient.$get, 200>
|
|
|
type WechatCouponStock = WechatCouponStockResponse['data'][0]
|
|
|
|
|
|
export default function IndexPage() {
|
|
|
@@ -45,11 +45,11 @@ export default function IndexPage() {
|
|
|
const { data: stocks, isLoading: stocksLoading } = useQuery({
|
|
|
queryKey: ['wechat-coupon-stocks'],
|
|
|
queryFn: async () => {
|
|
|
- const response = await wechatCouponStockClient.$get({
|
|
|
+ const response = await publicWechatCouponStockClient.$get({
|
|
|
query: {
|
|
|
page: 1,
|
|
|
pageSize: 20,
|
|
|
- filters: JSON.stringify({ status: 1 }),
|
|
|
+ filters: JSON.stringify({ status: 'RUNNING' }),
|
|
|
},
|
|
|
})
|
|
|
if (response.status !== 200) throw new Error('获取批次失败')
|
|
|
@@ -194,7 +194,7 @@ export default function IndexPage() {
|
|
|
|
|
|
<View className="flex justify-between items-center">
|
|
|
<Text className="text-xs text-gray-500">
|
|
|
- 剩余: {stock.couponRemaining}/{stock.couponTotal}
|
|
|
+ 剩余: {stock.availableQuantity}/{stock.couponQuantity}
|
|
|
</Text>
|
|
|
<Text className="text-xs text-gray-500">
|
|
|
{new Date(stock.endTime).toLocaleDateString()} 截止
|
|
|
@@ -208,10 +208,10 @@ export default function IndexPage() {
|
|
|
? 'bg-red-500 text-white'
|
|
|
: 'bg-gray-300 text-gray-500'
|
|
|
)}
|
|
|
- disabled={stock.couponRemaining === 0}
|
|
|
+ disabled={stock.availableQuantity === 0}
|
|
|
onClick={() => handleReceiveCoupon(stock.id)}
|
|
|
>
|
|
|
- {stock.couponRemaining > 0 ? '立即领取' : '已领完'}
|
|
|
+ {stock.availableQuantity > 0 ? '立即领取' : '已领完'}
|
|
|
</Button>
|
|
|
</CardContent>
|
|
|
</Card>
|