stellar-ui-v2 1.40.21 → 1.40.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,256 +1,256 @@
1
- <template>
2
- <view class="ste-price-root">
3
- <view class="content" :style="[cmpPriceStyle]">
4
- <text v-if="showUnit" class="unit" :style="[cmpUnitStyle]">{{ unitSymbol }}</text>
5
- <text class="yuan-price" :style="[cmpYuanPriceStyle]">{{ cmpYuanValue }}</text>
6
- <text v-if="valueUnit === 'fen'" class="fen-price" :style="[cmpFenPriceStyle]">{{ cmpFenValue }}</text>
7
- </view>
8
- </view>
9
- </template>
10
-
11
- <script>
12
- import utils from '../../utils/utils.js';
13
- /**
14
- * ste-price 价格
15
- * @description 金额组件
16
- * @tutorial https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui&menu=%E7%BB%84%E4%BB%B6&active=ste-price
17
- * @property {Number|String} value 金额 默认值 0
18
- * @property {String} valueUnit 金额单位
19
- * @value fen 分(默认值){String}
20
- * @value yuan 元{String}
21
- * @property {Boolean} showUnit 是否显示符号
22
- * @property {String} unitSymbol 符号标记,默认值 ¥
23
- * @property {Number} digits 精度 默认值 -1
24
- * @value -1 不处理(默认值){Number}
25
- * @value 0 取整(四舍五入){Number}
26
- * @value 1 保留1位小数(四舍五入){Number}
27
- * @value 2 保留2位小数(四舍五入){Number}
28
- * @property {Number|String} fontSize 金额文字尺寸 默认值 30
29
- * @property {String} color 文字颜色 默认值 #ff1e19
30
- * @property {String} linePriceColor 划线价文字颜色 默认值 #999999
31
- * @property {Number|String} lineHeight 行高,Number,单位rpx,String,同原生 默认值 1
32
- * @property {Boolean} isSuggestPrice 是否划线价 默认值 false
33
- * @property {Number|String} marginLeft 左边距 默认值 0
34
- * @property {Number|String} marginRight 右边距 默认值 0
35
- * @property {Number|String} marginTop 上边距 默认值 0
36
- * @property {Number|String} marginBottom 下边距 默认值 0
37
- * @property {Number} styleType 金额样式 默认值 2
38
- * @property {Boolean} bold 是否加粗 默认值 false
39
- * @property {Function(value)} formatter 用来格式化内容
40
- */
41
- export default {
42
- group: '电商组件',
43
- title: 'Price 价格',
44
- name: 'ste-price',
45
- props: {
46
- // 金额
47
- value: {
48
- type: [Number, String, null],
49
- default: 0
50
- },
51
- // 金额单位,fen | yuan,当为fen(分)时,值除以100
52
- valueUnit: {
53
- type: [String, null],
54
- default: 'fen'
55
- },
56
- // 精度 -1 不使用精度 0 保留0位小数 1 保留1位小数 2保留2位小数
57
- digits: {
58
- type: [Number, null],
59
- default: -1
60
- },
61
- // 是否显示单位符号
62
- showUnit: {
63
- type: [Boolean, null],
64
- default: true
65
- },
66
- // 单位符号
67
- unitSymbol: {
68
- type: [String, null],
69
- default: '¥'
70
- },
71
- // 金额文字尺寸
72
- fontSize: {
73
- type: [Number, String, null],
74
- default: 30
75
- },
76
- // 金额文字颜
77
- color: {
78
- type: [String, null, null],
79
- default: '#FF1E19'
80
- },
81
- // 划线价颜色
82
- linePriceColor: {
83
- type: [String, null, null],
84
- default: '#999999'
85
- },
86
- // 行高,默认值为-1,当为-1是,line-height:1
87
- lineHeight: {
88
- type: [Number, String, null],
89
- default: -1
90
- },
91
- // 是否是划线价
92
- isSuggestPrice: {
93
- type: [Boolean, null],
94
- default: false
95
- },
96
- // 左margin
97
- marginLeft: {
98
- type: [Number, String, null],
99
- default: 0
100
- }, // 右margin
101
- marginRight: {
102
- type: [Number, String, null],
103
- default: 0
104
- },
105
- // 上margin
106
- marginTop: {
107
- type: [Number, String, null],
108
- default: 0
109
- }, // 下margin
110
- marginBottom: {
111
- type: [Number, String, null],
112
- default: 0
113
- },
114
- // 金额样式 1 元和角分大小相等(特殊价格) 2 角分小于元(常规价格)3 价格符号和角,分相等
115
- styleType: {
116
- type: [Number, null],
117
- default: 2
118
- },
119
- bold: {
120
- type: [Boolean, null],
121
- default: false
122
- },
123
- // 过滤器
124
- formatter: {
125
- type: [Function, null],
126
- default: undefined
127
- }
128
- },
129
- data() {
130
- return {};
131
- },
132
- computed: {
133
- cmpValue() {
134
- if (this.formatter && typeof this.formatter === 'function') {
135
- return this.formatter(this.value);
136
- }
137
-
138
- let value = this.value;
139
- if (this.valueUnit == 'fen') {
140
- value = utils.fenToYuan(this.value, -1, '', 0);
141
- }
142
- if (this.digits == -1) {
143
- value = Number.parseFloat(Number(value)).toString();
144
- } else {
145
- value = Number(value).toFixed(this.digits).toString();
146
- }
147
- return value;
148
- },
149
- cmpYuanValue() {
150
- if (this.cmpValue) {
151
- if (this.cmpValue.indexOf('.') > -1) {
152
- return this.cmpValue.split('.')[0];
153
- } else {
154
- return this.cmpValue;
155
- }
156
- } else {
157
- return utils.fenToYuan(this.value, -1, '', 1);
158
- }
159
- },
160
- cmpFenValue() {
161
- if (this.cmpValue) {
162
- if (this.cmpValue.indexOf('.') > -1) {
163
- return '.' + this.cmpValue.split('.')[1];
164
- }
165
- return '';
166
- } else {
167
- return utils.fenToYuan(this.value, -1, '', 2);
168
- }
169
- },
170
- cmpPriceStyle() {
171
- return {
172
- lineHeight: this.lineHeight === -1 ? 0.8 : utils.formatPx(this.lineHeight),
173
- color: (this.isSuggestPrice ? this.linePriceColor : this.color) + ' !important',
174
- marginLeft: utils.formatPx(this.marginLeft),
175
- marginRight: utils.formatPx(this.marginRight),
176
- marginTop: utils.formatPx(this.marginTop),
177
- marginBottom: utils.formatPx(this.marginBottom),
178
- fontWeight: this.bold ? 'bold' : 'normal'
179
- };
180
- },
181
- cmpUnitStyle() {
182
- let style = {
183
- textDecoration: this.isSuggestPrice ? 'line-through' : 'none',
184
- color: (this.isSuggestPrice ? this.linePriceColor : this.color) + ' !important'
185
- };
186
-
187
- if (this.isSuggestPrice) {
188
- style.color = this.linePriceColor;
189
- style.fontSize = utils.formatPx(this.fontSize);
190
- } else {
191
- style.fontSize = this.calcFontSize();
192
- }
193
- return style;
194
- },
195
- cmpYuanPriceStyle() {
196
- return {
197
- fontSize: utils.formatPx(this.fontSize),
198
- textDecoration: this.isSuggestPrice ? 'line-through' : 'none'
199
- };
200
- },
201
- cmpFenPriceStyle() {
202
- let fontSize = 0;
203
- if (this.isSuggestPrice) {
204
- fontSize = utils.formatPx(this.fontSize);
205
- } else {
206
- if (this.styleType == 2) {
207
- fontSize = this.calcFontSize();
208
- } else {
209
- fontSize = utils.formatPx(this.fontSize);
210
- }
211
- }
212
- return {
213
- fontSize,
214
- textDecoration: this.isSuggestPrice ? 'line-through' : 'none'
215
- };
216
- }
217
- },
218
- methods: {
219
- calcFontSize() {
220
- let size = utils.formatPx(this.fontSize);
221
- if (this.styleType == 1) {
222
- if (this.fontSize <= 40) {
223
- size = utils.formatPx(20);
224
- } else {
225
- size = utils.formatPx(this.fontSize - 20);
226
- }
227
- } else if (this.styleType == 3) {
228
- size = utils.formatPx(this.fontSize);
229
- } else {
230
- // 常规 - 分元不一致
231
- if (this.fontSize > 28 && this.fontSize <= 40) {
232
- size = utils.formatPx(20);
233
- } else if (this.fontSize > 40) {
234
- size = utils.formatPx(this.fontSize - 20);
235
- }
236
- }
237
- return size;
238
- }
239
- }
240
- };
241
- </script>
242
-
243
- <style lang="scss" scoped>
244
- .ste-price-root {
245
- display: inline-flex;
246
- .content {
247
- display: inline-block;
248
- vertical-align: bottom;
249
- }
250
- .unit {
251
- vertical-align: baseline;
252
- }
253
- .yuan-price {
254
- }
255
- }
256
- </style>
1
+ <template>
2
+ <view class="ste-price-root">
3
+ <view class="content" :style="[cmpPriceStyle]">
4
+ <text v-if="showUnit" class="unit" :style="[cmpUnitStyle]">{{ unitSymbol }}</text>
5
+ <text class="yuan-price" :style="[cmpYuanPriceStyle]">{{ cmpYuanValue }}</text>
6
+ <text v-if="valueUnit === 'fen'" class="fen-price" :style="[cmpFenPriceStyle]">{{ cmpFenValue }}</text>
7
+ </view>
8
+ </view>
9
+ </template>
10
+
11
+ <script>
12
+ import utils from '../../utils/utils.js';
13
+ /**
14
+ * ste-price 价格
15
+ * @description 金额组件
16
+ * @tutorial https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui&menu=%E7%BB%84%E4%BB%B6&active=ste-price
17
+ * @property {Number|String} value 金额 默认值 0
18
+ * @property {String} valueUnit 金额单位
19
+ * @value fen 分(默认值){String}
20
+ * @value yuan 元{String}
21
+ * @property {Boolean} showUnit 是否显示符号
22
+ * @property {String} unitSymbol 符号标记,默认值 ¥
23
+ * @property {Number} digits 精度 默认值 -1
24
+ * @value -1 不处理(默认值){Number}
25
+ * @value 0 取整(四舍五入){Number}
26
+ * @value 1 保留1位小数(四舍五入){Number}
27
+ * @value 2 保留2位小数(四舍五入){Number}
28
+ * @property {Number|String} fontSize 金额文字尺寸 默认值 30
29
+ * @property {String} color 文字颜色 默认值 #ff1e19
30
+ * @property {String} linePriceColor 划线价文字颜色 默认值 #999999
31
+ * @property {Number|String} lineHeight 行高,Number,单位rpx,String,同原生 默认值 1
32
+ * @property {Boolean} isSuggestPrice 是否划线价 默认值 false
33
+ * @property {Number|String} marginLeft 左边距 默认值 0
34
+ * @property {Number|String} marginRight 右边距 默认值 0
35
+ * @property {Number|String} marginTop 上边距 默认值 0
36
+ * @property {Number|String} marginBottom 下边距 默认值 0
37
+ * @property {Number} styleType 金额样式 默认值 2
38
+ * @property {Boolean} bold 是否加粗 默认值 false
39
+ * @property {Function(value)} formatter 用来格式化内容
40
+ */
41
+ export default {
42
+ group: '电商组件',
43
+ title: 'Price 价格',
44
+ name: 'ste-price',
45
+ props: {
46
+ // 金额
47
+ value: {
48
+ type: [Number, String, null],
49
+ default: 0
50
+ },
51
+ // 金额单位,fen | yuan,当为fen(分)时,值除以100
52
+ valueUnit: {
53
+ type: [String, null],
54
+ default: 'fen'
55
+ },
56
+ // 精度 -1 不使用精度 0 保留0位小数 1 保留1位小数 2保留2位小数
57
+ digits: {
58
+ type: [Number, null],
59
+ default: -1
60
+ },
61
+ // 是否显示单位符号
62
+ showUnit: {
63
+ type: [Boolean, null],
64
+ default: true
65
+ },
66
+ // 单位符号
67
+ unitSymbol: {
68
+ type: [String, null],
69
+ default: '¥'
70
+ },
71
+ // 金额文字尺寸
72
+ fontSize: {
73
+ type: [Number, String, null],
74
+ default: 30
75
+ },
76
+ // 金额文字颜
77
+ color: {
78
+ type: [String, null, null],
79
+ default: '#FF1E19'
80
+ },
81
+ // 划线价颜色
82
+ linePriceColor: {
83
+ type: [String, null, null],
84
+ default: '#999999'
85
+ },
86
+ // 行高,默认值为-1,当为-1是,line-height:1
87
+ lineHeight: {
88
+ type: [Number, String, null],
89
+ default: -1
90
+ },
91
+ // 是否是划线价
92
+ isSuggestPrice: {
93
+ type: [Boolean, null],
94
+ default: false
95
+ },
96
+ // 左margin
97
+ marginLeft: {
98
+ type: [Number, String, null],
99
+ default: 0
100
+ }, // 右margin
101
+ marginRight: {
102
+ type: [Number, String, null],
103
+ default: 0
104
+ },
105
+ // 上margin
106
+ marginTop: {
107
+ type: [Number, String, null],
108
+ default: 0
109
+ }, // 下margin
110
+ marginBottom: {
111
+ type: [Number, String, null],
112
+ default: 0
113
+ },
114
+ // 金额样式 1 元和角分大小相等(特殊价格) 2 角分小于元(常规价格)3 价格符号和角,分相等
115
+ styleType: {
116
+ type: [Number, null],
117
+ default: 2
118
+ },
119
+ bold: {
120
+ type: [Boolean, null],
121
+ default: false
122
+ },
123
+ // 过滤器
124
+ formatter: {
125
+ type: [Function, null],
126
+ default: undefined
127
+ }
128
+ },
129
+ data() {
130
+ return {};
131
+ },
132
+ computed: {
133
+ cmpValue() {
134
+ if (this.formatter && typeof this.formatter === 'function') {
135
+ return this.formatter(this.value);
136
+ }
137
+
138
+ let value = this.value;
139
+ if (this.valueUnit == 'fen') {
140
+ value = utils.fenToYuan(this.value, -1, '', 0);
141
+ }
142
+ if (this.digits == -1) {
143
+ value = Number.parseFloat(Number(value)).toString();
144
+ } else {
145
+ value = Number(value).toFixed(this.digits).toString();
146
+ }
147
+ return value;
148
+ },
149
+ cmpYuanValue() {
150
+ if (this.cmpValue) {
151
+ if (this.cmpValue.indexOf('.') > -1) {
152
+ return this.cmpValue.split('.')[0];
153
+ } else {
154
+ return this.cmpValue;
155
+ }
156
+ } else {
157
+ return utils.fenToYuan(this.value, -1, '', 1);
158
+ }
159
+ },
160
+ cmpFenValue() {
161
+ if (this.cmpValue) {
162
+ if (this.cmpValue.indexOf('.') > -1) {
163
+ return '.' + this.cmpValue.split('.')[1];
164
+ }
165
+ return '';
166
+ } else {
167
+ return utils.fenToYuan(this.value, -1, '', 2);
168
+ }
169
+ },
170
+ cmpPriceStyle() {
171
+ return {
172
+ lineHeight: this.lineHeight === -1 ? 0.8 : utils.formatPx(this.lineHeight),
173
+ color: (this.isSuggestPrice ? this.linePriceColor : this.color) + ' !important',
174
+ marginLeft: utils.formatPx(this.marginLeft),
175
+ marginRight: utils.formatPx(this.marginRight),
176
+ marginTop: utils.formatPx(this.marginTop),
177
+ marginBottom: utils.formatPx(this.marginBottom),
178
+ fontWeight: this.bold ? 'bold' : 'normal'
179
+ };
180
+ },
181
+ cmpUnitStyle() {
182
+ let style = {
183
+ textDecoration: this.isSuggestPrice ? 'line-through' : 'none',
184
+ color: (this.isSuggestPrice ? this.linePriceColor : this.color) + ' !important'
185
+ };
186
+
187
+ if (this.isSuggestPrice) {
188
+ style.color = this.linePriceColor;
189
+ style.fontSize = utils.formatPx(this.fontSize);
190
+ } else {
191
+ style.fontSize = this.calcFontSize();
192
+ }
193
+ return style;
194
+ },
195
+ cmpYuanPriceStyle() {
196
+ return {
197
+ fontSize: utils.formatPx(this.fontSize),
198
+ textDecoration: this.isSuggestPrice ? 'line-through' : 'none'
199
+ };
200
+ },
201
+ cmpFenPriceStyle() {
202
+ let fontSize = 0;
203
+ if (this.isSuggestPrice) {
204
+ fontSize = utils.formatPx(this.fontSize);
205
+ } else {
206
+ if (this.styleType == 2) {
207
+ fontSize = this.calcFontSize();
208
+ } else {
209
+ fontSize = utils.formatPx(this.fontSize);
210
+ }
211
+ }
212
+ return {
213
+ fontSize,
214
+ textDecoration: this.isSuggestPrice ? 'line-through' : 'none'
215
+ };
216
+ }
217
+ },
218
+ methods: {
219
+ calcFontSize() {
220
+ let size = utils.formatPx(this.fontSize);
221
+ if (this.styleType == 1) {
222
+ if (this.fontSize <= 40) {
223
+ size = utils.formatPx(20);
224
+ } else {
225
+ size = utils.formatPx(this.fontSize - 20);
226
+ }
227
+ } else if (this.styleType == 3) {
228
+ size = utils.formatPx(this.fontSize);
229
+ } else {
230
+ // 常规 - 分元不一致
231
+ if (this.fontSize > 28 && this.fontSize <= 40) {
232
+ size = utils.formatPx(20);
233
+ } else if (this.fontSize > 40) {
234
+ size = utils.formatPx(this.fontSize - 20);
235
+ }
236
+ }
237
+ return size;
238
+ }
239
+ }
240
+ };
241
+ </script>
242
+
243
+ <style lang="scss" scoped>
244
+ .ste-price-root {
245
+ display: inline-flex;
246
+ .content {
247
+ display: inline-block;
248
+ vertical-align: bottom;
249
+ }
250
+ .unit {
251
+ vertical-align: baseline;
252
+ }
253
+ .yuan-price {
254
+ }
255
+ }
256
+ </style>
@@ -90,19 +90,19 @@ export default {
90
90
  ### API
91
91
  #### 组件属性(Props)
92
92
 
93
- | 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
94
- | --- | --- | --- | --- | --- | --- |
95
- | `value` | 当前评分数(支持v-model双向绑定) | `Number` | `0` | - | - |
96
- | `count` | 图标总数 | `Number` | `5` | - | - |
97
- | `score` | 每颗星星代表的分数 | `Number` | `1` | - | - |
98
- | `disabled` | 禁用 | `Boolean` | `false` | - | - |
99
- | `readonly ` | 只读(不置灰) | `Boolean` | `false` | - | - |
100
- | `size` | 评分图标的大小,单位`rpx` | `Number/String` | `44` | - | - |
101
- | `inactiveColor` | 未选中的颜色 | `String` | `#dddddd` | - | - |
102
- | `activeColor` | 选中的颜色 | `String` | `#0090FF` | - | - |
103
- | `inactiveCode` | 未选中的图标`code` | `String` | `&#xe681;`| - | - |
104
- | `activeCode` | 选中的图标`code` | `String` | `&#xe684;`| - | - |
105
- | `gutter` | 每个图标之间的距离,单位`rpx` | `Number/String` | `10` | - | - |
93
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
94
+ | --- | --- | --- | --- | --- | --- |
95
+ | `value` | 当前评分数(支持v-model双向绑定) | `Number` | `0` | - | - |
96
+ | `count` | 图标总数 | `Number` | `5` | - | - |
97
+ | `score` | 每颗星星代表的分数 | `Number` | `1` | - | - |
98
+ | `disabled` | 禁用 | `Boolean` | `false` | - | - |
99
+ | `readonly ` | 只读(不置灰) | `Boolean` | `false` | - | - |
100
+ | `size` | 评分图标的大小,单位`rpx` | `Number/String` | `44` | - | - |
101
+ | `inactiveColor` | 未选中的颜色 | `String` | `#dddddd` | - | - |
102
+ | `activeColor` | 选中的颜色 | `String` | `#0090FF` | - | - |
103
+ | `inactiveCode` | 未选中的图标`code` | `String` | `&#xe681;`| - | - |
104
+ | `activeCode` | 选中的图标`code` | `String` | `&#xe684;`| - | - |
105
+ | `gutter` | 每个图标之间的距离,单位`rpx` | `Number/String` | `10` | - | - |
106
106
  | `iconData` | 每个分值对应的图标code | `Array` | - | - | - |
107
107
 
108
108