Commit a72c68ce87731d3837176329ffe663a9361ffa60

Authored by sfmind
1 parent 64df5ce5

微调组件显示

yudao-ui-app/components/yd-text-price/yd-text-price.vue
1 <template> 1 <template>
2 <view> 2 <view>
3 - <text v-for="(item, index) in textArray" :key="index" :style="{ 'font-size': (index === 1 ? integerSize : size) + 'px', 'color': color }"> 3 + <text v-for="(item, index) in textArray" :key="index" :style="{ fontSize: (index === 1 ? integerSize : size) + 'px', color, textDecoration }">
4 {{ item }} 4 {{ item }}
5 </text> 5 </text>
6 </view> 6 </view>
@@ -8,15 +8,20 @@ @@ -8,15 +8,20 @@
8 8
9 <script> 9 <script>
10 /** 10 /**
11 - * 此组件简单的显示特定样式的(人名币)价格数字 11 + * 此组件简单的显示(驼峰式)的价格
12 */ 12 */
13 export default { 13 export default {
14 name: 'yd-text-price', 14 name: 'yd-text-price',
15 components: {}, 15 components: {},
16 props: { 16 props: {
  17 + //货币符号
  18 + symbol: {
  19 + type: String,
  20 + default: '¥'
  21 + },
17 price: { 22 price: {
18 type: [String, Number], 23 type: [String, Number],
19 - default: '0.00' 24 + default: ''
20 }, 25 },
21 color: { 26 color: {
22 type: String, 27 type: String,
@@ -30,14 +35,28 @@ export default { @@ -30,14 +35,28 @@ export default {
30 //整形部分字体大小可单独定义 35 //整形部分字体大小可单独定义
31 intSize: { 36 intSize: {
32 type: [String, Number], 37 type: [String, Number],
33 - default: 15 38 + default: ''
  39 + },
  40 + //文字装饰,下划线,中划线等
  41 + decoration: {
  42 + type: String,
  43 + default: 'none'
  44 + }
  45 + },
  46 + data() {
  47 + return {
  48 + textDecoration: this.decoration
34 } 49 }
35 }, 50 },
36 computed: { 51 computed: {
37 textArray() { 52 textArray() {
38 - let array = ['¥'] 53 + let array = []
  54 + if (this.price === '' || this.price === undefined) {
  55 + return []
  56 + }
  57 + array.push(this.symbol)
39 if (!/^\d+(\.\d+)?$/.test(this.price)) { 58 if (!/^\d+(\.\d+)?$/.test(this.price)) {
40 - console.error('组件<custom-text-price :text="???" 此处参数应为金额数字') 59 + console.error('组件<yd-text-price :text="???" 此处参数应为金额数字')
41 } else { 60 } else {
42 let arr = parseFloat(this.price).toFixed(2).split('.') 61 let arr = parseFloat(this.price).toFixed(2).split('.')
43 array.push(arr[0]) 62 array.push(arr[0])
yudao-ui-app/pages/index/index.vue
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 <!--商品展示栏--> 28 <!--商品展示栏-->
29 <yd-product-box :product-list="productList" :title="'每日上新'" show-type="normal"></yd-product-box> 29 <yd-product-box :product-list="productList" :title="'每日上新'" show-type="normal"></yd-product-box>
30 <yd-product-box :product-list="productList" :title="'热卖商品'" show-type="half"></yd-product-box> 30 <yd-product-box :product-list="productList" :title="'热卖商品'" show-type="half"></yd-product-box>
31 - <yd-product-more :product-list="productList" more-status="moreStatus"></yd-product-more> 31 + <yd-product-more :product-list="productList" :more-status="moreStatus"></yd-product-more>
32 32
33 <u-gap height="5px"></u-gap> 33 <u-gap height="5px"></u-gap>
34 </view> 34 </view>