recommend.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view>
  3. <view v-if="salesTop.length > 0 && storage&&showBanner" class="bg-white padding-tb-sm margin-top-sm"
  4. @click="naviageToPage('/pages/parity/parity?title=热卖推荐&id=11')" :class="{'padding-lr':showStyle!=='0px'}">
  5. <image :src="imgUrl" :mode="imgStyle==='cover'?'aspectFill':'scaleToFill'" style="width: 100%;height: 210rpx;">
  6. </image>
  7. </view>
  8. <view style="padding: 20rpx 12rpx 20rpx 30rpx;">
  9. <view v-if="salesTop.length > 0 && storage" class="flex" :class="{'flex-wrap':!scroll}"
  10. :style="{overflowX:scroll?'auto':'hidden'}">
  11. <view v-for="(item,index) in salesTop" :key="index"
  12. class="margin-bottom-sm bg-white flex align-center justify-center flex-direction"
  13. style="width: 335rpx;height: 520rpx;padding: 10rpx;margin-right: 18rpx;border-radius: 8rpx;"
  14. @click="navToDetailPage(item.productId)">
  15. <image style="width: 280rpx;height: 280rpx;margin: 10rpx;" :src="JSON.parse(item.img)[0].url"
  16. mode="aspectFit"></image>
  17. <view style="padding-top: 28rpx;">
  18. <view class="text-cut"
  19. style="width: 294rpx;height: 40rpx;font-size: 28rpx;font-weight: Medium; color: #2D4454;">{{item.title}}
  20. </view>
  21. <view class="text-cut margin-tb-xs" style="width: 294rpx;height: 40rpx;font-size: 28rpx;color: #999999;">
  22. {{item.storeInfo}}
  23. </view>
  24. <view style="padding-top: 6rpx;" class="flex align-center justify-between">
  25. <view style="width: 114rpx;height: 42rpx;line-height: 42rpx;font-size: 24rpx;color:#F62929;">
  26. ¥{{item.price}}</view>
  27. <view style="color: #B0B0B0;font-size: 24rpx;">{{item.unitName}}/份</view>
  28. <image @click.stop="addCart(item)" style="width: 48rpx;height: 48rpx;"
  29. src="../../../static/index/cart.png" mode="aspectFit" class="round"></image>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. name: 'Recommend',
  40. props: ['storage', 'salesTop', 'options'],
  41. computed: {
  42. showBanner() {
  43. return this.options.banner.show
  44. },
  45. imgUrl() {
  46. const {
  47. imgUrl
  48. } = this.options.banner
  49. if (imgUrl) {
  50. return JSON.parse(imgUrl)[0].url
  51. } else {
  52. return require('../../../static/index/command.png')
  53. }
  54. },
  55. showStyle() {
  56. return this.options.banner.showStyle
  57. },
  58. imgStyle() {
  59. return this.options.banner.imgStyle
  60. },
  61. scroll() {
  62. return this.options.scroll
  63. }
  64. },
  65. methods: {
  66. naviageToPage(url, title) {
  67. this.$emit('naviage-to-page', url, title)
  68. },
  69. navToDetailPage(id) {
  70. this.$emit('nav-to-detail-page', id)
  71. },
  72. addCart(item) {
  73. this.$emit('add-cart', item)
  74. }
  75. }
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. </style>