"use strict";const u=require("../../libs/function/index.js"),i=require("../../libs/function/test.js"),f={computed:{value(){const{text:t,mode:r,format:e,href:s}=this;return r==="price"?(/^\d+(\.\d+)?$/.test(t)||u.error("金额模式下，text参数需要为金额格式"),i.test.func(e)?e(t):u.priceFormat(t,2)):r==="date"?(!i.test.date(t)&&u.error("日期模式下，text参数需要为日期或时间戳格式"),i.test.func(e)?e(t):e?u.timeFormat(t,e):u.timeFormat(t,"yyyy-mm-dd")):r==="phone"?i.test.func(e)?e(t):e==="encrypt"?`${t.substr(0,3)}****${t.substr(7)}`:t:r==="name"?(typeof t!="string"&&u.error("姓名模式下，text参数需要为字符串格式"),i.test.func(e)?e(t):e==="encrypt"?this.formatName(t):t):(r==="link"&&!i.test.url(s)&&u.error("超链接模式下，href参数需要为URL格式"),t)}},methods:{formatName(t){let r="";if(t.length===2)r=t.substr(0,1)+"*";else if(t.length>2){let e="";for(let s=0,n=t.length-2;s<n;s++)e+="*";r=t.substr(0,1)+e+t.substr(-1,1)}else r=t;return r}}};exports.value=f;
