个别使用分支的内容

cyl/master-0819
wangxia 3 months ago
parent b04d145e98
commit d233132f6b

@ -1,22 +1,13 @@
<template>
<view :style="[customStyle]" class="u-icon" @tap="click" :class="['u-icon--' + labelPos]">
<image class="u-icon__img" v-if="isImg" :src="name" :mode="imgMode" :style="[imgStyle]"
></image>
<view
v-else
class="u-icon__icon"
:class="customClass"
:style="[iconStyle]"
:hover-class="hoverClass"
@touchstart="touchstart"
>
<text
v-if="showDecimalIcon"
:style="[decimalIconStyle]"
:class="decimalIconClass"
:hover-class="hoverClass"
class="u-icon__decimal"
></text>
<view class="" v-if="imgType == 'custom'">
<i class="tabImg iconfont" :class="name" />
</view>
<view class="" v-else>
<image class="u-icon__img" v-if="isImg" :src="name" :mode="imgMode" :style="[imgStyle]"></image>
<view v-else class="u-icon__icon" :class="customClass" :style="[iconStyle]" :hover-class="hoverClass" @touchstart="touchstart">
<text v-if="showDecimalIcon" :style="[decimalIconStyle]" :class="decimalIconClass" :hover-class="hoverClass" class="u-icon__decimal"></text>
</view>
</view>
<!-- 这里进行空字符串判断如果仅仅是v-if="label"可能会出现传递0的时候结果也无法显示微信小程序不传值默认为null故需要增加null的判断 -->
<text
@ -28,7 +19,7 @@
marginLeft: labelPos == 'right' ? $u.addUnit(marginLeft) : 0,
marginTop: labelPos == 'bottom' ? $u.addUnit(marginTop) : 0,
marginRight: labelPos == 'left' ? $u.addUnit(marginRight) : 0,
marginBottom: labelPos == 'top' ? $u.addUnit(marginBottom) : 0
marginBottom: labelPos == 'top' ? $u.addUnit(marginBottom) : 0,
}"
>
{{ label }}
@ -72,126 +63,129 @@ export default {
name: "u-icon",
emits: ["click", "touchstart"],
props: {
imgradius:{
default: '0'
imgradius: {
default: "0",
},
imgType: {
default: "",
},
//
name: {
type: String,
default: ""
default: "",
},
//
color: {
type: [String, null],
default: ""
default: "",
},
// rpx
size: {
type: [Number, String],
default: "inherit"
default: "inherit",
},
//
bold: {
type: Boolean,
default: false
default: false,
},
// index
index: {
type: [Number, String],
default: ""
default: "",
},
//
hoverClass: {
type: String,
default: ""
default: "",
},
// 便
customPrefix: {
type: String,
default: "uicon"
default: "uicon",
},
//
label: {
type: [String, Number],
default: ""
default: "",
},
// label
labelPos: {
type: String,
default: "right"
default: "right",
},
// label
labelSize: {
type: [String, Number],
default: "28"
default: "28",
},
// label
labelColor: {
type: String,
default: "#606266"
default: "#606266",
},
// label()
marginLeft: {
type: [String, Number],
default: "6"
default: "6",
},
// label()
marginTop: {
type: [String, Number],
default: "6"
default: "6",
},
// label()
marginRight: {
type: [String, Number],
default: "6"
default: "6",
},
// label()
marginBottom: {
type: [String, Number],
default: "6"
default: "6",
},
// mode
imgMode: {
type: String,
default: "widthFix"
default: "widthFix",
},
//
customStyle: {
type: Object,
default() {
return {};
}
},
},
//
width: {
type: [String, Number],
default: ""
default: "",
},
//
height: {
type: [String, Number],
default: ""
default: "",
},
//
top: {
type: [String, Number],
default: 0
default: 0,
},
// DecimalIcon
showDecimalIcon: {
type: Boolean,
default: false
default: false,
},
// Decimal
inactiveColor: {
type: String,
default: "#ececec"
default: "#ececec",
},
// Decimal
percent: {
type: [Number, String],
default: "50"
}
default: "50",
},
},
computed: {
customClass() {
@ -211,14 +205,9 @@ export default {
classes.push(customPrefix);
}
//
if (
this.showDecimalIcon &&
this.inactiveColor &&
this.$u.config.type.includes(this.inactiveColor)
) {
if (this.showDecimalIcon && this.inactiveColor && this.$u.config.type.includes(this.inactiveColor)) {
classes.push("u-icon__icon--" + this.inactiveColor);
} else if (this.color && this.$u.config.type.includes(this.color))
classes.push("u-icon__icon--" + this.color);
} else if (this.color && this.$u.config.type.includes(this.color)) classes.push("u-icon__icon--" + this.color);
// 使[a, b, c]
//
//#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
@ -232,14 +221,10 @@ export default {
fontSize: this.size == "inherit" ? "inherit" : this.$u.addUnit(this.size),
fontWeight: this.bold ? "bold" : "normal",
//
top: this.$u.addUnit(this.top)
top: this.$u.addUnit(this.top),
};
//
if (
this.showDecimalIcon &&
this.inactiveColor &&
!this.$u.config.type.includes(this.inactiveColor)
) {
if (this.showDecimalIcon && this.inactiveColor && !this.$u.config.type.includes(this.inactiveColor)) {
style.color = this.inactiveColor;
} else if (this.color && !this.$u.config.type.includes(this.color)) style.color = this.color;
@ -264,7 +249,7 @@ export default {
fontWeight: this.bold ? "bold" : "normal",
//
top: this.$u.addUnit(this.top),
width: this.percent + "%"
width: this.percent + "%",
};
//
if (this.color && !this.$u.config.type.includes(this.color)) style.color = this.color;
@ -280,8 +265,7 @@ export default {
classes.push(this.customPrefix);
}
//
if (this.color && this.$u.config.type.includes(this.color))
classes.push("u-icon__icon--" + this.color);
if (this.color && this.$u.config.type.includes(this.color)) classes.push("u-icon__icon--" + this.color);
else classes.push("u-icon__icon--primary");
// 使[a, b, c]
//
@ -289,7 +273,7 @@ export default {
classes = classes.join(" ");
//#endif
return classes;
}
},
},
methods: {
click() {
@ -297,15 +281,45 @@ export default {
},
touchstart() {
this.$emit("touchstart", this.index);
}
}
},
},
};
</script>
<style scoped lang="scss">
@import "../../libs/css/style.components.scss";
@import "../../iconfont.css";
@font-face {
font-family: "iconfont"; /* Project id 4374774 */
src: url("//at.alicdn.com/t/c/font_4374774_pt88dt6fxcj.woff2?t=1741923897019") format("woff2"), url("//at.alicdn.com/t/c/font_4374774_pt88dt6fxcj.woff?t=1741923897019") format("woff"), url("//at.alicdn.com/t/c/font_4374774_pt88dt6fxcj.ttf?t=1741923897019") format("truetype");
}
.iconfont {
font-family: "iconfont" !important;
font-size: 24px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
//
.icon-home:before {
content: "\e7e1";
}
//
.icon-order_active:before {
content: "\e617";
}
//
.icon-message:before {
content: "\e78a";
}
//
.icon-user:before {
content: "\e7ae";
}
//
.icon-fadanhao-31:before {
content: "\e65c";
}
.u-icon {
display: inline-flex;
align-items: center;

@ -22,23 +22,14 @@
backgroundColor: bgColor,
}"
>
<view :class="[midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button']"
<view
:class="[midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button']"
:style="{
top: item.text ? '7px' : '7px' ,
}">
<u-icon
:size="midButton && item.midButton ? midButtonSize : (item.iconSize ? item.iconSize : 24)"
:name="elIconPath(index)"
img-mode="scaleToFill"
:color="elColor(index)"
:custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'"
:imgradius="item.iconType == 'custom' ? '50%' : '0'"
></u-icon>
<u-badge :count="item.count"
:is-dot="item.isDot"
v-if="item.count"
:offset="[-2, getOffsetRight(item.count, item.isDot)]"
></u-badge>
top: item.text ? '7px' : '7px',
}"
>
<u-icon :size="midButton && item.midButton ? midButtonSize : item.iconSize ? item.iconSize : 24" :name="elIconPath(index)" img-mode="scaleToFill" :color="elColor(index)" :imgType="imgType" :custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'" :imgradius="item.iconType == 'custom' ? '50%' : '0'"></u-icon>
<u-badge :count="item.count" :is-dot="item.isDot" v-if="item.count" :offset="[-2, getOffsetRight(item.count, item.isDot)]"></u-badge>
</view>
<view
class="u-tabbar__content__item__text"
@ -83,6 +74,10 @@ export default {
type: [String, Number],
default: 0,
},
imgType: {
type: [String],
default: '',
},
modelValue: {
type: [String, Number],
default: 0,
@ -357,7 +352,7 @@ export default {
flex: 1;
justify-content: center;
height: 100%;
padding: 6px 0;
padding: 0;
@include vue-flex;
flex-direction: column;
align-items: center;
@ -411,8 +406,9 @@ export default {
}
}
}
.mround{
image,img{
.mround {
image,
img {
border-radius: 50%;
}
}

Loading…
Cancel
Save