import { Text, View } from "@tarojs/components"
import { memo, useCallback, useEffect, useMemo } from "react"
import {formatKbPrice} from '@/common/common'
import classnames from "classnames";
import styles  from './index.module.scss'
type Param = {
    style?: Object, 
    number?: number, //数量
    priceTitle: string //描述

}
export default memo(({style, number = 0, priceTitle = ''}:Param) => {
    const priceDom = useCallback(() => {
        let res = number.toFixed(2).split('.')
        let int_num  = parseInt(res[0]) + ''
        let decimals_num = res[1]
        return (
            <>
                <Text>¥</Text>
                <Text>{Number(int_num).toLocaleString()}</Text>
                <Text>.{decimals_num}</Text>
            </>
        )
    }, [number])
    return (
        <>
            <View className={styles.order_price}>
                <View className={classnames(styles.order_price_text, styles.emphasis)}>
                    <Text>{priceTitle}：</Text>
                </View>
                <View className={classnames(styles.order_price_num, styles.emphasis_num)} style={style}>
                    {priceDom()}
                </View>
                
            </View>
        </>
    )
})