From c24cdd854e258712408a7904bdb401c49e3f07c1 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 28 八月 2025 13:09:08 +0800
Subject: [PATCH] fix: 修改通道充值提示语
---
packages/components/src/utils/common.ts | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/packages/components/src/utils/common.ts b/packages/components/src/utils/common.ts
index 5b055b6..1d761af 100644
--- a/packages/components/src/utils/common.ts
+++ b/packages/components/src/utils/common.ts
@@ -54,6 +54,10 @@
return addStarForString(str, 2, end);
}
+export function addStarForPhone(str: string) {
+ return `*${str.substring(str.length - 4)}`;
+}
+
export function formatTimeAgo(date: string, format = 'YYYY-MM-DD HH:mm') {
const diff = dayjs().diff(date, 'seconds'); // 璁$畻鏃堕棿宸紝鍗曚綅涓虹
@@ -185,3 +189,33 @@
}
return LifeRechargeConstants.LifePayOrderFrontStatusEnum.鏀粯鎴愬姛;
}
+
+export class StringUtils {
+ static insertSpaces(str: string, space = 4) {
+ if (!str) return '';
+ const regex = new RegExp(`(.{${space}})`, 'g');
+ return str.replace(regex, '$1 ');
+ }
+
+ static societyCreditCodeInsertSpaces(str: string) {
+ if (!str) return '';
+ return str.replace(/(.{4})(.{4})(.{4})(.{6})/g, '$1 $2 $3 $4');
+ }
+
+ static idNumberInsertSpaces(str: string) {
+ if (!str) return '';
+ return str.replace(/(.{3})(.{3})(.{4})(.{4})(.{4})/g, '$1 $2 $3 $4 $5');
+ }
+
+ static phoneNumberAddSpace(realPhoneNumber: string) {
+ if (!realPhoneNumber) return '';
+ return realPhoneNumber.replace(/^(\d{3})(\d*)(\d{4})$/, '$1 $2 $3');
+ }
+
+ static formatterNumber(str: string) {
+ const cleanedValue = str.replace(/[^\d.]/g, '');
+ const singleDotValue = cleanedValue.replace(/(\..*)\./g, '$1');
+ const numberValue = parseFloat(singleDotValue);
+ return isNaN(numberValue) ? '' : singleDotValue;
+ }
+}
--
Gitblit v1.9.1