| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * Integer cents → display format utilities
- * All backend prices now stored as Integer cents (1元 = 100)
- * All backend rates stored as Integer bps (100% = 10000)
- * All backend scores stored as Integer percentile (5.00 = 500)
- */
- /**
- * Format cents to yuan string (no symbol)
- * 9900 → '99.00'
- */
- export function formatPrice (cents) {
- if (cents === null || cents === undefined) return '0.00'
- return (Number(cents) / 100).toFixed(2)
- }
- /**
- * Format cents to yuan with ¥ symbol
- * 9900 → '¥99.00'
- */
- export function formatPriceWithSymbol (cents) {
- return '¥' + formatPrice(cents)
- }
- /**
- * Format bps to percentage string
- * 235 → '2.35%' 1000 → '10.00%'
- */
- export function formatRate (bps) {
- if (bps === null || bps === undefined) return '0.00%'
- return (Number(bps) / 100).toFixed(2) + '%'
- }
- /**
- * Format percentile score to decimal display
- * 500 → '5.00' 435 → '4.35'
- */
- export function formatScore (percentile) {
- if (percentile === null || percentile === undefined) return '0.00'
- return (Number(percentile) / 100).toFixed(2)
- }
|