2251 lines
69 KiB
JavaScript
2251 lines
69 KiB
JavaScript
if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
|
||
Promise.prototype.finally = function(callback) {
|
||
const promise = this.constructor;
|
||
return this.then(
|
||
(value) => promise.resolve(callback()).then(() => value),
|
||
(reason) => promise.resolve(callback()).then(() => {
|
||
throw reason;
|
||
})
|
||
);
|
||
};
|
||
}
|
||
;
|
||
if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
|
||
const global = uni.requireGlobal();
|
||
ArrayBuffer = global.ArrayBuffer;
|
||
Int8Array = global.Int8Array;
|
||
Uint8Array = global.Uint8Array;
|
||
Uint8ClampedArray = global.Uint8ClampedArray;
|
||
Int16Array = global.Int16Array;
|
||
Uint16Array = global.Uint16Array;
|
||
Int32Array = global.Int32Array;
|
||
Uint32Array = global.Uint32Array;
|
||
Float32Array = global.Float32Array;
|
||
Float64Array = global.Float64Array;
|
||
BigInt64Array = global.BigInt64Array;
|
||
BigUint64Array = global.BigUint64Array;
|
||
}
|
||
;
|
||
if (uni.restoreGlobal) {
|
||
uni.restoreGlobal(Vue, weex, plus, setTimeout, clearTimeout, setInterval, clearInterval);
|
||
}
|
||
(function(vue) {
|
||
"use strict";
|
||
var _e, _f;
|
||
function formatAppLog(type, filename, ...args) {
|
||
if (uni.__log__) {
|
||
uni.__log__(type, filename, ...args);
|
||
} else {
|
||
console[type].apply(console, [...args, filename]);
|
||
}
|
||
}
|
||
function resolveEasycom(component, easycom) {
|
||
return typeof component === "string" ? easycom : component;
|
||
}
|
||
const mpMixin = {};
|
||
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$1(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: range$1,
|
||
rangeLength,
|
||
regExp,
|
||
string,
|
||
url,
|
||
video
|
||
}, Symbol.toStringTag, { value: "Module" }));
|
||
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) {
|
||
formatAppLog("warn", "at node_modules/@climblee/uv-ui/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;
|
||
}
|
||
function range(min = 0, max = 0, value = 0) {
|
||
return Math.max(min, Math.min(max, Number(value)));
|
||
}
|
||
function getPx(value, unit = false) {
|
||
if (number(value)) {
|
||
return unit ? `${value}px` : Number(value);
|
||
}
|
||
if (/(rpx|upx)$/.test(value)) {
|
||
return unit ? `${uni.upx2px(parseInt(value))}px` : Number(uni.upx2px(parseInt(value)));
|
||
}
|
||
return unit ? `${parseInt(value)}px` : parseInt(value);
|
||
}
|
||
function sleep(value = 30) {
|
||
return new Promise((resolve) => {
|
||
setTimeout(() => {
|
||
resolve();
|
||
}, value);
|
||
});
|
||
}
|
||
function os() {
|
||
return uni.getSystemInfoSync().platform.toLowerCase();
|
||
}
|
||
function sys() {
|
||
return uni.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 (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 string2 = "";
|
||
for (const i in customStyle) {
|
||
const key = i.replace(/([A-Z])/g, "-$1").toLowerCase();
|
||
string2 += `${key}:${customStyle[i]};`;
|
||
}
|
||
return trim(string2);
|
||
}
|
||
function addUnit(value = "auto", unit = ((_b) => (_b = ((_a) => (_a = uni == null ? void 0 : uni.$uv) == null ? void 0 : _a.config)()) == null ? void 0 : _b.unit)() ? ((_d) => (_d = ((_c) => (_c = uni == null ? void 0 : uni.$uv) == null ? void 0 : _c.config)()) == null ? void 0 : _d.unit)() : "px") {
|
||
value = String(value);
|
||
return 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 clone2;
|
||
if (obj instanceof Date) {
|
||
clone2 = new Date(obj.getTime());
|
||
} else if (obj instanceof RegExp) {
|
||
clone2 = new RegExp(obj);
|
||
} else if (obj instanceof Map) {
|
||
clone2 = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)]));
|
||
} else if (obj instanceof Set) {
|
||
clone2 = new Set(Array.from(obj, (value) => deepClone(value, cache)));
|
||
} else if (Array.isArray(obj)) {
|
||
clone2 = obj.map((value) => deepClone(value, cache));
|
||
} else if (Object.prototype.toString.call(obj) === "[object Object]") {
|
||
clone2 = Object.create(Object.getPrototypeOf(obj));
|
||
cache.set(obj, clone2);
|
||
for (const [key, value] of Object.entries(obj)) {
|
||
clone2[key] = deepClone(value, cache);
|
||
}
|
||
} else {
|
||
clone2 = Object.assign({}, obj);
|
||
}
|
||
cache.set(obj, clone2);
|
||
return clone2;
|
||
}
|
||
function deepMerge$1(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$1(targetValue, sourceValue);
|
||
} else {
|
||
merged[prop] = sourceValue;
|
||
}
|
||
}
|
||
return merged;
|
||
}
|
||
function error(err) {
|
||
{
|
||
formatAppLog("error", "at node_modules/@climblee/uv-ui/libs/function/index.js:250", `uvui提示:${err}`);
|
||
}
|
||
}
|
||
function randomArray(array2 = []) {
|
||
return array2.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 times2 = Math.ceil(fillLength / fillString.length);
|
||
while (times2 >>= 1) {
|
||
fillString += fillString;
|
||
if (times2 === 1) {
|
||
fillString += fillString;
|
||
}
|
||
}
|
||
return fillString.slice(0, fillLength) + str;
|
||
};
|
||
}
|
||
function timeFormat(dateTime = null, formatStr = "yyyy-mm-dd") {
|
||
let date2;
|
||
if (!dateTime) {
|
||
date2 = /* @__PURE__ */ new Date();
|
||
} else if (/^\d{10}$/.test(dateTime == null ? void 0 : dateTime.toString().trim())) {
|
||
date2 = new Date(dateTime * 1e3);
|
||
} else if (typeof dateTime === "string" && /^\d+$/.test(dateTime.trim())) {
|
||
date2 = new Date(Number(dateTime));
|
||
} else if (typeof dateTime === "string" && dateTime.includes("-") && !dateTime.includes("T")) {
|
||
date2 = new Date(dateTime.replace(/-/g, "/"));
|
||
} else {
|
||
date2 = new Date(dateTime);
|
||
}
|
||
const timeSource = {
|
||
"y": date2.getFullYear().toString(),
|
||
// 年
|
||
"m": (date2.getMonth() + 1).toString().padStart(2, "0"),
|
||
// 月
|
||
"d": date2.getDate().toString().padStart(2, "0"),
|
||
// 日
|
||
"h": date2.getHours().toString().padStart(2, "0"),
|
||
// 时
|
||
"M": date2.getMinutes().toString().padStart(2, "0"),
|
||
// 分
|
||
"s": date2.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) {
|
||
uni.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 ? 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 route2 = (_a = pages2[pages2.length - 1]) == null ? void 0 : _a.route;
|
||
return `/${route2 ? route2 : ""}`;
|
||
}
|
||
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: props2 = {},
|
||
config: config2 = {},
|
||
color = {},
|
||
zIndex = {}
|
||
}) {
|
||
const {
|
||
deepMerge: deepMerge2
|
||
} = uni.$uv;
|
||
uni.$uv.config = deepMerge2(uni.$uv.config, config2);
|
||
uni.$uv.props = deepMerge2(uni.$uv.props, props2);
|
||
uni.$uv.color = deepMerge2(uni.$uv.color, color);
|
||
uni.$uv.zIndex = deepMerge2(uni.$uv.zIndex, zIndex);
|
||
}
|
||
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||
__proto__: null,
|
||
$parent,
|
||
addStyle,
|
||
addUnit,
|
||
deepClone,
|
||
deepMerge: deepMerge$1,
|
||
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" }));
|
||
class Router {
|
||
constructor() {
|
||
this.config = {
|
||
type: "navigateTo",
|
||
url: "",
|
||
delta: 1,
|
||
// navigateBack页面后退时,回退的层数
|
||
params: {},
|
||
// 传递的参数
|
||
animationType: "pop-in",
|
||
// 窗口动画,只在APP有效
|
||
animationDuration: 300,
|
||
// 窗口动画持续时间,单位毫秒,只在APP有效
|
||
intercept: false,
|
||
// 是否需要拦截
|
||
events: {}
|
||
// 页面间通信接口,用于监听被打开页面发送到当前页面的数据。hbuilderx 2.8.9+ 开始支持。
|
||
};
|
||
this.route = this.route.bind(this);
|
||
}
|
||
// 判断url前面是否有"/",如果没有则加上,否则无法跳转
|
||
addRootPath(url2) {
|
||
return url2[0] === "/" ? url2 : `/${url2}`;
|
||
}
|
||
// 整合路由参数
|
||
mixinParam(url2, params) {
|
||
url2 = url2 && this.addRootPath(url2);
|
||
let query = "";
|
||
if (/.*\/.*\?.*=.*/.test(url2)) {
|
||
query = queryParams(params, false);
|
||
return url2 += `&${query}`;
|
||
}
|
||
query = queryParams(params);
|
||
return url2 += query;
|
||
}
|
||
// 对外的方法名称
|
||
async route(options = {}, params = {}) {
|
||
let mergeConfig2 = {};
|
||
if (typeof options === "string") {
|
||
mergeConfig2.url = this.mixinParam(options, params);
|
||
mergeConfig2.type = "navigateTo";
|
||
} else {
|
||
mergeConfig2 = deepMerge$1(this.config, options);
|
||
mergeConfig2.url = this.mixinParam(options.url, options.params);
|
||
}
|
||
if (mergeConfig2.url === page())
|
||
return;
|
||
if (params.intercept) {
|
||
mergeConfig2.intercept = params.intercept;
|
||
}
|
||
mergeConfig2.params = params;
|
||
mergeConfig2 = deepMerge$1(this.config, mergeConfig2);
|
||
if (typeof mergeConfig2.intercept === "function") {
|
||
const isNext = await new Promise((resolve, reject) => {
|
||
mergeConfig2.intercept(mergeConfig2, resolve);
|
||
});
|
||
isNext && this.openPage(mergeConfig2);
|
||
} else {
|
||
this.openPage(mergeConfig2);
|
||
}
|
||
}
|
||
// 执行路由跳转
|
||
openPage(config2) {
|
||
const {
|
||
url: url2,
|
||
type,
|
||
delta,
|
||
animationType,
|
||
animationDuration,
|
||
events
|
||
} = config2;
|
||
if (config2.type == "navigateTo" || config2.type == "to") {
|
||
uni.navigateTo({
|
||
url: url2,
|
||
animationType,
|
||
animationDuration,
|
||
events
|
||
});
|
||
}
|
||
if (config2.type == "redirectTo" || config2.type == "redirect") {
|
||
uni.redirectTo({
|
||
url: url2
|
||
});
|
||
}
|
||
if (config2.type == "switchTab" || config2.type == "tab") {
|
||
uni.switchTab({
|
||
url: url2
|
||
});
|
||
}
|
||
if (config2.type == "reLaunch" || config2.type == "launch") {
|
||
uni.reLaunch({
|
||
url: url2
|
||
});
|
||
}
|
||
if (config2.type == "navigateBack" || config2.type == "back") {
|
||
uni.navigateBack({
|
||
delta
|
||
});
|
||
}
|
||
}
|
||
}
|
||
const route = new Router().route;
|
||
let timeout = null;
|
||
function debounce(func2, wait = 500, immediate = false) {
|
||
if (timeout !== null)
|
||
clearTimeout(timeout);
|
||
if (immediate) {
|
||
const callNow = !timeout;
|
||
timeout = setTimeout(() => {
|
||
timeout = null;
|
||
}, wait);
|
||
if (callNow)
|
||
typeof func2 === "function" && func2();
|
||
} else {
|
||
timeout = setTimeout(() => {
|
||
typeof func2 === "function" && func2();
|
||
}, wait);
|
||
}
|
||
}
|
||
let flag;
|
||
function throttle(func2, wait = 500, immediate = true) {
|
||
if (immediate) {
|
||
if (!flag) {
|
||
flag = true;
|
||
typeof func2 === "function" && func2();
|
||
setTimeout(() => {
|
||
flag = false;
|
||
}, wait);
|
||
}
|
||
} else if (!flag) {
|
||
flag = true;
|
||
setTimeout(() => {
|
||
flag = false;
|
||
typeof func2 === "function" && func2();
|
||
}, wait);
|
||
}
|
||
}
|
||
const mixin = {
|
||
// 定义每个组件都可能需要用到的外部样式以及类名
|
||
props: {
|
||
// 每个组件都有的父组件传递的样式,可以为字符串或者对象形式
|
||
customStyle: {
|
||
type: [Object, String],
|
||
default: () => ({})
|
||
},
|
||
customClass: {
|
||
type: String,
|
||
default: ""
|
||
},
|
||
// 跳转的页面路径
|
||
url: {
|
||
type: String,
|
||
default: ""
|
||
},
|
||
// 页面跳转的类型
|
||
linkType: {
|
||
type: String,
|
||
default: "navigateTo"
|
||
}
|
||
},
|
||
data() {
|
||
return {};
|
||
},
|
||
onLoad() {
|
||
this.$uv.getRect = this.$uvGetRect;
|
||
},
|
||
created() {
|
||
this.$uv.getRect = this.$uvGetRect;
|
||
},
|
||
computed: {
|
||
$uv() {
|
||
var _a, _b;
|
||
return {
|
||
...index,
|
||
test,
|
||
route,
|
||
debounce,
|
||
throttle,
|
||
unit: (_b = (_a = uni == null ? void 0 : uni.$uv) == null ? void 0 : _a.config) == null ? void 0 : _b.unit
|
||
};
|
||
},
|
||
/**
|
||
* 生成bem规则类名
|
||
* 由于微信小程序,H5,nvue之间绑定class的差异,无法通过:class="[bem()]"的形式进行同用
|
||
* 故采用如下折中做法,最后返回的是数组(一般平台)或字符串(支付宝和字节跳动平台),类似['a', 'b', 'c']或'a b c'的形式
|
||
* @param {String} name 组件名称
|
||
* @param {Array} fixed 一直会存在的类名
|
||
* @param {Array} change 会根据变量值为true或者false而出现或者隐藏的类名
|
||
* @returns {Array|string}
|
||
*/
|
||
bem() {
|
||
return function(name, fixed, change) {
|
||
const prefix = `uv-${name}--`;
|
||
const classes = {};
|
||
if (fixed) {
|
||
fixed.map((item) => {
|
||
classes[prefix + this[item]] = true;
|
||
});
|
||
}
|
||
if (change) {
|
||
change.map((item) => {
|
||
this[item] ? classes[prefix + item] = this[item] : delete classes[prefix + item];
|
||
});
|
||
}
|
||
return Object.keys(classes);
|
||
};
|
||
}
|
||
},
|
||
methods: {
|
||
// 跳转某一个页面
|
||
openPage(urlKey = "url") {
|
||
const url2 = this[urlKey];
|
||
if (url2) {
|
||
uni[this.linkType]({
|
||
url: url2
|
||
});
|
||
}
|
||
},
|
||
// 查询节点信息
|
||
// 目前此方法在支付宝小程序中无法获取组件跟接点的尺寸,为支付宝的bug(2020-07-21)
|
||
// 解决办法为在组件根部再套一个没有任何作用的view元素
|
||
$uvGetRect(selector, all) {
|
||
return new Promise((resolve) => {
|
||
uni.createSelectorQuery().in(this)[all ? "selectAll" : "select"](selector).boundingClientRect((rect) => {
|
||
if (all && Array.isArray(rect) && rect.length) {
|
||
resolve(rect);
|
||
}
|
||
if (!all && rect) {
|
||
resolve(rect);
|
||
}
|
||
}).exec();
|
||
});
|
||
},
|
||
getParentData(parentName = "") {
|
||
if (!this.parent)
|
||
this.parent = {};
|
||
this.parent = this.$uv.$parent.call(this, parentName);
|
||
if (this.parent.children) {
|
||
this.parent.children.indexOf(this) === -1 && this.parent.children.push(this);
|
||
}
|
||
if (this.parent && this.parentData) {
|
||
Object.keys(this.parentData).map((key) => {
|
||
this.parentData[key] = this.parent[key];
|
||
});
|
||
}
|
||
},
|
||
// 阻止事件冒泡
|
||
preventEvent(e) {
|
||
e && typeof e.stopPropagation === "function" && e.stopPropagation();
|
||
},
|
||
// 空操作
|
||
noop(e) {
|
||
this.preventEvent(e);
|
||
}
|
||
},
|
||
onReachBottom() {
|
||
uni.$emit("uvOnReachBottom");
|
||
},
|
||
beforeDestroy() {
|
||
if (this.parent && array(this.parent.children)) {
|
||
const childrenList = this.parent.children;
|
||
childrenList.map((child, index2) => {
|
||
if (child === this) {
|
||
childrenList.splice(index2, 1);
|
||
}
|
||
});
|
||
}
|
||
},
|
||
// 兼容vue3
|
||
unmounted() {
|
||
if (this.parent && array(this.parent.children)) {
|
||
const childrenList = this.parent.children;
|
||
childrenList.map((child, index2) => {
|
||
if (child === this) {
|
||
childrenList.splice(index2, 1);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
};
|
||
const icons = {
|
||
"uvicon-level": "e68f",
|
||
"uvicon-checkbox-mark": "e659",
|
||
"uvicon-folder": "e694",
|
||
"uvicon-movie": "e67c",
|
||
"uvicon-star-fill": "e61e",
|
||
"uvicon-star": "e618",
|
||
"uvicon-phone-fill": "e6ac",
|
||
"uvicon-phone": "e6ba",
|
||
"uvicon-apple-fill": "e635",
|
||
"uvicon-backspace": "e64d",
|
||
"uvicon-attach": "e640",
|
||
"uvicon-empty-data": "e671",
|
||
"uvicon-empty-address": "e68a",
|
||
"uvicon-empty-favor": "e662",
|
||
"uvicon-empty-car": "e657",
|
||
"uvicon-empty-order": "e66b",
|
||
"uvicon-empty-list": "e672",
|
||
"uvicon-empty-search": "e677",
|
||
"uvicon-empty-permission": "e67d",
|
||
"uvicon-empty-news": "e67e",
|
||
"uvicon-empty-history": "e685",
|
||
"uvicon-empty-coupon": "e69b",
|
||
"uvicon-empty-page": "e60e",
|
||
"uvicon-empty-wifi-off": "e6cc",
|
||
"uvicon-reload": "e627",
|
||
"uvicon-order": "e695",
|
||
"uvicon-server-man": "e601",
|
||
"uvicon-search": "e632",
|
||
"uvicon-more-dot-fill": "e66f",
|
||
"uvicon-scan": "e631",
|
||
"uvicon-map": "e665",
|
||
"uvicon-map-fill": "e6a8",
|
||
"uvicon-tags": "e621",
|
||
"uvicon-tags-fill": "e613",
|
||
"uvicon-eye": "e664",
|
||
"uvicon-eye-fill": "e697",
|
||
"uvicon-eye-off": "e69c",
|
||
"uvicon-eye-off-outline": "e688",
|
||
"uvicon-mic": "e66d",
|
||
"uvicon-mic-off": "e691",
|
||
"uvicon-calendar": "e65c",
|
||
"uvicon-trash": "e623",
|
||
"uvicon-trash-fill": "e6ce",
|
||
"uvicon-play-left": "e6bf",
|
||
"uvicon-play-right": "e6b3",
|
||
"uvicon-minus": "e614",
|
||
"uvicon-plus": "e625",
|
||
"uvicon-info-circle": "e69f",
|
||
"uvicon-info-circle-fill": "e6a7",
|
||
"uvicon-question-circle": "e622",
|
||
"uvicon-question-circle-fill": "e6bc",
|
||
"uvicon-close": "e65a",
|
||
"uvicon-checkmark": "e64a",
|
||
"uvicon-checkmark-circle": "e643",
|
||
"uvicon-checkmark-circle-fill": "e668",
|
||
"uvicon-setting": "e602",
|
||
"uvicon-setting-fill": "e6d0",
|
||
"uvicon-heart": "e6a2",
|
||
"uvicon-heart-fill": "e68b",
|
||
"uvicon-camera": "e642",
|
||
"uvicon-camera-fill": "e650",
|
||
"uvicon-more-circle": "e69e",
|
||
"uvicon-more-circle-fill": "e684",
|
||
"uvicon-chat": "e656",
|
||
"uvicon-chat-fill": "e63f",
|
||
"uvicon-bag": "e647",
|
||
"uvicon-error-circle": "e66e",
|
||
"uvicon-error-circle-fill": "e655",
|
||
"uvicon-close-circle": "e64e",
|
||
"uvicon-close-circle-fill": "e666",
|
||
"uvicon-share": "e629",
|
||
"uvicon-share-fill": "e6bb",
|
||
"uvicon-share-square": "e6c4",
|
||
"uvicon-shopping-cart": "e6cb",
|
||
"uvicon-shopping-cart-fill": "e630",
|
||
"uvicon-bell": "e651",
|
||
"uvicon-bell-fill": "e604",
|
||
"uvicon-list": "e690",
|
||
"uvicon-list-dot": "e6a9",
|
||
"uvicon-zhifubao-circle-fill": "e617",
|
||
"uvicon-weixin-circle-fill": "e6cd",
|
||
"uvicon-weixin-fill": "e620",
|
||
"uvicon-qq-fill": "e608",
|
||
"uvicon-qq-circle-fill": "e6b9",
|
||
"uvicon-moments-circel-fill": "e6c2",
|
||
"uvicon-moments": "e6a0",
|
||
"uvicon-car": "e64f",
|
||
"uvicon-car-fill": "e648",
|
||
"uvicon-warning-fill": "e6c7",
|
||
"uvicon-warning": "e6c1",
|
||
"uvicon-clock-fill": "e64b",
|
||
"uvicon-clock": "e66c",
|
||
"uvicon-edit-pen": "e65d",
|
||
"uvicon-edit-pen-fill": "e679",
|
||
"uvicon-email": "e673",
|
||
"uvicon-email-fill": "e683",
|
||
"uvicon-minus-circle": "e6a5",
|
||
"uvicon-plus-circle": "e603",
|
||
"uvicon-plus-circle-fill": "e611",
|
||
"uvicon-file-text": "e687",
|
||
"uvicon-file-text-fill": "e67f",
|
||
"uvicon-pushpin": "e6d1",
|
||
"uvicon-pushpin-fill": "e6b6",
|
||
"uvicon-grid": "e68c",
|
||
"uvicon-grid-fill": "e698",
|
||
"uvicon-play-circle": "e6af",
|
||
"uvicon-play-circle-fill": "e62a",
|
||
"uvicon-pause-circle-fill": "e60c",
|
||
"uvicon-pause": "e61c",
|
||
"uvicon-pause-circle": "e696",
|
||
"uvicon-gift-fill": "e6b0",
|
||
"uvicon-gift": "e680",
|
||
"uvicon-kefu-ermai": "e660",
|
||
"uvicon-server-fill": "e610",
|
||
"uvicon-coupon-fill": "e64c",
|
||
"uvicon-coupon": "e65f",
|
||
"uvicon-integral": "e693",
|
||
"uvicon-integral-fill": "e6b1",
|
||
"uvicon-home-fill": "e68e",
|
||
"uvicon-home": "e67b",
|
||
"uvicon-account": "e63a",
|
||
"uvicon-account-fill": "e653",
|
||
"uvicon-thumb-down-fill": "e628",
|
||
"uvicon-thumb-down": "e60a",
|
||
"uvicon-thumb-up": "e612",
|
||
"uvicon-thumb-up-fill": "e62c",
|
||
"uvicon-lock-fill": "e6a6",
|
||
"uvicon-lock-open": "e68d",
|
||
"uvicon-lock-opened-fill": "e6a1",
|
||
"uvicon-lock": "e69d",
|
||
"uvicon-red-packet": "e6c3",
|
||
"uvicon-photo-fill": "e6b4",
|
||
"uvicon-photo": "e60d",
|
||
"uvicon-volume-off-fill": "e6c8",
|
||
"uvicon-volume-off": "e6bd",
|
||
"uvicon-volume-fill": "e624",
|
||
"uvicon-volume": "e605",
|
||
"uvicon-download": "e670",
|
||
"uvicon-arrow-up-fill": "e636",
|
||
"uvicon-arrow-down-fill": "e638",
|
||
"uvicon-play-left-fill": "e6ae",
|
||
"uvicon-play-right-fill": "e6ad",
|
||
"uvicon-arrow-downward": "e634",
|
||
"uvicon-arrow-leftward": "e63b",
|
||
"uvicon-arrow-rightward": "e644",
|
||
"uvicon-arrow-upward": "e641",
|
||
"uvicon-arrow-down": "e63e",
|
||
"uvicon-arrow-right": "e63c",
|
||
"uvicon-arrow-left": "e646",
|
||
"uvicon-arrow-up": "e633",
|
||
"uvicon-skip-back-left": "e6c5",
|
||
"uvicon-skip-forward-right": "e61f",
|
||
"uvicon-arrow-left-double": "e637",
|
||
"uvicon-man": "e675",
|
||
"uvicon-woman": "e626",
|
||
"uvicon-en": "e6b8",
|
||
"uvicon-twitte": "e607",
|
||
"uvicon-twitter-circle-fill": "e6cf"
|
||
};
|
||
const props = {
|
||
props: {
|
||
// 图标类名
|
||
name: {
|
||
type: String,
|
||
default: ""
|
||
},
|
||
// 图标颜色,可接受主题色
|
||
color: {
|
||
type: String,
|
||
default: "#606266"
|
||
},
|
||
// 字体大小,单位px
|
||
size: {
|
||
type: [String, Number],
|
||
default: "16px"
|
||
},
|
||
// 是否显示粗体
|
||
bold: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
// 点击图标的时候传递事件出去的index(用于区分点击了哪一个)
|
||
index: {
|
||
type: [String, Number],
|
||
default: null
|
||
},
|
||
// 触摸图标时的类名
|
||
hoverClass: {
|
||
type: String,
|
||
default: ""
|
||
},
|
||
// 自定义扩展前缀,方便用户扩展自己的图标库
|
||
customPrefix: {
|
||
type: String,
|
||
default: "uvicon"
|
||
},
|
||
// 图标右边或者下面的文字
|
||
label: {
|
||
type: [String, Number],
|
||
default: ""
|
||
},
|
||
// label的位置,只能右边或者下边
|
||
labelPos: {
|
||
type: String,
|
||
default: "right"
|
||
},
|
||
// label的大小
|
||
labelSize: {
|
||
type: [String, Number],
|
||
default: "15px"
|
||
},
|
||
// label的颜色
|
||
labelColor: {
|
||
type: String,
|
||
default: "#606266"
|
||
},
|
||
// label与图标的距离
|
||
space: {
|
||
type: [String, Number],
|
||
default: "3px"
|
||
},
|
||
// 图片的mode
|
||
imgMode: {
|
||
type: String,
|
||
default: "aspectFit"
|
||
},
|
||
// 用于显示图片小图标时,图片的宽度
|
||
width: {
|
||
type: [String, Number],
|
||
default: ""
|
||
},
|
||
// 用于显示图片小图标时,图片的高度
|
||
height: {
|
||
type: [String, Number],
|
||
default: ""
|
||
},
|
||
// 用于解决某些情况下,让图标垂直居中的用途
|
||
top: {
|
||
type: [String, Number],
|
||
default: 0
|
||
},
|
||
// 是否阻止事件传播
|
||
stop: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
...(_f = (_e = uni.$uv) == null ? void 0 : _e.props) == null ? void 0 : _f.icon
|
||
}
|
||
};
|
||
const _export_sfc = (sfc, props2) => {
|
||
const target = sfc.__vccOpts || sfc;
|
||
for (const [key, val] of props2) {
|
||
target[key] = val;
|
||
}
|
||
return target;
|
||
};
|
||
const _sfc_main$2 = {
|
||
name: "uv-icon",
|
||
emits: ["click"],
|
||
mixins: [mpMixin, mixin, props],
|
||
data() {
|
||
return {
|
||
colorType: [
|
||
"primary",
|
||
"success",
|
||
"info",
|
||
"error",
|
||
"warning"
|
||
]
|
||
};
|
||
},
|
||
computed: {
|
||
uClasses() {
|
||
let classes = [];
|
||
classes.push(this.customPrefix);
|
||
classes.push(this.customPrefix + "-" + this.name);
|
||
if (this.color && this.colorType.includes(this.color))
|
||
classes.push("uv-icon__icon--" + this.color);
|
||
return classes;
|
||
},
|
||
iconStyle() {
|
||
let style = {};
|
||
style = {
|
||
fontSize: this.$uv.addUnit(this.size),
|
||
lineHeight: this.$uv.addUnit(this.size),
|
||
fontWeight: this.bold ? "bold" : "normal",
|
||
// 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
|
||
top: this.$uv.addUnit(this.top)
|
||
};
|
||
if (this.color && !this.colorType.includes(this.color))
|
||
style.color = this.color;
|
||
return style;
|
||
},
|
||
// 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
|
||
isImg() {
|
||
const isBase64 = this.name.indexOf("data:") > -1 && this.name.indexOf("base64") > -1;
|
||
return this.name.indexOf("/") !== -1 || isBase64;
|
||
},
|
||
imgStyle() {
|
||
let style = {};
|
||
style.width = this.width ? this.$uv.addUnit(this.width) : this.$uv.addUnit(this.size);
|
||
style.height = this.height ? this.$uv.addUnit(this.height) : this.$uv.addUnit(this.size);
|
||
return style;
|
||
},
|
||
// 通过图标名,查找对应的图标
|
||
icon() {
|
||
const code2 = icons["uvicon-" + this.name];
|
||
return code2 ? unescape(`%u${code2}`) : ["uvicon"].indexOf(this.customPrefix) > -1 ? this.name : "";
|
||
}
|
||
},
|
||
methods: {
|
||
clickHandler(e) {
|
||
this.$emit("click", this.index);
|
||
this.stop && this.preventEvent(e);
|
||
}
|
||
}
|
||
};
|
||
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
||
return vue.openBlock(), vue.createElementBlock(
|
||
"view",
|
||
{
|
||
class: vue.normalizeClass(["uv-icon", ["uv-icon--" + _ctx.labelPos]]),
|
||
onClick: _cache[0] || (_cache[0] = (...args) => $options.clickHandler && $options.clickHandler(...args))
|
||
},
|
||
[
|
||
$options.isImg ? (vue.openBlock(), vue.createElementBlock("image", {
|
||
key: 0,
|
||
class: "uv-icon__img",
|
||
src: _ctx.name,
|
||
mode: _ctx.imgMode,
|
||
style: vue.normalizeStyle([$options.imgStyle, _ctx.$uv.addStyle(_ctx.customStyle)])
|
||
}, null, 12, ["src", "mode"])) : (vue.openBlock(), vue.createElementBlock("text", {
|
||
key: 1,
|
||
class: vue.normalizeClass(["uv-icon__icon", $options.uClasses]),
|
||
style: vue.normalizeStyle([$options.iconStyle, _ctx.$uv.addStyle(_ctx.customStyle)]),
|
||
"hover-class": _ctx.hoverClass
|
||
}, vue.toDisplayString($options.icon), 15, ["hover-class"])),
|
||
vue.createCommentVNode(' 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 '),
|
||
_ctx.label !== "" ? (vue.openBlock(), vue.createElementBlock(
|
||
"text",
|
||
{
|
||
key: 2,
|
||
class: "uv-icon__label",
|
||
style: vue.normalizeStyle({
|
||
color: _ctx.labelColor,
|
||
fontSize: _ctx.$uv.addUnit(_ctx.labelSize),
|
||
marginLeft: _ctx.labelPos == "right" ? _ctx.$uv.addUnit(_ctx.space) : 0,
|
||
marginTop: _ctx.labelPos == "bottom" ? _ctx.$uv.addUnit(_ctx.space) : 0,
|
||
marginRight: _ctx.labelPos == "left" ? _ctx.$uv.addUnit(_ctx.space) : 0,
|
||
marginBottom: _ctx.labelPos == "top" ? _ctx.$uv.addUnit(_ctx.space) : 0
|
||
})
|
||
},
|
||
vue.toDisplayString(_ctx.label),
|
||
5
|
||
/* TEXT, STYLE */
|
||
)) : vue.createCommentVNode("v-if", true)
|
||
],
|
||
2
|
||
/* CLASS */
|
||
);
|
||
}
|
||
const __easycom_0 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__scopeId", "data-v-7cc7ad3f"], ["__file", "D:/frontDev/project/OfficeSystem/node_modules/@climblee/uv-ui/components/uv-icon/uv-icon.vue"]]);
|
||
const _imports_0 = "/static/logo.png";
|
||
const _sfc_main$1 = {
|
||
data() {
|
||
return {
|
||
title: "Hello UNI"
|
||
};
|
||
},
|
||
onLoad() {
|
||
formatAppLog("log", "at pages/index/index.vue:20", uni.$uv.os());
|
||
},
|
||
methods: {}
|
||
};
|
||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
const _component_uv_icon = resolveEasycom(vue.resolveDynamicComponent("uv-icon"), __easycom_0);
|
||
return vue.openBlock(), vue.createElementBlock("view", { class: "content" }, [
|
||
vue.createElementVNode("image", {
|
||
class: "logo",
|
||
src: _imports_0
|
||
}),
|
||
vue.createElementVNode("view", { class: "text-area" }, [
|
||
vue.createElementVNode(
|
||
"text",
|
||
{ class: "title" },
|
||
vue.toDisplayString($data.title),
|
||
1
|
||
/* TEXT */
|
||
)
|
||
]),
|
||
vue.createVNode(_component_uv_icon, {
|
||
name: "photo",
|
||
size: "30",
|
||
color: "#909399"
|
||
})
|
||
]);
|
||
}
|
||
const PagesIndexIndex = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/frontDev/project/OfficeSystem/pages/index/index.vue"]]);
|
||
__definePage("pages/index/index", PagesIndexIndex);
|
||
const _sfc_main = {
|
||
onLaunch: function() {
|
||
formatAppLog("log", "at App.vue:4", "App Launch");
|
||
},
|
||
onShow: function() {
|
||
formatAppLog("log", "at App.vue:7", "App Show");
|
||
},
|
||
onHide: function() {
|
||
formatAppLog("log", "at App.vue:10", "App Hide");
|
||
}
|
||
};
|
||
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/frontDev/project/OfficeSystem/App.vue"]]);
|
||
var toString = Object.prototype.toString;
|
||
function isArray(val) {
|
||
return toString.call(val) === "[object Array]";
|
||
}
|
||
function isObject(val) {
|
||
return val !== null && typeof val === "object";
|
||
}
|
||
function isDate(val) {
|
||
return toString.call(val) === "[object Date]";
|
||
}
|
||
function isURLSearchParams(val) {
|
||
return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
|
||
}
|
||
function forEach(obj, fn) {
|
||
if (obj === null || typeof obj === "undefined") {
|
||
return;
|
||
}
|
||
if (typeof obj !== "object") {
|
||
obj = [obj];
|
||
}
|
||
if (isArray(obj)) {
|
||
for (var i = 0, l = obj.length; i < l; i++) {
|
||
fn.call(null, obj[i], i, obj);
|
||
}
|
||
} else {
|
||
for (var key in obj) {
|
||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
fn.call(null, obj[key], key, obj);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function isPlainObject(obj) {
|
||
return Object.prototype.toString.call(obj) === "[object Object]";
|
||
}
|
||
function deepMerge() {
|
||
let result = {};
|
||
function assignValue(val, key) {
|
||
if (typeof result[key] === "object" && typeof val === "object") {
|
||
result[key] = deepMerge(result[key], val);
|
||
} else if (typeof val === "object") {
|
||
result[key] = deepMerge({}, val);
|
||
} else {
|
||
result[key] = val;
|
||
}
|
||
}
|
||
for (let i = 0, l = arguments.length; i < l; i++) {
|
||
forEach(arguments[i], assignValue);
|
||
}
|
||
return result;
|
||
}
|
||
function isUndefined(val) {
|
||
return typeof val === "undefined";
|
||
}
|
||
function encode(val) {
|
||
return encodeURIComponent(val).replace(/%40/gi, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
||
}
|
||
function buildURL(url2, params, paramsSerializer) {
|
||
if (!params) {
|
||
return url2;
|
||
}
|
||
var serializedParams;
|
||
if (paramsSerializer) {
|
||
serializedParams = paramsSerializer(params);
|
||
} else if (isURLSearchParams(params)) {
|
||
serializedParams = params.toString();
|
||
} else {
|
||
var parts = [];
|
||
forEach(params, function serialize(val, key) {
|
||
if (val === null || typeof val === "undefined") {
|
||
return;
|
||
}
|
||
if (isArray(val)) {
|
||
key = key + "[]";
|
||
} else {
|
||
val = [val];
|
||
}
|
||
forEach(val, function parseValue(v) {
|
||
if (isDate(v)) {
|
||
v = v.toISOString();
|
||
} else if (isObject(v)) {
|
||
v = JSON.stringify(v);
|
||
}
|
||
parts.push(encode(key) + "=" + encode(v));
|
||
});
|
||
});
|
||
serializedParams = parts.join("&");
|
||
}
|
||
if (serializedParams) {
|
||
var hashmarkIndex = url2.indexOf("#");
|
||
if (hashmarkIndex !== -1) {
|
||
url2 = url2.slice(0, hashmarkIndex);
|
||
}
|
||
url2 += (url2.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
||
}
|
||
return url2;
|
||
}
|
||
function isAbsoluteURL(url2) {
|
||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url2);
|
||
}
|
||
function combineURLs(baseURL, relativeURL) {
|
||
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
||
}
|
||
function buildFullPath(baseURL, requestedURL) {
|
||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||
return combineURLs(baseURL, requestedURL);
|
||
}
|
||
return requestedURL;
|
||
}
|
||
function settle(resolve, reject, response) {
|
||
const validateStatus = response.config.validateStatus;
|
||
const status = response.statusCode;
|
||
if (status && (!validateStatus || validateStatus(status))) {
|
||
resolve(response);
|
||
} else {
|
||
reject(response);
|
||
}
|
||
}
|
||
const mergeKeys$1 = (keys, config2) => {
|
||
let config3 = {};
|
||
keys.forEach((prop) => {
|
||
if (!isUndefined(config2[prop])) {
|
||
config3[prop] = config2[prop];
|
||
}
|
||
});
|
||
return config3;
|
||
};
|
||
const adapter = (config2) => {
|
||
return new Promise((resolve, reject) => {
|
||
let fullPath = buildURL(buildFullPath(config2.baseURL, config2.url), config2.params, config2.paramsSerializer);
|
||
const _config = {
|
||
url: fullPath,
|
||
header: config2.header,
|
||
complete: (response) => {
|
||
config2.fullPath = fullPath;
|
||
response.config = config2;
|
||
response.rawData = response.data;
|
||
try {
|
||
let jsonParseHandle = false;
|
||
const forcedJSONParsingType = typeof config2.forcedJSONParsing;
|
||
if (forcedJSONParsingType === "boolean") {
|
||
jsonParseHandle = config2.forcedJSONParsing;
|
||
} else if (forcedJSONParsingType === "object") {
|
||
const includesMethod = config2.forcedJSONParsing.include || [];
|
||
jsonParseHandle = includesMethod.includes(config2.method);
|
||
}
|
||
if (jsonParseHandle && typeof response.data === "string") {
|
||
response.data = JSON.parse(response.data);
|
||
}
|
||
} catch (e) {
|
||
}
|
||
settle(resolve, reject, response);
|
||
}
|
||
};
|
||
let requestTask;
|
||
if (config2.method === "UPLOAD") {
|
||
delete _config.header["content-type"];
|
||
delete _config.header["Content-Type"];
|
||
let otherConfig = {
|
||
filePath: config2.filePath,
|
||
name: config2.name
|
||
};
|
||
const optionalKeys = [
|
||
"files",
|
||
"timeout",
|
||
"formData"
|
||
];
|
||
requestTask = uni.uploadFile({ ..._config, ...otherConfig, ...mergeKeys$1(optionalKeys, config2) });
|
||
} else if (config2.method === "DOWNLOAD") {
|
||
const optionalKeys = [
|
||
"timeout"
|
||
];
|
||
requestTask = uni.downloadFile({ ..._config, ...mergeKeys$1(optionalKeys, config2) });
|
||
} else {
|
||
const optionalKeys = [
|
||
"data",
|
||
"method",
|
||
"timeout",
|
||
"dataType",
|
||
"responseType",
|
||
"sslVerify",
|
||
"firstIpv4"
|
||
];
|
||
requestTask = uni.request({ ..._config, ...mergeKeys$1(optionalKeys, config2) });
|
||
}
|
||
if (config2.getTask) {
|
||
config2.getTask(requestTask, config2);
|
||
}
|
||
});
|
||
};
|
||
const dispatchRequest = (config2) => {
|
||
return adapter(config2);
|
||
};
|
||
function InterceptorManager() {
|
||
this.handlers = [];
|
||
}
|
||
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
||
this.handlers.push({
|
||
fulfilled,
|
||
rejected
|
||
});
|
||
return this.handlers.length - 1;
|
||
};
|
||
InterceptorManager.prototype.eject = function eject(id) {
|
||
if (this.handlers[id]) {
|
||
this.handlers[id] = null;
|
||
}
|
||
};
|
||
InterceptorManager.prototype.forEach = function forEach2(fn) {
|
||
this.handlers.forEach((h) => {
|
||
if (h !== null) {
|
||
fn(h);
|
||
}
|
||
});
|
||
};
|
||
const mergeKeys = (keys, globalsConfig, config2) => {
|
||
let config3 = {};
|
||
keys.forEach((prop) => {
|
||
if (!isUndefined(config2[prop])) {
|
||
config3[prop] = config2[prop];
|
||
} else if (!isUndefined(globalsConfig[prop])) {
|
||
config3[prop] = globalsConfig[prop];
|
||
}
|
||
});
|
||
return config3;
|
||
};
|
||
const mergeConfig = (globalsConfig, config2 = {}) => {
|
||
const method = config2.method || globalsConfig.method || "GET";
|
||
let config3 = {
|
||
baseURL: config2.baseURL || globalsConfig.baseURL || "",
|
||
method,
|
||
url: config2.url || "",
|
||
params: config2.params || {},
|
||
custom: { ...globalsConfig.custom || {}, ...config2.custom || {} },
|
||
header: deepMerge(globalsConfig.header || {}, config2.header || {})
|
||
};
|
||
const defaultToConfig2Keys = ["getTask", "validateStatus", "paramsSerializer", "forcedJSONParsing"];
|
||
config3 = { ...config3, ...mergeKeys(defaultToConfig2Keys, globalsConfig, config2) };
|
||
if (method === "DOWNLOAD") {
|
||
const downloadKeys = [
|
||
"timeout"
|
||
];
|
||
config3 = { ...config3, ...mergeKeys(downloadKeys, globalsConfig, config2) };
|
||
} else if (method === "UPLOAD") {
|
||
delete config3.header["content-type"];
|
||
delete config3.header["Content-Type"];
|
||
const uploadKeys = [
|
||
"files",
|
||
"filePath",
|
||
"name",
|
||
"timeout",
|
||
"formData"
|
||
];
|
||
uploadKeys.forEach((prop) => {
|
||
if (!isUndefined(config2[prop])) {
|
||
config3[prop] = config2[prop];
|
||
}
|
||
});
|
||
if (isUndefined(config3.timeout) && !isUndefined(globalsConfig.timeout)) {
|
||
config3["timeout"] = globalsConfig["timeout"];
|
||
}
|
||
} else {
|
||
const defaultsKeys = [
|
||
"data",
|
||
"timeout",
|
||
"dataType",
|
||
"responseType",
|
||
"sslVerify",
|
||
"firstIpv4"
|
||
];
|
||
config3 = { ...config3, ...mergeKeys(defaultsKeys, globalsConfig, config2) };
|
||
}
|
||
return config3;
|
||
};
|
||
const defaults = {
|
||
baseURL: "",
|
||
header: {},
|
||
method: "GET",
|
||
dataType: "json",
|
||
paramsSerializer: null,
|
||
responseType: "text",
|
||
custom: {},
|
||
timeout: 6e4,
|
||
sslVerify: true,
|
||
firstIpv4: false,
|
||
validateStatus: function validateStatus(status) {
|
||
return status >= 200 && status < 300;
|
||
},
|
||
// 是否尝试将响应数据json化
|
||
forcedJSONParsing: true
|
||
};
|
||
var clone = function() {
|
||
function _instanceof(obj, type) {
|
||
return type != null && obj instanceof type;
|
||
}
|
||
var nativeMap;
|
||
try {
|
||
nativeMap = Map;
|
||
} catch (_) {
|
||
nativeMap = function() {
|
||
};
|
||
}
|
||
var nativeSet;
|
||
try {
|
||
nativeSet = Set;
|
||
} catch (_) {
|
||
nativeSet = function() {
|
||
};
|
||
}
|
||
var nativePromise;
|
||
try {
|
||
nativePromise = Promise;
|
||
} catch (_) {
|
||
nativePromise = function() {
|
||
};
|
||
}
|
||
function clone2(parent, circular, depth, prototype, includeNonEnumerable) {
|
||
if (typeof circular === "object") {
|
||
depth = circular.depth;
|
||
prototype = circular.prototype;
|
||
includeNonEnumerable = circular.includeNonEnumerable;
|
||
circular = circular.circular;
|
||
}
|
||
var allParents = [];
|
||
var allChildren = [];
|
||
var useBuffer = typeof Buffer != "undefined";
|
||
if (typeof circular == "undefined")
|
||
circular = true;
|
||
if (typeof depth == "undefined")
|
||
depth = Infinity;
|
||
function _clone(parent2, depth2) {
|
||
if (parent2 === null)
|
||
return null;
|
||
if (depth2 === 0)
|
||
return parent2;
|
||
var child;
|
||
var proto;
|
||
if (typeof parent2 != "object") {
|
||
return parent2;
|
||
}
|
||
if (_instanceof(parent2, nativeMap)) {
|
||
child = new nativeMap();
|
||
} else if (_instanceof(parent2, nativeSet)) {
|
||
child = new nativeSet();
|
||
} else if (_instanceof(parent2, nativePromise)) {
|
||
child = new nativePromise(function(resolve, reject) {
|
||
parent2.then(function(value) {
|
||
resolve(_clone(value, depth2 - 1));
|
||
}, function(err) {
|
||
reject(_clone(err, depth2 - 1));
|
||
});
|
||
});
|
||
} else if (clone2.__isArray(parent2)) {
|
||
child = [];
|
||
} else if (clone2.__isRegExp(parent2)) {
|
||
child = new RegExp(parent2.source, __getRegExpFlags(parent2));
|
||
if (parent2.lastIndex)
|
||
child.lastIndex = parent2.lastIndex;
|
||
} else if (clone2.__isDate(parent2)) {
|
||
child = new Date(parent2.getTime());
|
||
} else if (useBuffer && Buffer.isBuffer(parent2)) {
|
||
if (Buffer.from) {
|
||
child = Buffer.from(parent2);
|
||
} else {
|
||
child = new Buffer(parent2.length);
|
||
parent2.copy(child);
|
||
}
|
||
return child;
|
||
} else if (_instanceof(parent2, Error)) {
|
||
child = Object.create(parent2);
|
||
} else {
|
||
if (typeof prototype == "undefined") {
|
||
proto = Object.getPrototypeOf(parent2);
|
||
child = Object.create(proto);
|
||
} else {
|
||
child = Object.create(prototype);
|
||
proto = prototype;
|
||
}
|
||
}
|
||
if (circular) {
|
||
var index2 = allParents.indexOf(parent2);
|
||
if (index2 != -1) {
|
||
return allChildren[index2];
|
||
}
|
||
allParents.push(parent2);
|
||
allChildren.push(child);
|
||
}
|
||
if (_instanceof(parent2, nativeMap)) {
|
||
parent2.forEach(function(value, key) {
|
||
var keyChild = _clone(key, depth2 - 1);
|
||
var valueChild = _clone(value, depth2 - 1);
|
||
child.set(keyChild, valueChild);
|
||
});
|
||
}
|
||
if (_instanceof(parent2, nativeSet)) {
|
||
parent2.forEach(function(value) {
|
||
var entryChild = _clone(value, depth2 - 1);
|
||
child.add(entryChild);
|
||
});
|
||
}
|
||
for (var i in parent2) {
|
||
var attrs = Object.getOwnPropertyDescriptor(parent2, i);
|
||
if (attrs) {
|
||
child[i] = _clone(parent2[i], depth2 - 1);
|
||
}
|
||
try {
|
||
var objProperty = Object.getOwnPropertyDescriptor(parent2, i);
|
||
if (objProperty.set === "undefined") {
|
||
continue;
|
||
}
|
||
child[i] = _clone(parent2[i], depth2 - 1);
|
||
} catch (e) {
|
||
if (e instanceof TypeError) {
|
||
continue;
|
||
} else if (e instanceof ReferenceError) {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
if (Object.getOwnPropertySymbols) {
|
||
var symbols = Object.getOwnPropertySymbols(parent2);
|
||
for (var i = 0; i < symbols.length; i++) {
|
||
var symbol = symbols[i];
|
||
var descriptor = Object.getOwnPropertyDescriptor(parent2, symbol);
|
||
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
|
||
continue;
|
||
}
|
||
child[symbol] = _clone(parent2[symbol], depth2 - 1);
|
||
Object.defineProperty(child, symbol, descriptor);
|
||
}
|
||
}
|
||
if (includeNonEnumerable) {
|
||
var allPropertyNames = Object.getOwnPropertyNames(parent2);
|
||
for (var i = 0; i < allPropertyNames.length; i++) {
|
||
var propertyName = allPropertyNames[i];
|
||
var descriptor = Object.getOwnPropertyDescriptor(parent2, propertyName);
|
||
if (descriptor && descriptor.enumerable) {
|
||
continue;
|
||
}
|
||
child[propertyName] = _clone(parent2[propertyName], depth2 - 1);
|
||
Object.defineProperty(child, propertyName, descriptor);
|
||
}
|
||
}
|
||
return child;
|
||
}
|
||
return _clone(parent, depth);
|
||
}
|
||
clone2.clonePrototype = function clonePrototype(parent) {
|
||
if (parent === null)
|
||
return null;
|
||
var c = function() {
|
||
};
|
||
c.prototype = parent;
|
||
return new c();
|
||
};
|
||
function __objToStr(o) {
|
||
return Object.prototype.toString.call(o);
|
||
}
|
||
clone2.__objToStr = __objToStr;
|
||
function __isDate(o) {
|
||
return typeof o === "object" && __objToStr(o) === "[object Date]";
|
||
}
|
||
clone2.__isDate = __isDate;
|
||
function __isArray(o) {
|
||
return typeof o === "object" && __objToStr(o) === "[object Array]";
|
||
}
|
||
clone2.__isArray = __isArray;
|
||
function __isRegExp(o) {
|
||
return typeof o === "object" && __objToStr(o) === "[object RegExp]";
|
||
}
|
||
clone2.__isRegExp = __isRegExp;
|
||
function __getRegExpFlags(re) {
|
||
var flags = "";
|
||
if (re.global)
|
||
flags += "g";
|
||
if (re.ignoreCase)
|
||
flags += "i";
|
||
if (re.multiline)
|
||
flags += "m";
|
||
return flags;
|
||
}
|
||
clone2.__getRegExpFlags = __getRegExpFlags;
|
||
return clone2;
|
||
}();
|
||
class Request {
|
||
/**
|
||
* @param {Object} arg - 全局配置
|
||
* @param {String} arg.baseURL - 全局根路径
|
||
* @param {Object} arg.header - 全局header
|
||
* @param {String} arg.method = [GET|POST|PUT|DELETE|CONNECT|HEAD|OPTIONS|TRACE] - 全局默认请求方式
|
||
* @param {String} arg.dataType = [json] - 全局默认的dataType
|
||
* @param {String} arg.responseType = [text|arraybuffer] - 全局默认的responseType。支付宝小程序不支持
|
||
* @param {Object} arg.custom - 全局默认的自定义参数
|
||
* @param {Number} arg.timeout - 全局默认的超时时间,单位 ms。默认60000。H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)、微信小程序(2.10.0)、支付宝小程序
|
||
* @param {Boolean} arg.sslVerify - 全局默认的是否验证 ssl 证书。默认true.仅App安卓端支持(HBuilderX 2.3.3+)
|
||
* @param {Boolean} arg.withCredentials - 全局默认的跨域请求时是否携带凭证(cookies)。默认false。仅H5支持(HBuilderX 2.6.15+)
|
||
* @param {Boolean} arg.firstIpv4 - 全DNS解析时优先使用ipv4。默认false。仅 App-Android 支持 (HBuilderX 2.8.0+)
|
||
* @param {Function(statusCode):Boolean} arg.validateStatus - 全局默认的自定义验证器。默认statusCode >= 200 && statusCode < 300
|
||
*/
|
||
constructor(arg = {}) {
|
||
if (!isPlainObject(arg)) {
|
||
arg = {};
|
||
formatAppLog("warn", "at node_modules/@climblee/uv-ui/libs/luch-request/core/Request.js:37", "设置全局参数必须接收一个Object");
|
||
}
|
||
this.config = clone({ ...defaults, ...arg });
|
||
this.interceptors = {
|
||
request: new InterceptorManager(),
|
||
response: new InterceptorManager()
|
||
};
|
||
}
|
||
/**
|
||
* @Function
|
||
* @param {Request~setConfigCallback} f - 设置全局默认配置
|
||
*/
|
||
setConfig(f) {
|
||
this.config = f(this.config);
|
||
}
|
||
middleware(config2) {
|
||
config2 = mergeConfig(this.config, config2);
|
||
let chain = [dispatchRequest, void 0];
|
||
let promise2 = Promise.resolve(config2);
|
||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
||
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||
});
|
||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
||
chain.push(interceptor.fulfilled, interceptor.rejected);
|
||
});
|
||
while (chain.length) {
|
||
promise2 = promise2.then(chain.shift(), chain.shift());
|
||
}
|
||
return promise2;
|
||
}
|
||
/**
|
||
* @Function
|
||
* @param {Object} config - 请求配置项
|
||
* @prop {String} options.url - 请求路径
|
||
* @prop {Object} options.data - 请求参数
|
||
* @prop {Object} [options.responseType = config.responseType] [text|arraybuffer] - 响应的数据类型
|
||
* @prop {Object} [options.dataType = config.dataType] - 如果设为 json,会尝试对返回的数据做一次 JSON.parse
|
||
* @prop {Object} [options.header = config.header] - 请求header
|
||
* @prop {Object} [options.method = config.method] - 请求方法
|
||
* @returns {Promise<unknown>}
|
||
*/
|
||
request(config2 = {}) {
|
||
return this.middleware(config2);
|
||
}
|
||
get(url2, options = {}) {
|
||
return this.middleware({
|
||
url: url2,
|
||
method: "GET",
|
||
...options
|
||
});
|
||
}
|
||
post(url2, data, options = {}) {
|
||
return this.middleware({
|
||
url: url2,
|
||
data,
|
||
method: "POST",
|
||
...options
|
||
});
|
||
}
|
||
put(url2, data, options = {}) {
|
||
return this.middleware({
|
||
url: url2,
|
||
data,
|
||
method: "PUT",
|
||
...options
|
||
});
|
||
}
|
||
delete(url2, data, options = {}) {
|
||
return this.middleware({
|
||
url: url2,
|
||
data,
|
||
method: "DELETE",
|
||
...options
|
||
});
|
||
}
|
||
options(url2, data, options = {}) {
|
||
return this.middleware({
|
||
url: url2,
|
||
data,
|
||
method: "OPTIONS",
|
||
...options
|
||
});
|
||
}
|
||
upload(url2, config2 = {}) {
|
||
config2.url = url2;
|
||
config2.method = "UPLOAD";
|
||
return this.middleware(config2);
|
||
}
|
||
download(url2, config2 = {}) {
|
||
config2.url = url2;
|
||
config2.method = "DOWNLOAD";
|
||
return this.middleware(config2);
|
||
}
|
||
get version() {
|
||
return "3.1.0";
|
||
}
|
||
}
|
||
function colorGradient(startColor = "rgb(0, 0, 0)", endColor = "rgb(255, 255, 255)", step = 10) {
|
||
const startRGB = hexToRgb(startColor, false);
|
||
const startR = startRGB[0];
|
||
const startG = startRGB[1];
|
||
const startB = startRGB[2];
|
||
const endRGB = hexToRgb(endColor, false);
|
||
const endR = endRGB[0];
|
||
const endG = endRGB[1];
|
||
const endB = endRGB[2];
|
||
const sR = (endR - startR) / step;
|
||
const sG = (endG - startG) / step;
|
||
const sB = (endB - startB) / step;
|
||
const colorArr = [];
|
||
for (let i = 0; i < step; i++) {
|
||
let hex = rgbToHex(`rgb(${Math.round(sR * i + startR)},${Math.round(sG * i + startG)},${Math.round(sB * i + startB)})`);
|
||
if (i === 0)
|
||
hex = rgbToHex(startColor);
|
||
if (i === step - 1)
|
||
hex = rgbToHex(endColor);
|
||
colorArr.push(hex);
|
||
}
|
||
return colorArr;
|
||
}
|
||
function hexToRgb(sColor, str = true) {
|
||
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
||
sColor = String(sColor).toLowerCase();
|
||
if (sColor && reg.test(sColor)) {
|
||
if (sColor.length === 4) {
|
||
let sColorNew = "#";
|
||
for (let i = 1; i < 4; i += 1) {
|
||
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
|
||
}
|
||
sColor = sColorNew;
|
||
}
|
||
const sColorChange = [];
|
||
for (let i = 1; i < 7; i += 2) {
|
||
sColorChange.push(parseInt(`0x${sColor.slice(i, i + 2)}`));
|
||
}
|
||
if (!str) {
|
||
return sColorChange;
|
||
}
|
||
return `rgb(${sColorChange[0]},${sColorChange[1]},${sColorChange[2]})`;
|
||
}
|
||
if (/^(rgb|RGB)/.test(sColor)) {
|
||
const arr = sColor.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
|
||
return arr.map((val) => Number(val));
|
||
}
|
||
return sColor;
|
||
}
|
||
function rgbToHex(rgb) {
|
||
const _this = rgb;
|
||
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
||
if (/^(rgb|RGB)/.test(_this)) {
|
||
const aColor = _this.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
|
||
let strHex = "#";
|
||
for (let i = 0; i < aColor.length; i++) {
|
||
let hex = Number(aColor[i]).toString(16);
|
||
hex = String(hex).length == 1 ? `${0}${hex}` : hex;
|
||
if (hex === "0") {
|
||
hex += hex;
|
||
}
|
||
strHex += hex;
|
||
}
|
||
if (strHex.length !== 7) {
|
||
strHex = _this;
|
||
}
|
||
return strHex;
|
||
}
|
||
if (reg.test(_this)) {
|
||
const aNum = _this.replace(/#/, "").split("");
|
||
if (aNum.length === 6) {
|
||
return _this;
|
||
}
|
||
if (aNum.length === 3) {
|
||
let numHex = "#";
|
||
for (let i = 0; i < aNum.length; i += 1) {
|
||
numHex += aNum[i] + aNum[i];
|
||
}
|
||
return numHex;
|
||
}
|
||
} else {
|
||
return _this;
|
||
}
|
||
}
|
||
function colorToRgba(color, alpha) {
|
||
color = rgbToHex(color);
|
||
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
||
let sColor = String(color).toLowerCase();
|
||
if (sColor && reg.test(sColor)) {
|
||
if (sColor.length === 4) {
|
||
let sColorNew = "#";
|
||
for (let i = 1; i < 4; i += 1) {
|
||
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
|
||
}
|
||
sColor = sColorNew;
|
||
}
|
||
const sColorChange = [];
|
||
for (let i = 1; i < 7; i += 2) {
|
||
sColorChange.push(parseInt(`0x${sColor.slice(i, i + 2)}`));
|
||
}
|
||
return `rgba(${sColorChange.join(",")},${alpha})`;
|
||
}
|
||
return sColor;
|
||
}
|
||
const version = "1.1.20";
|
||
{
|
||
formatAppLog("log", "at node_modules/@climblee/uv-ui/libs/config/config.js:6", `
|
||
%c uvui V${version} https://www.uvui.cn/
|
||
|
||
`, "color: #ffffff; background: #3c9cff; padding:5px 0; border-radius: 5px;");
|
||
}
|
||
const config = {
|
||
v: version,
|
||
version,
|
||
// 主题名称
|
||
type: [
|
||
"primary",
|
||
"success",
|
||
"info",
|
||
"error",
|
||
"warning"
|
||
],
|
||
// 颜色部分,本来可以通过scss的:export导出供js使用,但是奈何nvue不支持
|
||
color: {
|
||
"uv-primary": "#2979ff",
|
||
"uv-warning": "#ff9900",
|
||
"uv-success": "#19be6b",
|
||
"uv-error": "#fa3534",
|
||
"uv-info": "#909399",
|
||
"uv-main-color": "#303133",
|
||
"uv-content-color": "#606266",
|
||
"uv-tips-color": "#909399",
|
||
"uv-light-color": "#c0c4cc"
|
||
},
|
||
// 默认单位,可以通过配置为rpx,那么在用于传入组件大小参数为数值时,就默认为rpx
|
||
unit: "px"
|
||
};
|
||
let platform = "none";
|
||
platform = "vue3";
|
||
platform = "plus";
|
||
const platform$1 = platform;
|
||
const $uv = {
|
||
route,
|
||
config,
|
||
test,
|
||
date: timeFormat,
|
||
// 另名date
|
||
...index,
|
||
colorGradient,
|
||
hexToRgb,
|
||
rgbToHex,
|
||
colorToRgba,
|
||
http: new Request(),
|
||
debounce,
|
||
throttle,
|
||
platform: platform$1,
|
||
mixin,
|
||
mpMixin
|
||
};
|
||
uni.$uv = $uv;
|
||
const install = (Vue2, options = {}) => {
|
||
var _a, _b;
|
||
const cloneMixin = deepClone(mixin);
|
||
(_a = cloneMixin == null ? void 0 : cloneMixin.props) == null ? true : delete _a.customClass;
|
||
(_b = cloneMixin == null ? void 0 : cloneMixin.props) == null ? true : delete _b.customStyle;
|
||
Vue2.mixin(cloneMixin);
|
||
Vue2.config.globalProperties.$uv = $uv;
|
||
};
|
||
const uvUI = {
|
||
install
|
||
};
|
||
function createApp() {
|
||
const app = vue.createVueApp(App);
|
||
app.use(uvUI);
|
||
return {
|
||
app
|
||
};
|
||
}
|
||
const { app: __app__, Vuex: __Vuex__, Pinia: __Pinia__ } = createApp();
|
||
uni.Vuex = __Vuex__;
|
||
uni.Pinia = __Pinia__;
|
||
__app__.provide("__globalStyles", __uniConfig.styles);
|
||
__app__._component.mpType = "app";
|
||
__app__._component.render = () => {
|
||
};
|
||
__app__.mount("#app");
|
||
})(Vue);
|