This commit is contained in:
zoujiandong
2025-07-30 13:58:39 +08:00
parent afc79a0f26
commit 43abd1f3d6
360 changed files with 27253 additions and 0 deletions
@@ -0,0 +1,152 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-image",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props],
data() {
return {
// 图片是否加载错误,如果是,则显示错误占位图
isError: false,
// 初始化组件时,默认为加载中状态
loading: true,
// 不透明度,为了实现淡入淡出的效果
opacity: 1,
// 过渡时间,因为props的值无法修改,故需要一个中间值
durationTime: this.duration,
// 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
backgroundStyle: {},
// 用于fade模式的控制组件显示与否
show: false
};
},
watch: {
src: {
immediate: true,
handler(n) {
if (!n) {
this.isError = true;
} else {
this.isError = false;
this.loading = true;
}
}
}
},
computed: {
transStyle() {
let style = {};
if (this.loading || this.isError || this.width == "100%" || this.mode != "heightFix") {
style.width = this.width;
} else {
style.width = "fit-content";
}
if (this.loading || this.isError || this.height == "100%" || this.mode != "widthFix") {
style.height = this.height;
} else {
style.height = "fit-content";
}
return style;
},
wrapStyle() {
let style = {};
if (this.loading || this.isError || this.width == "100%" || this.mode != "heightFix") {
style.width = this.width;
} else {
style.width = "fit-content";
}
if (this.loading || this.isError || this.height == "100%" || this.mode != "widthFix") {
style.height = this.height;
} else {
style.height = "fit-content";
}
style.borderRadius = this.shape == "circle" ? "10000px" : common_vendor.addUnit(this.radius);
style.overflow = this.radius > 0 ? "hidden" : "visible";
return common_vendor.deepMerge(style, common_vendor.addStyle(this.customStyle));
}
},
mounted() {
this.show = true;
},
emits: ["click", "error", "load"],
methods: {
addUnit: common_vendor.addUnit,
// 点击图片
onClick(e) {
this.$emit("click", e);
},
// 图片加载失败
onErrorHandler(err) {
this.loading = false;
this.isError = true;
this.$emit("error", err);
},
// 图片加载完成,标记loading结束
onLoadHandler(event) {
this.loading = false;
this.isError = false;
this.$emit("load", event);
this.removeBgColor();
},
// 移除图片的背景色
removeBgColor() {
this.backgroundStyle = {
backgroundColor: this.bgColor || "#ffffff"
};
}
}
};
if (!Array) {
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
const _easycom_u_transition2 = common_vendor.resolveComponent("u-transition");
(_easycom_u_icon2 + _easycom_u_transition2)();
}
const _easycom_u_icon = () => "../u-icon/u-icon.js";
const _easycom_u_transition = () => "../u-transition/u-transition.js";
if (!Math) {
(_easycom_u_icon + _easycom_u_transition)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: !$data.isError
}, !$data.isError ? {
b: _ctx.src,
c: _ctx.mode,
d: common_vendor.o((...args) => $options.onErrorHandler && $options.onErrorHandler(...args)),
e: common_vendor.o((...args) => $options.onLoadHandler && $options.onLoadHandler(...args)),
f: _ctx.showMenuByLongpress,
g: _ctx.lazyLoad,
h: $options.addUnit(_ctx.width),
i: $options.addUnit(_ctx.height),
j: _ctx.shape == "circle" ? "10000px" : $options.addUnit(_ctx.radius)
} : {}, {
k: _ctx.showLoading && $data.loading
}, _ctx.showLoading && $data.loading ? {
l: common_vendor.p({
name: _ctx.loadingIcon
}),
m: _ctx.shape == "circle" ? "50%" : $options.addUnit(_ctx.radius),
n: this.bgColor,
o: $options.addUnit(_ctx.width),
p: $options.addUnit(_ctx.height)
} : {}, {
q: _ctx.showError && $data.isError && !$data.loading
}, _ctx.showError && $data.isError && !$data.loading ? {
r: common_vendor.p({
name: _ctx.errorIcon
}),
s: _ctx.shape == "circle" ? "50%" : $options.addUnit(_ctx.radius)
} : {}, {
t: common_vendor.o((...args) => $options.onClick && $options.onClick(...args)),
v: common_vendor.s($options.wrapStyle),
w: common_vendor.s($data.backgroundStyle),
x: common_vendor.s($options.transStyle),
y: common_vendor.p({
mode: "fade",
show: $data.show,
duration: _ctx.fade ? 1e3 : 0
})
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-9d58ba7c"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/uview-plus/components/u-image/u-image.js.map
@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"u-icon": "../u-icon/u-icon",
"u-transition": "../u-transition/u-transition"
}
}
@@ -0,0 +1 @@
<u-transition wx:if="{{y}}" class="data-v-9d58ba7c" u-s="{{['d']}}" style="{{x}}" u-i="9d58ba7c-0" bind:__l="__l" u-p="{{y}}"><view class="u-image box-border data-v-9d58ba7c" bindtap="{{t}}" style="{{v + ';' + w}}"><image wx:if="{{a}}" src="{{b}}" mode="{{c}}" binderror="{{d}}" bindload="{{e}}" show-menu-by-longpress="{{f}}" lazy-load="{{g}}" class="u-image__image data-v-9d58ba7c" style="{{'width:' + h + ';' + ('height:' + i) + ';' + ('border-radius:' + j)}}"></image><view wx:if="{{k}}" class="u-image__loading data-v-9d58ba7c" style="{{'border-radius:' + m + ';' + ('background-color:' + n) + ';' + ('width:' + o) + ';' + ('height:' + p)}}"><block wx:if="{{$slots.loading}}"><slot name="loading"></slot></block><block wx:else><u-icon wx:if="{{l}}" class="data-v-9d58ba7c" u-i="9d58ba7c-1,9d58ba7c-0" bind:__l="__l" u-p="{{l}}"></u-icon></block></view><view wx:if="{{q}}" class="u-image__error data-v-9d58ba7c" style="{{'border-radius:' + s}}"><block wx:if="{{$slots.error}}"><slot name="error"></slot></block><block wx:else><u-icon wx:if="{{r}}" class="data-v-9d58ba7c" u-i="9d58ba7c-2,9d58ba7c-0" bind:__l="__l" u-p="{{r}}"></u-icon></block></view></view></u-transition>
@@ -0,0 +1,71 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.u-empty.data-v-9d58ba7c,
.u-empty__wrap.data-v-9d58ba7c,
.u-tabs.data-v-9d58ba7c,
.u-tabs__wrapper.data-v-9d58ba7c,
.u-tabs__wrapper__scroll-view-wrapper.data-v-9d58ba7c,
.u-tabs__wrapper__scroll-view.data-v-9d58ba7c,
.u-tabs__wrapper__nav.data-v-9d58ba7c,
.u-tabs__wrapper__nav__line.data-v-9d58ba7c,
.up-empty.data-v-9d58ba7c,
.up-empty__wrap.data-v-9d58ba7c,
.up-tabs.data-v-9d58ba7c,
.up-tabs__wrapper.data-v-9d58ba7c,
.up-tabs__wrapper__scroll-view-wrapper.data-v-9d58ba7c,
.up-tabs__wrapper__scroll-view.data-v-9d58ba7c,
.up-tabs__wrapper__nav.data-v-9d58ba7c,
.up-tabs__wrapper__nav__line.data-v-9d58ba7c {
display: flex;
flex-direction: column;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}
.u-image.data-v-9d58ba7c {
position: relative;
transition: opacity 0.5s ease-in-out;
}
.u-image__image.data-v-9d58ba7c {
width: 100%;
height: 100%;
}
.u-image__loading.data-v-9d58ba7c, .u-image__error.data-v-9d58ba7c {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
background-color: #f3f4f6;
color: #909193;
font-size: 46rpx;
}