Browse Source

commit

master
yyy9608 1 year ago
parent
commit
10829255e2
  1. 30
      src/api/index.ts
  2. 13
      src/components/Modal.tsx
  3. 65
      src/components/ProductInfo.tsx
  4. 2
      src/components/ProductItem.tsx
  5. 1
      src/hooks/useConnectWallet.ts
  6. 2
      src/hooks/useLike.ts
  7. 85
      src/pages/detail/AuctionNFT.tsx
  8. 14
      src/pages/detail/BuyNft.tsx
  9. 101
      src/pages/detail/IssuanceRushNFT.tsx
  10. 144
      src/pages/detail/OnShelvesNFT.tsx
  11. 58
      src/pages/detail/RemoveMarketMyNFT.tsx
  12. 82
      src/pages/detail/index.tsx
  13. 82
      src/pages/home/index.tsx
  14. 104
      src/pages/no-share/index.tsx
  15. 5
      src/pages/personal/AccountAssetsCard.tsx
  16. 40
      src/pages/record/index.tsx
  17. 2
      src/pages/share/index.tsx
  18. 1
      src/pages/withdraw/index.tsx
  19. 20
      src/router/layout/Navbar.tsx
  20. 4
      src/router/layout/index.tsx
  21. 5
      src/router/routes.tsx
  22. 3
      src/store/index.ts
  23. 13
      src/styles/components.scss
  24. 93
      src/styles/detail.scss
  25. 8
      src/styles/global.scss
  26. 11
      src/styles/home.scss
  27. 6
      src/styles/share.scss
  28. 10
      src/types/store.d.ts

30
src/api/index.ts

@ -124,7 +124,35 @@ export const nft_detail = (query: object) =>
* @description Buy NFT * @description Buy NFT
* @param {number} id * @param {number} id
* @param {number} type * @param {number} type
* @param {string} amount
* @param {string} mark
*/ */
export const buy_nft = (query: object) => export const buy_nft = (query: object) =>
request({ url: "/v1/buy", data: query }); request({ url: "/v1/buy", data: query });
/**
* @description NFT
* @param {number} id NFT id
* @param {number} type 1. 2.
* @param {string} amount
* @param {number} mark
* @param {string} symbol USDT FIL
* @param {number} time
*/
export const shelves_nft = (query: object) =>
request({ url: "/v1/shelves", data: query });
/**
* @description NFT
* @param {number} id NFT id
*/
export const un_shelves_nft = (id: number) =>
request({ url: "/v1/unshelves", data: { id } });
/**
* @description
* @param {number} id user id
*/
export const no_user_info = (id: number) =>
request({ url: "/v1/showAccount", data: { id } });

13
src/components/Modal.tsx

