diff --git a/src/api/index.ts b/src/api/index.ts index 6dc3459..981f63c 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -57,6 +57,5 @@ export interface PageParam { dateTime?: string; lang?: string; model?: string; - type?: string; BaseUrl?: string; } diff --git a/src/api/shop/shopCoupon/model/index.ts b/src/api/shop/shopCoupon/model/index.ts index a81755e..7837ba0 100644 --- a/src/api/shop/shopCoupon/model/index.ts +++ b/src/api/shop/shopCoupon/model/index.ts @@ -65,5 +65,9 @@ export interface ShopCouponParam extends PageParam { status?: number; isExpire?: number; sortBy?: string; + sortOrder?: 'asc' | 'desc'; keywords?: string; + enabled?: number; + type?: number; + minAmount?: number; } diff --git a/src/app.config.ts b/src/app.config.ts index 30df9f2..ff390b7 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -40,7 +40,8 @@ export default defineAppConfig({ "wallet/wallet", "coupon/index", "points/points", - "gift/index" + "gift/index", + "gift/redeem" ] }, { diff --git a/src/components/CouponCard.tsx b/src/components/CouponCard.tsx index 5c82f5e..66ff8b3 100644 --- a/src/components/CouponCard.tsx +++ b/src/components/CouponCard.tsx @@ -129,6 +129,8 @@ const CouponCard: React.FC = ({ return '' } + console.log(getValidityText) + const themeClass = getThemeClass() return ( diff --git a/src/components/CouponStats.tsx b/src/components/CouponStats.tsx index 2b81af2..11285fc 100644 --- a/src/components/CouponStats.tsx +++ b/src/components/CouponStats.tsx @@ -25,9 +25,9 @@ const CouponStats: React.FC = ({ return ( - 优惠券统计 + 优惠券统计 - + {/* 可用优惠券 */} = ({ - availableCount, - usedCount, - expiredCount, - onStatsClick -}) => { + availableCount, + usedCount, + expiredCount, + totalValue, + onStatsClick + }) => { const handleStatsClick = (type: 'available' | 'used' | 'expired' | 'total') => { onStatsClick?.(type) } return ( - + {/* 紧凑的统计卡片 - 2x2 网格 */} - + {/* 可用礼品卡 */} handleStatsClick('available')} > - + 可用 {availableCount} @@ -43,11 +44,11 @@ const GiftCardStats: React.FC = ({ {/* 已使用礼品卡 */} handleStatsClick('used')} > - + 已使用 {usedCount} @@ -55,15 +56,29 @@ const GiftCardStats: React.FC = ({ {/* 已过期礼品卡 */} handleStatsClick('expired')} > - + 已过期 {expiredCount} + + {/* 总价值 */} + {totalValue !== undefined && ( + handleStatsClick('total')} + > + + + 总价值 + + ¥{totalValue} + + )} ) diff --git a/src/user/coupon/index.tsx b/src/user/coupon/index.tsx index e3f15c1..ec0ed8b 100644 --- a/src/user/coupon/index.tsx +++ b/src/user/coupon/index.tsx @@ -1,7 +1,7 @@ import {useState} from "react"; import Taro, {useDidShow} from '@tarojs/taro' import {Button, Empty, ConfigProvider, SearchBar, InfiniteLoading, Loading, PullToRefresh, Tabs, TabPane} from '@nutui/nutui-react-taro' -import {Gift, Search, Plus, Filter} from '@nutui/icons-react-taro' +import {Plus, Filter} from '@nutui/icons-react-taro' import {View} from '@tarojs/components' import {ShopCoupon} from "@/api/shop/shopCoupon/model"; import {pageShopCoupon} from "@/api/shop/shopCoupon"; @@ -20,6 +20,7 @@ const CouponManage = () => { const [searchValue, setSearchValue] = useState('') const [page, setPage] = useState(1) const [total, setTotal] = useState(0) + console.log('total = ',total) const [activeTab, setActiveTab] = useState('0') // 0-可用 1-已使用 2-已过期 const [stats, setStats] = useState({ available: 0, @@ -191,7 +192,7 @@ const CouponManage = () => { } // 优惠券点击事件 - const handleCouponClick = (coupon: CouponCardProps, index: number) => { + const handleCouponClick = (_coupon: CouponCardProps, index: number) => { const originalCoupon = list[index] if (originalCoupon) { // 显示优惠券详情 @@ -317,15 +318,14 @@ const CouponManage = () => { return ( {/* 搜索栏和领取入口 */} - + } /> - - )} - {/* 使用指南弹窗 */} { page: currentPage, limit: 10, keywords: searchValue, - enabled: '1', // 启用状态 + enabled: 1, // 启用状态 isExpire: 0 // 未过期 }) @@ -77,7 +77,7 @@ const CouponReceive = () => { const transformCouponData = (coupon: ShopCoupon): CouponCardProps => { let amount = 0 let type: 1 | 2 | 3 = 1 - + if (coupon.type === 10) { // 满减券 type = 1 amount = parseFloat(coupon.reducePrice || '0') @@ -114,16 +114,16 @@ const CouponReceive = () => { } // 领取优惠券 - const handleReceiveCoupon = async (coupon: ShopCoupon) => { + const handleReceiveCoupon = async (_coupon: ShopCoupon) => { try { // 这里应该调用领取优惠券的API // await receiveCoupon(coupon.id) - + Taro.showToast({ title: '领取成功', icon: 'success' }) - + // 刷新列表 reload(true) } catch (error) { @@ -136,7 +136,7 @@ const CouponReceive = () => { } // 优惠券点击事件 - const handleCouponClick = (coupon: CouponCardProps, index: number) => { + const handleCouponClick = (_coupon: CouponCardProps, index: number) => { const originalCoupon = list[index] if (originalCoupon) { // 显示优惠券详情 @@ -168,11 +168,10 @@ const CouponReceive = () => { {/* 搜索栏 */} } /> diff --git a/src/user/gift/index.tsx b/src/user/gift/index.tsx index a0a422a..52617c5 100644 --- a/src/user/gift/index.tsx +++ b/src/user/gift/index.tsx @@ -1,7 +1,7 @@ import {useState} from "react"; import Taro, {useDidShow} from '@tarojs/taro' -import {Button, Empty, ConfigProvider, InfiniteLoading, Loading, PullToRefresh, Tabs, TabPane} from '@nutui/nutui-react-taro' -import {Gift, Plus, Board, QrCode} from '@nutui/icons-react-taro' +import {Button, Empty, ConfigProvider,SearchBar, InfiniteLoading, Loading, PullToRefresh, Tabs, TabPane} from '@nutui/nutui-react-taro' +import {Gift, Retweet, Board, QrCode} from '@nutui/icons-react-taro' import {View} from '@tarojs/components' import {ShopGift} from "@/api/shop/shopGift/model"; import {getUserGifts} from "@/api/shop/shopGift"; @@ -14,7 +14,7 @@ const GiftCardManage = () => { const [list, setList] = useState([]) const [loading, setLoading] = useState(false) const [hasMore, setHasMore] = useState(true) - // const [searchValue, setSearchValue] = useState('') + const [searchValue, setSearchValue] = useState('') const [page, setPage] = useState(1) // const [total, setTotal] = useState(0) const [activeTab, setActiveTab] = useState('0') // 0-可用 1-已使用 2-已过期 @@ -97,10 +97,10 @@ const GiftCardManage = () => { } // 搜索功能 - // const handleSearch = (value: string) => { - // setSearchValue(value) - // reload(true) - // } + const handleSearch = (value: string) => { + setSearchValue(value) + reload(true) + } // 下拉刷新 const handleRefresh = async () => { @@ -272,10 +272,19 @@ const GiftCardManage = () => { {/* 搜索栏和功能入口 */} + + +