You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
46 lines
1.0 KiB
<template>
|
|
<view>
|
|
<block v-if="isPoint">
|
|
<text class="text-price lf-font-48 lf-font-bold lf-color-price">{{ showPrice(1) }}</text>
|
|
<text class="lf-font-28 lf-font-bold lf-color-price">.{{ showPrice(2) }}</text>
|
|
</block>
|
|
<block v-else>
|
|
<text class="text-price lf-font-48 lf-font-bold lf-color-price">{{ showPrice() }}</text>
|
|
</block>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
price: {
|
|
type: [Number, String],
|
|
default: ''
|
|
}
|
|
},
|
|
computed: {
|
|
// 是否存在小数点
|
|
isPoint(){
|
|
let price = parseFloat(this.$props.price).toString();
|
|
return price.indexOf('.') >= 0;
|
|
},
|
|
showPrice(){
|
|
let price = parseFloat(this.$props.price).toString(); // 过滤价格出现.00的情况
|
|
return function(type){
|
|
let price_arr = price.split('.');
|
|
if(type == 1){
|
|
return price_arr[0];
|
|
}else if(type == 2){
|
|
return price_arr[1];
|
|
}else{
|
|
return price_arr[0];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped="scoped">
|
|
|
|
</style>
|