IndexProductBody.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view
  3. class="div product-info"
  4. @click="productClick"
  5. >
  6. <view class="div wrapper">
  7. <view class="product-icon-wrapper" :style="'width:'+windowWidth+'px;height:'+windowWidth+'px'"><image mode="aspectFit" class="img product-icon" :src="item.goods_img_480"/></view>
  8. <text class="span product-title">{{ item.goods_name }}</text>
  9. <view class="div product-bottom">
  10. <text class="span product-price">¥<text class="i price">{{ item.goods_promotion_price }}</text></text>
  11. <text class="span product-buy">已售{{ item.goods_salenum }}件</text>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { urlencode,getFontSize } from '@/util/common'
  18. export default {
  19. name: 'IndexProductBody',
  20. data () {
  21. return {
  22. itemWidth: 0,
  23. itemHeight: 0,
  24. showRightBorder: this.index % 2 == 0
  25. }
  26. },
  27. props: ['item', 'index'],
  28. computed: {
  29. windowWidth: function () {
  30. const res = uni.getSystemInfoSync()
  31. var width=res.windowWidth
  32. var size=getFontSize()
  33. return (width-3*.6*size)/2
  34. },
  35. },
  36. methods: {
  37. productClick: function () {
  38. uni.navigateTo({ url: '/pages/home/goodsdetail/Goodsdetail'+'?'+urlencode( { goods_id: this.item.goods_id } )})
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .border {
  45. border-right: 1px solid #f5f5f5;
  46. }
  47. .product-info {
  48. display: flex;
  49. flex-direction: column;
  50. justify-content: flex-end;
  51. box-sizing:border-box;
  52. .wrapper{
  53. box-shadow: 0px 2px 4px #ececec;
  54. margin-left:$pageSpace;
  55. margin-bottom:.5rem;
  56. border-radius:.4rem;
  57. }
  58. .product-icon {
  59. align-self: center;
  60. width:100%;box-sizing:border-box;
  61. border-radius:.4rem;
  62. }
  63. .product-title {
  64. color: $formInputColor;
  65. font-size: $subFontSize;
  66. line-height:.8rem;
  67. height:1.6rem;
  68. margin-top: 0.4rem;
  69. overflow: hidden;
  70. display: -webkit-box;
  71. -webkit-box-orient: vertical;
  72. -webkit-line-clamp: 2;
  73. padding:0 .3rem;
  74. }
  75. .product-bottom {
  76. display: flex;
  77. justify-content: space-between;
  78. margin-top:.4rem;
  79. line-height:1rem;
  80. padding:0 .3rem;
  81. padding-bottom:.5rem;
  82. .product-price {
  83. color: $primaryColor;
  84. font-size:$fontSize;
  85. .price{font-size:$mainFontSize}
  86. }
  87. .product-buy {
  88. color: $descTextColor;
  89. font-size:$fontSize;
  90. }
  91. }
  92. }
  93. </style>