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

type Param = {
  number: number //数字
  status: 0 | 1 | 2 //0 小型，1中型，2大
}
export default memo(({ number = 0, status = 1 }: Param) => {
  const priceDom = useCallback(() => {
    let res = number.toFixed(2).split('.')
    let int_num = parseInt(res[0]) + ''
    let 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>
})
