From f4991944d13b94355fb8aaf03dad7d60ca530ee9 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Thu, 30 Nov 2023 16:36:45 +0800 Subject: [PATCH] fix:是否修改 --- uni_modules/uview-ui/components/u-text/value.js | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 85 insertions(+), 0 deletions(-) diff --git a/uni_modules/uview-ui/components/u-text/value.js b/uni_modules/uview-ui/components/u-text/value.js new file mode 100644 index 0000000..9859bbb --- /dev/null +++ b/uni_modules/uview-ui/components/u-text/value.js @@ -0,0 +1,85 @@ +export default { + computed: { + // ������������������������������ + value() { + const { + text, + mode, + format, + href + } = this + // ������������ + if (mode === 'price') { + // ������text������������������������ + if (!/^\d+(\.\d+)?$/.test(text)) { + uni.$u.error('������������������text���������������������������'); + } + // ���������������������������������������format���������������������������������������������������format������������������������������������������ + if (uni.$u.test.func(format)) { + // ������������������������������������������������������ + return format(text) + } + // ������format��������������������������������������������������������������������������� + return uni.$u.priceFormat(text, 2) + } if (mode === 'date') { + // ������������������������������������������ + !uni.$u.test.date(text) && uni.$u.error('������������������text���������������������������������������') + // ���������������������������������������format���������������������������������������������������format������������������������������������ + if (uni.$u.test.func(format)) { + // ������������������������������������������������������ + return format(text) + } if (format) { + // ������format��������������������������������������������������������������������������� + return uni.$u.timeFormat(text, format) + } + // ������������������format��������������������������������������������� + return uni.$u.timeFormat(text, 'yyyy-mm-dd') + } if (mode === 'phone') { + // ������������������������������ + // !uni.$u.test.mobile(text) && uni.$u.error('���������������������text���������������������������������') + if (uni.$u.test.func(format)) { + // ������������������������������������������������������ + return format(text) + } if (format === 'encrypt') { + // ������format���encrypt������������������������������������������ + return `${text.substr(0, 3)}****${text.substr(7)}` + } + return text + } if (mode === 'name') { + // ������������������������������ + !(typeof (text) === 'string') && uni.$u.error('������������������text������������������������������') + if (uni.$u.test.func(format)) { + // ������������������������������������������������������ + return format(text) + } if (format === 'encrypt') { + // ������format���encrypt��������������������������������������� + return this.formatName(text) + } + return text + } if (mode === 'link') { + // ������������������������������ + !uni.$u.test.url(href) && uni.$u.error('���������������������href���������������URL������') + return text + } + return text + } + }, + methods: { + // ��������������������������� + formatName(name) { + let value = '' + if (name.length === 2) { + value = name.substr(0, 1) + '*' + } else if (name.length > 2) { + let char = '' + for (let i = 0, len = name.length - 2; i < len; i++) { + char += '*' + } + value = name.substr(0, 1) + char + name.substr(-1, 1) + } else { + value = name + } + return value + } + } +} -- Gitblit v1.8.0