1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
| <template>
| <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:1 63,营业执照号: 9 15 10131 3 3 20061 9 3K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
| <!-- #ifndef APP-NVUE -->
| <text :style="{ color:getColor, fontSize: getSize, fontWeight: fontWeight}" class="fui-icon"
| :class="[!getColor && !primary?'fui-icon__color':'',primary && (!color || color===true)?'fui-icon__active-color':'',disabled?'fui-icon__not-allowed':'',customPrefix && customPrefix!==true?customPrefix:'',customPrefix && customPrefix!==true?name:'']"
| @click="handleClick">{{ icons[name] || '' }}</text>
| <!-- #endif -->
| <!-- #ifdef APP-NVUE -->
| <text
| :style="{ color: primary && (!color || color===true)?primaryColor:getColor, fontSize: getSize,lineHeight:getSize, fontWeight: fontWeight}"
| class="fui-icon" :class="[customPrefix && customPrefix!==true?customPrefix:'']"
| @click="handleClick">{{ customPrefix && customPrefix!==true?name:icons[name] }}</text>
| <!-- #endif -->
| </template>
|
| <script>
| import icons from './fui-icon.js';
| // #ifdef APP-NVUE
| var domModule = weex.requireModule('dom');
| import fuiicons from './fui-icon.ttf'
| domModule.addRule('fontFace', {
| 'fontFamily': 'fuiFont',
| 'src': "url('" + fuiicons + "')"
| });
| // #endif
|
| export default {
| name: "fui-icon",
| emits: ['click'],
| // #ifdef MP-WEIXIN
| options: {
| addGlobalClass: true
| },
| // #endif
| props: {
| name: {
| type: String,
| default: ''
| },
| size: {
| type: [Number, String],
| default: 0
| },
| //rpx | px
| unit: {
| type: String,
| default: ''
| },
| color: {
| type: String,
| default: ''
| },
| //字重
| fontWeight: {
| type: [Number, String],
| default: 'normal'
| },
| //是否禁用点击
| disabled: {
| type: Boolean,
| default: false
| },
| params: {
| type: [Number, String],
| default: 0
| },
| customPrefix: {
| type: String,
| default: ''
| },
| //是否显示为主色调,color为空时有效。【内部使用】
| primary: {
| type: Boolean,
| default: false
| }
| },
| computed: {
| getSize() {
| const size = (uni.$fui && uni.$fui.fuiIcon && uni.$fui.fuiIcon.size) || 64
| const unit = (uni.$fui && uni.$fui.fuiIcon && uni.$fui.fuiIcon.unit) || 'rpx'
| return (this.size || size) + (this.unit || unit)
| },
| primaryColor() {
| const app = uni && uni.$fui && uni.$fui.color;
| return (app && app.primary) || '#465CFF';
| },
| getColor() {
| const app = uni && uni.$fui && uni.$fui.fuiIcon;
| let color = this.color;
| if (!color || (color && color === true)) {
| color = (app && app.color)
| }
| // #ifdef APP-NVUE
| if (!color || color === true) {
| color = '#333333'
| }
| // #endif
| return color;
| }
| },
| data() {
| return {
| icons: icons
| };
| },
| methods: {
| handleClick() {
| if (this.disabled) return;
| this.$emit('click', {
| params: this.params
| });
| }
| }
| }
| </script>
|
| <style scoped>
| /* #ifndef APP-NVUE */
| /* 头条小程序组件内不能引入字体,需要在父级页面引入字体文件*/
| @font-face {
| font-family: fuiFont;
| src: url("./fui-icon.ttf") format("truetype");
| }
|
| /* #endif */
| .fui-icon {
| font-family: fuiFont;
| text-decoration: none;
| text-align: center;
| /* #ifdef H5 */
| cursor: pointer;
| /* #endif */
| }
|
| /* #ifndef APP-NVUE */
| .fui-icon__color {
| color: var(--fui-color-section, #333333) !important;
| }
|
| .fui-icon__active-color {
| color: var(--fui-color-primary, #465CFF) !important;
| }
|
| /* #endif */
|
| .fui-icon__not-allowed {
| /* #ifdef H5 */
| cursor: not-allowed !important;
| /* #endif */
| }
| </style>
|
|