2024-09-06 17:26:09 +08:00
|
|
|
import { useEffect, useState } from 'react'
|
2024-08-30 15:53:34 +08:00
|
|
|
import './HeadCouponModal.css'
|
2024-09-11 14:04:53 +08:00
|
|
|
import {
|
|
|
|
get,
|
|
|
|
getCouponUrl
|
|
|
|
} from '../../util/AjaxUtils'
|
2024-09-06 17:26:09 +08:00
|
|
|
import {
|
|
|
|
Pagination,
|
|
|
|
message,
|
|
|
|
Empty,
|
|
|
|
Spin
|
|
|
|
} from 'antd';
|
2024-09-02 16:41:02 +08:00
|
|
|
// import { useNavigate } from 'react-router-dom';
|
|
|
|
// import { Empty } from 'antd'
|
|
|
|
// import contentImg from '../../static/coupon/content.png'
|
|
|
|
import useLogo from '../../static/coupon/useLogo.png'
|
|
|
|
import overdueImg from '../../static/coupon/overdueImg.png'
|
|
|
|
export default function HeadCouponModal(props: any) {
|
2024-09-06 17:26:09 +08:00
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
2024-09-11 09:22:39 +08:00
|
|
|
const [loading, setLoading] = useState(false)
|
2024-09-11 14:04:53 +08:00
|
|
|
const [title, setTitle] = useState('可用')
|
2024-09-06 17:26:09 +08:00
|
|
|
// 分页
|
|
|
|
const [page, setPage] = useState(1)
|
|
|
|
const [total, setTotal] = useState(0)
|
|
|
|
// 是否有效
|
2024-09-11 14:20:23 +08:00
|
|
|
const [isEffective, setisEffective] = useState<any>(1)
|
2024-09-06 17:26:09 +08:00
|
|
|
const [isUsed, setisUsed] = useState(0)
|
|
|
|
// 展示的优惠券数组
|
|
|
|
const [couponArray, setCouponArray] = useState<any[]>([])
|
|
|
|
// 获取优惠券信息
|
|
|
|
const getCouponData = () => {
|
|
|
|
get({
|
|
|
|
messageApi,
|
|
|
|
url: `/api/coupon/user/listpage/self`,
|
|
|
|
// url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
|
|
|
|
config: {
|
|
|
|
params: {
|
|
|
|
page: page,
|
|
|
|
rows: 10,
|
|
|
|
isEffective,
|
|
|
|
isUsed,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onBefore() {
|
|
|
|
setLoading(true)
|
|
|
|
},
|
|
|
|
onSuccess(data: any) {
|
|
|
|
setTotal(data.data.total)
|
|
|
|
setCouponArray(data.data.rows)
|
|
|
|
},
|
|
|
|
onFinally() {
|
|
|
|
setLoading(false)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
useEffect(() => {
|
|
|
|
getCouponData()
|
|
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
|
|
getCouponData()
|
|
|
|
}, [page, isEffective, isUsed])
|
2024-08-30 15:53:34 +08:00
|
|
|
return (
|
2024-09-02 16:41:02 +08:00
|
|
|
<div className='headModal'>
|
2024-09-06 17:26:09 +08:00
|
|
|
{contextHolder}
|
2024-08-30 15:53:34 +08:00
|
|
|
<div className='headModal-top'>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div className={title == '可用' ? 'top-active' : 'top-title'}
|
2024-08-30 15:53:34 +08:00
|
|
|
onClick={() => {
|
2024-09-11 14:04:53 +08:00
|
|
|
setTitle('可用')
|
2024-09-06 17:26:09 +08:00
|
|
|
setisUsed(0)
|
|
|
|
setisEffective(1)
|
|
|
|
setPage(1)
|
2024-08-30 15:53:34 +08:00
|
|
|
}}
|
2024-09-11 14:04:53 +08:00
|
|
|
>可用</div>
|
2024-08-30 15:53:34 +08:00
|
|
|
<div className={title == '已使用' ? 'top-active' : 'top-title'} style={{ marginLeft: 50 }}
|
|
|
|
onClick={() => {
|
|
|
|
setTitle('已使用')
|
2024-09-06 17:26:09 +08:00
|
|
|
setisUsed(1)
|
2024-09-11 14:04:53 +08:00
|
|
|
setisEffective(null)
|
2024-09-06 17:26:09 +08:00
|
|
|
setPage(1)
|
2024-08-30 15:53:34 +08:00
|
|
|
}}
|
|
|
|
>已使用</div>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div className={title == '不可用' ? 'top-active' : 'top-title'} style={{ marginLeft: 50 }}
|
2024-08-30 15:53:34 +08:00
|
|
|
onClick={() => {
|
2024-09-11 14:04:53 +08:00
|
|
|
setTitle('不可用')
|
2024-09-06 17:26:09 +08:00
|
|
|
setisUsed(0)
|
|
|
|
setisEffective(0)
|
|
|
|
setPage(1)
|
2024-08-30 15:53:34 +08:00
|
|
|
}}
|
2024-09-11 14:04:53 +08:00
|
|
|
>不可用</div>
|
2024-08-30 15:53:34 +08:00
|
|
|
</div>
|
|
|
|
<div className='headModal-bot'>
|
2024-09-06 17:26:09 +08:00
|
|
|
<Spin tip="加载中,请稍后..." size="small" spinning={loading}>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div style={{ display: title == '可用' ? 'block' : 'none' }}>
|
2024-09-11 09:22:39 +08:00
|
|
|
{/* <div className='couponList' >
|
|
|
|
<div className='content'>
|
|
|
|
<div className='content-noUse-left'>
|
|
|
|
<div className='content-left-num'>
|
|
|
|
<div
|
|
|
|
style={{ marginTop: -10 }}
|
|
|
|
>
|
|
|
|
<span style={{ fontSize: 30 }}>¥</span>
|
|
|
|
<span style={{ fontSize: 60, fontWeight: 700 }}>100</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='content-right'>
|
|
|
|
<div style={{ display: 'flex', marginTop: 20, justifyContent: 'space-between' }}>
|
|
|
|
<div className='content-text'>
|
|
|
|
可购买平台内任意软著时使用
|
|
|
|
</div>
|
|
|
|
<div className='content-rule' onClick={() => {
|
|
|
|
// window.open('https://www.aimzhu.com/CouponRule.html')
|
|
|
|
|
|
|
|
getCouponUrl()
|
|
|
|
}}>
|
|
|
|
使用规则
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='content-bot'>
|
|
|
|
<div className='content-time'>
|
|
|
|
有效期:2008 至 2008
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='content-button' onClick={() => {
|
|
|
|
props.closeModal()
|
|
|
|
}}>
|
|
|
|
去使用
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div> */}
|
2024-09-06 17:26:09 +08:00
|
|
|
{couponArray.map((item) => {
|
|
|
|
return (
|
|
|
|
<div className='couponList' key={item.couponId}>
|
|
|
|
<div className='content'>
|
|
|
|
<div className='content-noUse-left'>
|
|
|
|
<div className='content-left-num'>
|
|
|
|
<div
|
|
|
|
style={{ marginTop: -10 }}
|
|
|
|
>
|
|
|
|
<span style={{ fontSize: 30 }}>¥</span>
|
|
|
|
<span style={{ fontSize: 60, fontWeight: 700 }}>{item.coupon.amount / 100}</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='content-right'>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div style={{ display: 'flex', marginTop: 20, justifyContent: 'space-between' }}>
|
|
|
|
<div className='content-text'>
|
|
|
|
可购买平台内任意软著时使用
|
|
|
|
</div>
|
|
|
|
<div className='content-rule' onClick={() => {
|
|
|
|
// window.open('https://www.aimzhu.com/CouponRule.html')
|
|
|
|
|
|
|
|
getCouponUrl()
|
|
|
|
}}>
|
|
|
|
使用规则
|
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
<div className='content-bot'>
|
|
|
|
<div className='content-time'>
|
2024-09-11 14:04:53 +08:00
|
|
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div className='content-button'
|
|
|
|
|
|
|
|
style={{
|
|
|
|
background: item.coupon.isEffective ? '#1677FF' : '#d3d3d3',
|
|
|
|
cursor: item.coupon.isEffective ? 'pointer' : 'not-allowed',
|
|
|
|
|
|
|
|
}}
|
|
|
|
onClick={() => {
|
|
|
|
if (item.coupon.isEffective) {
|
|
|
|
props.closeModal()
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
title={item.coupon.isEffective ? '' : '不在有效期'}
|
|
|
|
>
|
2024-09-06 17:26:09 +08:00
|
|
|
去使用
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-08-30 15:53:34 +08:00
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
|
2024-08-30 15:53:34 +08:00
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
|
|
|
|
<div style={{ display: couponArray.length > 10 ? 'unset' : 'none' }}>
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
|
|
<Pagination defaultCurrent={page} total={total} pageSize={10} showSizeChanger={false}
|
|
|
|
onChange={(value) => {
|
|
|
|
setPage(value)
|
|
|
|
}}
|
|
|
|
/>
|
2024-08-30 15:53:34 +08:00
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
<div style={{ display: couponArray.length <= 0 ? 'unset' : 'none' }}>
|
|
|
|
<div className='noDatebox'>
|
2024-09-11 14:04:53 +08:00
|
|
|
<Empty description="暂无优惠券" />
|
2024-08-30 15:53:34 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
<div style={{ display: title == '已使用' ? 'block' : 'none' }}>
|
|
|
|
{couponArray.map((item) => {
|
|
|
|
return (
|
|
|
|
<div className='couponList' key={item.couponId}>
|
|
|
|
<div className='content'>
|
|
|
|
<div className='content-use-left'>
|
|
|
|
<div className='content-left-num'>
|
|
|
|
<div
|
|
|
|
style={{ marginTop: -10 }}
|
|
|
|
>
|
|
|
|
<span style={{ fontSize: 30 }}>¥</span>
|
|
|
|
<span style={{ fontSize: 60, fontWeight: 700 }}>{item.coupon.amount / 100}</span>
|
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='content-right'>
|
|
|
|
<div className='content-text' style={{ marginTop: 10 }}>
|
|
|
|
可购买平台内任意软著时使用
|
|
|
|
</div>
|
|
|
|
<div className='content-bot' style={{ marginTop: 5 }}>
|
|
|
|
<div className='content-time'>
|
2024-09-11 14:04:53 +08:00
|
|
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div className='content-projName' title={item.productName}>
|
2024-09-06 17:26:09 +08:00
|
|
|
{/* 使用的产品 */}
|
|
|
|
{item.productName}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
|
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
<div className='use-img'>
|
|
|
|
<img src={useLogo} alt="" width={'100%'} height={'100%'} />
|
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
)
|
|
|
|
})}
|
|
|
|
<div style={{ display: couponArray.length > 10 ? 'unset' : 'none' }}>
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
|
|
<Pagination defaultCurrent={page} total={total} pageSize={10} showSizeChanger={false}
|
|
|
|
onChange={(value) => {
|
|
|
|
setPage(value)
|
|
|
|
}} />
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
<div style={{ display: couponArray.length <= 0 ? 'unset' : 'none' }}>
|
|
|
|
<div className='noDatebox'>
|
|
|
|
<Empty description="无已使用优惠券" />
|
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div style={{ display: title == '不可用' ? 'block' : 'none' }}>
|
2024-09-06 17:26:09 +08:00
|
|
|
{couponArray.map((item) => {
|
|
|
|
return (
|
|
|
|
<div className='couponList' key={item.couponId}>
|
|
|
|
<div className='content'>
|
|
|
|
<div className='content-use-left'>
|
|
|
|
<div className='content-left-num'>
|
|
|
|
<div
|
|
|
|
style={{ marginTop: -10 }}
|
|
|
|
>
|
|
|
|
<span style={{ fontSize: 30 }}>¥</span>
|
|
|
|
<span style={{ fontSize: 60, fontWeight: 700 }}>{item.coupon.amount / 100}</span>
|
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='content-right'>
|
2024-09-11 14:04:53 +08:00
|
|
|
<div style={{ display: 'flex', marginTop: 20, justifyContent: 'space-between' }}>
|
|
|
|
<div className='content-text'>
|
|
|
|
可购买平台内任意软著时使用
|
|
|
|
</div>
|
|
|
|
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
<div className='content-bot'>
|
|
|
|
<div className='content-time'>
|
2024-09-11 14:04:53 +08:00
|
|
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
2024-09-11 14:04:53 +08:00
|
|
|
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-09-11 14:04:53 +08:00
|
|
|
</div>
|
|
|
|
<div className='use-img'
|
|
|
|
style={{
|
|
|
|
width:88,
|
|
|
|
height:76
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<img src={overdueImg} alt="" width={'100%'} height={'100%'} />
|
|
|
|
</div>
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
2024-09-11 14:04:53 +08:00
|
|
|
|
2024-09-06 17:26:09 +08:00
|
|
|
)
|
|
|
|
})}
|
|
|
|
<div style={{ display: couponArray.length > 10 ? 'unset' : 'none' }}>
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
|
|
<Pagination defaultCurrent={page} total={total} pageSize={10} showSizeChanger={false}
|
|
|
|
onChange={(value) => {
|
|
|
|
setPage(value)
|
|
|
|
}}
|
|
|
|
/>
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
</div>
|
|
|
|
<div style={{ display: couponArray.length <= 0 ? 'unset' : 'none' }}>
|
|
|
|
<div className='noDatebox'>
|
|
|
|
<Empty description="无已过期优惠券" />
|
2024-09-02 16:41:02 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-06 17:26:09 +08:00
|
|
|
</Spin>
|
2024-08-30 15:53:34 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|