feat:初始提交uni-app项目
This commit is contained in:
20
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/debounce.js
vendored
Normal file
20
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/debounce.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
let timeout = null;
|
||||
function debounce(func, wait = 500, immediate = false) {
|
||||
if (timeout !== null)
|
||||
clearTimeout(timeout);
|
||||
if (immediate) {
|
||||
const callNow = !timeout;
|
||||
timeout = setTimeout(() => {
|
||||
timeout = null;
|
||||
}, wait);
|
||||
if (callNow)
|
||||
typeof func === "function" && func();
|
||||
} else {
|
||||
timeout = setTimeout(() => {
|
||||
typeof func === "function" && func();
|
||||
}, wait);
|
||||
}
|
||||
}
|
||||
exports.debounce = debounce;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uv-ui-tools/libs/function/debounce.js.map
|
||||
65
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/digit.js
vendored
Normal file
65
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/digit.js
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
function strip(num, precision = 15) {
|
||||
return +parseFloat(Number(num).toPrecision(precision));
|
||||
}
|
||||
function digitLength(num) {
|
||||
const eSplit = num.toString().split(/[eE]/);
|
||||
const len = (eSplit[0].split(".")[1] || "").length - +(eSplit[1] || 0);
|
||||
return len > 0 ? len : 0;
|
||||
}
|
||||
function float2Fixed(num) {
|
||||
if (num.toString().indexOf("e") === -1) {
|
||||
return Number(num.toString().replace(".", ""));
|
||||
}
|
||||
const dLen = digitLength(num);
|
||||
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
|
||||
}
|
||||
function checkBoundary(num) {
|
||||
{
|
||||
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
|
||||
common_vendor.index.__f__("warn", "at uni_modules/uv-ui-tools/libs/function/digit.js:45", `${num} 超出了精度限制,结果可能不正确`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function iteratorOperation(arr, operation) {
|
||||
const [num1, num2, ...others] = arr;
|
||||
let res = operation(num1, num2);
|
||||
others.forEach((num) => {
|
||||
res = operation(res, num);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
function times(...nums) {
|
||||
if (nums.length > 2) {
|
||||
return iteratorOperation(nums, times);
|
||||
}
|
||||
const [num1, num2] = nums;
|
||||
const num1Changed = float2Fixed(num1);
|
||||
const num2Changed = float2Fixed(num2);
|
||||
const baseNum = digitLength(num1) + digitLength(num2);
|
||||
const leftValue = num1Changed * num2Changed;
|
||||
checkBoundary(leftValue);
|
||||
return leftValue / Math.pow(10, baseNum);
|
||||
}
|
||||
function divide(...nums) {
|
||||
if (nums.length > 2) {
|
||||
return iteratorOperation(nums, divide);
|
||||
}
|
||||
const [num1, num2] = nums;
|
||||
const num1Changed = float2Fixed(num1);
|
||||
const num2Changed = float2Fixed(num2);
|
||||
checkBoundary(num1Changed);
|
||||
checkBoundary(num2Changed);
|
||||
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
|
||||
}
|
||||
function round(num, ratio) {
|
||||
const base = Math.pow(10, ratio);
|
||||
let result = divide(Math.round(Math.abs(times(num, base))), base);
|
||||
if (num < 0 && result !== 0) {
|
||||
result = times(result, -1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.round = round;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uv-ui-tools/libs/function/digit.js.map
|
||||
503
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/index.js
vendored
Normal file
503
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/index.js
vendored
Normal file
@@ -0,0 +1,503 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_uvUiTools_libs_function_test = require("./test.js");
|
||||
const uni_modules_uvUiTools_libs_function_digit = require("./digit.js");
|
||||
function range(min = 0, max = 0, value = 0) {
|
||||
return Math.max(min, Math.min(max, Number(value)));
|
||||
}
|
||||
function getPx(value, unit = false) {
|
||||
if (uni_modules_uvUiTools_libs_function_test.number(value)) {
|
||||
return unit ? `${value}px` : Number(value);
|
||||
}
|
||||
if (/(rpx|upx)$/.test(value)) {
|
||||
return unit ? `${common_vendor.index.upx2px(parseInt(value))}px` : Number(common_vendor.index.upx2px(parseInt(value)));
|
||||
}
|
||||
return unit ? `${parseInt(value)}px` : parseInt(value);
|
||||
}
|
||||
function sleep(value = 30) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, value);
|
||||
});
|
||||
}
|
||||
function os() {
|
||||
return common_vendor.index.getSystemInfoSync().platform.toLowerCase();
|
||||
}
|
||||
function sys() {
|
||||
return common_vendor.index.getSystemInfoSync();
|
||||
}
|
||||
function random(min, max) {
|
||||
if (min >= 0 && max > 0 && max >= min) {
|
||||
const gab = max - min + 1;
|
||||
return Math.floor(Math.random() * gab + min);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function guid(len = 32, firstU = true, radix = null) {
|
||||
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
|
||||
const uuid = [];
|
||||
radix = radix || chars.length;
|
||||
if (len) {
|
||||
for (let i = 0; i < len; i++)
|
||||
uuid[i] = chars[0 | Math.random() * radix];
|
||||
} else {
|
||||
let r;
|
||||
uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
|
||||
uuid[14] = "4";
|
||||
for (let i = 0; i < 36; i++) {
|
||||
if (!uuid[i]) {
|
||||
r = 0 | Math.random() * 16;
|
||||
uuid[i] = chars[i == 19 ? r & 3 | 8 : r];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (firstU) {
|
||||
uuid.shift();
|
||||
return `u${uuid.join("")}`;
|
||||
}
|
||||
return uuid.join("");
|
||||
}
|
||||
function $parent(name = void 0) {
|
||||
let parent = this.$parent;
|
||||
while (parent) {
|
||||
if (parent.$options && parent.$options.name !== name) {
|
||||
parent = parent.$parent;
|
||||
} else {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function addStyle(customStyle, target = "object") {
|
||||
if (uni_modules_uvUiTools_libs_function_test.empty(customStyle) || typeof customStyle === "object" && target === "object" || target === "string" && typeof customStyle === "string") {
|
||||
return customStyle;
|
||||
}
|
||||
if (target === "object") {
|
||||
customStyle = trim(customStyle);
|
||||
const styleArray = customStyle.split(";");
|
||||
const style = {};
|
||||
for (let i = 0; i < styleArray.length; i++) {
|
||||
if (styleArray[i]) {
|
||||
const item = styleArray[i].split(":");
|
||||
style[trim(item[0])] = trim(item[1]);
|
||||
}
|
||||
}
|
||||
return style;
|
||||
}
|
||||
let string = "";
|
||||
for (const i in customStyle) {
|
||||
const key = i.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||||
string += `${key}:${customStyle[i]};`;
|
||||
}
|
||||
return trim(string);
|
||||
}
|
||||
function addUnit(value = "auto", unit = ((_c) => (_c = ((_b) => (_b = ((_a) => (_a = common_vendor.index) == null ? void 0 : _a.$uv)()) == null ? void 0 : _b.config)()) == null ? void 0 : _c.unit)() ? ((_f) => (_f = ((_e) => (_e = ((_d) => (_d = common_vendor.index) == null ? void 0 : _d.$uv)()) == null ? void 0 : _e.config)()) == null ? void 0 : _f.unit)() : "px") {
|
||||
value = String(value);
|
||||
return uni_modules_uvUiTools_libs_function_test.number(value) ? `${value}${unit}` : value;
|
||||
}
|
||||
function deepClone(obj, cache = /* @__PURE__ */ new WeakMap()) {
|
||||
if (obj === null || typeof obj !== "object")
|
||||
return obj;
|
||||
if (cache.has(obj))
|
||||
return cache.get(obj);
|
||||
let clone;
|
||||
if (obj instanceof Date) {
|
||||
clone = new Date(obj.getTime());
|
||||
} else if (obj instanceof RegExp) {
|
||||
clone = new RegExp(obj);
|
||||
} else if (obj instanceof Map) {
|
||||
clone = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)]));
|
||||
} else if (obj instanceof Set) {
|
||||
clone = new Set(Array.from(obj, (value) => deepClone(value, cache)));
|
||||
} else if (Array.isArray(obj)) {
|
||||
clone = obj.map((value) => deepClone(value, cache));
|
||||
} else if (Object.prototype.toString.call(obj) === "[object Object]") {
|
||||
clone = Object.create(Object.getPrototypeOf(obj));
|
||||
cache.set(obj, clone);
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
clone[key] = deepClone(value, cache);
|
||||
}
|
||||
} else {
|
||||
clone = Object.assign({}, obj);
|
||||
}
|
||||
cache.set(obj, clone);
|
||||
return clone;
|
||||
}
|
||||
function deepMerge(target = {}, source = {}) {
|
||||
target = deepClone(target);
|
||||
if (typeof target !== "object" || target === null || typeof source !== "object" || source === null)
|
||||
return target;
|
||||
const merged = Array.isArray(target) ? target.slice() : Object.assign({}, target);
|
||||
for (const prop in source) {
|
||||
if (!source.hasOwnProperty(prop))
|
||||
continue;
|
||||
const sourceValue = source[prop];
|
||||
const targetValue = merged[prop];
|
||||
if (sourceValue instanceof Date) {
|
||||
merged[prop] = new Date(sourceValue);
|
||||
} else if (sourceValue instanceof RegExp) {
|
||||
merged[prop] = new RegExp(sourceValue);
|
||||
} else if (sourceValue instanceof Map) {
|
||||
merged[prop] = new Map(sourceValue);
|
||||
} else if (sourceValue instanceof Set) {
|
||||
merged[prop] = new Set(sourceValue);
|
||||
} else if (typeof sourceValue === "object" && sourceValue !== null) {
|
||||
merged[prop] = deepMerge(targetValue, sourceValue);
|
||||
} else {
|
||||
merged[prop] = sourceValue;
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
function error(err) {
|
||||
{
|
||||
common_vendor.index.__f__("error", "at uni_modules/uv-ui-tools/libs/function/index.js:250", `uvui提示:${err}`);
|
||||
}
|
||||
}
|
||||
function randomArray(array = []) {
|
||||
return array.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
if (!String.prototype.padStart) {
|
||||
String.prototype.padStart = function(maxLength, fillString = " ") {
|
||||
if (Object.prototype.toString.call(fillString) !== "[object String]") {
|
||||
throw new TypeError(
|
||||
"fillString must be String"
|
||||
);
|
||||
}
|
||||
const str = this;
|
||||
if (str.length >= maxLength)
|
||||
return String(str);
|
||||
const fillLength = maxLength - str.length;
|
||||
let times = Math.ceil(fillLength / fillString.length);
|
||||
while (times >>= 1) {
|
||||
fillString += fillString;
|
||||
if (times === 1) {
|
||||
fillString += fillString;
|
||||
}
|
||||
}
|
||||
return fillString.slice(0, fillLength) + str;
|
||||
};
|
||||
}
|
||||
function timeFormat(dateTime = null, formatStr = "yyyy-mm-dd") {
|
||||
let date;
|
||||
if (!dateTime) {
|
||||
date = /* @__PURE__ */ new Date();
|
||||
} else if (/^\d{10}$/.test(dateTime == null ? void 0 : dateTime.toString().trim())) {
|
||||
date = new Date(dateTime * 1e3);
|
||||
} else if (typeof dateTime === "string" && /^\d+$/.test(dateTime.trim())) {
|
||||
date = new Date(Number(dateTime));
|
||||
} else if (typeof dateTime === "string" && dateTime.includes("-") && !dateTime.includes("T")) {
|
||||
date = new Date(dateTime.replace(/-/g, "/"));
|
||||
} else {
|
||||
date = new Date(dateTime);
|
||||
}
|
||||
const timeSource = {
|
||||
"y": date.getFullYear().toString(),
|
||||
// 年
|
||||
"m": (date.getMonth() + 1).toString().padStart(2, "0"),
|
||||
// 月
|
||||
"d": date.getDate().toString().padStart(2, "0"),
|
||||
// 日
|
||||
"h": date.getHours().toString().padStart(2, "0"),
|
||||
// 时
|
||||
"M": date.getMinutes().toString().padStart(2, "0"),
|
||||
// 分
|
||||
"s": date.getSeconds().toString().padStart(2, "0")
|
||||
// 秒
|
||||
// 有其他格式化字符需求可以继续添加,必须转化成字符串
|
||||
};
|
||||
for (const key in timeSource) {
|
||||
const [ret] = new RegExp(`${key}+`).exec(formatStr) || [];
|
||||
if (ret) {
|
||||
const beginIndex = key === "y" && ret.length === 2 ? 2 : 0;
|
||||
formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex));
|
||||
}
|
||||
}
|
||||
return formatStr;
|
||||
}
|
||||
function timeFrom(timestamp = null, format = "yyyy-mm-dd") {
|
||||
if (timestamp == null)
|
||||
timestamp = Number(/* @__PURE__ */ new Date());
|
||||
timestamp = parseInt(timestamp);
|
||||
if (timestamp.toString().length == 10)
|
||||
timestamp *= 1e3;
|
||||
let timer = (/* @__PURE__ */ new Date()).getTime() - timestamp;
|
||||
timer = parseInt(timer / 1e3);
|
||||
let tips = "";
|
||||
switch (true) {
|
||||
case timer < 300:
|
||||
tips = "刚刚";
|
||||
break;
|
||||
case (timer >= 300 && timer < 3600):
|
||||
tips = `${parseInt(timer / 60)}分钟前`;
|
||||
break;
|
||||
case (timer >= 3600 && timer < 86400):
|
||||
tips = `${parseInt(timer / 3600)}小时前`;
|
||||
break;
|
||||
case (timer >= 86400 && timer < 2592e3):
|
||||
tips = `${parseInt(timer / 86400)}天前`;
|
||||
break;
|
||||
default:
|
||||
if (format === false) {
|
||||
if (timer >= 2592e3 && timer < 365 * 86400) {
|
||||
tips = `${parseInt(timer / (86400 * 30))}个月前`;
|
||||
} else {
|
||||
tips = `${parseInt(timer / (86400 * 365))}年前`;
|
||||
}
|
||||
} else {
|
||||
tips = timeFormat(timestamp, format);
|
||||
}
|
||||
}
|
||||
return tips;
|
||||
}
|
||||
function trim(str, pos = "both") {
|
||||
str = String(str);
|
||||
if (pos == "both") {
|
||||
return str.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
if (pos == "left") {
|
||||
return str.replace(/^\s*/, "");
|
||||
}
|
||||
if (pos == "right") {
|
||||
return str.replace(/(\s*$)/g, "");
|
||||
}
|
||||
if (pos == "all") {
|
||||
return str.replace(/\s+/g, "");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function queryParams(data = {}, isPrefix = true, arrayFormat = "brackets") {
|
||||
const prefix = isPrefix ? "?" : "";
|
||||
const _result = [];
|
||||
if (["indices", "brackets", "repeat", "comma"].indexOf(arrayFormat) == -1)
|
||||
arrayFormat = "brackets";
|
||||
for (const key in data) {
|
||||
const value = data[key];
|
||||
if (["", void 0, null].indexOf(value) >= 0) {
|
||||
continue;
|
||||
}
|
||||
if (value.constructor === Array) {
|
||||
switch (arrayFormat) {
|
||||
case "indices":
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
_result.push(`${key}[${i}]=${value[i]}`);
|
||||
}
|
||||
break;
|
||||
case "brackets":
|
||||
value.forEach((_value) => {
|
||||
_result.push(`${key}[]=${_value}`);
|
||||
});
|
||||
break;
|
||||
case "repeat":
|
||||
value.forEach((_value) => {
|
||||
_result.push(`${key}=${_value}`);
|
||||
});
|
||||
break;
|
||||
case "comma":
|
||||
let commaStr = "";
|
||||
value.forEach((_value) => {
|
||||
commaStr += (commaStr ? "," : "") + _value;
|
||||
});
|
||||
_result.push(`${key}=${commaStr}`);
|
||||
break;
|
||||
default:
|
||||
value.forEach((_value) => {
|
||||
_result.push(`${key}[]=${_value}`);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_result.push(`${key}=${value}`);
|
||||
}
|
||||
}
|
||||
return _result.length ? prefix + _result.join("&") : "";
|
||||
}
|
||||
function toast(title, duration = 2e3) {
|
||||
common_vendor.index.showToast({
|
||||
title: String(title),
|
||||
icon: "none",
|
||||
duration
|
||||
});
|
||||
}
|
||||
function type2icon(type = "success", fill = false) {
|
||||
if (["primary", "info", "error", "warning", "success"].indexOf(type) == -1)
|
||||
type = "success";
|
||||
let iconName = "";
|
||||
switch (type) {
|
||||
case "primary":
|
||||
iconName = "info-circle";
|
||||
break;
|
||||
case "info":
|
||||
iconName = "info-circle";
|
||||
break;
|
||||
case "error":
|
||||
iconName = "close-circle";
|
||||
break;
|
||||
case "warning":
|
||||
iconName = "error-circle";
|
||||
break;
|
||||
case "success":
|
||||
iconName = "checkmark-circle";
|
||||
break;
|
||||
default:
|
||||
iconName = "checkmark-circle";
|
||||
}
|
||||
if (fill)
|
||||
iconName += "-fill";
|
||||
return iconName;
|
||||
}
|
||||
function priceFormat(number2, decimals = 0, decimalPoint = ".", thousandsSeparator = ",") {
|
||||
number2 = `${number2}`.replace(/[^0-9+-Ee.]/g, "");
|
||||
const n = !isFinite(+number2) ? 0 : +number2;
|
||||
const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals);
|
||||
const sep = typeof thousandsSeparator === "undefined" ? "," : thousandsSeparator;
|
||||
const dec = typeof decimalPoint === "undefined" ? "." : decimalPoint;
|
||||
let s = "";
|
||||
s = (prec ? uni_modules_uvUiTools_libs_function_digit.round(n, prec) + "" : `${Math.round(n)}`).split(".");
|
||||
const re = /(-?\d+)(\d{3})/;
|
||||
while (re.test(s[0])) {
|
||||
s[0] = s[0].replace(re, `$1${sep}$2`);
|
||||
}
|
||||
if ((s[1] || "").length < prec) {
|
||||
s[1] = s[1] || "";
|
||||
s[1] += new Array(prec - s[1].length + 1).join("0");
|
||||
}
|
||||
return s.join(dec);
|
||||
}
|
||||
function getDuration(value, unit = true) {
|
||||
const valueNum = parseInt(value);
|
||||
if (unit) {
|
||||
if (/s$/.test(value))
|
||||
return value;
|
||||
return value > 30 ? `${value}ms` : `${value}s`;
|
||||
}
|
||||
if (/ms$/.test(value))
|
||||
return valueNum;
|
||||
if (/s$/.test(value))
|
||||
return valueNum > 30 ? valueNum : valueNum * 1e3;
|
||||
return valueNum;
|
||||
}
|
||||
function padZero(value) {
|
||||
return `00${value}`.slice(-2);
|
||||
}
|
||||
function formValidate(instance, event) {
|
||||
const formItem = $parent.call(instance, "uv-form-item");
|
||||
const form = $parent.call(instance, "uv-form");
|
||||
if (formItem && form) {
|
||||
form.validateField(formItem.prop, () => {
|
||||
}, event);
|
||||
}
|
||||
}
|
||||
function getProperty(obj, key) {
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
if (typeof key !== "string" || key === "") {
|
||||
return "";
|
||||
}
|
||||
if (key.indexOf(".") !== -1) {
|
||||
const keys = key.split(".");
|
||||
let firstObj = obj[keys[0]] || {};
|
||||
for (let i = 1; i < keys.length; i++) {
|
||||
if (firstObj) {
|
||||
firstObj = firstObj[keys[i]];
|
||||
}
|
||||
}
|
||||
return firstObj;
|
||||
}
|
||||
return obj[key];
|
||||
}
|
||||
function setProperty(obj, key, value) {
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
const inFn = function(_obj, keys, v) {
|
||||
if (keys.length === 1) {
|
||||
_obj[keys[0]] = v;
|
||||
return;
|
||||
}
|
||||
while (keys.length > 1) {
|
||||
const k = keys[0];
|
||||
if (!_obj[k] || typeof _obj[k] !== "object") {
|
||||
_obj[k] = {};
|
||||
}
|
||||
keys.shift();
|
||||
inFn(_obj[k], keys, v);
|
||||
}
|
||||
};
|
||||
if (typeof key !== "string" || key === "")
|
||||
;
|
||||
else if (key.indexOf(".") !== -1) {
|
||||
const keys = key.split(".");
|
||||
inFn(obj, keys, value);
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
}
|
||||
function page() {
|
||||
var _a;
|
||||
const pages2 = getCurrentPages();
|
||||
const route = (_a = pages2[pages2.length - 1]) == null ? void 0 : _a.route;
|
||||
return `/${route ? route : ""}`;
|
||||
}
|
||||
function pages() {
|
||||
const pages2 = getCurrentPages();
|
||||
return pages2;
|
||||
}
|
||||
function getHistoryPage(back = 0) {
|
||||
const pages2 = getCurrentPages();
|
||||
const len = pages2.length;
|
||||
return pages2[len - 1 + back];
|
||||
}
|
||||
function setConfig({
|
||||
props = {},
|
||||
config = {},
|
||||
color = {},
|
||||
zIndex = {}
|
||||
}) {
|
||||
const {
|
||||
deepMerge: deepMerge2
|
||||
} = common_vendor.index.$uv;
|
||||
common_vendor.index.$uv.config = deepMerge2(common_vendor.index.$uv.config, config);
|
||||
common_vendor.index.$uv.props = deepMerge2(common_vendor.index.$uv.props, props);
|
||||
common_vendor.index.$uv.color = deepMerge2(common_vendor.index.$uv.color, color);
|
||||
common_vendor.index.$uv.zIndex = deepMerge2(common_vendor.index.$uv.zIndex, zIndex);
|
||||
}
|
||||
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||||
__proto__: null,
|
||||
$parent,
|
||||
addStyle,
|
||||
addUnit,
|
||||
deepClone,
|
||||
deepMerge,
|
||||
error,
|
||||
formValidate,
|
||||
getDuration,
|
||||
getHistoryPage,
|
||||
getProperty,
|
||||
getPx,
|
||||
guid,
|
||||
os,
|
||||
padZero,
|
||||
page,
|
||||
pages,
|
||||
priceFormat,
|
||||
queryParams,
|
||||
random,
|
||||
randomArray,
|
||||
range,
|
||||
setConfig,
|
||||
setProperty,
|
||||
sleep,
|
||||
sys,
|
||||
timeFormat,
|
||||
timeFrom,
|
||||
toast,
|
||||
trim,
|
||||
type2icon
|
||||
}, Symbol.toStringTag, { value: "Module" }));
|
||||
exports.deepMerge = deepMerge;
|
||||
exports.index = index;
|
||||
exports.page = page;
|
||||
exports.queryParams = queryParams;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uv-ui-tools/libs/function/index.js.map
|
||||
178
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/test.js
vendored
Normal file
178
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/test.js
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
"use strict";
|
||||
function email(value) {
|
||||
return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value);
|
||||
}
|
||||
function mobile(value) {
|
||||
return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value);
|
||||
}
|
||||
function url(value) {
|
||||
return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/.test(value);
|
||||
}
|
||||
function date(value) {
|
||||
if (!value)
|
||||
return false;
|
||||
if (number(value))
|
||||
value = +value;
|
||||
return !/Invalid|NaN/.test(new Date(value).toString());
|
||||
}
|
||||
function dateISO(value) {
|
||||
return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value);
|
||||
}
|
||||
function number(value) {
|
||||
return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value);
|
||||
}
|
||||
function string(value) {
|
||||
return typeof value === "string";
|
||||
}
|
||||
function digits(value) {
|
||||
return /^\d+$/.test(value);
|
||||
}
|
||||
function idCard(value) {
|
||||
return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(
|
||||
value
|
||||
);
|
||||
}
|
||||
function carNo(value) {
|
||||
const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
|
||||
const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
|
||||
if (value.length === 7) {
|
||||
return creg.test(value);
|
||||
}
|
||||
if (value.length === 8) {
|
||||
return xreg.test(value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function amount(value) {
|
||||
return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value);
|
||||
}
|
||||
function chinese(value) {
|
||||
const reg = /^[\u4e00-\u9fa5]+$/gi;
|
||||
return reg.test(value);
|
||||
}
|
||||
function letter(value) {
|
||||
return /^[a-zA-Z]*$/.test(value);
|
||||
}
|
||||
function enOrNum(value) {
|
||||
const reg = /^[0-9a-zA-Z]*$/g;
|
||||
return reg.test(value);
|
||||
}
|
||||
function contains(value, param) {
|
||||
return value.indexOf(param) >= 0;
|
||||
}
|
||||
function range(value, param) {
|
||||
return value >= param[0] && value <= param[1];
|
||||
}
|
||||
function rangeLength(value, param) {
|
||||
return value.length >= param[0] && value.length <= param[1];
|
||||
}
|
||||
function landline(value) {
|
||||
const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/;
|
||||
return reg.test(value);
|
||||
}
|
||||
function empty(value) {
|
||||
switch (typeof value) {
|
||||
case "undefined":
|
||||
return true;
|
||||
case "string":
|
||||
if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, "").length == 0)
|
||||
return true;
|
||||
break;
|
||||
case "boolean":
|
||||
if (!value)
|
||||
return true;
|
||||
break;
|
||||
case "number":
|
||||
if (value === 0 || isNaN(value))
|
||||
return true;
|
||||
break;
|
||||
case "object":
|
||||
if (value === null || value.length === 0)
|
||||
return true;
|
||||
for (const i in value) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function jsonString(value) {
|
||||
if (typeof value === "string") {
|
||||
try {
|
||||
const obj = JSON.parse(value);
|
||||
if (typeof obj === "object" && obj) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function array(value) {
|
||||
if (typeof Array.isArray === "function") {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
return Object.prototype.toString.call(value) === "[object Array]";
|
||||
}
|
||||
function object(value) {
|
||||
return Object.prototype.toString.call(value) === "[object Object]";
|
||||
}
|
||||
function code(value, len = 6) {
|
||||
return new RegExp(`^\\d{${len}}$`).test(value);
|
||||
}
|
||||
function func(value) {
|
||||
return typeof value === "function";
|
||||
}
|
||||
function promise(value) {
|
||||
return object(value) && func(value.then) && func(value.catch);
|
||||
}
|
||||
function image(value) {
|
||||
const newValue = value.split("?")[0];
|
||||
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
||||
return IMAGE_REGEXP.test(newValue);
|
||||
}
|
||||
function video(value) {
|
||||
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i;
|
||||
return VIDEO_REGEXP.test(value);
|
||||
}
|
||||
function regExp(o) {
|
||||
return o && Object.prototype.toString.call(o) === "[object RegExp]";
|
||||
}
|
||||
const test = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||||
__proto__: null,
|
||||
amount,
|
||||
array,
|
||||
carNo,
|
||||
chinese,
|
||||
code,
|
||||
contains,
|
||||
date,
|
||||
dateISO,
|
||||
digits,
|
||||
email,
|
||||
empty,
|
||||
enOrNum,
|
||||
func,
|
||||
idCard,
|
||||
image,
|
||||
jsonString,
|
||||
landline,
|
||||
letter,
|
||||
mobile,
|
||||
number,
|
||||
object,
|
||||
promise,
|
||||
range,
|
||||
rangeLength,
|
||||
regExp,
|
||||
string,
|
||||
url,
|
||||
video
|
||||
}, Symbol.toStringTag, { value: "Module" }));
|
||||
exports.array = array;
|
||||
exports.empty = empty;
|
||||
exports.number = number;
|
||||
exports.test = test;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uv-ui-tools/libs/function/test.js.map
|
||||
21
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/throttle.js
vendored
Normal file
21
unpackage/dist/dev/mp-weixin/uni_modules/uv-ui-tools/libs/function/throttle.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
let flag;
|
||||
function throttle(func, wait = 500, immediate = true) {
|
||||
if (immediate) {
|
||||
if (!flag) {
|
||||
flag = true;
|
||||
typeof func === "function" && func();
|
||||
setTimeout(() => {
|
||||
flag = false;
|
||||
}, wait);
|
||||
}
|
||||
} else if (!flag) {
|
||||
flag = true;
|
||||
setTimeout(() => {
|
||||
flag = false;
|
||||
typeof func === "function" && func();
|
||||
}, wait);
|
||||
}
|
||||
}
|
||||
exports.throttle = throttle;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uv-ui-tools/libs/function/throttle.js.map
|
||||
Reference in New Issue
Block a user