import { formatImgUrl } from "@/common/fotmat"; import { Image, Text, View } from "@tarojs/components"; import { memo, useEffect, useMemo, useRef, useState } from "react"; import classnames from "classnames"; import styles from './index.module.scss' import dayjs from "dayjs"; import { useTimeCountDown } from "@/use/useCommon"; import { ORDER_STATUS, PAYMENT_METHOD } from "@/common/enum"; type List = { status: string, time: string, tag: string, desc: string, expire_time: string } type Param = { onRefresh?: () => void, orderInfo?: { logistics_details:List[], //订单状态列表 payment_method: number, //支付方式 status: number, //订单状态 } } export default memo(({orderInfo, onRefresh}:Param) => { const {showTime, onStart, timeStatus} = useTimeCountDown() //订单状态枚举 const {SaleorderstatusWaitingPrePayment} = ORDER_STATUS //获取预付款最后时间 const endTime = useMemo(() => { if(orderInfo?.status == SaleorderstatusWaitingPrePayment.value && orderInfo.logistics_details.length > 0) { return orderInfo.logistics_details[0].expire_time } return '' }, [orderInfo]) useEffect(() => { if(endTime) onStart(endTime) }, [endTime]) useEffect(() => { if(timeStatus == 2) onRefresh?.() }, [timeStatus]) return ( {showTime.HH} : {showTime.MM} : {showTime.SS} 等待买家付款,超时自动取消 onRefresh?.()}> 刷新 ) })