|
@ -1,7 +1,7 @@ |
|
|
import {useState} from "react"; |
|
|
import {useState} from "react"; |
|
|
import Taro, {useDidShow} from '@tarojs/taro' |
|
|
import Taro, {useDidShow} from '@tarojs/taro' |
|
|
import {Button, Empty, ConfigProvider, SearchBar, InfiniteLoading, Loading, PullToRefresh, Tabs, TabPane} from '@nutui/nutui-react-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 {View} from '@tarojs/components' |
|
|
import {ShopCoupon} from "@/api/shop/shopCoupon/model"; |
|
|
import {ShopCoupon} from "@/api/shop/shopCoupon/model"; |
|
|
import {pageShopCoupon} from "@/api/shop/shopCoupon"; |
|
|
import {pageShopCoupon} from "@/api/shop/shopCoupon"; |
|
@ -20,6 +20,7 @@ const CouponManage = () => { |
|
|
const [searchValue, setSearchValue] = useState('') |
|
|
const [searchValue, setSearchValue] = useState('') |
|
|
const [page, setPage] = useState(1) |
|
|
const [page, setPage] = useState(1) |
|
|
const [total, setTotal] = useState(0) |
|
|
const [total, setTotal] = useState(0) |
|
|
|
|
|
console.log('total = ',total) |
|
|
const [activeTab, setActiveTab] = useState('0') // 0-可用 1-已使用 2-已过期
|
|
|
const [activeTab, setActiveTab] = useState('0') // 0-可用 1-已使用 2-已过期
|
|
|
const [stats, setStats] = useState({ |
|
|
const [stats, setStats] = useState({ |
|
|
available: 0, |
|
|
available: 0, |
|
@ -191,7 +192,7 @@ const CouponManage = () => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 优惠券点击事件
|
|
|
// 优惠券点击事件
|
|
|
const handleCouponClick = (coupon: CouponCardProps, index: number) => { |
|
|
|
|
|
|
|
|
const handleCouponClick = (_coupon: CouponCardProps, index: number) => { |
|
|
const originalCoupon = list[index] |
|
|
const originalCoupon = list[index] |
|
|
if (originalCoupon) { |
|
|
if (originalCoupon) { |
|
|
// 显示优惠券详情
|
|
|
// 显示优惠券详情
|
|
@ -317,15 +318,14 @@ const CouponManage = () => { |
|
|
return ( |
|
|
return ( |
|
|
<ConfigProvider> |
|
|
<ConfigProvider> |
|
|
{/* 搜索栏和领取入口 */} |
|
|
{/* 搜索栏和领取入口 */} |
|
|
<View className="bg-white px-4 py-3"> |
|
|
|
|
|
|
|
|
<View className="bg-white px-4 py-3 hidden"> |
|
|
<View className="flex items-center gap-3"> |
|
|
<View className="flex items-center gap-3"> |
|
|
<View className="flex-1"> |
|
|
<View className="flex-1"> |
|
|
<SearchBar |
|
|
<SearchBar |
|
|
placeholder="搜索优惠券名称" |
|
|
|
|
|
|
|
|
placeholder="搜索" |
|
|
value={searchValue} |
|
|
value={searchValue} |
|
|
onChange={setSearchValue} |
|
|
onChange={setSearchValue} |
|
|
onSearch={handleSearch} |
|
|
onSearch={handleSearch} |
|
|
leftIcon={<Search />} |
|
|
|
|
|
/> |
|
|
/> |
|
|
</View> |
|
|
</View> |
|
|
<Button |
|
|
<Button |
|
@ -374,13 +374,6 @@ const CouponManage = () => { |
|
|
</Tabs> |
|
|
</Tabs> |
|
|
</View> |
|
|
</View> |
|
|
|
|
|
|
|
|
{/* 统计信息 */} |
|
|
|
|
|
{total > 0 && ( |
|
|
|
|
|
<View className="px-4 py-2 text-sm text-gray-500 bg-gray-50"> |
|
|
|
|
|
共找到 {total} 张优惠券 |
|
|
|
|
|
</View> |
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
{/* 优惠券列表 */} |
|
|
{/* 优惠券列表 */} |
|
|
<PullToRefresh |
|
|
<PullToRefresh |
|
|
onRefresh={handleRefresh} |
|
|
onRefresh={handleRefresh} |
|
@ -425,23 +418,6 @@ const CouponManage = () => { |
|
|
</View> |
|
|
</View> |
|
|
</PullToRefresh> |
|
|
</PullToRefresh> |
|
|
|
|
|
|
|
|
{/* 底部提示 */} |
|
|
|
|
|
{activeTab === '0' && list.length === 0 && !loading && ( |
|
|
|
|
|
<View className="text-center py-8"> |
|
|
|
|
|
<View className="text-gray-400 mb-4"> |
|
|
|
|
|
<Gift size="48" /> |
|
|
|
|
|
</View> |
|
|
|
|
|
<View className="text-gray-500 mb-2">暂无可用优惠券</View> |
|
|
|
|
|
<Button |
|
|
|
|
|
size="small" |
|
|
|
|
|
type="primary" |
|
|
|
|
|
onClick={() => Taro.navigateTo({url: '/pages/index/index'})} |
|
|
|
|
|
> |
|
|
|
|
|
去逛逛 |
|
|
|
|
|
</Button> |
|
|
|
|
|
</View> |
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
{/* 使用指南弹窗 */} |
|
|
{/* 使用指南弹窗 */} |
|
|
<CouponGuide |
|
|
<CouponGuide |
|
|
visible={showGuide} |
|
|
visible={showGuide} |
|
|