import {CollectionInterface, ProfileInterface, TokensInterface, BankCardInfoInterface} from '../interfaces' import {OrderStatus, ProfileVerifyStatus} from '../constants/enum' export const isSelling = (collection: CollectionInterface | undefined): boolean => { if (!collection) { return false } const now = parseInt((+new Date()).toString().substring(0, 10)) return now > collection?.sale_time } export const getActivityAction = ( token: TokensInterface | undefined, profile: ProfileInterface | undefined, bankCardInfo: BankCardInfoInterface | undefined ) => { if (!token) { return { text: '立即登录', status: 3, } } // if (profile?.status === ProfileVerifyStatus.Unverified) { // return { // text: '实名验证', // status: 4, // } // } // if (!collection) { // return {text: '还未开售', status: 0} // } // // if (isSelling(collection)) { // return {text: '立即购买', status: 1} // } // if (!bankCardInfo || !bankCardInfo.card_no) { // return { // text: '绑定银行卡', // status: 5, // } // } return {text: '立即购买', status: 2} } export const getOrderStatusText = (status: number): string => { switch (status) { case OrderStatus.Done: return '已完成' case OrderStatus.Cancel: return '已取消' case OrderStatus.Timeout: return '已超时' case OrderStatus.Prepare: return '待支付' default: return '未知' } } export const getOrderStatusColor = (status: number): string => { switch (status) { case OrderStatus.Done: return 'primary.main' case OrderStatus.Cancel: return 'red.main' case OrderStatus.Timeout: return 'red.main' case OrderStatus.Prepare: return 'orange.main' default: return 'gray.main' } } export const getOrderStatusDesc = (status: number | undefined) => { if (status === OrderStatus.Done) { return '订单已完成' } if (status === OrderStatus.Timeout) { return '订单已超时' } if (status === OrderStatus.Cancel) { return '订单已取消' } return '订单待支付' }