my-goods.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view>
  3. <view class="goods-item">
  4. <!-- 商品左侧图片区域 -->
  5. <view class="goods-item-left">
  6. <image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image>
  7. </view>
  8. <!-- 商品右侧信息区域 -->
  9. <view class="goods-item-right">
  10. <!-- 商品标题 -->
  11. <view class="goods-name">{{goods.goods_name}}</view>
  12. <view class="goods-info-box">
  13. <!-- 商品价格 -->
  14. <view class="goods-price">¥{{goods.goods_price | tofixed}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name:"my-goods",
  23. // 定义 props 属性,用来接收外界传递到当前组件的数据
  24. props: {
  25. // 商品的信息对象
  26. goods: {
  27. type: Object,
  28. defaul: {},
  29. },
  30. },
  31. data() {
  32. return {
  33. defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
  34. };
  35. },
  36. filters: {
  37. // 把数字处理为带两位小数点的数字
  38. tofixed(num) {
  39. return Number(num).toFixed(2)
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss">
  45. .goods-item {
  46. display: flex;
  47. padding: 10px 5px;
  48. border-bottom: 1px solid #f0f0f0;
  49. .goods-item-left {
  50. margin-right: 5px;
  51. .goods-pic {
  52. width: 100px;
  53. height: 100px;
  54. display: block;
  55. }
  56. }
  57. .goods-item-right {
  58. display: flex;
  59. flex-direction: column;
  60. justify-content: space-between;
  61. .goods-name {
  62. font-size: 13px;
  63. }
  64. .goods-price {
  65. font-size: 16px;
  66. color: #c00000;
  67. }
  68. }
  69. }
  70. </style>