Commit d2c8d408 authored by hewenhao's avatar hewenhao

feat: 兑换礼物优化

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