已支付订单列表:where.payStatus = 1;
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
const version = "1.1.20";
|
||||
{
|
||||
console.log(`
|
||||
%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"
|
||||
};
|
||||
exports.config = config;
|
||||
@@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
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;
|
||||
}
|
||||
exports.colorGradient = colorGradient;
|
||||
exports.colorToRgba = colorToRgba;
|
||||
exports.hexToRgb = hexToRgb;
|
||||
exports.rgbToHex = rgbToHex;
|
||||
@@ -0,0 +1,17 @@
|
||||
"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;
|
||||
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
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) {
|
||||
console.warn(`${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;
|
||||
@@ -0,0 +1,492 @@
|
||||
"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) {
|
||||
{
|
||||
console.error(`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.deepClone = deepClone;
|
||||
exports.deepMerge = deepMerge;
|
||||
exports.error = error;
|
||||
exports.guid = guid;
|
||||
exports.index = index;
|
||||
exports.page = page;
|
||||
exports.priceFormat = priceFormat;
|
||||
exports.queryParams = queryParams;
|
||||
exports.timeFormat = timeFormat;
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
let platform = "none";
|
||||
platform = "vue3";
|
||||
platform = "weixin";
|
||||
platform = "mp";
|
||||
const platform$1 = platform;
|
||||
exports.platform = platform$1;
|
||||
@@ -0,0 +1,175 @@
|
||||
"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.date = date;
|
||||
exports.empty = empty;
|
||||
exports.func = func;
|
||||
exports.number = number;
|
||||
exports.range = range;
|
||||
exports.test = test;
|
||||
exports.url = url;
|
||||
@@ -0,0 +1,20 @@
|
||||
"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;
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../../common/vendor.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_helpers_buildURL = require("../helpers/buildURL.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_buildFullPath = require("../core/buildFullPath.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_settle = require("../core/settle.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_utils = require("../utils.js");
|
||||
const mergeKeys = (keys, config2) => {
|
||||
let config = {};
|
||||
keys.forEach((prop) => {
|
||||
if (!uni_modules_uvUiTools_libs_luchRequest_utils.isUndefined(config2[prop])) {
|
||||
config[prop] = config2[prop];
|
||||
}
|
||||
});
|
||||
return config;
|
||||
};
|
||||
const adapter = (config) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let fullPath = uni_modules_uvUiTools_libs_luchRequest_helpers_buildURL.buildURL(uni_modules_uvUiTools_libs_luchRequest_core_buildFullPath.buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer);
|
||||
const _config = {
|
||||
url: fullPath,
|
||||
header: config.header,
|
||||
complete: (response) => {
|
||||
config.fullPath = fullPath;
|
||||
response.config = config;
|
||||
response.rawData = response.data;
|
||||
try {
|
||||
let jsonParseHandle = false;
|
||||
const forcedJSONParsingType = typeof config.forcedJSONParsing;
|
||||
if (forcedJSONParsingType === "boolean") {
|
||||
jsonParseHandle = config.forcedJSONParsing;
|
||||
} else if (forcedJSONParsingType === "object") {
|
||||
const includesMethod = config.forcedJSONParsing.include || [];
|
||||
jsonParseHandle = includesMethod.includes(config.method);
|
||||
}
|
||||
if (jsonParseHandle && typeof response.data === "string") {
|
||||
response.data = JSON.parse(response.data);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
uni_modules_uvUiTools_libs_luchRequest_core_settle.settle(resolve, reject, response);
|
||||
}
|
||||
};
|
||||
let requestTask;
|
||||
if (config.method === "UPLOAD") {
|
||||
delete _config.header["content-type"];
|
||||
delete _config.header["Content-Type"];
|
||||
let otherConfig = {
|
||||
filePath: config.filePath,
|
||||
name: config.name
|
||||
};
|
||||
const optionalKeys = [
|
||||
"timeout",
|
||||
"formData"
|
||||
];
|
||||
requestTask = common_vendor.index.uploadFile({ ..._config, ...otherConfig, ...mergeKeys(optionalKeys, config) });
|
||||
} else if (config.method === "DOWNLOAD") {
|
||||
const optionalKeys = [
|
||||
"timeout",
|
||||
"filePath"
|
||||
];
|
||||
requestTask = common_vendor.index.downloadFile({ ..._config, ...mergeKeys(optionalKeys, config) });
|
||||
} else {
|
||||
const optionalKeys = [
|
||||
"data",
|
||||
"method",
|
||||
"timeout",
|
||||
"dataType",
|
||||
"responseType",
|
||||
"enableHttp2",
|
||||
"enableQuic",
|
||||
"enableCache",
|
||||
"enableHttpDNS",
|
||||
"httpDNSServiceId",
|
||||
"enableChunked",
|
||||
"forceCellularNetwork"
|
||||
];
|
||||
requestTask = common_vendor.index.request({ ..._config, ...mergeKeys(optionalKeys, config) });
|
||||
}
|
||||
if (config.getTask) {
|
||||
config.getTask(requestTask, config);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.adapter = adapter;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
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 forEach(fn) {
|
||||
this.handlers.forEach((h) => {
|
||||
if (h !== null) {
|
||||
fn(h);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.InterceptorManager = InterceptorManager;
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
"use strict";
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_dispatchRequest = require("./dispatchRequest.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_InterceptorManager = require("./InterceptorManager.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_mergeConfig = require("./mergeConfig.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_defaults = require("./defaults.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_utils = require("../utils.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_utils_clone = require("../utils/clone.js");
|
||||
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 (!uni_modules_uvUiTools_libs_luchRequest_utils.isPlainObject(arg)) {
|
||||
arg = {};
|
||||
console.warn("设置全局参数必须接收一个Object");
|
||||
}
|
||||
this.config = uni_modules_uvUiTools_libs_luchRequest_utils_clone.clone({ ...uni_modules_uvUiTools_libs_luchRequest_core_defaults.defaults, ...arg });
|
||||
this.interceptors = {
|
||||
request: new uni_modules_uvUiTools_libs_luchRequest_core_InterceptorManager.InterceptorManager(),
|
||||
response: new uni_modules_uvUiTools_libs_luchRequest_core_InterceptorManager.InterceptorManager()
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @Function
|
||||
* @param {Request~setConfigCallback} f - 设置全局默认配置
|
||||
*/
|
||||
setConfig(f) {
|
||||
this.config = f(this.config);
|
||||
}
|
||||
middleware(config) {
|
||||
config = uni_modules_uvUiTools_libs_luchRequest_core_mergeConfig.mergeConfig(this.config, config);
|
||||
let chain = [uni_modules_uvUiTools_libs_luchRequest_core_dispatchRequest.dispatchRequest, void 0];
|
||||
let promise = Promise.resolve(config);
|
||||
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) {
|
||||
promise = promise.then(chain.shift(), chain.shift());
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
/**
|
||||
* @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(config = {}) {
|
||||
return this.middleware(config);
|
||||
}
|
||||
get(url, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
method: "GET",
|
||||
...options
|
||||
});
|
||||
}
|
||||
post(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "POST",
|
||||
...options
|
||||
});
|
||||
}
|
||||
put(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "PUT",
|
||||
...options
|
||||
});
|
||||
}
|
||||
delete(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "DELETE",
|
||||
...options
|
||||
});
|
||||
}
|
||||
connect(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "CONNECT",
|
||||
...options
|
||||
});
|
||||
}
|
||||
head(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "HEAD",
|
||||
...options
|
||||
});
|
||||
}
|
||||
options(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "OPTIONS",
|
||||
...options
|
||||
});
|
||||
}
|
||||
trace(url, data, options = {}) {
|
||||
return this.middleware({
|
||||
url,
|
||||
data,
|
||||
method: "TRACE",
|
||||
...options
|
||||
});
|
||||
}
|
||||
upload(url, config = {}) {
|
||||
config.url = url;
|
||||
config.method = "UPLOAD";
|
||||
return this.middleware(config);
|
||||
}
|
||||
download(url, config = {}) {
|
||||
config.url = url;
|
||||
config.method = "DOWNLOAD";
|
||||
return this.middleware(config);
|
||||
}
|
||||
get version() {
|
||||
return "3.1.0";
|
||||
}
|
||||
}
|
||||
exports.Request = Request;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
const uni_modules_uvUiTools_libs_luchRequest_helpers_isAbsoluteURL = require("../helpers/isAbsoluteURL.js");
|
||||
const uni_modules_uvUiTools_libs_luchRequest_helpers_combineURLs = require("../helpers/combineURLs.js");
|
||||
function buildFullPath(baseURL, requestedURL) {
|
||||
if (baseURL && !uni_modules_uvUiTools_libs_luchRequest_helpers_isAbsoluteURL.isAbsoluteURL(requestedURL)) {
|
||||
return uni_modules_uvUiTools_libs_luchRequest_helpers_combineURLs.combineURLs(baseURL, requestedURL);
|
||||
}
|
||||
return requestedURL;
|
||||
}
|
||||
exports.buildFullPath = buildFullPath;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
const defaults = {
|
||||
baseURL: "",
|
||||
header: {},
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
paramsSerializer: null,
|
||||
responseType: "text",
|
||||
custom: {},
|
||||
timeout: 6e4,
|
||||
validateStatus: function validateStatus(status) {
|
||||
return status >= 200 && status < 300;
|
||||
},
|
||||
// 是否尝试将响应数据json化
|
||||
forcedJSONParsing: true
|
||||
};
|
||||
exports.defaults = defaults;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
const uni_modules_uvUiTools_libs_luchRequest_adapters_index = require("../adapters/index.js");
|
||||
const dispatchRequest = (config) => {
|
||||
return uni_modules_uvUiTools_libs_luchRequest_adapters_index.adapter(config);
|
||||
};
|
||||
exports.dispatchRequest = dispatchRequest;
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
const uni_modules_uvUiTools_libs_luchRequest_utils = require("../utils.js");
|
||||
const mergeKeys = (keys, globalsConfig, config2) => {
|
||||
let config = {};
|
||||
keys.forEach((prop) => {
|
||||
if (!uni_modules_uvUiTools_libs_luchRequest_utils.isUndefined(config2[prop])) {
|
||||
config[prop] = config2[prop];
|
||||
} else if (!uni_modules_uvUiTools_libs_luchRequest_utils.isUndefined(globalsConfig[prop])) {
|
||||
config[prop] = globalsConfig[prop];
|
||||
}
|
||||
});
|
||||
return config;
|
||||
};
|
||||
const mergeConfig = (globalsConfig, config2 = {}) => {
|
||||
const method = config2.method || globalsConfig.method || "GET";
|
||||
let config = {
|
||||
baseURL: config2.baseURL || globalsConfig.baseURL || "",
|
||||
method,
|
||||
url: config2.url || "",
|
||||
params: config2.params || {},
|
||||
custom: { ...globalsConfig.custom || {}, ...config2.custom || {} },
|
||||
header: uni_modules_uvUiTools_libs_luchRequest_utils.deepMerge(globalsConfig.header || {}, config2.header || {})
|
||||
};
|
||||
const defaultToConfig2Keys = ["getTask", "validateStatus", "paramsSerializer", "forcedJSONParsing"];
|
||||
config = { ...config, ...mergeKeys(defaultToConfig2Keys, globalsConfig, config2) };
|
||||
if (method === "DOWNLOAD") {
|
||||
const downloadKeys = [
|
||||
"timeout",
|
||||
"filePath"
|
||||
];
|
||||
config = { ...config, ...mergeKeys(downloadKeys, globalsConfig, config2) };
|
||||
} else if (method === "UPLOAD") {
|
||||
delete config.header["content-type"];
|
||||
delete config.header["Content-Type"];
|
||||
const uploadKeys = [
|
||||
"filePath",
|
||||
"name",
|
||||
"timeout",
|
||||
"formData"
|
||||
];
|
||||
uploadKeys.forEach((prop) => {
|
||||
if (!uni_modules_uvUiTools_libs_luchRequest_utils.isUndefined(config2[prop])) {
|
||||
config[prop] = config2[prop];
|
||||
}
|
||||
});
|
||||
if (uni_modules_uvUiTools_libs_luchRequest_utils.isUndefined(config.timeout) && !uni_modules_uvUiTools_libs_luchRequest_utils.isUndefined(globalsConfig.timeout)) {
|
||||
config["timeout"] = globalsConfig["timeout"];
|
||||
}
|
||||
} else {
|
||||
const defaultsKeys = [
|
||||
"data",
|
||||
"timeout",
|
||||
"dataType",
|
||||
"responseType",
|
||||
"enableHttp2",
|
||||
"enableQuic",
|
||||
"enableCache",
|
||||
"enableHttpDNS",
|
||||
"httpDNSServiceId",
|
||||
"enableChunked",
|
||||
"forceCellularNetwork"
|
||||
];
|
||||
config = { ...config, ...mergeKeys(defaultsKeys, globalsConfig, config2) };
|
||||
}
|
||||
return config;
|
||||
};
|
||||
exports.mergeConfig = mergeConfig;
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
function settle(resolve, reject, response) {
|
||||
const validateStatus = response.config.validateStatus;
|
||||
const status = response.statusCode;
|
||||
if (status && (!validateStatus || validateStatus(status))) {
|
||||
resolve(response);
|
||||
} else {
|
||||
reject(response);
|
||||
}
|
||||
}
|
||||
exports.settle = settle;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
const uni_modules_uvUiTools_libs_luchRequest_utils = require("../utils.js");
|
||||
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(url, params, paramsSerializer) {
|
||||
if (!params) {
|
||||
return url;
|
||||
}
|
||||
var serializedParams;
|
||||
if (paramsSerializer) {
|
||||
serializedParams = paramsSerializer(params);
|
||||
} else if (uni_modules_uvUiTools_libs_luchRequest_utils.isURLSearchParams(params)) {
|
||||
serializedParams = params.toString();
|
||||
} else {
|
||||
var parts = [];
|
||||
uni_modules_uvUiTools_libs_luchRequest_utils.forEach(params, function serialize(val, key) {
|
||||
if (val === null || typeof val === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (uni_modules_uvUiTools_libs_luchRequest_utils.isArray(val)) {
|
||||
key = key + "[]";
|
||||
} else {
|
||||
val = [val];
|
||||
}
|
||||
uni_modules_uvUiTools_libs_luchRequest_utils.forEach(val, function parseValue(v) {
|
||||
if (uni_modules_uvUiTools_libs_luchRequest_utils.isDate(v)) {
|
||||
v = v.toISOString();
|
||||
} else if (uni_modules_uvUiTools_libs_luchRequest_utils.isObject(v)) {
|
||||
v = JSON.stringify(v);
|
||||
}
|
||||
parts.push(encode(key) + "=" + encode(v));
|
||||
});
|
||||
});
|
||||
serializedParams = parts.join("&");
|
||||
}
|
||||
if (serializedParams) {
|
||||
var hashmarkIndex = url.indexOf("#");
|
||||
if (hashmarkIndex !== -1) {
|
||||
url = url.slice(0, hashmarkIndex);
|
||||
}
|
||||
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
exports.buildURL = buildURL;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
function combineURLs(baseURL, relativeURL) {
|
||||
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
||||
}
|
||||
exports.combineURLs = combineURLs;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
function isAbsoluteURL(url) {
|
||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||
}
|
||||
exports.isAbsoluteURL = isAbsoluteURL;
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
const uni_modules_uvUiTools_libs_luchRequest_core_Request = require("./core/Request.js");
|
||||
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
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";
|
||||
}
|
||||
exports.deepMerge = deepMerge;
|
||||
exports.forEach = forEach;
|
||||
exports.isArray = isArray;
|
||||
exports.isDate = isDate;
|
||||
exports.isObject = isObject;
|
||||
exports.isPlainObject = isPlainObject;
|
||||
exports.isURLSearchParams = isURLSearchParams;
|
||||
exports.isUndefined = isUndefined;
|
||||
@@ -0,0 +1,191 @@
|
||||
"use strict";
|
||||
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 index = allParents.indexOf(parent2);
|
||||
if (index != -1) {
|
||||
return allChildren[index];
|
||||
}
|
||||
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;
|
||||
}();
|
||||
exports.clone = clone;
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
const button = {
|
||||
props: {
|
||||
lang: String,
|
||||
sessionFrom: String,
|
||||
sendMessageTitle: String,
|
||||
sendMessagePath: String,
|
||||
sendMessageImg: String,
|
||||
showMessageCard: Boolean,
|
||||
appParameter: String,
|
||||
formType: String,
|
||||
openType: String
|
||||
}
|
||||
};
|
||||
exports.button = button;
|
||||
@@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_uvUiTools_libs_function_index = require("../function/index.js");
|
||||
const uni_modules_uvUiTools_libs_function_test = require("../function/test.js");
|
||||
const uni_modules_uvUiTools_libs_util_route = require("../util/route.js");
|
||||
const uni_modules_uvUiTools_libs_function_debounce = require("../function/debounce.js");
|
||||
const uni_modules_uvUiTools_libs_function_throttle = require("../function/throttle.js");
|
||||
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, _c;
|
||||
return {
|
||||
...uni_modules_uvUiTools_libs_function_index.index,
|
||||
test: uni_modules_uvUiTools_libs_function_test.test,
|
||||
route: uni_modules_uvUiTools_libs_util_route.route,
|
||||
debounce: uni_modules_uvUiTools_libs_function_debounce.debounce,
|
||||
throttle: uni_modules_uvUiTools_libs_function_throttle.throttle,
|
||||
unit: (_c = (_b = (_a = common_vendor.index) == null ? void 0 : _a.$uv) == null ? void 0 : _b.config) == null ? void 0 : _c.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 url = this[urlKey];
|
||||
if (url) {
|
||||
common_vendor.index[this.linkType]({
|
||||
url
|
||||
});
|
||||
}
|
||||
},
|
||||
// 查询节点信息
|
||||
// 目前此方法在支付宝小程序中无法获取组件跟接点的尺寸,为支付宝的bug(2020-07-21)
|
||||
// 解决办法为在组件根部再套一个没有任何作用的view元素
|
||||
$uvGetRect(selector, all) {
|
||||
return new Promise((resolve) => {
|
||||
common_vendor.index.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() {
|
||||
common_vendor.index.$emit("uvOnReachBottom");
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.parent && uni_modules_uvUiTools_libs_function_test.array(this.parent.children)) {
|
||||
const childrenList = this.parent.children;
|
||||
childrenList.map((child, index) => {
|
||||
if (child === this) {
|
||||
childrenList.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// 兼容vue3
|
||||
unmounted() {
|
||||
if (this.parent && uni_modules_uvUiTools_libs_function_test.array(this.parent.children)) {
|
||||
const childrenList = this.parent.children;
|
||||
childrenList.map((child, index) => {
|
||||
if (child === this) {
|
||||
childrenList.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.mixin = mixin;
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
const mpMixin = {
|
||||
// 将自定义节点设置成虚拟的(去掉自定义组件包裹层),更加接近Vue组件的表现,能更好的使用flex属性
|
||||
options: {
|
||||
virtualHost: true
|
||||
}
|
||||
};
|
||||
exports.mpMixin = mpMixin;
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const mpShare = {
|
||||
onLoad() {
|
||||
common_vendor.index.$uv.mpShare = {
|
||||
title: "",
|
||||
// 默认为小程序名称
|
||||
path: "",
|
||||
// 默认为当前页面路径
|
||||
imageUrl: ""
|
||||
// 默认为当前页面的截图
|
||||
};
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return common_vendor.index.$uv.mpShare;
|
||||
}
|
||||
};
|
||||
exports.mpShare = mpShare;
|
||||
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
const openType = {
|
||||
props: {
|
||||
openType: String
|
||||
},
|
||||
emits: ["getphonenumber", "getuserinfo", "error", "opensetting", "launchapp", "contact", "chooseavatar", "addgroupapp", "chooseaddress", "subscribe", "login", "im"],
|
||||
methods: {
|
||||
onGetPhoneNumber(event) {
|
||||
this.$emit("getphonenumber", event.detail);
|
||||
},
|
||||
onGetUserInfo(event) {
|
||||
this.$emit("getuserinfo", event.detail);
|
||||
},
|
||||
onError(event) {
|
||||
this.$emit("error", event.detail);
|
||||
},
|
||||
onOpenSetting(event) {
|
||||
this.$emit("opensetting", event.detail);
|
||||
},
|
||||
onLaunchApp(event) {
|
||||
this.$emit("launchapp", event.detail);
|
||||
},
|
||||
onContact(event) {
|
||||
this.$emit("contact", event.detail);
|
||||
},
|
||||
onChooseavatar(event) {
|
||||
this.$emit("chooseavatar", event.detail);
|
||||
},
|
||||
onAgreeprivacyauthorization(event) {
|
||||
this.$emit("agreeprivacyauthorization", event.detail);
|
||||
},
|
||||
onAddgroupapp(event) {
|
||||
this.$emit("addgroupapp", event.detail);
|
||||
},
|
||||
onChooseaddress(event) {
|
||||
this.$emit("chooseaddress", event.detail);
|
||||
},
|
||||
onSubscribe(event) {
|
||||
this.$emit("subscribe", event.detail);
|
||||
},
|
||||
onLogin(event) {
|
||||
this.$emit("login", event.detail);
|
||||
},
|
||||
onIm(event) {
|
||||
this.$emit("im", event.detail);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.openType = openType;
|
||||
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_uvUiTools_libs_function_index = require("../function/index.js");
|
||||
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(url) {
|
||||
return url[0] === "/" ? url : `/${url}`;
|
||||
}
|
||||
// 整合路由参数
|
||||
mixinParam(url, params) {
|
||||
url = url && this.addRootPath(url);
|
||||
let query = "";
|
||||
if (/.*\/.*\?.*=.*/.test(url)) {
|
||||
query = uni_modules_uvUiTools_libs_function_index.queryParams(params, false);
|
||||
return url += `&${query}`;
|
||||
}
|
||||
query = uni_modules_uvUiTools_libs_function_index.queryParams(params);
|
||||
return url += query;
|
||||
}
|
||||
// 对外的方法名称
|
||||
async route(options = {}, params = {}) {
|
||||
let mergeConfig = {};
|
||||
if (typeof options === "string") {
|
||||
mergeConfig.url = this.mixinParam(options, params);
|
||||
mergeConfig.type = "navigateTo";
|
||||
} else {
|
||||
mergeConfig = uni_modules_uvUiTools_libs_function_index.deepMerge(this.config, options);
|
||||
mergeConfig.url = this.mixinParam(options.url, options.params);
|
||||
}
|
||||
if (mergeConfig.url === uni_modules_uvUiTools_libs_function_index.page()) return;
|
||||
if (params.intercept) {
|
||||
mergeConfig.intercept = params.intercept;
|
||||
}
|
||||
mergeConfig.params = params;
|
||||
mergeConfig = uni_modules_uvUiTools_libs_function_index.deepMerge(this.config, mergeConfig);
|
||||
if (typeof mergeConfig.intercept === "function") {
|
||||
const isNext = await new Promise((resolve, reject) => {
|
||||
mergeConfig.intercept(mergeConfig, resolve);
|
||||
});
|
||||
isNext && this.openPage(mergeConfig);
|
||||
} else {
|
||||
this.openPage(mergeConfig);
|
||||
}
|
||||
}
|
||||
// 执行路由跳转
|
||||
openPage(config) {
|
||||
const {
|
||||
url,
|
||||
type,
|
||||
delta,
|
||||
animationType,
|
||||
animationDuration,
|
||||
events
|
||||
} = config;
|
||||
if (config.type == "navigateTo" || config.type == "to") {
|
||||
common_vendor.index.navigateTo({
|
||||
url,
|
||||
animationType,
|
||||
animationDuration,
|
||||
events
|
||||
});
|
||||
}
|
||||
if (config.type == "redirectTo" || config.type == "redirect") {
|
||||
common_vendor.index.redirectTo({
|
||||
url
|
||||
});
|
||||
}
|
||||
if (config.type == "switchTab" || config.type == "tab") {
|
||||
common_vendor.index.switchTab({
|
||||
url
|
||||
});
|
||||
}
|
||||
if (config.type == "reLaunch" || config.type == "launch") {
|
||||
common_vendor.index.reLaunch({
|
||||
url
|
||||
});
|
||||
}
|
||||
if (config.type == "navigateBack" || config.type == "back") {
|
||||
common_vendor.index.navigateBack({
|
||||
delta
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
const route = new Router().route;
|
||||
exports.route = route;
|
||||
Reference in New Issue
Block a user