refactor(coupon): 重构优惠券页面布局和样式

-调整 CouponCard 和 CouponList 组件的样式,使其更加简洁和一致
- 优化页面布局,利用 flex 布局实现全屏布局
- 移除冗余代码和不必要的组件
- 调整空状态展示方式,增加查看我的优惠券按钮
This commit is contained in:
2025-08-22 18:20:00 +08:00
parent 1e51a137ee
commit c87731f1d5
3 changed files with 99 additions and 103 deletions

View File

@@ -1,7 +1,6 @@
import {useState} from "react";
import Taro, {useDidShow} from '@tarojs/taro'
import {
Button,
Empty,
ConfigProvider,
InfiniteLoading,
@@ -10,7 +9,6 @@ import {
Tabs,
TabPane
} from '@nutui/nutui-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";
@@ -279,7 +277,7 @@ const CouponReceiveCenter = () => {
});
return (
<ConfigProvider className={'pt-3'}>
<ConfigProvider className="h-screen flex flex-col">
{/* Tab切换 */}
<View className="bg-white hidden">
<Tabs value={activeTab} onChange={handleTabChange}>
@@ -294,63 +292,60 @@ const CouponReceiveCenter = () => {
</Tabs>
</View>
{/* 优惠券列表 */}
<PullToRefresh
onRefresh={handleRefresh}
headHeight={60}
>
<View style={{ height: '600px', overflowY: 'auto' }} id="coupon-scroll">
{list.length === 0 && !loading ? (
<View className="flex flex-col justify-center items-center" style={{height: '500px'}}>
<Empty
description="暂无可领取的优惠券"
style={{backgroundColor: 'transparent'}}
/>
</View>
) : (
<InfiniteLoading
target="coupon-scroll"
hasMore={hasMore}
onLoadMore={loadMore}
loadingText={
<View className="flex justify-center items-center py-4">
<Loading />
<View className="ml-2">...</View>
</View>
}
loadMoreText={
<View className="text-center py-4 text-gray-500">
{list.length === 0 ? "暂无数据" : "没有更多了"}
</View>
}
{/* 优惠券列表 - 占满剩余空间 */}
<View className="flex-1 overflow-hidden">
<PullToRefresh
onRefresh={handleRefresh}
headHeight={60}
>
<View
style={{
height: 'calc(100vh - 60px)',
overflowY: 'auto',
paddingTop: '24px',
paddingBottom: '32px'
}}
id="coupon-scroll"
>
<CouponList
coupons={list.map(transformCouponData)}
showEmpty={false}
/>
</InfiniteLoading>
)}
</View>
</PullToRefresh>
{/* 底部提示 */}
{list.length === 0 && !loading && (
<View className="text-center py-8">
<View className="text-gray-400 mb-4">
<Gift size="48" />
{list.length === 0 && !loading ? (
<View className="flex flex-col justify-center items-center h-full">
<Empty
description="暂无可领取的优惠券"
style={{backgroundColor: 'transparent'}}
actions={[
{
text: '查看我的优惠券',
onClick: handleViewMyCoupons
}
]}
/>
</View>
) : (
<InfiniteLoading
target="coupon-scroll"
hasMore={hasMore}
onLoadMore={loadMore}
loadingText={
<View className="flex justify-center items-center py-4">
<Loading />
<View className="ml-2">...</View>
</View>
}
loadMoreText={
<View className="text-center py-4 text-gray-500">
{list.length === 0 ? "暂无数据" : "没有更多了"}
</View>
}
>
<CouponList
coupons={list.map(transformCouponData)}
showEmpty={false}
/>
</InfiniteLoading>
)}
</View>
<View className="text-gray-500 mb-2"></View>
<View className="flex gap-2 justify-center">
<Button
size="small"
type="primary"
onClick={handleViewMyCoupons}
>
</Button>
</View>
</View>
)}
</PullToRefresh>
</View>
{/* 使用指南弹窗 */}
<CouponGuide