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

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