index.js 4.9 KB

12
  1. "use strict";const c=require("../../../../common/vendor.js"),a=require("./test.js"),$=require("./digit.js"),y=require("../config/config.js");function w(t,e=!1){return a.number(t)?e?`${t}px`:Number(t):/(rpx|upx)$/.test(t)?e?`${c.index.rpx2px(parseInt(t))}px`:Number(c.index.rpx2px(parseInt(t))):e?`${parseInt(t)}px`:parseInt(t)}function b(t=30){return new Promise(e=>{setTimeout(()=>{e()},t)})}function m(){const e=(c.index.getWindowInfo()||{}).platform||"";return String(e).toLowerCase()}function _(){return c.index.getWindowInfo()}function x(t,e){if(t>=0&&e>0&&e>=t){const n=e-t+1;return Math.floor(Math.random()*n+t)}return 0}function M(t=32,e=!0,n=null){const r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];if(n=n||r.length,t)for(let o=0;o<t;o++)i[o]=r[0|Math.random()*n];else{let o;i[8]=i[13]=i[18]=i[23]="-",i[14]="4";for(let f=0;f<36;f++)i[f]||(o=0|Math.random()*16,i[f]=r[f==19?o&3|8:o])}return e?(i.shift(),`u${i.join("")}`):i.join("")}function l(t=void 0){let e=this.$parent;for(;e;)if(e.$options&&e.$options.name!==t)e=e.$parent;else return e;return!1}function S(t,e="object"){if(a.empty(t)||typeof t=="object"&&e==="object"||e==="string"&&typeof t=="string")return t;if(e==="object"){t=u(t);const r=t.split(";"),i={};for(let o=0;o<r.length;o++)if(r[o]){const f=r[o].split(":");i[u(f[0])]=u(f[1])}return i}let n="";return typeof t=="object"&&t.forEach((r,i)=>{const o=i.replace(/([A-Z])/g,"-$1").toLowerCase();n+=`${o}:${r};`}),u(n)}function k(t="auto",e=""){return e||(e=y.config.unit),t=String(t),a.number(t)?`${t}${e}`:t}function d(t){if([null,void 0,NaN,!1].includes(t)||typeof t!="object"&&typeof t!="function")return t;const e=a.array(t)?[]:{};for(const n in t)t.hasOwnProperty(n)&&(e[n]=typeof t[n]=="object"?d(t[n]):t[n]);return e}function h(t={},e={}){let n=d(t);if(typeof n!="object"||typeof e!="object")return!1;for(const r in e)e.hasOwnProperty(r)&&(r in n?e[r]==null||typeof n[r]!="object"||typeof e[r]!="object"?n[r]=e[r]:n[r].concat&&e[r].concat?n[r]=n[r].concat(e[r]):n[r]=h(n[r],e[r]):n[r]=e[r]);return n}function I(t){c.index.__f__("error","at uni_modules/uview-plus/libs/function/index.js:281",`uView提示:${t}`)}String.prototype.padStart||(String.prototype.padStart=function(t,e=" "){if(Object.prototype.toString.call(e)!=="[object String]")throw new TypeError("fillString must be String");const n=this;if(n.length>=t)return String(n);const r=t-n.length;let i=Math.ceil(r/e.length);for(;i>>=1;)e+=e,i===1&&(e+=e);return e.slice(0,r)+n});function P(t=null,e="yyyy-mm-dd"){let n;t?/^\d{10}$/.test(t.toString().trim())?n=new Date(t*1e3):typeof t=="string"&&/^\d+$/.test(t.trim())?n=new Date(Number(t)):n=new Date(typeof t=="string"?t.replace(/-/g,"/"):t):n=new Date;const r={y:n.getFullYear().toString(),m:(n.getMonth()+1).toString().padStart(2,"0"),d:n.getDate().toString().padStart(2,"0"),h:n.getHours().toString().padStart(2,"0"),M:n.getMinutes().toString().padStart(2,"0"),s:n.getSeconds().toString().padStart(2,"0")};for(const i in r){const[o]=new RegExp(`${i}+`).exec(e)||[];if(o){const f=i==="y"&&o.length===2?2:0;e=e.replace(o,r[i].slice(f))}}return e}function u(t,e="both"){return t=String(t),e=="both"?t.replace(/^\s+|\s+$/g,""):e=="left"?t.replace(/^\s*/,""):e=="right"?t.replace(/(\s*$)/g,""):e=="all"?t.replace(/\s+/g,""):t}function j(t={},e=!0,n="brackets"){const r=e?"?":"",i=[];["indices","brackets","repeat","comma"].indexOf(n)==-1&&(n="brackets");for(const o in t){const f=t[o];if(!(["",void 0,null].indexOf(f)>=0))if(f.constructor===Array)switch(n){case"indices":for(let s=0;s<f.length;s++)i.push(`${o}[${s}]=${f[s]}`);break;case"brackets":f.forEach(s=>{i.push(`${o}[]=${s}`)});break;case"repeat":f.forEach(s=>{i.push(`${o}=${s}`)});break;case"comma":let p="";f.forEach(s=>{p+=(p?",":"")+s}),i.push(`${o}=${p}`);break;default:f.forEach(s=>{i.push(`${o}[]=${s}`)})}else i.push(`${o}=${f}`)}return i.length?r+i.join("&"):""}function E(t,e=2e3){c.index.showToast({title:String(t),icon:"none",duration:e})}function q(t,e=0,n=".",r=","){t=`${t}`.replace(/[^0-9+-Ee.]/g,"");const i=isFinite(+t)?+t:0,o=isFinite(+e)?Math.abs(e):0,f=typeof r>"u"?",":r,p=typeof n>"u"?".":n;let s="";s=(o?$.round(i,o)+"":`${Math.round(i)}`).split(".");const g=/(-?\d+)(\d{3})/;for(;g.test(s[0]);)s[0]=s[0].replace(g,`$1${f}$2`);return(s[1]||"").length<o&&(s[1]=s[1]||"",s[1]+=new Array(o-s[1].length+1).join("0")),s.join(p)}function F(t,e){const n=l.call(t,"u-form-item"),r=l.call(t,"u-form");n&&r&&r.validateField(n.prop,()=>{},e)}function D(){const t=getCurrentPages();return`/${t[t.length-1].route||""}`}exports.$parent=l;exports.addStyle=S;exports.addUnit=k;exports.deepMerge=h;exports.error=I;exports.formValidate=F;exports.getPx=w;exports.guid=M;exports.os=m;exports.page=D;exports.priceFormat=q;exports.queryParams=j;exports.random=x;exports.sleep=b;exports.sys=_;exports.timeFormat=P;exports.toast=E;
  2. //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-plus/libs/function/index.js.map