优惠券优化
This commit is contained in:
parent
0ee68cbf84
commit
23d4ddb7c5
@ -124,13 +124,14 @@
|
|||||||
.content-button {
|
.content-button {
|
||||||
width: 94px;
|
width: 94px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
background: #1677FF;
|
background: #d3d3d3;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-projName {
|
.content-projName {
|
||||||
@ -143,6 +144,10 @@
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
border-top: 1px dashed #DCDCDC;
|
border-top: 1px dashed #DCDCDC;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.noDatebox {
|
.noDatebox {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import './HeadCouponModal.css'
|
import './HeadCouponModal.css'
|
||||||
import { get,
|
import {
|
||||||
// getCouponUrl
|
get,
|
||||||
} from '../../util/AjaxUtils'
|
getCouponUrl
|
||||||
|
} from '../../util/AjaxUtils'
|
||||||
import {
|
import {
|
||||||
Pagination,
|
Pagination,
|
||||||
message,
|
message,
|
||||||
@ -17,12 +18,12 @@ import overdueImg from '../../static/coupon/overdueImg.png'
|
|||||||
export default function HeadCouponModal(props: any) {
|
export default function HeadCouponModal(props: any) {
|
||||||
const [messageApi, contextHolder] = message.useMessage();
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [title, setTitle] = useState('未使用')
|
const [title, setTitle] = useState('可用')
|
||||||
// 分页
|
// 分页
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [total, setTotal] = useState(0)
|
const [total, setTotal] = useState(0)
|
||||||
// 是否有效
|
// 是否有效
|
||||||
const [isEffective, setisEffective] = useState(1)
|
const [isEffective, setisEffective] = useState<any>(null)
|
||||||
const [isUsed, setisUsed] = useState(0)
|
const [isUsed, setisUsed] = useState(0)
|
||||||
// 展示的优惠券数组
|
// 展示的优惠券数组
|
||||||
const [couponArray, setCouponArray] = useState<any[]>([])
|
const [couponArray, setCouponArray] = useState<any[]>([])
|
||||||
@ -62,34 +63,34 @@ export default function HeadCouponModal(props: any) {
|
|||||||
<div className='headModal'>
|
<div className='headModal'>
|
||||||
{contextHolder}
|
{contextHolder}
|
||||||
<div className='headModal-top'>
|
<div className='headModal-top'>
|
||||||
<div className={title == '未使用' ? 'top-active' : 'top-title'}
|
<div className={title == '可用' ? 'top-active' : 'top-title'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTitle('未使用')
|
setTitle('可用')
|
||||||
setisUsed(0)
|
setisUsed(0)
|
||||||
setisEffective(1)
|
setisEffective(1)
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}}
|
}}
|
||||||
>未使用</div>
|
>可用</div>
|
||||||
<div className={title == '已使用' ? 'top-active' : 'top-title'} style={{ marginLeft: 50 }}
|
<div className={title == '已使用' ? 'top-active' : 'top-title'} style={{ marginLeft: 50 }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTitle('已使用')
|
setTitle('已使用')
|
||||||
setisUsed(1)
|
setisUsed(1)
|
||||||
setisEffective(1)
|
setisEffective(null)
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}}
|
}}
|
||||||
>已使用</div>
|
>已使用</div>
|
||||||
<div className={title == '已过期' ? 'top-active' : 'top-title'} style={{ marginLeft: 50 }}
|
<div className={title == '不可用' ? 'top-active' : 'top-title'} style={{ marginLeft: 50 }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTitle('已过期')
|
setTitle('不可用')
|
||||||
setisUsed(0)
|
setisUsed(0)
|
||||||
setisEffective(0)
|
setisEffective(0)
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}}
|
}}
|
||||||
>已过期</div>
|
>不可用</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='headModal-bot'>
|
<div className='headModal-bot'>
|
||||||
<Spin tip="加载中,请稍后..." size="small" spinning={loading}>
|
<Spin tip="加载中,请稍后..." size="small" spinning={loading}>
|
||||||
<div style={{ display: title == '未使用' ? 'block' : 'none' }}>
|
<div style={{ display: title == '可用' ? 'block' : 'none' }}>
|
||||||
{/* <div className='couponList' >
|
{/* <div className='couponList' >
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<div className='content-noUse-left'>
|
<div className='content-noUse-left'>
|
||||||
@ -148,16 +149,36 @@ export default function HeadCouponModal(props: any) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='content-right'>
|
<div className='content-right'>
|
||||||
<div className='content-text'>
|
<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>
|
||||||
<div className='content-bot'>
|
<div className='content-bot'>
|
||||||
<div className='content-time'>
|
<div className='content-time'>
|
||||||
有效期:{item.coupon.gmtStart} 至 {item.coupon.gmtEnd}
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
||||||
</div>
|
</div>
|
||||||
<div className='content-button' onClick={() => {
|
<div className='content-button'
|
||||||
props.closeModal()
|
|
||||||
}}>
|
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 ? '' : '不在有效期'}
|
||||||
|
>
|
||||||
去使用
|
去使用
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -181,7 +202,7 @@ export default function HeadCouponModal(props: any) {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ display: couponArray.length <= 0 ? 'unset' : 'none' }}>
|
<div style={{ display: couponArray.length <= 0 ? 'unset' : 'none' }}>
|
||||||
<div className='noDatebox'>
|
<div className='noDatebox'>
|
||||||
<Empty description="暂无 优惠券" />
|
<Empty description="暂无优惠券" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -207,11 +228,11 @@ export default function HeadCouponModal(props: any) {
|
|||||||
</div>
|
</div>
|
||||||
<div className='content-bot' style={{ marginTop: 5 }}>
|
<div className='content-bot' style={{ marginTop: 5 }}>
|
||||||
<div className='content-time'>
|
<div className='content-time'>
|
||||||
有效期:{item.coupon.gmtStart} 至 {item.coupon.gmtEnd}
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className='content-projName'>
|
<div className='content-projName' title={item.productName}>
|
||||||
{/* 使用的产品 */}
|
{/* 使用的产品 */}
|
||||||
{item.productName}
|
{item.productName}
|
||||||
</div>
|
</div>
|
||||||
@ -239,7 +260,7 @@ export default function HeadCouponModal(props: any) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: title == '已过期' ? 'block' : 'none' }}>
|
<div style={{ display: title == '不可用' ? 'block' : 'none' }}>
|
||||||
{couponArray.map((item) => {
|
{couponArray.map((item) => {
|
||||||
return (
|
return (
|
||||||
<div className='couponList' key={item.couponId}>
|
<div className='couponList' key={item.couponId}>
|
||||||
@ -256,22 +277,31 @@ export default function HeadCouponModal(props: any) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='content-right'>
|
<div className='content-right'>
|
||||||
<div className='content-text'>
|
<div style={{ display: 'flex', marginTop: 20, justifyContent: 'space-between' }}>
|
||||||
可购买平台内任意软著时使用
|
<div className='content-text'>
|
||||||
|
可购买平台内任意软著时使用
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className='content-bot'>
|
<div className='content-bot'>
|
||||||
<div className='content-time'>
|
<div className='content-time'>
|
||||||
有效期至:{item.coupon.gmtEnd}
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='use-img' style={{ height: 76, width: 88 }}>
|
|
||||||
<img src={overdueImg} alt="" width={'100%'} height={'100%'} />
|
</div>
|
||||||
</div>
|
<div className='use-img'
|
||||||
|
style={{
|
||||||
|
width:88,
|
||||||
|
height:76
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img src={overdueImg} alt="" width={'100%'} height={'100%'} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
<div style={{ display: couponArray.length > 10 ? 'unset' : 'none' }}>
|
<div style={{ display: couponArray.length > 10 ? 'unset' : 'none' }}>
|
||||||
|
@ -102,7 +102,7 @@ export default function SelectCouponModal(props: any) {
|
|||||||
{item.coupon.title}
|
{item.coupon.title}
|
||||||
</div>
|
</div>
|
||||||
<div className='use-coupon-time'>
|
<div className='use-coupon-time'>
|
||||||
有效期至{item.coupon.gmtEnd}
|
有效期 : {item.coupon.useGmtStart} 至 {item.coupon.useGmtEnd}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import {
|
|||||||
CloseOutlined
|
CloseOutlined
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { get, downloadUrl, post } from '../../util/AjaxUtils.ts'
|
import { get, downloadUrl, post, getCouponUrl } from '../../util/AjaxUtils.ts'
|
||||||
import { setMenuActive } from '../../util/cache.ts'
|
import { setMenuActive } from '../../util/cache.ts'
|
||||||
import gpsImg from '../../static/right/gps.png'
|
import gpsImg from '../../static/right/gps.png'
|
||||||
import backImg from '../../static/right/back.png'
|
import backImg from '../../static/right/back.png'
|
||||||
@ -485,6 +485,10 @@ export default function Index() {
|
|||||||
const [correctionSearchBox, setCorrectionSearchBox] = useState(false)
|
const [correctionSearchBox, setCorrectionSearchBox] = useState(false)
|
||||||
// 优惠券遮罩层是否i西安市
|
// 优惠券遮罩层是否i西安市
|
||||||
const [coupon, setCoupon] = useState(false)
|
const [coupon, setCoupon] = useState(false)
|
||||||
|
// 获取优惠券弹出层是否显示
|
||||||
|
const [getCouponModal, setGetCouponModal] = useState(false)
|
||||||
|
// 优惠券数组
|
||||||
|
const [couponArray, setCouponArray] = useState<any>([])
|
||||||
//优惠券id
|
//优惠券id
|
||||||
const [couponId, setCouponId] = useState('')
|
const [couponId, setCouponId] = useState('')
|
||||||
// 优惠券图片 const imgSrc = `${Axios.defaults?.baseURL}/route/file/v2/download/true/${data.data.couponId}`;
|
// 优惠券图片 const imgSrc = `${Axios.defaults?.baseURL}/route/file/v2/download/true/${data.data.couponId}`;
|
||||||
@ -493,7 +497,7 @@ export default function Index() {
|
|||||||
const getCoupon = () => {
|
const getCoupon = () => {
|
||||||
get({
|
get({
|
||||||
messageApi,
|
messageApi,
|
||||||
url: `/api/coupon/get-can-claim`,
|
url: `/api/coupon/list-can-claim`,
|
||||||
// url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
|
// url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
|
||||||
config: {
|
config: {
|
||||||
params: {
|
params: {
|
||||||
@ -505,11 +509,20 @@ export default function Index() {
|
|||||||
},
|
},
|
||||||
onSuccess(data: any) {
|
onSuccess(data: any) {
|
||||||
// console.log(data.data);
|
// console.log(data.data);
|
||||||
if (data.data.couponId) {
|
// if (data.data.couponId) {
|
||||||
setCouponId(data.data.couponId)
|
// setCouponId(data.data.couponId)
|
||||||
setCouponImg(data.data.logo)
|
// setCouponImg(data.data.logo)
|
||||||
|
// setCoupon(true)
|
||||||
|
// }
|
||||||
|
setCouponArray(data.data)
|
||||||
|
if (data.data.length == 1) {
|
||||||
|
setCouponId((data.data)[0].couponId)
|
||||||
|
setCouponImg((data.data)[0].logo)
|
||||||
setCoupon(true)
|
setCoupon(true)
|
||||||
}
|
}
|
||||||
|
if (data.data.length > 1) {
|
||||||
|
setGetCouponModal(true)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
onFinally() {
|
onFinally() {
|
||||||
@ -517,7 +530,7 @@ export default function Index() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 领取优惠券
|
// 领取优惠券单张
|
||||||
const receiveCoupon = () => {
|
const receiveCoupon = () => {
|
||||||
post<any>({
|
post<any>({
|
||||||
messageApi,
|
messageApi,
|
||||||
@ -540,6 +553,52 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 领取优惠券(多张)
|
||||||
|
const receiveCoupons = (id: string) => {
|
||||||
|
post<any>({
|
||||||
|
messageApi,
|
||||||
|
url: `/api/coupon/user/save`,
|
||||||
|
body: {
|
||||||
|
couponId: id
|
||||||
|
},
|
||||||
|
onBefore() {
|
||||||
|
|
||||||
|
},
|
||||||
|
onSuccess() {
|
||||||
|
messageApi.success('领取成功')
|
||||||
|
//更新列表
|
||||||
|
get({
|
||||||
|
messageApi,
|
||||||
|
url: `/api/coupon/list-can-claim`,
|
||||||
|
// url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
|
||||||
|
config: {
|
||||||
|
params: {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onBefore() {
|
||||||
|
|
||||||
|
},
|
||||||
|
onSuccess(data: any) {
|
||||||
|
setCouponArray(data.data)
|
||||||
|
if (data.data.length == 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
setGetCouponModal(false)
|
||||||
|
// getCoupon()
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
onFinally() {
|
||||||
|
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onFinally() {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// const nowname = sessionStorage.getItem('now')
|
// const nowname = sessionStorage.getItem('now')
|
||||||
if (location.pathname == '/') {
|
if (location.pathname == '/') {
|
||||||
@ -1575,22 +1634,74 @@ export default function Index() {
|
|||||||
setMenuActive('ALL')
|
setMenuActive('ALL')
|
||||||
}}></HeadCouponModal>
|
}}></HeadCouponModal>
|
||||||
</Modal>
|
</Modal>
|
||||||
{/* <Modal title="优惠券"
|
<Modal title="可领取优惠券"
|
||||||
footer={null}
|
footer={null}
|
||||||
|
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
open={true}
|
open={getCouponModal}
|
||||||
|
|
||||||
width={809}
|
width={809}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
// setCouponModal(false)
|
// setCouponModal(false)
|
||||||
// setUnRead(0)
|
// setUnRead(0)
|
||||||
|
setGetCouponModal(false)
|
||||||
}}>
|
}}>
|
||||||
嘻嘻嘻
|
<div className='headModal-bot'>
|
||||||
</Modal> */}
|
{couponArray.map((item: any) => {
|
||||||
<div className='couponMask-box' style={{ display: coupon && (location.pathname == '/' || location.pathname.includes('/home')) ? 'unset' : 'none' }}>
|
return (
|
||||||
<div className='couponMask'>
|
<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.amount / 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'>
|
||||||
|
有效期:{item.useGmtStart} 至 {item.useGmtEnd}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='content-button' onClick={() => {
|
||||||
|
// props.closeModal()
|
||||||
|
receiveCoupons(item.couponId)
|
||||||
|
|
||||||
|
}}>
|
||||||
|
立即领取
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
<div className='couponMask-box'
|
||||||
|
style={{ display: coupon && (location.pathname == '/' || location.pathname.includes('/home')) && couponArray.length == 1 ? 'unset' : 'none' }}
|
||||||
|
>
|
||||||
|
|
||||||
|
<div className='couponMask' >
|
||||||
<div className='couponMask-img'>
|
<div className='couponMask-img'>
|
||||||
|
|
||||||
<img src={downloadUrl(cpuponImg, false)} alt="" width={'100%'} height={'100%'} onClick={() => {
|
<img src={downloadUrl(cpuponImg, false)} alt="" width={'100%'} height={'100%'} onClick={() => {
|
||||||
@ -1612,6 +1723,8 @@ export default function Index() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
Loading…
Reference in New Issue
Block a user