@ -15,10 +15,11 @@ interface ModalProps {
showConfirmButton?: boolean; showConfirmButton?: boolean;
confirmButtonClass?: string; confirmButtonClass?: string;
backgroundColosed?: boolean; backgroundColosed?: boolean;
width?: string;
} }
const Modal = ( const Modal = (
{ title, buttonClick, visible, setVisible, children, buttonText, hiddenCloseIcon, showCancelButton, showCancelButtonText, showCancelButtonClick, showConfirmButton, backgroundColosed }: ModalProps
{ title, buttonClick, visible, setVisible, children, buttonText, hiddenCloseIcon, showCancelButton, showCancelButtonText, showCancelButtonClick, showConfirmButton, backgroundColosed, width }: ModalProps
) => { ) => {
return ( return (
<Overlay <Overlay
@ -27,7 +28,7 @@ const Modal = (
style={{ height: '100%' }} style={{ height: '100%' }}
onClick={() => backgroundColosed && setVisible(false)} onClick={() => backgroundColosed && setVisible(false)}
> >
<div className='modal-content'>
<div className='modal-content' style={{ width: width }}>
<div className='tac row-center'> <div className='tac row-center'>
<div style={{ flex: 1 }}></div> <div style={{ flex: 1 }}></div>
<div style={{ flex: 1, whiteSpace: 'nowrap' }} className='fz-20 fz-wb-550'>{title}</div> <div style={{ flex: 1, whiteSpace: 'nowrap' }} className='fz-20 fz-wb-550'>{title}</div>
@ -40,17 +41,19 @@ const Modal = (
</div> </div>
</div> </div>
{children} {children}
<div className='mt-3 row-center'>
<div className='row-center'>
{ {
!showConfirmButton && ( !showConfirmButton && (
<div className={`modal-button row-center`} onClick={() => buttonClick && buttonClick()}>{buttonText}</div>
<div className={`modal-button row-center mt-3 `} onClick={() => buttonClick && buttonClick()}>{buttonText}</div>
) )
} }
{ {
showCancelButton && showCancelButton &&
<div className='modal-button row-center ml-2' onClick={() => showCancelButtonClick && showCancelButtonClick()}>{showCancelButtonText || '關閉'}</div>
<div className='modal-button row-center ml-2 mt-3 ' onClick={() => showCancelButtonClick && showCancelButtonClick()}>{showCancelButtonText || '關閉'}</div>
} }
</div> </div>
</div> </div>
</Overlay> </Overlay>
) )

65
src/components/ProductInfo.tsx

@ -1,10 +1,12 @@
import { observer } from 'mobx-react' import { observer } from 'mobx-react'
import { useState } from 'react' import { useState } from 'react'
import { CountDown, Toast } from 'react-vant'
import useLike from '~/hooks/useLike' import useLike from '~/hooks/useLike'
import { useRouter } from '~/hooks/useRouter'
import store from '~/store' import store from '~/store'
import '~/styles/components.scss' import '~/styles/components.scss'
import { MarketNFTData } from '~/types/store' import { MarketNFTData } from '~/types/store'
import { toThousands } from '~/utils'
import { getTime, toThousands } from '~/utils'
import { copy } from '~/utils/copy' import { copy } from '~/utils/copy'
import Modal from './Modal' import Modal from './Modal'
@ -15,7 +17,8 @@ interface ProductInfoProps {
const ProductInfo = (props: ProductInfoProps) => { const ProductInfo = (props: ProductInfoProps) => {
const { data } = props const { data } = props
const { likeNft } = store.state
const { push } = useRouter()
const { likeNft, userInfo } = store.state
const { setLike, isLike } = useLike() const { setLike, isLike } = useLike()
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
@ -25,6 +28,32 @@ const ProductInfo = (props: ProductInfoProps) => {
setVisible(true) setVisible(true)
} }
const toShare = (type: "cast" | "sell") => {
if (type === 'cast') {
if (data.cast_id === userInfo.id) {
push('/share')
return
}
if (data.cast_show === 1) {
push('/noShare', { id: data.cast_id })
} else {
Toast.fail('對方未開放')
}
}
if (type === 'sell') {
if (data.sell_id === userInfo.id) {
push('/share')
return
}
if (data.sell_show === 1) {
push('/noShare', { id: data.sell_id })
} else {
Toast.fail('對方未開放')
}
}
}
return ( return (
<div className='product-info'> <div className='product-info'>
<div className='row-center'> <div className='row-center'>
@ -32,6 +61,12 @@ const ProductInfo = (props: ProductInfoProps) => {
<img src={data.url} className="img" alt="" /> <img src={data.url} className="img" alt="" />
</div> </div>
</div> </div>
{data.type === 1 && <div className='row-center mt-1'>
<CountDown time={data.end_Time * 1000 - Date.now()} className="fz-18 fz-wb-550" style={{ letterSpacing: 2 }} />
</div>}
{data.type === 3 && <div className='row-center mt-1'>
<CountDown time={data.start_time * 1000 - Date.now()} className="fz-18 fz-wb-550" style={{ letterSpacing: 2 }} />
</div>}
{data.type !== 0 && <div className='mt-1 row-center'> {data.type !== 0 && <div className='mt-1 row-center'>
<i className={`iconfont icon-daohangshoucangyishoucang fz-20 ${isLike(data.id, likeNft) ? 'like-text' : 'sub-text'}`} onClick={() => setLike(data.id)} /> <i className={`iconfont icon-daohangshoucangyishoucang fz-20 ${isLike(data.id, likeNft) ? 'like-text' : 'sub-text'}`} onClick={() => setLike(data.id)} />
<i className='iconfont icon-shangchuandaochu fz-24 ml-4' onClick={share} /> <i className='iconfont icon-shangchuandaochu fz-24 ml-4' onClick={share} />
@ -39,21 +74,29 @@ const ProductInfo = (props: ProductInfoProps) => {
<div className='mt-3 fz-30 fz-wb-550'>{data.name}</div> <div className='mt-3 fz-30 fz-wb-550'>{data.name}</div>
<div className={`price-tag mt-1 ${data.symbol}-bg`}>{data.symbol} {toThousands(data.price)}</div> <div className={`price-tag mt-1 ${data.symbol}-bg`}>{data.symbol} {toThousands(data.price)}</div>
<div className='mt-3 row-between'> <div className='mt-3 row-between'>
<div>
<div onClick={() => toShare('cast')}>
<div></div> <div></div>
<div className='user-tag mt-2 plr-1 row-items'> <div className='user-tag mt-2 plr-1 row-items'>
<img src={data.cast_url} alt="" /> <img src={data.cast_url} alt="" />
<div className='fz-12 tac flex-1 name-overflow'>{data.cast_name}</div> <div className='fz-12 tac flex-1 name-overflow'>{data.cast_name}</div>
</div> </div>
</div> </div>
<div>
<div></div>
<div className='user-tag mt-2 plr-1 row-items'>
<img src={data.sell_url} alt="" />
<div className='fz-12 tac flex-1 name-overflow'>{data.sell_name}</div>
{data.type === 3 ? (
<div className={`mt-5 row-items fz-14 ${data.symbol}-text`}>
<div>{data.current_number}</div>
<div className='ml-1'>{data.remain_quantity}</div>
</div> </div>
</div>
</div>
) : (
<div onClick={() => toShare('sell')}>
<div></div>
<div className='user-tag mt-2 plr-1 row-items'>
<img src={data.sell_url} alt="" />
<div className='fz-12 tac flex-1 name-overflow'>{data.sell_name}</div>
</div>
</div>
)
}
</div >
<Modal <Modal
visible={visible} visible={visible}
title="分享給朋友" title="分享給朋友"
@ -65,7 +108,7 @@ const ProductInfo = (props: ProductInfoProps) => {
</div> </div>
</Modal> </Modal>
</div>
</div >
) )
} }

2
src/components/ProductItem.tsx

@ -20,7 +20,7 @@ const ProductItem = (props: ProductItemProps) => {
<div className='price-tag fz-10'>{data?.symbol} {toThousands(data?.price)}</div> <div className='price-tag fz-10'>{data?.symbol} {toThousands(data?.price)}</div>
<div className='user-tag'> <div className='user-tag'>
<img src={data.sell_url} className="user-img" alt="" /> <img src={data.sell_url} className="user-img" alt="" />
<div className='fz-10 ml-3px'>{splitAddress(data.sell_name,4)}</div>
<div className='fz-10 ml-3px text-overflow'>{data.sell_name}</div>
</div> </div>
</div> </div>
</div> </div>

1
src/hooks/useConnectWallet.ts

@ -6,6 +6,7 @@ import $store from "../store";
export default function useConnectWallet() { export default function useConnectWallet() {
const connect = async () => { const connect = async () => {
if (!(window as any).ethereum) { if (!(window as any).ethereum) {
window.location.reload();
return; return;
} }
let res = await (window as any).ethereum.request({ let res = await (window as any).ethereum.request({

2
src/hooks/useLike.ts

@ -19,7 +19,7 @@ const useLike = () => {
let res: any = await set_like(id, status); let res: any = await set_like(id, status);
throttle.current = false throttle.current = false
if (res && res.code === 0) { if (res && res.code === 0) {
store.getMyNft("likeNft", 2);
store.getMyNft("likeNft");
} }
}; };

85
src/pages/detail/AuctionNFT.tsx

@ -0,0 +1,85 @@
import { useMemo, useState } from "react"
import { Button, Toast } from "react-vant"
import { buy_nft } from "~/api"
import Modal from "~/components/Modal"
import store from "~/store"
import '~/styles/detail.scss'
import { MarketNFTData } from "~/types/store"
import { toFixed2, toThousands } from "~/utils"
interface AuctionNFTProps {
data: MarketNFTData,
getData: Function
}
const AuctionNFT = (props: AuctionNFTProps) => {
const { data, getData } = props
const [visible, setVisible] = useState(false)
const [markupCount, setMarkupCount] = useState(0)
const currentPrice = useMemo(() => {
let price = (data.mark * markupCount / 100 * Number(data.auction_price)) + Number(data.price)
return toFixed2(`${price}`, 3)
}, [data, markupCount])
const openModal = () => {
if (!store.state.token) return store.setVisibleUnLogin(true)
const diffTime = data.end_Time - Date.now() / 1000
if (diffTime <= 0) return Toast.fail("拍賣時間已過")
setVisible(true)
}
const confirm = async () => {
setVisible(false)
const params = {
mark: markupCount * data.mark,
id: data.id,
type: data.type
}
const res: any = await buy_nft(params)
if (res && res.code === 0) {
getData()
store.getMarketNft("auctionNft")
store.getUserInfo()
Toast.success('出價成功')
}
}
return (
<div className='mt-4 buy-nft'>
<Button
className='button'
style={{
background: 'linear-gradient(103deg, #1DD0DF -1%, #1DD0DF -1%, #1BEDFF -1%, #14BDEB 108%)',
borderRadius: 10,
}}
onClick={openModal}
>
<span className="fz-20 fz-wb-550"></span>
</Button>
<Modal
title={data.name}
visible={visible}
setVisible={setVisible}
showConfirmButton
width="90%"
>
<div>
<div className={`tac mt-2 fz-wb-550`}> "<span className={`${data.symbol}-text`}>{toThousands(currentPrice)}</span>" {data.symbol}</div>
<div className={`tac mt-1 fz-wb-550`}> +{data.mark}% <span className={`${data.symbol}-text`}>{toThousands((data.mark / 100 * Number(data.auction_price)) + Number(data.price))}</span> {data.symbol}</div>
<div className="row-center mt-3">
<div className={`tag-mark ${data.symbol}-bg`} onClick={() => {
setMarkupCount(val => val + 1)
}}>+{data.mark}%</div>
<div className={`tag-mark ml-2 ${markupCount <= 0 ? 'mark-button-disable' : data.symbol + '-bg'}`} onClick={() => markupCount > 0 && setMarkupCount(val => val - 1)}>-{data.mark}%</div>
</div>
<div className="mt-3 row-center">
<Button onClick={confirm} className={`mark-button ${data.symbol}-bg`} disabled={markupCount <= 0}></Button>
</div>
</div>
</Modal>
</div>
)
}
export default AuctionNFT

14
src/pages/detail/BuyNft.tsx

@ -42,14 +42,14 @@ const BuyNft = (props: BuyNftProps) => {
const res: any = await buy_nft(params) const res: any = await buy_nft(params)
if (res && res.code === 0) { if (res && res.code === 0) {
setSuccessVisible(true) setSuccessVisible(true)
store.getMyNft("myNft", 1)
store.getMarketNft("issueNft")
store.getMyNft("myNft")
store.getMarketNft("sellNft") store.getMarketNft("sellNft")
store.getUserInfo()
} }
} }
return ( return (
<div className='mt-4 buy-nft'>
<div className='mtb-4 buy-nft'>
<Button <Button
className='button' className='button'
style={{ style={{
@ -65,12 +65,14 @@ const BuyNft = (props: BuyNftProps) => {
visible={buyVisible} visible={buyVisible}
setVisible={setBuyVisible} setVisible={setBuyVisible}
title="購買" title="購買"
buttonText={<div className='black fz-wb-550'></div>}
buttonClick={buyNft}
showConfirmButton
> >
<div className='fz-wb-550' style={{ fontStyle: 'italic' }}> <div className='fz-wb-550' style={{ fontStyle: 'italic' }}>
<div className='tac mt-3'> <span className='primary'>{toThousands(data.price)}</span> {data.symbol}</div>
<div className='tac mt-3'> <span className={`${data.symbol}-text`}>{toThousands(data.price)}</span> {data.symbol}</div>
<div className='tac mt-5px'> "{data.name}" NFT</div> <div className='tac mt-5px'> "{data.name}" NFT</div>
<div className="mt-3 row-center">
<Button onClick={buyNft} className={`mark-button ${data.symbol}-bg`}></Button>
</div>
</div> </div>
</Modal > </Modal >
{/* success */} {/* success */}

101
src/pages/detail/IssuanceRushNFT.tsx

@ -0,0 +1,101 @@
import { useMemo, useState } from "react"
import { Button, CountDown } from "react-vant"
import { buy_nft } from "~/api"
import Modal from "~/components/Modal"
import store from "~/store"
import '~/styles/detail.scss'
import { MarketNFTData } from "~/types/store"
import { getTime, toThousands } from "~/utils"
import NFTProperties from "./NFTProperties"
interface IssuanceRushNFTProps {
data: MarketNFTData,
getData: Function
}
const IssuanceRushNFT = (props: IssuanceRushNFTProps) => {
const { data, getData } = props
const [isBuy, setIsBuy] = useState(false)
const [buyVisible, setBuyVisible] = useState(false)
const [successVisible, setSuccessVisible] = useState(false)
const openModal = () => {
if (!isBuy) return
setBuyVisible(true)
}
const buyNft = async () => {
setBuyVisible(false)
const params = {
id: data.id,
type: data.type
}
const res: any = await buy_nft(params)
if (res && res.code === 0) {
setSuccessVisible(true)
getData()
store.getMyNft("myNft")
store.getMarketNft("issueNft")
store.getUserInfo()
}
}
return (
<div className='mt-2 buy-nft'>
<div className="fz-wb-550">NFT説明:</div>
<div className="fz-14 mt-1 taj">{data.illustrate}</div>
<div className="mt-2">
<NFTProperties data={data} />
</div>
<Button
className={`button ${data.symbol}-bg mtb-3`}
style={{
borderRadius: 10,
}}
onClick={openModal}
>
{
isBuy ? (
<span className="fz-20 fz-wb-550 white"></span>
) : (
<CountDown onFinish={() => {
setIsBuy(true)
}} time={data.start_time * 1000 - Date.now()} className="fz-20 white" style={{ letterSpacing: 2 }} />
)
}
</Button>
<Modal
visible={buyVisible}
setVisible={setBuyVisible}
title="購買"
showConfirmButton
>
<div className='fz-wb-550' style={{ fontStyle: 'italic' }}>
<div className='tac mt-3'> <span className={`${data.symbol}-text`}>{toThousands(data.price)}</span> {data.symbol}</div>
<div className='tac mt-5px'> "{data.name}" NFT</div>
<div className="mt-3 row-center">
<Button onClick={buyNft} className={`mark-button ${data.symbol}-bg`}></Button>
</div>
</div>
</Modal >
{/* success */}
<Modal
visible={successVisible}
setVisible={setSuccessVisible}
showConfirmButton
title=''
>
<div>
<div className='row-center'>
<img src={require('~/assets/buy-success.png')} alt="" className='success-img' />
</div>
<div className='fz-18 fz-wb-550 tac'></div>
<div className='fz-24 fz-wb-550 tac mt-1'>{data.name}</div>
</div>
</Modal>
</div>
)
}
export default IssuanceRushNFT

144
src/pages/detail/OnShelvesNFT.tsx

@ -1,4 +1,12 @@
import { useMemo, useRef, useState } from "react"
import { Button, Radio, Toast } from "react-vant"
import { MarketNFTData } from "~/types/store" import { MarketNFTData } from "~/types/store"
import '~/styles/detail.scss'
import Modal from "~/components/Modal"
import { toThousands } from "~/utils"
import { shelves_nft } from "~/api"
import store from "~/store"
import { useRouter } from "~/hooks/useRouter"
interface OnShelvesNFTProps { interface OnShelvesNFTProps {
data: MarketNFTData data: MarketNFTData
@ -7,10 +15,142 @@ interface OnShelvesNFTProps {
const OnShelvesNFT = (props: OnShelvesNFTProps) => { const OnShelvesNFT = (props: OnShelvesNFTProps) => {
const { data } = props const { data } = props
const { push } = useRouter()
const [defaultValue, setDefaultValue] = useState("") //1.拍賣 2.售賣
const symbols = useMemo(() => ['FIL', 'USDT'], [])
const markups = useMemo(() => [1, 5, 10], []) // 拍賣加價
const auctionTimes = useMemo(() => [24, 48, 72], []) // 拍賣時間
const [currentMarkeup, setCurrentMarkeup] = useState(5) //當前拍賣加價
const [currentSymbol, setCurrentSymbol] = useState('') //當前代筆
const [currentAuctionTime, setCurrentAuctionTime] = useState(24) //當前拍賣時間
const [visible, setVisible] = useState(false)//拍賣
const [sellVisible, setSellVisible] = useState(false)//售賣
const amountRef = useRef<HTMLInputElement>(null)
const openModal = () => {
if (!store.state.token) return store.setVisibleUnLogin(true)
if (!defaultValue) return Toast.fail('請選擇拍賣或售賣')
if (!currentSymbol) return Toast.fail('請選擇代筆')
if (!amountRef.current!.value) return Toast.fail('請輸入上架金額');
if (defaultValue === "1") return setVisible(true)
setSellVisible(true)
}
// 確認拍賣
const confirmAuction = async () => {
setVisible(false)
const params = {
id: data.id,
amount: amountRef.current?.value,
symbol: currentSymbol,
mark: currentMarkeup,
time: currentAuctionTime,
type: Number(defaultValue)
}
const res: any = await shelves_nft(params)
if (res && res.code === 0) {
Toast.success('上架成功')
store.getMarketNft("auctionNft")
store.getMyNft("myNft");
store.getUserInfo()
push(-1)
}
}
// 確認售賣
const confirmSell = async () => {
setSellVisible(false)
const params = {
id: data.id,
amount: amountRef.current?.value,
symbol: currentSymbol,
type: Number(defaultValue)
}
const res: any = await shelves_nft(params)
if (res && res.code === 0) {
Toast.success('上架成功')
store.getMarketNft("sellNft")
store.getMyNft("myNft");
store.getUserInfo()
push(-1)
}
}
return ( return (
<div className="mt-2">
<div className="mt-2 on-shelves-nft">
<Radio.Group defaultValue={defaultValue} onChange={setDefaultValue} direction="horizontal" checkedColor="#0FC6D4">
<Radio name="1"></Radio>
<Radio name="2" className="ml-2"></Radio>
</Radio.Group>
<div className="mt-2 row-items">
{
symbols.map(item => (
<div key={item} className={`row-center tag ${item}-bg mr-2 ${currentSymbol === item && 'tag-active'}`} onClick={() => {
setCurrentSymbol(item)
console.log(currentSymbol);
}}>
<img src={require(`~/assets/${item}.png`)} alt="" />
<div>{item}</div>
</div>
))
}
</div>
<div className="mt-2">
<input placeholder="請輸入上架金額" className="input" ref={amountRef} />
</div>
<div className="mtb-2">
<Button className="on-button" onClick={openModal}></Button>
</div>
{/* 拍賣 */}
<Modal
width="90%"
title={data.name}
visible={visible}
setVisible={setVisible}
showConfirmButton
>
<div className="mt-2">
<div className="tac fz-wb-550"> "<span className={`${currentSymbol}-text`}>{toThousands(amountRef.current?.value || '0')}</span>" {currentSymbol}</div>
<div className="tac mt-5px fz-wb-550"> <span className={`${currentSymbol}-text`}>{currentMarkeup}%</span></div>
<div className="row-center mt-1">
{
markups.map((item, index) => (
<div key={item} className={`row-center ${index === 1 && 'mlr-3'} fz-14 auction-tag ${currentSymbol}-bg`} onClick={() => setCurrentMarkeup(item)}>+{item}%</div>
))
}
</div>
<div className="tac mt-3 fz-wb-550"> "<span className={`${currentSymbol}-text`}>{currentAuctionTime}</span>" </div>
<div className="row-center mt-2">
{
auctionTimes.map((item, index) => (
<div key={item} className={`row-center ${index === 1 && 'mlr-3'} fz-14 auction-tag ${currentSymbol}-bg`} onClick={() => setCurrentAuctionTime(item)}>{item}</div>
))
}
</div>
<div className="row-center mt-3">
<Button onClick={confirmAuction} className={`markeup-button ${currentSymbol}-bg`}></Button>
</div>
</div>
</Modal>
{/* 售賣 */}
<Modal
width="90%"
title={data.name}
visible={sellVisible}
setVisible={setSellVisible}
showConfirmButton
>
<div className="mt-2">
<div className="tac fz-wb-550"> "<span className={`${currentSymbol}-text`}>{toThousands(amountRef.current?.value || '0')}</span>" {currentSymbol}</div>
<div className="row-center mt-3">
<Button onClick={confirmSell} className={`markeup-button ${currentSymbol}-bg`}></Button>
</div>
</div>
</Modal>
</div> </div>
) )
} }

58
src/pages/detail/RemoveMarketMyNFT.tsx

@ -0,0 +1,58 @@
import { useState } from 'react'
import { Button, Toast } from 'react-vant'
import { un_shelves_nft } from '~/api'
import Modal from '~/components/Modal'
import { useRouter } from '~/hooks/useRouter'
import store from '~/store'
import '~/styles/detail.scss'
import { MarketNFTData } from '~/types/store'
interface RemoveMarketMyNFTProps {
data: MarketNFTData
}
const RemoveMarketMyNFT = (props: RemoveMarketMyNFTProps) => {
const { data } = props
const { push } = useRouter()
const [visible, setVisible] = useState(false)
const confirm = async () => {
setVisible(false)
const res: any = await un_shelves_nft(data.id)
if (res && res.code === 0) {
Toast.success('下架成功')
store.getMarketNft("auctionNft")
store.getMarketNft("sellNft")
store.getMyNft("myNft")
store.getUserInfo()
push(-1)
}
}
return (
<div className='mt-4 buy-nft'>
<Button
className='button'
style={{
background: 'linear-gradient(103deg, #1DD0DF -1%, #1DD0DF -1%, #1BEDFF -1%, #14BDEB 108%)',
borderRadius: 10,
}}
onClick={() => setVisible(true)}
>
<span className="fz-20 fz-wb-550"></span>
</Button>
<Modal
title='確定下架嗎?'
visible={visible}
setVisible={setVisible}
buttonText={<div className='fz-wb-550 black'></div>}
buttonClick={confirm}
>
<></>
</Modal>
</div>
)
}
export default RemoveMarketMyNFT

82
src/pages/detail/index.tsx

@ -1,18 +1,24 @@
import { useEffect, useMemo, useState } from "react"
import { observer } from "mobx-react"
import { useEffect, useMemo, useRef, useState } from "react"
import { Button, Empty, Loading } from "react-vant" import { Button, Empty, Loading } from "react-vant"
import { nft_detail } from "~/api" import { nft_detail } from "~/api"
import BackBar from "~/components/BackBar" import BackBar from "~/components/BackBar"
import ProductInfo from "~/components/ProductInfo" import ProductInfo from "~/components/ProductInfo"
import { useRouter } from "~/hooks/useRouter" import { useRouter } from "~/hooks/useRouter"
import store from "~/store"
import '~/styles/detail.scss' import '~/styles/detail.scss'
import { MarketNFTData } from "~/types/store" import { MarketNFTData } from "~/types/store"
import AuctionNFT from "./AuctionNFT"
import BuyNft from "./BuyNft" import BuyNft from "./BuyNft"
import IssuanceRushNFT from "./IssuanceRushNFT"
import NFTProperties from "./NFTProperties" import NFTProperties from "./NFTProperties"
import OnShelvesNFT from "./OnShelvesNFT" import OnShelvesNFT from "./OnShelvesNFT"
import RemoveMarketMyNFT from "./RemoveMarketMyNFT"
const Detail = () => { const Detail = () => {
const { location } = useRouter() const { location } = useRouter()
const { userInfo } = store.state
const query = useMemo(() => { const query = useMemo(() => {
let obj = {} as { [key: string]: number } let obj = {} as { [key: string]: number }
if (location.state) { if (location.state) {
@ -31,23 +37,56 @@ const Detail = () => {
const [product, setProduct] = useState({} as MarketNFTData) const [product, setProduct] = useState({} as MarketNFTData)
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
console.log(product);
const isFirst = useRef(false)
const titles = useMemo(() => ({ const titles = useMemo(() => ({
"0": "上架",
"1": "拍賣", "1": "拍賣",
"2": "售賣", "2": "售賣",
"3": "發行"
"3": "發行搶購"
} as any), []) } as any), [])
useEffect(() => {
const getData = async () => {
const renderItem = () => {
// type為 0 時 顯示NFT屬性
if (product.type === 0) {
return (
<>
<div className="mt-3">
<NFTProperties data={product} />
</div>
{/* 屬於自己時顯示上架 */}
{product.sell_id === userInfo.id && <OnShelvesNFT data={product} />}
</>
)
}
// 如果type為2時 并且不屬於自己時 顯示購買
if (product.type === 2 && product.sell_id !== userInfo.id) {
return <BuyNft data={product} />
}
// 如果type為1時 并且不屬於自己時 顯示拍賣
if (product.type === 1 && product.sell_id !== userInfo.id) {
return <AuctionNFT data={product} getData={getData} />
}
// {/* 如果type為1或2時 并且屬於自己時 顯示下架 */ }
if (product.type === 2 && product.sell_id === userInfo.id) {
return <RemoveMarketMyNFT data={product} />
}
if (product.type === 3) {
return <IssuanceRushNFT data={product} getData={getData} />
}
return <></>
}
const getData = async () => {
if (!isFirst.current) {
setLoading(true) setLoading(true)
const res: any = await nft_detail(query)
setLoading(false)
res && res.code === 0 && setProduct(res.data)
} }
isFirst.current = true
const res: any = await nft_detail(query)
setLoading(false)
res && res.code === 0 && setProduct(res.data)
}
useEffect(() => {
Object.keys(query).length === 2 && getData() Object.keys(query).length === 2 && getData()
}, []) }, [])
@ -74,33 +113,14 @@ const Detail = () => {
return ( return (
<div className="plr-3 detail"> <div className="plr-3 detail">
<BackBar <BackBar
title={titles[`${product.type}`] || "詳情"}
title={titles[`${product.type}`] || ""}
/> />
<div className="mt-2"> <div className="mt-2">
<ProductInfo data={product} /> <ProductInfo data={product} />
</div> </div>
{/* type 0.表示上架NFT 2.購買NFT 3.搶購 */}
{
product.type === 0 && (
<div className="mt-3">
<NFTProperties data={product} />
</div>
)
}
{
product.type === 0 && (
<OnShelvesNFT data={product} />
)
}
{
product.type === 2 && (
<BuyNft data={product} />
)
}
{renderItem()}
</div> </div>
) )
} }
export default Detail
export default observer(Detail)

82
src/pages/home/index.tsx

@ -1,9 +1,9 @@
import '~/styles/home.scss' import '~/styles/home.scss'
import ProductItem from '~/components/ProductItem' import ProductItem from '~/components/ProductItem'
import { useRouter } from '~/hooks/useRouter' import { useRouter } from '~/hooks/useRouter'
import { Button, Swiper, SwiperInstance } from 'react-vant'
import { Button, CountDown, Swiper, SwiperInstance } from 'react-vant'
import { useEffect, useRef } from 'react' import { useEffect, useRef } from 'react'
import { splitAddress } from '~/utils'
import { getTime, splitAddress } from '~/utils'
import { observer } from 'mobx-react' import { observer } from 'mobx-react'
import store from '~/store' import store from '~/store'
import useLike from '~/hooks/useLike' import useLike from '~/hooks/useLike'
@ -11,7 +11,7 @@ import useLike from '~/hooks/useLike'
const Home = () => { const Home = () => {
const { push } = useRouter() const { push } = useRouter()
const { sellNft, auctionNft, likeNft } = store.state
const { sellNft, auctionNft, likeNft, issueNft } = store.state
const like = useLike() const like = useLike()
const swiperRef = useRef<SwiperInstance>(null) const swiperRef = useRef<SwiperInstance>(null)
@ -31,34 +31,40 @@ const Home = () => {
}}></i> }}></i>
</div> </div>
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<Swiper ref={swiperRef} indicator={false} autoplay={5000}>
<Swiper.Item>
<div className='plr-5px'>
<div className='rush-swiper'>
<img src={require('~/assets/cover.png')} alt="" />
<div className='content-box p-2'>
<div className='sub-text fz-14'>NFT</div>
<div className='mt-5px'>-</div>
<div className='mt-5px fz-12'>
<div className='row-between'>
<div className='tag'>USDT 10000</div>
<div className='row-center right-box'>
<img src={require('~/assets/user.png')} className='avatar-img' alt="" />
<Swiper ref={swiperRef} indicator={false}>
{
issueNft.map(item => (
<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} {item.price}</div>
<div className='row-center right-box'>
<img src={item.cast_url} className='avatar-img' alt="" />
</div>
</div>
<div className='row-between'>
<div className='row-items'>
<div></div>
<div className='ml-1 fz-14 like-text mt-3px'>
<CountDown time={item.start_time * 1000 - Date.now()} className="like-text" />
</div>
</div>
<div className='right-box'>{item.cast_name}</div>
</div>
</div> </div>
</div> </div>
<div className='row-between'>
<div className='row-items'>
<div></div>
<div className='ml-1 fz-wb-550 fz-14 like-text'>54:42:15</div>
</div>
<div className='right-box'>Filefaasdasdasdfdsfsdf</div>
</div>
</div> </div>
</div> </div>
</div>
</div>
</Swiper.Item>
</Swiper.Item>
))
}
</Swiper> </Swiper>
</div> </div>
<div> <div>
@ -67,39 +73,39 @@ const Home = () => {
}}></i> }}></i>
</div> </div>
</div> </div>
<div className='plr-2 fz-20 mt-2'></div>
<div className='plr-3 fz-20 mt-2'></div>
<div className='mt-2 row-items swiper'> <div className='mt-2 row-items swiper'>
{ {
auctionNft.map((item, index) => ( auctionNft.map((item, index) => (
<div <div
key={index} key={index}
className={`swiper-item ${index === 0 ? 'ml-2' : 'ml-1'} ${index === 4 && 'mr-2'}`}
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 })} /> <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' >
<div className='cover-box-item p-1 fz-12'> <div className='cover-box-item p-1 fz-12'>
<div> <div>
<div>{item.name}</div> <div>{item.name}</div>
<div className='row-items mt-2px'> <div className='row-items mt-2px'>
<div className='flex-1'> <div className='flex-1'>
<div className='fz-8 fz-wb-550'></div>
<div className='fz-8 fz-wb-550'></div>
<div className='user-tag row-items mt-2px'> <div className='user-tag row-items mt-2px'>
<img src={item.cast_url} alt="" /> <img src={item.cast_url} alt="" />
<div className='flex-1 ml-5px'>{splitAddress(item.cast_name, 4)}</div>
<div className='flex-1 ml-5px text-overflow'>{item.cast_name}</div>
</div> </div>
</div> </div>
<div className='flex-1'> <div className='flex-1'>
<div className='fz-8 fz-wb-550'></div>
<div className='fz-8 fz-wb-550'></div>
<div className='user-tag row-items mt-2px'> <div className='user-tag row-items mt-2px'>
<img src={item.sell_url} alt="" /> <img src={item.sell_url} alt="" />
<div className='flex-1 ml-5px'>{splitAddress(item.sell_name, 4)}</div>
<div className='flex-1 ml-5px text-overflow'>{item.sell_name}</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className='row-between'> <div className='row-between'>
<Button className='button' round>
<div className='fz-wb-550'></div>
<Button className='button' round onClick={() => push('/detail', { id: item.id, type: item.type })}>
<div className='fz-wb-550'></div>
</Button> </Button>
<i className={` <i className={`
iconfont icon-daohangshoucangyishoucang fz-18 ${like.isLike(item.id, likeNft) ? 'like-text' : 'sub-text'} iconfont icon-daohangshoucangyishoucang fz-18 ${like.isLike(item.id, likeNft) ? 'like-text' : 'sub-text'}
@ -111,8 +117,8 @@ const Home = () => {
)) ))
} }
</div> </div>
<div className='plr-2 fz-20 mt-2'></div>
<div className='plr-2'>
<div className='plr-3 fz-20 mt-2'></div>
<div className='plr-3'>
<div className='row-between flex-wrap'> <div className='row-between flex-wrap'>
{ {
sellNft.map((item, index) => ( sellNft.map((item, index) => (

104
src/pages/no-share/index.tsx

@ -0,0 +1,104 @@
import '~/styles/share.scss'
import { Tabs, Toast } from 'react-vant'
import ProductItem from '~/components/ProductItem'
import store from '~/store'
import { toFixed2 } from '~/utils'
import { useEffect, useMemo, useState } from 'react'
import { no_user_info } from '~/api'
import { useRouter } from '~/hooks/useRouter'
import { UserInfo } from '~/types/store'
const NoShare = () => {
const { location } = useRouter()
const state = location.state
const [userInfo, setUserInfo] = useState({} as UserInfo)
const tabs = useMemo(() => ['我的NFT', '我喜歡的NFT'], [])
const getLength = (index: number) => {
if(!userInfo.my_like || !userInfo.my_nft ) return 0
if(index === 0) return userInfo.my_nft.length
return userInfo.my_like.length
}
useEffect(() => {
const getData = async () => {
const res: any = await no_user_info(state.id)
res && res.code === 0 && setUserInfo(res.data)
}
if (state && state.id) {
getData()
}
}, [state])
return (
<div className="share">
<div className='box'>
<img src={require('~/assets/personal.png')} alt="" className='bg-cover'></img>
<div className='row-center avatar'>
<img src={userInfo.url} className="img" alt="" />
</div>
</div>
<div className='box-block'></div>
<div className='row-center mt-1 name-box'>
<div className='fz-wb-550 shar-name-overflow'>{userInfo.name}</div>
</div>
<div className='row-between plr-5 mt-3'>
<div className='tac'>
<div className='fz-20 fz-wb-550'>{userInfo.sell || 0}</div>
<div className='mt-8px'></div>
</div>
<div className='tac'>
<div className='fz-20 fz-wb-550'>{userInfo.auction || 0}</div>
<div className='mt-8px'></div>
</div>
<div className='tac'>
<div className='fz-20 fz-wb-550'>{toFixed2(userInfo.income, 2)} FIL</div>
<div className='mt-8px'></div>
</div>
</div>
<div className='mt-3'>
<Tabs
lineWidth={100}
background="none"
titleInactiveColor='#000'
titleActiveColor='#000'
color='#11C0CB'
animated
swipeable
>
{
tabs.map((item, index) => (
<Tabs.TabPane
key={index}
title={<div>
<span>{item}</span>
<span className='ml-5px' style={{ color: '#11C0CB' }}>{getLength(index)}</span>
</div>}
titleClass='fz-wb-550'
>
<div>
{
userInfo.my_like && userInfo.my_nft && <div className='row-between flex-wrap plr-3'>
{(index === 0 ? userInfo.my_nft : userInfo.my_like).map((item, index) => (
<div key={index}>
<ProductItem data={item} />
</div>
))}
</div>
}
</div>
</Tabs.TabPane>
))
}
</Tabs>
</div>
</div>
)
}
export default NoShare

5
src/pages/personal/AccountAssetsCard.tsx

@ -3,6 +3,7 @@ import { useMemo } from "react";
import { useRouter } from "~/hooks/useRouter"; import { useRouter } from "~/hooks/useRouter";
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import store from '~/store'; import store from '~/store';
import { toThousands } from '~/utils';
const AccountAssetsCard = () => { const AccountAssetsCard = () => {
@ -27,7 +28,7 @@ const AccountAssetsCard = () => {
<div className='card'> <div className='card'>
<div> <div>
<div className='sub-color'></div> <div className='sub-color'></div>
<div className='mt-5px'><span className='fz-24 fz-wb-550'>{userInfo.total}</span> <span>USDT</span></div>
<div className='mt-5px'><span className='fz-24 fz-wb-550'>{toThousands(userInfo.total)}</span> <span>USDT</span></div>
</div> </div>
<div className='row-items'> <div className='row-items'>
{ {
@ -36,7 +37,7 @@ const AccountAssetsCard = () => {
<div className='sub-color'>{item.title}</div> <div className='sub-color'>{item.title}</div>
<div className='mt-5px' style={{ wordBreak: 'break-word' }}> <div className='mt-5px' style={{ wordBreak: 'break-word' }}>
<div className='mt-5px'> <div className='mt-5px'>
<span className='fz-24 fz-wb-550'>{item.value}</span>
<span className='fz-24 fz-wb-550'>{toThousands(item.value)}</span>
<span className='ml-5px'>{item.symbol}</span> <span className='ml-5px'>{item.symbol}</span>
</div> </div>
</div> </div>

40
src/pages/record/index.tsx

@ -1,6 +1,6 @@
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import useCopyLink from "~/hooks/useCopy"; import useCopyLink from "~/hooks/useCopy";
import { getTime, splitAddress } from "~/utils";
import { getTime, splitAddress, toThousands } from "~/utils";
import store from "~/store"; import store from "~/store";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { useRouter } from "~/hooks/useRouter"; import { useRouter } from "~/hooks/useRouter";
@ -13,9 +13,11 @@ import { history_record } from "~/api";
const Record = () => { const Record = () => {
const { token } = store.state; const { token } = store.state;
const { push } = useRouter()
const { push, location } = useRouter()
console.log(location);
const recordTabs = useMemo(() => ['充值', '提现', '收益'], []); const recordTabs = useMemo(() => ['充值', '提现', '收益'], []);
const [recordIndex, setRecordIndex] = useState(0);
const [recordIndex, setRecordIndex] = useState(location.state ? location.state.index : 0);
const { copyVal } = useCopyLink(); const { copyVal } = useCopyLink();
const [query, setQuery] = useState([ const [query, setQuery] = useState([
{ page: 1, page_size: 20 }, { page: 1, page_size: 20 },
@ -83,6 +85,7 @@ const Record = () => {
type="capsule" type="capsule"
background="rgb(248,247,255)" background="rgb(248,247,255)"
sticky sticky
defaultActive={recordIndex}
offsetTop={window.innerWidth / 430 * 60} offsetTop={window.innerWidth / 430 * 60}
onChange={(_, index) => setRecordIndex(index)} onChange={(_, index) => setRecordIndex(index)}
align="start" align="start"
@ -137,7 +140,7 @@ const RechargeRecord = (
</div> </div>
</div> </div>
<div className='column-justify-between tae'> <div className='column-justify-between tae'>
<div className='green'>+{item.amount} {item.symbol}</div>
<div className='green fz-wb-550'>+{toThousands(item.amount)} {item.symbol}</div>
<div className={`tar ${item.status === 1 && 'green'}`}> <div className={`tar ${item.status === 1 && 'green'}`}>
{item.status === 1 ? '完成' : '確認中'} {item.status === 1 ? '完成' : '確認中'}
</div> </div>
@ -158,25 +161,24 @@ const WithdrawRecord = ({ list, finished, getData, copy }: ChildProps) => {
<List finished={finished} onLoad={() => getData()} errorText="请求失败,点击重新加载" offset={10}> <List finished={finished} onLoad={() => getData()} errorText="请求失败,点击重新加载" offset={10}>
{ {
list.map((item, index) => ( list.map((item, index) => (
<Cell className='ptb-1' key={item.id} style={{ background: 'none' }}>
<Cell className='ptb-1' key={item.id} style={{ background: 'none' }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div> <div>
<div className='fz-wb-550'></div> <div className='fz-wb-550'></div>
<div className='fz-wb-550'></div>
<div className='sub-color fz-14'>{getTime(item.time * 1000)}</div> <div className='sub-color fz-14'>{getTime(item.time * 1000)}</div>
<div className='sub-color fz-14'> <div className='sub-color fz-14'>
{item.order && splitAddress(item.order, 10)}
{item.order && <i className='iconfont icon-fuzhi ml-5px' onClick={() => {
copy && copy(item.order)
{item.tx_hash && splitAddress(item.tx_hash, 8)}
{item.tx_hash && <i className='iconfont icon-fuzhi_copy black ml-5px' onClick={() => {
copy && copy(item.tx_hash)
}}></i>} }}></i>}
</div> </div>
</div> </div>
<div className='column-justify-between tae'> <div className='column-justify-between tae'>
<div className='red-color'>
<div>{item.amount} {item.symbol}</div>
<div>{item.amount_fee} {item.symbol_fee}</div>
<div className='tar'>
<div className="red fz-wb-550">-{toThousands(item.amount)} {item.symbol}</div>
<div className="sub-text fz-14">{item.withdraw_fee} {item.withdraw_fee_symbol}</div>
</div> </div>
<div className='blue-color'>{item.status === 5 ? '完成' : '审核中'}</div>
<div className='tar sub-text fz-14'>{item.status === 4 ? '完成' : '確認中'}</div>
</div> </div>
</div> </div>
</Cell> </Cell>
@ -195,19 +197,17 @@ const TransferRecord = ({ list, finished, getData }: ChildProps) => {
<List finished={finished} onLoad={() => getData()} errorText="请求失败,点击重新加载" offset={10}> <List finished={finished} onLoad={() => getData()} errorText="请求失败,点击重新加载" offset={10}>
{ {
list.map((item, index) => ( list.map((item, index) => (
<Cell className="ptb-1" key={item.id} style={{ background: 'none' }}>
<Cell className="ptb-1" key={item.id} style={{ background: 'none' }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div> <div>
<div className='fz-wb-550'> {item.name}</div>
<div className='fz-wb-550'></div>
<div className='fz-wb-550'> {item.name}</div>
<div className='sub-color fz-14 mt-6px'>{getTime(item.time * 1000)}</div> <div className='sub-color fz-14 mt-6px'>{getTime(item.time * 1000)}</div>
</div> </div>
<div className='column-justify-between tae'>
<div className='column-justify-between tar fz-wb-550'>
<div> <div>
<div className={Number(item.amount) < 0 ? 'red-color' : 'green-color'}>{Number(item.amount) >= 0 && '+'}{item.amount} {item.symbol}</div>
<div className='red-color'>{item.amount_fee} {item.symbol_fee}</div>
<div className=" green">+{toThousands(item.amount)} {item.symbol}</div>
</div> </div>
<div className='blue-color'></div>
<div className='sub-text'>+{toThousands(item.amount_usdt)} USDT()</div>
</div> </div>
</div> </div>
</Cell> </Cell>

2
src/pages/share/index.tsx

@ -109,7 +109,7 @@ const Share = () => {
}, 100) }, 100)
}} /> }} />
) : ( ) : (
<div className='fz-wb-550 text-overflow'>{userInfo.name}</div>
<div className='fz-wb-550 shar-name-overflow'>{userInfo.name}</div>
) )
} }
<div className='ml-1'> <div className='ml-1'>

1
src/pages/withdraw/index.tsx

@ -17,6 +17,7 @@ const Recharge = () => {
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const currentCoin = useMemo(() => coinList[coinIndex], [coinIndex, coinList]) const currentCoin = useMemo(() => coinList[coinIndex], [coinIndex, coinList])
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
console.log(currentCoin);
const withdraw = async () => { const withdraw = async () => {
const amount = inputRef.current?.value const amount = inputRef.current?.value

20
src/router/layout/Navbar.tsx

@ -1,4 +1,5 @@
import { useRouter } from '~/hooks/useRouter'
import '~/styles/layout.scss' import '~/styles/layout.scss'
import ConnectButton from './ConnectButton' import ConnectButton from './ConnectButton'
@ -10,11 +11,26 @@ interface NavbarProps {
const Navbar = (props: NavbarProps) => { const Navbar = (props: NavbarProps) => {
const { pathname, setVisible } = props const { pathname, setVisible } = props
const { push } = useRouter()
const isBlue = () => {
if (pathname === '/share') return 'header-bg-color'
if (pathname === '/noShare') return 'header-bg-color'
return ''
}
return ( return (
<div> <div>
<div className={`header plr-3 ${pathname === '/share' && 'header-bg-color'}`}>
<div className='fz-wb-550' style={{ flex: 1 }}>9527</div>
<div className={`header plr-3 ${isBlue()}`}>
<div className='fz-wb-550' style={{ flex: 1 }}>
{
pathname === '/noShare' ? (
<div className="iconfont icon-arrow-left-bold fz-24" onClick={() => push(-1)}></div>
) : (
<div>9527</div>
)
}
</div>
{/* <div style={{ flex: 1 }} className='tac'>首页</div> */} {/* <div style={{ flex: 1 }} className='tac'>首页</div> */}
<div className='row-justify-end' style={{ flex: 1 }}> <div className='row-justify-end' style={{ flex: 1 }}>
<ConnectButton /> <ConnectButton />

4
src/router/layout/index.tsx

@ -44,8 +44,8 @@ const LayoutRouter = () => {
if (token) { if (token) {
store.getUserInfo() store.getUserInfo()
store.getCoinList() store.getCoinList()
store.getMyNft('myNft', 1)
store.getMyNft('likeNft', 2)
store.getMyNft('myNft')
store.getMyNft('likeNft')
} }
if (!token) { if (!token) {

5
src/router/routes.tsx

@ -10,6 +10,7 @@ const Recharge = lazy(() => import("~/pages/recharge"));
const Withdraw = lazy(() => import("~/pages/withdraw")); const Withdraw = lazy(() => import("~/pages/withdraw"));
const Record = lazy(() => import("~/pages/record")); const Record = lazy(() => import("~/pages/record"));
const Team = lazy(() => import("~/pages/team")) const Team = lazy(() => import("~/pages/team"))
const NoShare = lazy(() => import("~/pages/no-share"));
const routes = [ const routes = [
{ {
@ -51,6 +52,10 @@ const routes = [
{ {
path: '/team', path: '/team',
element: <Team /> element: <Team />
},
{
path: '/noShare',
element: <NoShare />
} }
] as RouteObject[]; ] as RouteObject[];

3
src/store/index.ts

@ -100,7 +100,8 @@ class AppStore implements Store {
* @param key * @param key
* @param type 1. 2. * @param type 1. 2.
*/ */
async getMyNft(key: "myNft" | "likeNft", type: number) {
async getMyNft(key: "myNft" | "likeNft") {
let type = key === "myNft" ? 1 : 2;
const res: any = await personal_nft(type); const res: any = await personal_nft(type);
if (res && res.code === 0) { if (res && res.code === 0) {
this.state[key] = res.data; this.state[key] = res.data;

13
src/styles/components.scss

@ -2,6 +2,13 @@
width: 181px; width: 181px;
height: 160px; height: 160px;
position: relative; position: relative;
.text-overflow{
max-width: 50px;
overflow: hidden;
text-overflow: ellipsis;
}
.img{ .img{
width: 171px; width: 171px;
height: 132px; height: 132px;
@ -33,6 +40,9 @@
display: flex; display: flex;
align-items: center; align-items: center;
white-space: nowrap; white-space: nowrap;
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
} }
.user-tag{ .user-tag{
@ -115,5 +125,8 @@
border-radius: 10px; border-radius: 10px;
background: $button-background; background: $button-background;
color: $white; color: $white;
&:active{
opacity: .8;
}
} }
} }

93
src/styles/detail.scss

@ -8,9 +8,100 @@
.buy-nft{ .buy-nft{
.success-img{ .success-img{
width: 125px; width: 125px;
height: 100%;
height: 140px;
object-fit: cover; object-fit: cover;
} }
.tag-mark{
width: 90px;
height: 35px;
border-radius: 20px;
display: flex;
color: $white;
justify-content: center;
align-items: center;
&:active{
opacity: .8;
}
}
.mark-button{
width: 240px;
height: 45px;
border-radius: 45px;
color: $white;
font-weight: bold;
}
.mark-button-disable{
background-color: #C4C4C4;
color: $black;
font-weight: bold;
}
}
.on-shelves-nft{
.tag{
width: 102px;
height: 35px;
border-radius: 10px;
color: #fff;
font-size: 14px;
font-weight: bold;
font-family:Georgia, 'Times New Roman', Times, serif;
&:active{
opacity: 0.8;
}
img{
@include img-size(20px,20px);
margin-right: 5px;
}
}
.tag-active{
border: 3px solid $black;
}
.input{
width: 100%;
height: 45px;
background: none;
border: 1px solid #898989;
border-radius: 10px;
padding: 0 10px;
}
.on-button{
width: 100%;
height: 50px;
background-color: $primary;
border-radius: 10px;
color: $white;
font-weight: bold;
font-size: 18px;
}
.auction-tag{
width: 80px;
height: 35px;
border-radius: 35px;
font-weight: bold;
color: $white;
&:active{
opacity: 0.8;
}
}
.markeup-button{
width: 240px;
height: 45px;
border-radius: 45px;
color: $white;
font-weight: bold;
}
} }
} }

8
src/styles/global.scss

@ -27,6 +27,14 @@ body {
background-color: rgb(248,247,255); background-color: rgb(248,247,255);
} }
.FIL-text{
color: #F96900;
}
.USDT-text{
color: #8A4CED;
}
.USDT-bg{ .USDT-bg{
background: $usdt-bg; background: $usdt-bg;
} }

11
src/styles/home.scss

@ -25,6 +25,8 @@
.tag{ .tag{
background: $usdt-bg; background: $usdt-bg;
color: $white; color: $white;
padding: 3px 15px;
border-radius: 20px;
} }
.avatar-img { .avatar-img {
@ -56,8 +58,8 @@
} }
.swiper-item{ .swiper-item{
min-width: 284px;
min-height: 375px;
min-width: 264px;
min-height: 355px;
position: relative; position: relative;
} }
@ -91,6 +93,11 @@
background: #f5f5f5; background: #f5f5f5;
font-size: 8px; font-size: 8px;
border-radius: 8px; border-radius: 8px;
.text-overflow{
text-overflow: ellipsis;
overflow: hidden;
max-width: 50px;
}
img{ img{
width: 16px; width: 16px;

6
src/styles/share.scss

@ -46,7 +46,7 @@
width: 100%; width: 100%;
} }
.text-overflow{
.shar-name-overflow{
max-width: 200px; max-width: 200px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@ -60,3 +60,7 @@
} }
} }
.rv-tabs__line{
z-index: 0;
}

10
src/types/store.d.ts

@ -16,6 +16,9 @@ interface UserInfo {
total: string; total: string;
url: string; url: string;
assets: Assets[]; assets: Assets[];
id: number;
my_like: MarketNFTData[];
my_nft: MarketNFTData[];
} }
interface Assets { interface Assets {
@ -59,7 +62,12 @@ interface MarketNFTData {
time: number; time: number;
total_stock: number; total_stock: number;
url: string; url: string;
type:number;
type: number;
start_time: number;
end_time: number;
current_number: number;
remain_quantity: number;
illustrate: string;
} }
interface InviteRecordData { interface InviteRecordData {

Loading…
Cancel
Save