添加新文件
This commit is contained in:
+82
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
const uni_modules_uviewPlus_libs_vue = require("../../libs/vue.js");
|
||||
const uni_modules_uviewPlus_libs_config_props = require("../../libs/config/props.js");
|
||||
const props = uni_modules_uviewPlus_libs_vue.defineMixin({
|
||||
props: {
|
||||
// 是否显示圆点
|
||||
isDot: {
|
||||
type: Boolean,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.isDot
|
||||
},
|
||||
// 显示的内容
|
||||
value: {
|
||||
type: [Number, String],
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.value
|
||||
},
|
||||
// 显示的内容
|
||||
modelValue: {
|
||||
type: [Number, String],
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.modelValue
|
||||
},
|
||||
// 是否显示
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.show
|
||||
},
|
||||
// 最大值,超过最大值会显示 '{max}+'
|
||||
max: {
|
||||
type: [Number, String],
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.max
|
||||
},
|
||||
// 主题类型,error|warning|success|primary
|
||||
type: {
|
||||
type: String,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.type
|
||||
},
|
||||
// 当数值为 0 时,是否展示 Badge
|
||||
showZero: {
|
||||
type: Boolean,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.showZero
|
||||
},
|
||||
// 背景颜色,优先级比type高,如设置,type参数会失效
|
||||
bgColor: {
|
||||
type: [String, null],
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.bgColor
|
||||
},
|
||||
// 字体颜色
|
||||
color: {
|
||||
type: [String, null],
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.color
|
||||
},
|
||||
// 徽标形状,circle-四角均为圆角,horn-左下角为直角
|
||||
shape: {
|
||||
type: String,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.shape
|
||||
},
|
||||
// 设置数字的显示方式,overflow|ellipsis|limit
|
||||
// overflow会根据max字段判断,超出显示`${max}+`
|
||||
// ellipsis会根据max判断,超出显示`${max}...`
|
||||
// limit会依据1000作为判断条件,超出1000,显示`${value/1000}K`,比如2.2k、3.34w,最多保留2位小数
|
||||
numberType: {
|
||||
type: String,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.numberType
|
||||
},
|
||||
// 设置badge的位置偏移,格式为 [x, y],也即设置的为top和right的值,absolute为true时有效
|
||||
offset: {
|
||||
type: Array,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.offset
|
||||
},
|
||||
// 是否反转背景和字体颜色
|
||||
inverted: {
|
||||
type: Boolean,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.inverted
|
||||
},
|
||||
// 是否绝对定位
|
||||
absolute: {
|
||||
type: Boolean,
|
||||
default: () => uni_modules_uviewPlus_libs_config_props.defProps.badge.absolute
|
||||
}
|
||||
}
|
||||
});
|
||||
exports.props = props;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-plus/components/u-badge/props.js.map
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
const uni_modules_uviewPlus_components_uBadge_props = require("./props.js");
|
||||
const uni_modules_uviewPlus_libs_mixin_mpMixin = require("../../libs/mixin/mpMixin.js");
|
||||
const uni_modules_uviewPlus_libs_mixin_mixin = require("../../libs/mixin/mixin.js");
|
||||
const uni_modules_uviewPlus_libs_function_index = require("../../libs/function/index.js");
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
name: "u-badge",
|
||||
mixins: [uni_modules_uviewPlus_libs_mixin_mpMixin.mpMixin, uni_modules_uviewPlus_components_uBadge_props.props, uni_modules_uviewPlus_libs_mixin_mixin.mixin],
|
||||
computed: {
|
||||
// 是否将badge中心与父组件右上角重合
|
||||
boxStyle() {
|
||||
let style = {};
|
||||
return style;
|
||||
},
|
||||
// 整个组件的样式
|
||||
badgeStyle() {
|
||||
const style = {};
|
||||
if (this.color) {
|
||||
style.color = this.color;
|
||||
}
|
||||
if (this.bgColor && !this.inverted) {
|
||||
style.backgroundColor = this.bgColor;
|
||||
}
|
||||
if (this.absolute) {
|
||||
style.position = "absolute";
|
||||
if (this.offset.length) {
|
||||
const top = this.offset[0];
|
||||
const right = this.offset[1] || top;
|
||||
style.top = uni_modules_uviewPlus_libs_function_index.addUnit(top);
|
||||
style.right = uni_modules_uviewPlus_libs_function_index.addUnit(right);
|
||||
}
|
||||
}
|
||||
return style;
|
||||
},
|
||||
showValue() {
|
||||
switch (this.numberType) {
|
||||
case "overflow":
|
||||
return Number(this.value) > Number(this.max) ? this.max + "+" : this.value;
|
||||
case "ellipsis":
|
||||
return Number(this.value) > Number(this.max) ? "..." : this.value;
|
||||
case "limit":
|
||||
return Number(this.value) > 999 ? Number(this.value) >= 9999 ? Math.floor(this.value / 1e4 * 100) / 100 + "w" : Math.floor(this.value / 1e3 * 100) / 100 + "k" : this.value;
|
||||
default:
|
||||
return Number(this.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addStyle: uni_modules_uviewPlus_libs_function_index.addStyle
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: _ctx.show && ((Number(_ctx.value) === 0 ? _ctx.showZero : true) || _ctx.isDot)
|
||||
}, _ctx.show && ((Number(_ctx.value) === 0 ? _ctx.showZero : true) || _ctx.isDot) ? {
|
||||
b: common_vendor.t(_ctx.isDot ? "" : $options.showValue),
|
||||
c: common_vendor.n(_ctx.isDot ? "u-badge--dot" : "u-badge--not-dot"),
|
||||
d: common_vendor.n(_ctx.inverted && "u-badge--inverted"),
|
||||
e: common_vendor.n(_ctx.shape === "horn" && "u-badge--horn"),
|
||||
f: common_vendor.n(`u-badge--${_ctx.type}${_ctx.inverted ? "--inverted" : ""}`),
|
||||
g: common_vendor.s($options.addStyle(_ctx.customStyle)),
|
||||
h: common_vendor.s($options.badgeStyle)
|
||||
} : {});
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-06cca9b7"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-plus/components/u-badge/u-badge.js.map
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
<text wx:if="{{a}}" class="{{[c, d, e, f, 'u-badge', 'data-v-06cca9b7']}}" style="{{g + ';' + h}}">{{b}}</text>
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/* uni.scss */
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
.u-empty.data-v-06cca9b7,
|
||||
.u-empty__wrap.data-v-06cca9b7,
|
||||
.u-tabs.data-v-06cca9b7,
|
||||
.u-tabs__wrapper.data-v-06cca9b7,
|
||||
.u-tabs__wrapper__scroll-view-wrapper.data-v-06cca9b7,
|
||||
.u-tabs__wrapper__scroll-view.data-v-06cca9b7,
|
||||
.u-tabs__wrapper__nav.data-v-06cca9b7,
|
||||
.u-tabs__wrapper__nav__line.data-v-06cca9b7,
|
||||
.up-empty.data-v-06cca9b7,
|
||||
.up-empty__wrap.data-v-06cca9b7,
|
||||
.up-tabs.data-v-06cca9b7,
|
||||
.up-tabs__wrapper.data-v-06cca9b7,
|
||||
.up-tabs__wrapper__scroll-view-wrapper.data-v-06cca9b7,
|
||||
.up-tabs__wrapper__scroll-view.data-v-06cca9b7,
|
||||
.up-tabs__wrapper__nav.data-v-06cca9b7,
|
||||
.up-tabs__wrapper__nav__line.data-v-06cca9b7 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: auto;
|
||||
align-items: stretch;
|
||||
align-content: flex-start;
|
||||
}
|
||||
.u-badge.data-v-06cca9b7 {
|
||||
border-top-right-radius: 100px;
|
||||
border-top-left-radius: 100px;
|
||||
border-bottom-left-radius: 100px;
|
||||
border-bottom-right-radius: 100px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
line-height: 11px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.u-badge--dot.data-v-06cca9b7 {
|
||||
height: 8px;
|
||||
width: 8px;
|
||||
}
|
||||
.u-badge--inverted.data-v-06cca9b7 {
|
||||
font-size: 13px;
|
||||
}
|
||||
.u-badge--not-dot.data-v-06cca9b7 {
|
||||
padding: 2px 5px;
|
||||
}
|
||||
.u-badge--horn.data-v-06cca9b7 {
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
.u-badge--primary.data-v-06cca9b7 {
|
||||
background-color: #3c9cff;
|
||||
}
|
||||
.u-badge--primary--inverted.data-v-06cca9b7 {
|
||||
color: #3c9cff;
|
||||
}
|
||||
.u-badge--error.data-v-06cca9b7 {
|
||||
background-color: #f56c6c;
|
||||
}
|
||||
.u-badge--error--inverted.data-v-06cca9b7 {
|
||||
color: #f56c6c;
|
||||
}
|
||||
.u-badge--success.data-v-06cca9b7 {
|
||||
background-color: #5ac725;
|
||||
}
|
||||
.u-badge--success--inverted.data-v-06cca9b7 {
|
||||
color: #5ac725;
|
||||
}
|
||||
.u-badge--info.data-v-06cca9b7 {
|
||||
background-color: #909399;
|
||||
}
|
||||
.u-badge--info--inverted.data-v-06cca9b7 {
|
||||
color: #909399;
|
||||
}
|
||||
.u-badge--warning.data-v-06cca9b7 {
|
||||
background-color: #f9ae3d;
|
||||
}
|
||||
.u-badge--warning--inverted.data-v-06cca9b7 {
|
||||
color: #f9ae3d;
|
||||
}
|
||||
Reference in New Issue
Block a user