procurement_good.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="pro-good" @click.stop="handleJumpLink">
  3. <view class="img">
  4. <image :src="storeInfo.mainImage" mode="aspectFill" style="width: 100%;height: 100%;"></image>
  5. </view>
  6. <view class="pro-content">
  7. <view class="pro-title">
  8. {{storeInfo.name | sliceText(18)}}
  9. </view>
  10. <view class="pro-price" v-if='hasLogin'>
  11. ¥{{ storeInfo.price | NumFormat }}
  12. </view>
  13. <view class="product-price-none" v-else>
  14. <uni-grader :grade="Number(storeInfo.priceGrade)"></uni-grader>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { mapState } from 'vuex'
  21. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  22. export default {
  23. props: {
  24. storeInfo: {
  25. type: Object,
  26. default: () => {}
  27. }
  28. },
  29. components: {
  30. uniGrader
  31. },
  32. filters: {
  33. // 字符过滤
  34. sliceText(text, num) {
  35. if (text && text.length > num) {
  36. let value = text.substring(0, num)
  37. return value + '...'
  38. }
  39. return text
  40. },
  41. NumFormat(value) {
  42. //处理金额
  43. if(value){
  44. return Number(value).toFixed(2)
  45. }else{
  46. return '0.00'
  47. }
  48. }
  49. },
  50. computed: {
  51. ...mapState(['hasLogin'])
  52. },
  53. data() {
  54. return {
  55. }
  56. },
  57. methods: {
  58. handleJumpLink() {
  59. this.$api.navigateTo(`/pages/goods/product?id=${this.storeInfo.productId}`)
  60. },
  61. }
  62. }
  63. </script>
  64. <style scoped lang="scss">
  65. .pro-good {
  66. width: 339rpx;
  67. height: 518rpx;
  68. border-radius: 8rpx;
  69. background-color: #fff;
  70. overflow: hidden;
  71. margin-bottom: 24rpx;
  72. }
  73. .img {
  74. width: 339rpx;
  75. height: 339rpx;
  76. // border: 1px dotted;
  77. box-sizing: border-box;
  78. }
  79. .pro-content {
  80. padding: 14rpx 24rpx 20rpx 24rpx;
  81. display: flex;
  82. justify-content: space-between;
  83. align-items: center;
  84. flex-direction: column;
  85. height: 179rpx;
  86. box-sizing: border-box;
  87. background-color: #fff;
  88. }
  89. .pro-title {
  90. color: #333333;
  91. font-size: 28rpx;
  92. width: 100%;
  93. }
  94. .pro-price {
  95. width: 100%;
  96. color: #F85050;
  97. font-size: 28rpx;
  98. }
  99. .product-price-none {
  100. width: 100%;
  101. color: #f8c499;
  102. float: left;
  103. line-height: 54rpx;
  104. margin-top: 16rpx;
  105. .p-no {
  106. float: left;
  107. font-size: $font-size-24;
  108. color: $text-color;
  109. }
  110. }
  111. </style>