refactor(shop): 重构优惠券和礼品卡相关功能

- 优化了优惠券和礼品卡的搜索功能
- 重新设计了统计卡片的样式和布局- 改进了优惠券和礼品卡的领取和兑换流程
- 统一了图标样式和大小
- 调整了部分组件的显示逻辑
This commit is contained in:
2025-08-13 11:17:00 +08:00
parent 5d4dc4518f
commit 89cadc3886
11 changed files with 74 additions and 68 deletions

View File

@@ -1,7 +1,7 @@
import {useState} from "react";
import Taro, {useDidShow} from '@tarojs/taro'
import {Button, Empty, ConfigProvider, SearchBar, InfiniteLoading, Loading, PullToRefresh} from '@nutui/nutui-react-taro'
import {Gift, Search} from '@nutui/icons-react-taro'
import {Gift} from '@nutui/icons-react-taro'
import {View} from '@tarojs/components'
import {ShopCoupon} from "@/api/shop/shopCoupon/model";
import {pageShopCoupon} from "@/api/shop/shopCoupon";
@@ -31,7 +31,7 @@ const CouponReceive = () => {
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 = () => {
{/* 搜索栏 */}
<View className="bg-white px-4 py-3">
<SearchBar
placeholder="搜索优惠券名称"
placeholder="搜索"
value={searchValue}
onChange={setSearchValue}
onSearch={handleSearch}
leftIcon={<Search />}
/>
</View>