en-price.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view>
  3. <view class="item-price">
  4. <text class="item-current-price">¥<text class="price-integer">{{ integer }}</text>.<text>{{ decimal }}</text></text>
  5. <text class="item-original-price" v-show="originalPrice!==''">{{ originalPrice }}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: "en-price",
  12. props: {
  13. 'currentPrice': {
  14. default: ''
  15. },
  16. 'originalPrice': {
  17. default: ''
  18. }
  19. },
  20. data() {
  21. return {
  22. integer: 0,
  23. decimal: 0,
  24. }
  25. },
  26. mounted() {
  27. if (this.currentPrice !== '') {
  28. let currentPrice = this.currentPrice * 1
  29. this.integer = Math.trunc(currentPrice)
  30. currentPrice = (currentPrice.toFixed(2)) + ''
  31. this.decimal = currentPrice.substring((currentPrice.length) - 2)
  32. }
  33. },
  34. methods: {}
  35. }
  36. </script>
  37. <style scoped lang="scss">
  38. .item-price {
  39. .item-current-price {
  40. color: #ED301D;
  41. font-size: 24rpx;
  42. text{
  43. color: #ED301D;
  44. font-size: 24rpx;
  45. }
  46. .price-integer{
  47. font-size: 40rpx;
  48. }
  49. }
  50. .item-original-price {
  51. margin-left: 12rpx;
  52. color: #999999;
  53. font-size: 24rpx;
  54. text-decoration: line-through;
  55. }
  56. }
  57. </style>