个别使用分支的内容

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

@ -1,22 +1,13 @@
<template> <template>
<view :style="[customStyle]" class="u-icon" @tap="click" :class="['u-icon--' + labelPos]"> <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]" <view class="" v-if="imgType == 'custom'">
></image> <i class="tabImg iconfont" :class="name" />
<view </view>
v-else <view class="" v-else>
class="u-icon__icon" <image class="u-icon__img" v-if="isImg" :src="name" :mode="imgMode" :style="[imgStyle]"></image>
:class="customClass" <view v-else class="u-icon__icon" :class="customClass" :style="[iconStyle]" :hover-class="hoverClass" @touchstart="touchstart">
:style="[iconStyle]" <text v-if="showDecimalIcon" :style="[decimalIconStyle]" :class="decimalIconClass" :hover-class="hoverClass" class="u-icon__decimal"></text>
:hover-class="hoverClass" </view>
@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的判断 --> <!-- 这里进行空字符串判断如果仅仅是v-if="label"可能会出现传递0的时候结果也无法显示微信小程序不传值默认为null故需要增加null的判断 -->
<text <text
@ -28,7 +19,7 @@
marginLeft: labelPos == 'right' ? $u.addUnit(marginLeft) : 0, marginLeft: labelPos == 'right' ? $u.addUnit(marginLeft) : 0,
marginTop: labelPos == 'bottom' ? $u.addUnit(marginTop) : 0, marginTop: labelPos == 'bottom' ? $u.addUnit(marginTop) : 0,
marginRight: labelPos == 'left' ? $u.addUnit(marginRight) : 0, marginRight: labelPos == 'left' ? $u.addUnit(marginRight) : 0,
marginBottom: labelPos == 'top' ? $u.addUnit(marginBottom) : 0 marginBottom: labelPos == 'top' ? $u.addUnit(marginBottom) : 0,
}" }"
> >
{{ label }} {{ label }}
@ -73,125 +64,128 @@ export default {
emits: ["click", "touchstart"], emits: ["click", "touchstart"],
props: { props: {
imgradius: { imgradius: {
default: '0' default: "0",
},
imgType: {
default: "",
}, },
// //
name: { name: {
type: String, type: String,
default: "" default: "",
}, },
// //
color: { color: {
type: [String, null], type: [String, null],
default: "" default: "",
}, },
// rpx // rpx
size: { size: {
type: [Number, String], type: [Number, String],
default: "inherit" default: "inherit",
}, },
// //
bold: { bold: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
// index // index
index: { index: {
type: [Number, String], type: [Number, String],
default: "" default: "",
}, },
// //
hoverClass: { hoverClass: {
type: String, type: String,
default: "" default: "",
}, },
// 便 // 便
customPrefix: { customPrefix: {
type: String, type: String,
default: "uicon" default: "uicon",
}, },
// //
label: { label: {
type: [String, Number], type: [String, Number],
default: "" default: "",
}, },
// label // label
labelPos: { labelPos: {
type: String, type: String,
default: "right" default: "right",
}, },
// label // label
labelSize: { labelSize: {
type: [String, Number], type: [String, Number],
default: "28" default: "28",
}, },
// label // label
labelColor: { labelColor: {
type: String, type: String,
default: "#606266" default: "#606266",
}, },
// label() // label()
marginLeft: { marginLeft: {
type: [String, Number], type: [String, Number],
default: "6" default: "6",
}, },
// label() // label()
marginTop: { marginTop: {
type: [String, Number], type: [String, Number],
default: "6" default: "6",
}, },
// label() // label()
marginRight: { marginRight: {
type: [String, Number], type: [String, Number],
default: "6" default: "6",
}, },
// label() // label()
marginBottom: { marginBottom: {
type: [String, Number], type: [String, Number],
default: "6" default: "6",
}, },
// mode // mode
imgMode: { imgMode: {
type: String, type: String,
default: "widthFix" default: "widthFix",
}, },
// //
customStyle: { customStyle: {
type: Object, type: Object,
default() { default() {
return {}; return {};
} },
}, },
// //
width: { width: {
type: [String, Number], type: [String, Number],
default: "" default: "",
}, },
// //
height: { height: {
type: [String, Number], type: [String, Number],
default: "" default: "",
}, },
// //
top: { top: {
type: [String, Number], type: [String, Number],
default: 0 default: 0,
}, },
// DecimalIcon // DecimalIcon
showDecimalIcon: { showDecimalIcon: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
// Decimal // Decimal
inactiveColor: { inactiveColor: {
type: String, type: String,
default: "#ececec" default: "#ececec",
}, },
// Decimal // Decimal
percent: { percent: {
type: [Number, String], type: [Number, String],
default: "50" default: "50",
} },
}, },
computed: { computed: {
customClass() { customClass() {
@ -211,14 +205,9 @@ export default {
classes.push(customPrefix); classes.push(customPrefix);
} }
// //
if ( if (this.showDecimalIcon && this.inactiveColor && this.$u.config.type.includes(this.inactiveColor)) {
this.showDecimalIcon &&
this.inactiveColor &&
this.$u.config.type.includes(this.inactiveColor)
) {
classes.push("u-icon__icon--" + this.inactiveColor); classes.push("u-icon__icon--" + this.inactiveColor);
} else if (this.color && this.$u.config.type.includes(this.color)) } else if (this.color && this.$u.config.type.includes(this.color)) classes.push("u-icon__icon--" + this.color);
classes.push("u-icon__icon--" + this.color);
// 使[a, b, c] // 使[a, b, c]
// //
//#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU //#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
@ -232,14 +221,10 @@ export default {
fontSize: this.size == "inherit" ? "inherit" : this.$u.addUnit(this.size), fontSize: this.size == "inherit" ? "inherit" : this.$u.addUnit(this.size),
fontWeight: this.bold ? "bold" : "normal", fontWeight: this.bold ? "bold" : "normal",
// //
top: this.$u.addUnit(this.top) top: this.$u.addUnit(this.top),
}; };
// //
if ( if (this.showDecimalIcon && this.inactiveColor && !this.$u.config.type.includes(this.inactiveColor)) {
this.showDecimalIcon &&
this.inactiveColor &&
!this.$u.config.type.includes(this.inactiveColor)
) {
style.color = this.inactiveColor; style.color = this.inactiveColor;
} else if (this.color && !this.$u.config.type.includes(this.color)) style.color = this.color; } 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", fontWeight: this.bold ? "bold" : "normal",
// //
top: this.$u.addUnit(this.top), 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; if (this.color && !this.$u.config.type.includes(this.color)) style.color = this.color;
@ -280,8 +265,7 @@ export default {
classes.push(this.customPrefix); classes.push(this.customPrefix);
} }
// //
if (this.color && this.$u.config.type.includes(this.color)) if (this.color && this.$u.config.type.includes(this.color)) classes.push("u-icon__icon--" + this.color);
classes.push("u-icon__icon--" + this.color);
else classes.push("u-icon__icon--primary"); else classes.push("u-icon__icon--primary");
// 使[a, b, c] // 使[a, b, c]
// //
@ -289,7 +273,7 @@ export default {
classes = classes.join(" "); classes = classes.join(" ");
//#endif //#endif
return classes; return classes;
} },
}, },
methods: { methods: {
click() { click() {
@ -297,15 +281,45 @@ export default {
}, },
touchstart() { touchstart() {
this.$emit("touchstart", this.index); this.$emit("touchstart", this.index);
} },
} },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "../../libs/css/style.components.scss"; @import "../../libs/css/style.components.scss";
@import "../../iconfont.css"; @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 { .u-icon {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;

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

Loading…
Cancel
Save