78 lines
3.1 KiB
JavaScript
78 lines
3.1 KiB
JavaScript
"use strict";
|
|
var common_vendor = require("../../../../common/vendor.js");
|
|
var uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
|
|
var uni_modules_wotDesignUni_components_wdImg_types = require("./types.js");
|
|
require("../common/AbortablePromise.js");
|
|
require("../common/props.js");
|
|
const __default__ = {
|
|
name: "wd-img",
|
|
options: {
|
|
virtualHost: true,
|
|
addGlobalClass: true,
|
|
styleIsolation: "shared"
|
|
}
|
|
};
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
...__default__,
|
|
props: uni_modules_wotDesignUni_components_wdImg_types.imgProps,
|
|
emits: ["error", "click", "load"],
|
|
setup(__props, { emit }) {
|
|
const props = __props;
|
|
const rootStyle = common_vendor.computed$1(() => {
|
|
const style = {};
|
|
if (uni_modules_wotDesignUni_components_common_util.isDef(props.height)) {
|
|
style["height"] = uni_modules_wotDesignUni_components_common_util.addUnit(props.height);
|
|
}
|
|
if (uni_modules_wotDesignUni_components_common_util.isDef(props.width)) {
|
|
style["width"] = uni_modules_wotDesignUni_components_common_util.addUnit(props.width);
|
|
}
|
|
if (uni_modules_wotDesignUni_components_common_util.isDef(props.radius)) {
|
|
style["border-radius"] = uni_modules_wotDesignUni_components_common_util.addUnit(props.radius);
|
|
style["overflow"] = "hidden";
|
|
}
|
|
return `${uni_modules_wotDesignUni_components_common_util.objToStyle(style)}${props.customStyle}`;
|
|
});
|
|
const rootClass = common_vendor.computed$1(() => {
|
|
return `wd-img ${props.round ? "is-round" : ""} ${props.customClass}`;
|
|
});
|
|
const status = common_vendor.ref("loading");
|
|
function handleError(event) {
|
|
status.value = "error";
|
|
emit("error", event);
|
|
}
|
|
function handleClick(event) {
|
|
if (props.enablePreview && props.src && status.value == "success") {
|
|
common_vendor.index.previewImage({
|
|
urls: [props.previewSrc || props.src]
|
|
});
|
|
}
|
|
emit("click", event);
|
|
}
|
|
function handleLoad(event) {
|
|
status.value = "success";
|
|
emit("load", event);
|
|
}
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.n(`wd-img__image ${_ctx.customImage}`),
|
|
b: common_vendor.s(status.value !== "success" ? "width: 0;height: 0;" : ""),
|
|
c: _ctx.src,
|
|
d: _ctx.mode,
|
|
e: _ctx.showMenuByLongpress,
|
|
f: _ctx.lazyLoad,
|
|
g: common_vendor.o(handleLoad),
|
|
h: common_vendor.o(handleError),
|
|
i: status.value === "loading"
|
|
}, status.value === "loading" ? {} : {}, {
|
|
j: status.value === "error"
|
|
}, status.value === "error" ? {} : {}, {
|
|
k: common_vendor.n(common_vendor.unref(rootClass)),
|
|
l: common_vendor.o(handleClick),
|
|
m: common_vendor.s(common_vendor.unref(rootStyle))
|
|
});
|
|
};
|
|
}
|
|
});
|
|
var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-37510d1a"], ["__file", "D:/\u7F51\u6291\u4E91Time/\u79C1\u6D3B/2000\u7B97\u5366/src/uni_modules/wot-design-uni/components/wd-img/wd-img.vue"]]);
|
|
wx.createComponent(Component);
|