金诚优选前端代码
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

  1. <template>
  2. <view>
  3. <block v-if="isPoint">
  4. <text class="text-price lf-font-48 lf-font-bold lf-color-price">{{ showPrice(1) }}</text>
  5. <text class="lf-font-28 lf-font-bold lf-color-price">.{{ showPrice(2) }}</text>
  6. </block>
  7. <block v-else>
  8. <text class="text-price lf-font-48 lf-font-bold lf-color-price">{{ showPrice() }}</text>
  9. </block>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. price: {
  16. type: [Number, String],
  17. default: ''
  18. }
  19. },
  20. computed: {
  21. // 是否存在小数点
  22. isPoint(){
  23. let price = parseFloat(this.$props.price).toString();
  24. return price.indexOf('.') >= 0;
  25. },
  26. showPrice(){
  27. let price = parseFloat(this.$props.price).toString(); // 过滤价格出现.00的情况
  28. return function(type){
  29. let price_arr = price.split('.');
  30. if(type == 1){
  31. return price_arr[0];
  32. }else if(type == 2){
  33. return price_arr[1];
  34. }else{
  35. return price_arr[0];
  36. }
  37. }
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped="scoped">
  43. </style>