1 |
- "use strict";const p=require("../../../../common/vendor.js"),u=require("./test.js"),$=require("./digit.js"),y=require("../config/config.js");function w(t,e=!1){return u.number(t)?e?`${t}px`:Number(t):/(rpx|upx)$/.test(t)?e?`${p.index.rpx2px(parseInt(t))}px`:Number(p.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=(p.index.getWindowInfo()||{}).platform||"";return String(e).toLowerCase()}function x(){return p.index.getWindowInfo()}function _(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(""),o=[];if(n=n||r.length,t)for(let i=0;i<t;i++)o[i]=r[0|Math.random()*n];else{let i;o[8]=o[13]=o[18]=o[23]="-",o[14]="4";for(let f=0;f<36;f++)o[f]||(i=0|Math.random()*16,o[f]=r[f==19?i&3|8:i])}return e?(o.shift(),`u${o.join("")}`):o.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(u.empty(t)||typeof t=="object"&&e==="object"||e==="string"&&typeof t=="string")return t;if(e==="object"){t=a(t);const r=t.split(";"),o={};for(let i=0;i<r.length;i++)if(r[i]){const f=r[i].split(":");o[a(f[0])]=a(f[1])}return o}let n="";return typeof t=="object"&&t.forEach((r,o)=>{const i=o.replace(/([A-Z])/g,"-$1").toLowerCase();n+=`${i}:${r};`}),a(n)}function k(t="auto",e=""){return e||(e=y.config.unit),t=String(t),u.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=u.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){console.error(`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 o=Math.ceil(r/e.length);for(;o>>=1;)e+=e,o===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 o in r){const[i]=new RegExp(`${o}+`).exec(e)||[];if(i){const f=o==="y"&&i.length===2?2:0;e=e.replace(i,r[o].slice(f))}}return e}function a(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?"?":"",o=[];["indices","brackets","repeat","comma"].indexOf(n)==-1&&(n="brackets");for(const i in t){const f=t[i];if(!(["",void 0,null].indexOf(f)>=0))if(f.constructor===Array)switch(n){case"indices":for(let s=0;s<f.length;s++)o.push(`${i}[${s}]=${f[s]}`);break;case"brackets":f.forEach(s=>{o.push(`${i}[]=${s}`)});break;case"repeat":f.forEach(s=>{o.push(`${i}=${s}`)});break;case"comma":let c="";f.forEach(s=>{c+=(c?",":"")+s}),o.push(`${i}=${c}`);break;default:f.forEach(s=>{o.push(`${i}[]=${s}`)})}else o.push(`${i}=${f}`)}return o.length?r+o.join("&"):""}function E(t,e=2e3){p.index.showToast({title:String(t),icon:"none",duration:e})}function q(t,e=0,n=".",r=","){t=`${t}`.replace(/[^0-9+-Ee.]/g,"");const o=isFinite(+t)?+t:0,i=isFinite(+e)?Math.abs(e):0,f=typeof r>"u"?",":r,c=typeof n>"u"?".":n;let s="";s=(i?$.round(o,i)+"":`${Math.round(o)}`).split(".");const g=/(-?\d+)(\d{3})/;for(;g.test(s[0]);)s[0]=s[0].replace(g,`$1${f}$2`);return(s[1]||"").length<i&&(s[1]=s[1]||"",s[1]+=new Array(i-s[1].length+1).join("0")),s.join(c)}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=_;exports.sleep=b;exports.sys=x;exports.timeFormat=P;exports.toast=E;
|