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