@netang/quasar 0.0.78 → 0.0.80
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.
- package/components/img/index.vue +25 -2
- package/components/price/index.vue +188 -0
- package/package.json +1 -1
- package/sass/common.scss +2 -2
- package/utils/config.js +0 -1
- package/utils/price.js +3 -7
package/components/img/index.vue
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<q-img
|
|
3
|
+
class="n-img"
|
|
4
|
+
:class="{
|
|
5
|
+
'rounded-borders': rounded,
|
|
6
|
+
'n-img--round': round,
|
|
7
|
+
}"
|
|
3
8
|
:src="currentSrc"
|
|
4
9
|
:width="imageProps.width"
|
|
5
10
|
:height="imageProps.height"
|
|
@@ -33,7 +38,11 @@
|
|
|
33
38
|
|
|
34
39
|
<!-- 如果没有图片 -->
|
|
35
40
|
<div
|
|
36
|
-
class="q-img"
|
|
41
|
+
class="q-img n-img"
|
|
42
|
+
:class="{
|
|
43
|
+
'rounded-borders': rounded,
|
|
44
|
+
'n-img--round': round,
|
|
45
|
+
}"
|
|
37
46
|
v-bind="imageProps"
|
|
38
47
|
v-else
|
|
39
48
|
>
|
|
@@ -81,6 +90,10 @@ export default {
|
|
|
81
90
|
width: [ String, Number ],
|
|
82
91
|
// 高
|
|
83
92
|
height: [ String, Number ],
|
|
93
|
+
// 是否为圆形
|
|
94
|
+
round: Boolean,
|
|
95
|
+
// 是否为圆角
|
|
96
|
+
rounded: Boolean,
|
|
84
97
|
// 加载旋转器尺寸
|
|
85
98
|
spinnerSize: [ String, Number ],
|
|
86
99
|
// 错误尺寸
|
|
@@ -91,7 +104,7 @@ export default {
|
|
|
91
104
|
// 错误图标大小
|
|
92
105
|
errorIconSize: {
|
|
93
106
|
type: String,
|
|
94
|
-
default: '
|
|
107
|
+
default: 'md',
|
|
95
108
|
},
|
|
96
109
|
// 错误图标
|
|
97
110
|
errorIcon: {
|
|
@@ -177,3 +190,13 @@ export default {
|
|
|
177
190
|
}
|
|
178
191
|
}
|
|
179
192
|
</script>
|
|
193
|
+
|
|
194
|
+
<style lang="scss">
|
|
195
|
+
.n-img {
|
|
196
|
+
// 圆形
|
|
197
|
+
&--round {
|
|
198
|
+
border-radius: 50%;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
</style>
|
|
202
|
+
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="n-price">
|
|
3
|
+
<!-- 价格符号 -->
|
|
4
|
+
<span v-if="sign" :style="signStyle">{{sign}}</span>
|
|
5
|
+
<!-- 价格 -->
|
|
6
|
+
<span :style="priceStyle">{{currentPrice.main}}</span>
|
|
7
|
+
<!-- 价格后缀 -->
|
|
8
|
+
<span :style="signStyle" v-if="currentPrice.odd">{{currentPrice.odd}}</span>
|
|
9
|
+
<!-- 删除价格 -->
|
|
10
|
+
<span class="n-price__del" :style="[
|
|
11
|
+
signBaseStyle,
|
|
12
|
+
{
|
|
13
|
+
marginLeft: toPx(delPriceMarginLeft),
|
|
14
|
+
color: delPriceColor,
|
|
15
|
+
}
|
|
16
|
+
]" v-if="delPrice && delPrice > price">{{sign}}{{getPrice(delPrice)}}</span>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { computed } from 'vue'
|
|
22
|
+
|
|
23
|
+
import $n_px from '@netang/utils/px'
|
|
24
|
+
import $n_split from '@netang/utils/split'
|
|
25
|
+
|
|
26
|
+
import $n_price from '../../utils/price'
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 标识
|
|
32
|
+
*/
|
|
33
|
+
name: 'NPrice',
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 声明属性
|
|
37
|
+
*/
|
|
38
|
+
props: {
|
|
39
|
+
// 颜色
|
|
40
|
+
color: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: '#ff3750',
|
|
43
|
+
},
|
|
44
|
+
// 删除价格颜色
|
|
45
|
+
delPriceColor: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: '#999999',
|
|
48
|
+
},
|
|
49
|
+
// 价格符号
|
|
50
|
+
sign: {
|
|
51
|
+
type: [ String, Boolean ],
|
|
52
|
+
default: '¥'
|
|
53
|
+
},
|
|
54
|
+
// 价格符号大小
|
|
55
|
+
signSize: {
|
|
56
|
+
type: Number,
|
|
57
|
+
default: 12,
|
|
58
|
+
},
|
|
59
|
+
// 价格符号是否加粗
|
|
60
|
+
signBold: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true,
|
|
63
|
+
},
|
|
64
|
+
// 价格
|
|
65
|
+
price: [ String, Number ],
|
|
66
|
+
// 最高价格
|
|
67
|
+
maxPrice: [ String, Number ],
|
|
68
|
+
// 删除价格
|
|
69
|
+
delPrice: [ String, Number ],
|
|
70
|
+
// 删除价格左边距
|
|
71
|
+
delPriceMarginLeft: {
|
|
72
|
+
type: [ String, Number ],
|
|
73
|
+
default: 8,
|
|
74
|
+
},
|
|
75
|
+
// 价格符号大小
|
|
76
|
+
priceSize: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: 16,
|
|
79
|
+
},
|
|
80
|
+
// 价格是否加粗
|
|
81
|
+
priceBold: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: true,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 组合式
|
|
89
|
+
*/
|
|
90
|
+
setup(props) {
|
|
91
|
+
|
|
92
|
+
// ==========【计算属性】==========================================================================================
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 当前价格
|
|
96
|
+
*/
|
|
97
|
+
const currentPrice = computed(function () {
|
|
98
|
+
|
|
99
|
+
const price = $n_price(props.price)
|
|
100
|
+
const arr = $n_split(String(price), '.')
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
main: arr[0],
|
|
104
|
+
odd: arr.length > 1 ? '.' + arr[1] : ''
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 价格符号基础样式
|
|
110
|
+
*/
|
|
111
|
+
const signBaseStyle = computed(function () {
|
|
112
|
+
return {
|
|
113
|
+
fontSize: $n_px(props.signSize),
|
|
114
|
+
marginBottom: $n_px((props.priceSize - props.signSize) * 0.5 / 2),
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 价格符号样式
|
|
120
|
+
*/
|
|
121
|
+
const signStyle = computed(function () {
|
|
122
|
+
|
|
123
|
+
const style = {
|
|
124
|
+
color: props.color,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (props.signBold) {
|
|
128
|
+
style.fontWeight = 'bold'
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return [
|
|
132
|
+
style,
|
|
133
|
+
signBaseStyle.value,
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 价格样式
|
|
139
|
+
*/
|
|
140
|
+
const priceStyle = computed(function () {
|
|
141
|
+
|
|
142
|
+
const style = {
|
|
143
|
+
color: props.color,
|
|
144
|
+
fontSize: $n_px(props.priceSize),
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (props.priceBold) {
|
|
148
|
+
style.fontWeight = 'bold'
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return style
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
// ==========【方法】=============================================================================================
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
// 当前价格
|
|
158
|
+
currentPrice,
|
|
159
|
+
// 价格符号基础样式
|
|
160
|
+
signBaseStyle,
|
|
161
|
+
// 价格符号样式
|
|
162
|
+
signStyle,
|
|
163
|
+
// 价格样式
|
|
164
|
+
priceStyle,
|
|
165
|
+
|
|
166
|
+
// 转为像素
|
|
167
|
+
toPx: $n_px,
|
|
168
|
+
// 获取价格
|
|
169
|
+
getPrice: $n_price
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<style lang="scss">
|
|
176
|
+
|
|
177
|
+
.n-price {
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: row;
|
|
180
|
+
align-items: flex-end;
|
|
181
|
+
|
|
182
|
+
// 删除价格
|
|
183
|
+
&__del {
|
|
184
|
+
text-decoration: line-through;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
</style>
|
package/package.json
CHANGED
package/sass/common.scss
CHANGED
package/utils/config.js
CHANGED
package/utils/price.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import $n_decimal from '@netang/utils/decimal'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
// 是否开启人民币分转元
|
|
7
|
-
priceCentToYuan,
|
|
8
|
-
} = configs
|
|
3
|
+
import $n_config from './config'
|
|
9
4
|
|
|
10
5
|
/**
|
|
11
6
|
* 换算金额
|
|
12
7
|
*/
|
|
13
8
|
export default function price(value, params) {
|
|
9
|
+
|
|
14
10
|
return $n_decimal(value, Object.assign({
|
|
15
11
|
// 最小值
|
|
16
12
|
min: 0,
|
|
17
13
|
// 小数点位数
|
|
18
14
|
decimalLength: 2,
|
|
19
15
|
// 是否开启人民币分转元(如值 189 -> 1.89)
|
|
20
|
-
centToYuan: priceCentToYuan === true,
|
|
16
|
+
centToYuan: $n_config('priceCentToYuan') === true,
|
|
21
17
|
}, params))
|
|
22
18
|
}
|