|
@ -1,7 +1,7 @@ |
|
|
import '~/styles/home.scss' |
|
|
import '~/styles/home.scss' |
|
|
import ProductItem, { NotOpenProductItem } from '~/components/ProductItem' |
|
|
import ProductItem, { NotOpenProductItem } from '~/components/ProductItem' |
|
|
import { useRouter } from '~/hooks/useRouter' |
|
|
import { useRouter } from '~/hooks/useRouter' |
|
|
import { Button, CountDown, Swiper, SwiperInstance } from 'react-vant' |
|
|
|
|
|
|
|
|
import { Button, CountDown, PullRefresh, Swiper, SwiperInstance } from 'react-vant' |
|
|
import { useEffect, useRef } from 'react' |
|
|
import { useEffect, useRef } from 'react' |
|
|
import { observer } from 'mobx-react' |
|
|
import { observer } from 'mobx-react' |
|
|
import store from '~/store' |
|
|
import store from '~/store' |
|
@ -14,139 +14,157 @@ const Home = () => { |
|
|
const like = useLike() |
|
|
const like = useLike() |
|
|
const swiperRef = useRef<SwiperInstance>(null) |
|
|
const swiperRef = useRef<SwiperInstance>(null) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
|
const onRefresh = () => { |
|
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
|
getData() |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
resolve(true) |
|
|
|
|
|
},2000) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getData = () => { |
|
|
store.getMarketNft("sellNft") |
|
|
store.getMarketNft("sellNft") |
|
|
store.getMarketNft("auctionNft") |
|
|
store.getMarketNft("auctionNft") |
|
|
store.getMarketNft("issueNft") |
|
|
store.getMarketNft("issueNft") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
getData() |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div className="home"> |
|
|
|
|
|
{issueNft.length > 0 && <div className='fz-20 mt-2 plr-3'>發行搶購</div>} |
|
|
|
|
|
<div className='row-between mt-2 plr-5px'> |
|
|
|
|
|
<div> |
|
|
|
|
|
<i className='iconfont icon-arrow-left-bold fz-wb-550 fz-24' onClick={() => { |
|
|
|
|
|
swiperRef.current && swiperRef.current.swipePrev() |
|
|
|
|
|
}}></i> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div style={{ flex: 1 }}> |
|
|
|
|
|
<Swiper ref={swiperRef} indicator={false}> |
|
|
|
|
|
{ |
|
|
|
|
|
issueNft.map((item, index) => ( |
|
|
|
|
|
<Swiper.Item key={item.id}> |
|
|
|
|
|
<div className='plr-5px' onClick={() => push('/detail', { id: item.id, type: item.type })}> |
|
|
|
|
|
<div className='rush-swiper'> |
|
|
|
|
|
<img src={item.url} alt="" /> |
|
|
|
|
|
<div className='content-box p-2'> |
|
|
|
|
|
<div className='sub-text fz-14'>回購型NFT</div> |
|
|
|
|
|
<div className='mt-5px'>{item.name}</div> |
|
|
|
|
|
<div className='mt-5px fz-12'> |
|
|
|
|
|
<div className='row-between'> |
|
|
|
|
|
<div className={`tag ${item.symbol}-bg`}>{item.symbol} {item.price}</div> |
|
|
|
|
|
<div className='row-center right-box'> |
|
|
|
|
|
<img src={item.cast_url} className='avatar-img' alt="" /> |
|
|
|
|
|
|
|
|
<PullRefresh |
|
|
|
|
|
onRefresh={onRefresh} |
|
|
|
|
|
> |
|
|
|
|
|
<div className="home"> |
|
|
|
|
|
{issueNft.length > 0 && <div className='fz-20 mt-2 plr-3'>發行搶購</div>} |
|
|
|
|
|
<div className='row-between mt-2 plr-5px'> |
|
|
|
|
|
<div> |
|
|
|
|
|
<i className='iconfont icon-arrow-left-bold fz-wb-550 fz-24' onClick={() => { |
|
|
|
|
|
swiperRef.current && swiperRef.current.swipePrev() |
|
|
|
|
|
}}></i> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div style={{ flex: 1 }}> |
|
|
|
|
|
<Swiper ref={swiperRef} indicator={false}> |
|
|
|
|
|
{ |
|
|
|
|
|
issueNft.map((item, index) => ( |
|
|
|
|
|
<Swiper.Item key={item.id}> |
|
|
|
|
|
<div className='plr-5px' onClick={() => push('/detail', { id: item.id, type: item.type })}> |
|
|
|
|
|
<div className='rush-swiper'> |
|
|
|
|
|
<img src={item.url} alt="" /> |
|
|
|
|
|
<div className='content-box p-2'> |
|
|
|
|
|
<div className='sub-text fz-14'>回購型NFT</div> |
|
|
|
|
|
<div className='mt-5px'>{item.name}</div> |
|
|
|
|
|
<div className='mt-5px fz-12'> |
|
|
|
|
|
<div className='row-between'> |
|
|
|
|
|
<div className={`tag ${item.symbol}-bg`}>{item.symbol} {item.price}</div> |
|
|
|
|
|
<div className='row-center right-box'> |
|
|
|
|
|
<img src={item.cast_url} className='avatar-img' alt="" /> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div className='row-between'> |
|
|
|
|
|
{ |
|
|
|
|
|
item.isTime ? ( |
|
|
|
|
|
<div className={`${item.symbol}-text`}>售賣中</div> |
|
|
|
|
|
) : ( |
|
|
|
|
|
<div className='row-items'> |
|
|
|
|
|
<div>即將發售</div> |
|
|
|
|
|
<div className={`ml-1 fz-14 mt-3px ${item.symbol}-text`}> |
|
|
|
|
|
<CountDown time={item.start_time * 1000 - Date.now()} className={`${item.symbol}-text`} onFinish={() => store.updateIssueNftIsTime(index)} /> |
|
|
|
|
|
|
|
|
<div className='row-between'> |
|
|
|
|
|
{ |
|
|
|
|
|
item.isTime ? ( |
|
|
|
|
|
<div className={`${item.symbol}-text`}>售賣中</div> |
|
|
|
|
|
) : ( |
|
|
|
|
|
<div className='row-items'> |
|
|
|
|
|
<div>即將發售</div> |
|
|
|
|
|
<div className={`ml-1 fz-14 mt-3px ${item.symbol}-text`}> |
|
|
|
|
|
<CountDown time={item.start_time * 1000 - Date.now()} className={`${item.symbol}-text`} onFinish={() => store.updateIssueNftIsTime(index)} /> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
<div className='right-box'>{item.cast_name}</div> |
|
|
|
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
<div className='right-box'>{item.cast_name}</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</Swiper.Item> |
|
|
|
|
|
)) |
|
|
|
|
|
} |
|
|
|
|
|
</Swiper> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div> |
|
|
|
|
|
<i className='iconfont icon-arrow-right-bold fz-wb-550 fz-24' onClick={() => { |
|
|
|
|
|
swiperRef.current && swiperRef.current.swipeNext() |
|
|
|
|
|
}}></i> |
|
|
|
|
|
|
|
|
</Swiper.Item> |
|
|
|
|
|
)) |
|
|
|
|
|
} |
|
|
|
|
|
</Swiper> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div> |
|
|
|
|
|
<i className='iconfont icon-arrow-right-bold fz-wb-550 fz-24' onClick={() => { |
|
|
|
|
|
swiperRef.current && swiperRef.current.swipeNext() |
|
|
|
|
|
}}></i> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div className='plr-3 fz-20 mt-2'>拍賣趨勢</div> |
|
|
|
|
|
<div className='mt-2 row-items swiper'> |
|
|
|
|
|
{ |
|
|
|
|
|
auctionNft.length <= 0 ? |
|
|
|
|
|
Array.from({ length: 2 }).map((_, index) => ( |
|
|
|
|
|
<div key={index} className={`${index === 0 ? 'ml-3' : 'ml-1 mr-3'}`}> |
|
|
|
|
|
<AuctionNotOpen /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) : auctionNft.map((item, index) => ( |
|
|
|
|
|
<div |
|
|
|
|
|
key={index} |
|
|
|
|
|
className={`swiper-item ${index === 0 ? 'ml-3' : 'ml-1'} ${index === auctionNft.length - 1 && 'mr-3'}`} |
|
|
|
|
|
> |
|
|
|
|
|
<img src={item.url} alt="" className='swiper-img' onClick={() => push('/detail', { id: item.id, type: item.type })} /> |
|
|
|
|
|
<div className='cover-box' > |
|
|
|
|
|
<div className='cover-box-item p-1 fz-12'> |
|
|
|
|
|
<div> |
|
|
|
|
|
<div>{item.name}</div> |
|
|
|
|
|
<div className='row-items mt-2px'> |
|
|
|
|
|
<div className='flex-1'> |
|
|
|
|
|
<div className='fz-8 fz-wb-550'>鑄造者</div> |
|
|
|
|
|
<div className='user-tag row-items mt-2px'> |
|
|
|
|
|
<img src={item.cast_url} alt="" /> |
|
|
|
|
|
<div className='flex-1 ml-5px text-overflow'>{item.cast_name}</div> |
|
|
|
|
|
|
|
|
<div className='plr-3 fz-20 mt-2'>拍賣趨勢</div> |
|
|
|
|
|
<div className='mt-2 row-items swiper'> |
|
|
|
|
|
{ |
|
|
|
|
|
auctionNft.length <= 0 ? |
|
|
|
|
|
Array.from({ length: 2 }).map((_, index) => ( |
|
|
|
|
|
<div key={index} className={`${index === 0 ? 'ml-3' : 'ml-1 mr-3'}`}> |
|
|
|
|
|
<AuctionNotOpen /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) : auctionNft.map((item, index) => ( |
|
|
|
|
|
<div |
|
|
|
|
|
key={index} |
|
|
|
|
|
className={`swiper-item ${index === 0 ? 'ml-3' : 'ml-1'} ${index === auctionNft.length - 1 && 'mr-3'}`} |
|
|
|
|
|
> |
|
|
|
|
|
<img src={item.url} alt="" className='swiper-img' onClick={() => push('/detail', { id: item.id, type: item.type })} /> |
|
|
|
|
|
<div className='cover-box' > |
|
|
|
|
|
<div className='cover-box-item p-1 fz-12'> |
|
|
|
|
|
<div> |
|
|
|
|
|
<div>{item.name}</div> |
|
|
|
|
|
<div className='row-items mt-2px'> |
|
|
|
|
|
<div className='flex-1'> |
|
|
|
|
|
<div className='fz-8 fz-wb-550'>鑄造者</div> |
|
|
|
|
|
<div className='user-tag row-items mt-2px'> |
|
|
|
|
|
<img src={item.cast_url} alt="" /> |
|
|
|
|
|
<div className='flex-1 ml-5px text-overflow'>{item.cast_name}</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div className='flex-1'> |
|
|
|
|
|
<div className='fz-8 fz-wb-550'>售賣者</div> |
|
|
|
|
|
<div className='user-tag row-items mt-2px'> |
|
|
|
|
|
<img src={item.sell_url} alt="" /> |
|
|
|
|
|
<div className='flex-1 ml-5px text-overflow'>{item.sell_name}</div> |
|
|
|
|
|
|
|
|
<div className='flex-1'> |
|
|
|
|
|
<div className='fz-8 fz-wb-550'>售賣者</div> |
|
|
|
|
|
<div className='user-tag row-items mt-2px'> |
|
|
|
|
|
<img src={item.sell_url} alt="" /> |
|
|
|
|
|
<div className='flex-1 ml-5px text-overflow'>{item.sell_name}</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div className='row-between'> |
|
|
|
|
|
<Button className={`button ${item.symbol}-bg`} round onClick={() => push('/detail', { id: item.id, type: item.type })}> |
|
|
|
|
|
<div className='fz-wb-550 white'>出價</div> |
|
|
|
|
|
</Button> |
|
|
|
|
|
<i className={`
|
|
|
|
|
|
|
|
|
<div className='row-between'> |
|
|
|
|
|
<Button className={`button ${item.symbol}-bg`} round onClick={() => push('/detail', { id: item.id, type: item.type })}> |
|
|
|
|
|
<div className='fz-wb-550 white'>出價</div> |
|
|
|
|
|
</Button> |
|
|
|
|
|
<i className={`
|
|
|
iconfont icon-daohangshoucangyishoucang fz-18 ${like.isLike(item.id, likeNft) ? item.symbol + '-text' : 'sub-text'} |
|
|
iconfont icon-daohangshoucangyishoucang fz-18 ${like.isLike(item.id, likeNft) ? item.symbol + '-text' : 'sub-text'} |
|
|
`} onClick={() => like.setLike(item.id)} />
|
|
|
`} onClick={() => like.setLike(item.id)} />
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
)) |
|
|
|
|
|
} |
|
|
|
|
|
</div> |
|
|
|
|
|
<div className='plr-3 fz-20 mt-2'>售賣市場</div> |
|
|
|
|
|
<div className='plr-3'> |
|
|
|
|
|
<div className='row-between flex-wrap'> |
|
|
|
|
|
{ |
|
|
|
|
|
sellNft.length <= 0 ? |
|
|
|
|
|
Array.from({ length: 2 }).map((_, index) => ( |
|
|
|
|
|
<div key={index}> |
|
|
|
|
|
<NotOpenProductItem /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) |
|
|
|
|
|
: sellNft.map((item, index) => ( |
|
|
|
|
|
<div key={index} onClick={() => push('/detail', { id: item.id, type: item.type })}> |
|
|
|
|
|
<ProductItem data={item} /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) |
|
|
)) |
|
|
} |
|
|
} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div className='plr-3 fz-20 mt-2'>售賣市場</div> |
|
|
|
|
|
<div className='plr-3'> |
|
|
|
|
|
<div className='row-between flex-wrap'> |
|
|
|
|
|
{ |
|
|
|
|
|
sellNft.length <= 0 ? |
|
|
|
|
|
Array.from({ length: 2 }).map((_, index) => ( |
|
|
|
|
|
<div key={index}> |
|
|
|
|
|
<NotOpenProductItem /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) |
|
|
|
|
|
: sellNft.map((item, index) => ( |
|
|
|
|
|
<div key={index} onClick={() => push('/detail', { id: item.id, type: item.type })}> |
|
|
|
|
|
<ProductItem data={item} /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) |
|
|
|
|
|
} |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</PullRefresh> |
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|