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
| <template>
| <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID: 163,营业执照号:91 51 0 1 31 3320 06 1 93 K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
| <text class="fui-digitalnumbers"
| :class="{'fui-number__highlight':!disabled && highlight,'fui-number__color':!color || color===true}"
| :style="{color:getColor, fontSize: getSize, fontWeight: fontWeight,lineHeight:lineHeight?getSize:'auto',textDecoration:decoration}"
| @click="handleClick">{{text}}</text>
| </template>
|
| <script>
| // #ifdef APP-NVUE
| var domModule = weex.requireModule('dom');
| import fuinumbers from './numbers.ttf'
| domModule.addRule('fontFace', {
| 'fontFamily': 'DigitalNumbers',
| 'src': "url('" + fuinumbers + "')"
| });
| // #endif
| export default {
| emits: ['click'],
| name: "fui-number",
| // #ifdef MP-WEIXIN
| options: {
| virtualHost: true,
| addGlobalClass: true
| },
| // #endif
| props: {
| //数字值
| text: {
| type: [Number, String],
| default: ''
| },
| size: {
| type: [Number, String],
| default: 0
| },
| //rpx | px
| unit: {
| type: String,
| default: ''
| },
| color: {
| type: String,
| default: '#333'
| },
| //字重
| fontWeight: {
| type: [Number, String],
| default: 'normal'
| },
| //是否禁用点击
| disabled: {
| type: Boolean,
| default: false
| },
| //是否有点击效果
| highlight: {
| type: Boolean,
| default: false
| },
| //none、 underline、line-through
| decoration: {
| type: String,
| default: 'none'
| },
| //是否将行高设置与字体大小一致
| lineHeight: {
| type: Boolean,
| default: false
| },
| params: {
| type: [Number, String],
| default: 0
| }
| },
| computed: {
| getSize() {
| const size = (uni.$fui && uni.$fui.fuiNumber && uni.$fui.fuiNumber.size) || 32
| const unit = (uni.$fui && uni.$fui.fuiNumber && uni.$fui.fuiNumber.unit) || 'rpx'
| return (this.size || size) + (this.unit || unit)
| },
| getColor() {
| let color = this.color;
| // #ifdef APP-NVUE
| if (!color && color !== true) {
| color = '#333333'
| }
| // #endif
| return color;
| }
| },
| methods: {
| handleClick() {
| if (this.disabled) return;
| this.$emit('click', {
| text: this.text,
| params: this.params
| });
| }
| }
| }
| </script>
|
| <style scoped>
| /* #ifndef APP-NVUE */
| /* 头条小程序组件内不能引入字体,需要在父级页面引入字体文件*/
| @font-face {
| font-family: DigitalNumbers;
| src: url("./numbers.ttf") format("truetype");
| font-weight: normal;
| font-style: normal;
| }
|
| .fui-number__color {
| color: var(--fui-color-section, #333333) !important;
| }
|
| /* #endif */
|
| .fui-digitalnumbers {
| font-family: DigitalNumbers;
| text-decoration: none;
| }
|
| .fui-number__highlight {
| /* #ifdef H5 */
| cursor: pointer;
| /* #endif */
| opacity: 1;
| }
|
| .fui-number__highlight:active {
| opacity: .5;
| }
| </style>
|
|