61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../common/vendor.js");
|
|
if (!Array) {
|
|
const _easycom_wd_overlay2 = common_vendor.resolveComponent("wd-overlay");
|
|
_easycom_wd_overlay2();
|
|
}
|
|
const _easycom_wd_overlay = () => "../node-modules/wot-design-uni/components/wd-overlay/wd-overlay.js";
|
|
if (!Math) {
|
|
_easycom_wd_overlay();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "LoadingAnimation",
|
|
props: {
|
|
modelValue: Boolean,
|
|
timeout: {
|
|
// 添加timeout属性来控制加载时间
|
|
type: Number,
|
|
default: 5e3
|
|
// 默认5秒后自动关闭
|
|
}
|
|
},
|
|
emits: ["update:modelValue"],
|
|
setup(__props, { emit: __emit }) {
|
|
const props = __props;
|
|
const emit = __emit;
|
|
let timer = null;
|
|
const colors = ["#FF6347", "#4682B4", "#32CD32", "#FFD700", "#FF69B4", "#00FA9A"];
|
|
const startTimeout = () => {
|
|
clearTimeout(timer);
|
|
timer = setTimeout(() => {
|
|
stopLoading();
|
|
}, props.timeout);
|
|
};
|
|
const stopLoading = () => {
|
|
clearTimeout(timer);
|
|
emit("update:modelValue", false);
|
|
};
|
|
common_vendor.onLoad(() => {
|
|
startTimeout();
|
|
});
|
|
common_vendor.onUnload(() => {
|
|
clearTimeout(timer);
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.f(colors, (color, k0, i0) => {
|
|
return {
|
|
a: color,
|
|
b: color
|
|
};
|
|
}),
|
|
b: common_vendor.p({
|
|
show: __props.modelValue
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ca9fbe80"]]);
|
|
wx.createComponent(Component);
|