Commit e46903f7 authored by hewenhao's avatar hewenhao

feat: update

parent cb4c5302
......@@ -25,6 +25,7 @@
width: 300px;
height: 300px;
display: block;
position: relative;
}
......
......@@ -10,6 +10,13 @@
width: 300px;
height: 300px;
display: block;
position: absolute;
opacity: 0;
transition: opacity 1s ease;
&.is_current {
opacity: 1;
}
}
.dialog {
......
......@@ -56,15 +56,12 @@ const Scene1 = ({ onNext }: Scene1Props) => {
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={cs.sprite}>
{current === 0 && (
<Image src={assets['cat.png'].u} className={cs.cat} />
)}
{current === 1 && (
<Image src={assets['cat-2.png'].u} className={cs.cat} />
)}
{(current === 2 || current === 3) && (
<Image src={assets['cat-3.png'].u} className={cs.cat} />
)}
<View className={cs.cat}>
<Image src={assets['cat.png'].u} className={classNames(styles.cat, current === 0 && styles.is_current)} />
<Image src={assets['cat-3.png'].u} className={classNames(styles.cat, current === 1 && styles.is_current)} />
<Image src={assets['cat-2.png'].u} className={classNames(styles.cat, current === 2 && styles.is_current)} />
<Image src={assets['cat-3.png'].u} className={classNames(styles.cat, current === 3 && styles.is_current)} />
</View>
<View className={styles.dialog}>
{current === 0 && (
<View className={styles.modal_1}>
......
......@@ -86,12 +86,40 @@
padding: 28px 0 20px 0;
text-align: center;
position: relative;
animation-name: fadeInUp;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-fill-mode: backwards;
animation-iteration-count: 1;
&:nth-child(1) {
animation-delay: 0;
}
&:nth-child(2) {
animation-delay: .3s;
}
&:nth-child(3) {
animation-delay: .6s;
}
&:last-child {
margin-right: 0;
}
}
@keyframes fadeInUp {
0% {
opacity: 0;
transform: translateY(82px) scale(0.5, 0.5);
}
100% {
opacity: 1;
transform: translateY(0) scale(1, 1);
}
}
.right {
position: absolute;
right: 0;
......
......@@ -9,6 +9,7 @@ interface CardMainProps {
subtitle: string;
disabled?: boolean;
extra?: React.ReactNode;
disabledText?: string;
price: number;
stock: number | null;
}
......@@ -21,7 +22,8 @@ export default ({
onClick,
disabled,
price,
stock
stock,
disabledText = '积分不足'
}: CardMainProps) => {
const _onClick = () => {
if (!disabled) {
......@@ -54,7 +56,7 @@ export default ({
onClick={_onClick}
hoverClass={!disabled ? styles.btn_on : ''}
>
兑换
{disabled ? disabledText : '兑换'}
</View>
</View>
</View>
......
/* eslint-disable import/no-commonjs */
import { useState, useCallback } from 'react'
import { useState, useCallback, useMemo } from 'react'
import { View, Text, Image } from '@tarojs/components'
import { useDidShow } from '@tarojs/taro'
......@@ -21,26 +21,6 @@ type ExchangeGoods = {
img: string;
}
const ExchangeItems: ExchangeGoods[] = [
{
title: '答题卡',
subTitle: '答题卡',
description: '答题卡是不断追求更高档位与排名的必备道具',
price: 30,
stock: null,
img: require('./assets/ph.png'),
},
// {
// title: '月度神秘大礼',
// subTitle: '神秘大礼',
// description: '兑换神秘大礼,线下领取超级大礼',
// price: 30,
// stock: 10,
// img: require('./assets/gift.png'),
// }
]
const StudyMarket = () => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [currentGoods, setCurrentGoods] = useState<ExchangeGoods | null>(null)
......@@ -53,6 +33,27 @@ const StudyMarket = () => {
getSetting()
fetchAccount()
})
const list: ExchangeGoods[] = useMemo(() => {
return [
{
title: '答题卡',
subTitle: '答题卡',
description: '答题卡是不断追求更高档位与排名的必备道具',
price: setting.pointToCard,
stock: null,
img: require('./assets/ph.png'),
},
{
title: '月度神秘大礼',
subTitle: '神秘大礼',
description: '兑换神秘大礼,线下领取超级大礼',
price: 1000,
stock: null,
img: require('./assets/gift.png'),
}
]
}, [setting])
const open = useCallback((goods: ExchangeGoods) => {
setCurrentGoods(goods)
......@@ -66,23 +67,36 @@ const StudyMarket = () => {
<Image src={require('./assets/score.png')} className={styles.score_icon}></Image>
</View>
<View className={styles.card_list}>
{ExchangeItems.map(item => (
{list.map(item => {
const pric = item.price
let disabledText = '积分不足'
let disabled = point < pric || (item.stock !== null && item.stock < 1)
if (item.title === '月度神秘大礼') {
disabled = true
if (point >= pric) {
disabledText = '敬请期待'
}
}
return (
<Card title={item.title} key={item.title}>
<View className={styles['card-body']}>
<CardMain
title={item.subTitle}
cover={item.img}
stock={item.stock}
price={setting.pointToCard}
disabled={item.stock !== null && item.stock < 1}
price={pric}
disabled={disabled}
subtitle={item.description}
disabledText={disabledText}
onClick={() => {
open(item)
}}
/>
</View>
</Card>
))}
)
})}
</View>
<Modal isVisible={isVisible} bodyClassName={styles.moal_body} onClose={setFalse} maskClosable={false} tilte={`兑换${currentGoods?.title ?? ''}`}>
......
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