import { Text, View } from '@tarojs/components'
import { memo, useCallback } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
import { numberWithCommas } from '@/common/format'

interface Param {
  number: number // 数字
  status: 0 | 1 | 2 // 0 小型，1中型，2大
}
const AmountShow = ({ number = 0, status = 1 }: Param) => {
  const priceDom = useCallback(() => {
    const res = number.toFixed(2).split('.')
    const int_num = `${parseInt(res[0])}`
    const decimals_num = res[1]
    return (
      <>
        <Text className={styles.price_text}>¥</Text>
        <Text className={styles.price_text}>{numberWithCommas({ number: int_num, digit: 0 })}</Text>
        <Text className={styles.price_text}>.{decimals_num}</Text>
      </>
    )
  }, [number])
  return <View className={classnames(styles.order_price_num, status == 1 && styles.emphasis_num, status == 2 && styles.emphasis_num_big)}>{priceDom()}</View>
}
export default memo(AmountShow)
