12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- "use strict";
- var uni_modules_uviewPlus_libs_function_index = require("../../libs/function/index.js");
- var uni_modules_uviewPlus_libs_function_test = require("../../libs/function/test.js");
- var value = {
- computed: {
- value() {
- const {
- text,
- mode,
- format,
- href
- } = this;
- if (mode === "price") {
- if (!/^\d+(\.\d+)?$/.test(text)) {
- uni_modules_uviewPlus_libs_function_index.error("\u91D1\u989D\u6A21\u5F0F\u4E0B\uFF0Ctext\u53C2\u6570\u9700\u8981\u4E3A\u91D1\u989D\u683C\u5F0F");
- }
- if (uni_modules_uviewPlus_libs_function_test.test.func(format)) {
- return format(text);
- }
- return uni_modules_uviewPlus_libs_function_index.priceFormat(text, 2);
- }
- if (mode === "date") {
- !uni_modules_uviewPlus_libs_function_test.test.date(text) && uni_modules_uviewPlus_libs_function_index.error("\u65E5\u671F\u6A21\u5F0F\u4E0B\uFF0Ctext\u53C2\u6570\u9700\u8981\u4E3A\u65E5\u671F\u6216\u65F6\u95F4\u6233\u683C\u5F0F");
- if (uni_modules_uviewPlus_libs_function_test.test.func(format)) {
- return format(text);
- }
- if (format) {
- return uni_modules_uviewPlus_libs_function_index.timeFormat(text, format);
- }
- return uni_modules_uviewPlus_libs_function_index.timeFormat(text, "yyyy-mm-dd");
- }
- if (mode === "phone") {
- if (uni_modules_uviewPlus_libs_function_test.test.func(format)) {
- return format(text);
- }
- if (format === "encrypt") {
- return `${text.substr(0, 3)}****${text.substr(7)}`;
- }
- return text;
- }
- if (mode === "name") {
- !(typeof text === "string") && uni_modules_uviewPlus_libs_function_index.error("\u59D3\u540D\u6A21\u5F0F\u4E0B\uFF0Ctext\u53C2\u6570\u9700\u8981\u4E3A\u5B57\u7B26\u4E32\u683C\u5F0F");
- if (uni_modules_uviewPlus_libs_function_test.test.func(format)) {
- return format(text);
- }
- if (format === "encrypt") {
- return this.formatName(text);
- }
- return text;
- }
- if (mode === "link") {
- !uni_modules_uviewPlus_libs_function_test.test.url(href) && uni_modules_uviewPlus_libs_function_index.error("\u8D85\u94FE\u63A5\u6A21\u5F0F\u4E0B\uFF0Chref\u53C2\u6570\u9700\u8981\u4E3AURL\u683C\u5F0F");
- return text;
- }
- return text;
- }
- },
- methods: {
- formatName(name) {
- let value2 = "";
- if (name.length === 2) {
- value2 = name.substr(0, 1) + "*";
- } else if (name.length > 2) {
- let char = "";
- for (let i = 0, len = name.length - 2; i < len; i++) {
- char += "*";
- }
- value2 = name.substr(0, 1) + char + name.substr(-1, 1);
- } else {
- value2 = name;
- }
- return value2;
- }
- }
- };
- exports.value = value;
|