|
|
|
@ -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;
|
|
|
|
|