Commit a72c68ce87731d3837176329ffe663a9361ffa60

Authored by sfmind
1 parent 64df5ce5

微调组件显示

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