From d7bde217b0afff193764269a94a7b4f0b29fdd48 Mon Sep 17 00:00:00 2001 From: wangjiahai <1556608@qq.com> Date: Tue, 9 Jan 2024 16:02:30 +0800 Subject: [PATCH] 111 --- common/price.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 common/price.js diff --git a/common/price.js b/common/price.js new file mode 100644 index 0000000..682fda4 --- /dev/null +++ b/common/price.js @@ -0,0 +1,15 @@ +// 10.00 10.60 +function convertPrice(str) { + if (str == undefined || str == null || str == '') + return '' + if (str.endsWith('.00')) { + return str.substring(0, str.length - 3) + } else if (str.endsWith('0') && str.includes('.')) { + return str.substring(0, str.length - 1) + } + + return str +} +export { + convertPrice +} \ No newline at end of file