Commit d2c8d408 authored by hewenhao's avatar hewenhao

feat: 兑换礼物优化

parent 51cf0600
......@@ -36,17 +36,19 @@ const ExchangeItem = (props: ExchangeItemProps) => {
}, [val])
useEffect(() => {
if (!visible) {
setTimeout(() => {
if (visible) {
if (maxValue > stepValue) {
setVal(1)
}, 1000)
} else {
setVal(0)
}
}
}, [visible])
}, [visible, stepValue, maxValue])
const handleAdd = useCallback(() => {
const next = val + 1
if (next * stepValue > maxValue) {
return showToast({ title: '学分不足~', icon: 'none' })
return showToast({ title: '水晶不足~', icon: 'none' })
}
setVal(next)
}, [val, stepValue, maxValue])
......
......@@ -21,6 +21,7 @@ import styles from './index.module.scss'
type ExchangeGoods = {
title?: string;
subTitle: string;
isUpComing?: boolean;
description: string;
price: number;
isGuideCard?: boolean;
......@@ -36,6 +37,7 @@ const itemList: ExchangeGoods[] = [
price: 600,
isGuideCard: true,
stock: null,
isUpComing: true,
img: assets['item-1.png'].u,
},
{
......@@ -43,6 +45,7 @@ const itemList: ExchangeGoods[] = [
description: '让元气满满的向日葵,陪伴你一起向阳而生吧。',
price: 600,
stock: null,
isUpComing: true,
img: assets['item-2.png'].u,
},
{
......@@ -50,6 +53,7 @@ const itemList: ExchangeGoods[] = [
description: '播下种子,浇水施肥,收获属于你的酸甜小小西红柿。',
price: 600,
stock: null,
isUpComing: true,
img: assets['item-3.png'].u,
},
{
......@@ -57,6 +61,7 @@ const itemList: ExchangeGoods[] = [
description: '用心拼一朵玫瑰,送给为你辛苦的妈妈。',
price: 700,
stock: null,
isUpComing: true,
img: assets['item-4.png'].u,
},
{
......@@ -64,6 +69,7 @@ const itemList: ExchangeGoods[] = [
description: '自带颜料的创意绘画本,让你随地作画,随时随地开启小画家模式。',
price: 700,
stock: null,
isUpComing: true,
img: assets['item-5.png'].u,
},
]
......@@ -137,7 +143,7 @@ const StudyMarket = () => {
const pric = item.price
let disabledText = '积分不足'
let disabled = point < pric || (item.stock !== null && item.stock < 1)
if (item.subTitle === '神秘大礼') {
if (item.isUpComing) {
disabled = true
if (point >= pric) {
disabledText = '敬请期待'
......@@ -171,7 +177,7 @@ const StudyMarket = () => {
cover={item.img}
stock={item.stock}
price={pric}
disabled={disabled}
disabled={!storeGuideActive && disabled}
subtitle={item.description}
disabledText={disabledText}
isGuideActive={isMaskActive && storeGuideStep === 2 && index === 0}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment