扫二维码码支付
This commit is contained in:
1 parent
8dc692796c
commit
8bff006f5a
5 files changed
+154
-63
No files matched your search
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 显示价格把分转换到元
|
||||
* @param price
|
||||
* @returns
|
||||
*/
|
||||
export function displayPrice(price: any, suffix: string = "元", fixed = 2) {
|
||||
if (typeof price === "undefined") return "0.00" + suffix
|
||||
const parsedNumber = typeof price === "string" ? parseFloat(price) : price
|
||||
return (parsedNumber / 100.0).toFixed(fixed) + suffix
|
||||
}
|
||||
|
||||
/**
|
||||
* 把显示价格改为分
|
||||
* @param price
|
||||
* @returns
|
||||
*/
|
||||
export const storePrice = (num: number | string | undefined) => {
|
||||
if (typeof num === "undefined") return 0
|
||||
const parsedNumber = typeof num === "string" ? parseFloat(num) : num
|
||||
return Math.round(parsedNumber * 100)
|
||||
}
|
||||
Reference in new issue
Block a user