recommend.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view class="wrapper">
  3. <view class="font4 bold color-1">商品推荐</view>
  4. <view class="marginT15">
  5. <scroll-view scroll-x class="scroll-wrapper">
  6. <view v-for="item in data" :key="item.id" class="item" @click="showDetail(item)">
  7. <image :src="item.cover" class="image" mode="aspectFit"/>
  8. <view class="paddingT2 title">{{item.name}}</view>
  9. <view class="paddingT6 flex-align">
  10. <view class="color-money font0 marginL6">¥{{item.price}}</view>
  11. </view>
  12. </view>
  13. </scroll-view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. props: {
  20. data: Array
  21. },
  22. methods: {
  23. showDetail(item) {
  24. this.$router.pushCheck('product', {
  25. id: item.id
  26. })
  27. }
  28. }
  29. }
  30. </script>
  31. <style lang="scss" scoped>
  32. .wrapper {
  33. margin-top: 20rpx;
  34. background: #fff;
  35. border-radius: 20rpx;
  36. padding: 36rpx 28rpx;
  37. overflow: hidden;
  38. .scroll-wrapper {
  39. overflow: hidden;
  40. height: 290rpx;
  41. white-space: nowrap;
  42. width: 100%;
  43. .item {
  44. display: inline-block;
  45. width: 180rpx;
  46. height: 290rpx;
  47. margin-right: 20rpx;
  48. .image {
  49. width: 180rpx;
  50. height: 180rpx;
  51. border-radius: 8rpx;
  52. }
  53. .title {
  54. line-clamp: 2;
  55. word-break: break-all;
  56. overflow: hidden;
  57. text-overflow: ellipsis;
  58. }
  59. }
  60. }
  61. }
  62. </style>