special.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view>
  3. <view v-if="cheapRecommend.length > 0 && storage&&showBanner"
  4. @click="naviageToPage('/pages/parity/parity?title=今日特价&id=1')"
  5. :style="{'padding-left': showStyle!=='0px'?'30rpx':0,'padding-right': showStyle!=='0px'?'26rpx':0}">
  6. <image :src="imgUrl" :mode="imgStyle==='cover'?'aspectFill':'scaleToFill'" style="width: 100%;height: 94rpx;">
  7. </image>
  8. </view>
  9. <scroll-view :scroll-x="scroll" :scroll-y="!scroll" style="width: 750rpx;">
  10. <view v-if="cheapRecommend.length > 0 && storage" class="flex padding-left-sm padding-top-sm">
  11. <view v-for="(item,index) in cheapRecommend" :key="index"
  12. class="margin-lr-xs bg-white flex align-center justify-center flex-direction"
  13. style="width: 200rpx;height: 340rpx;padding: 5rpx;border: 8rpx;" @click="navToDetailPage(item.productId)">
  14. <image style="width: 186rpx;height: 172rpx" :src="JSON.parse(item.img)[0].url" mode="aspectFit"></image>
  15. <view style="padding-top: 28rpx;">
  16. <view class="text-2-cut" style="width: 182rpx;height: 68rpx;font-size: 24rpx;color: #2D4454;">
  17. {{item.title}}
  18. </view>
  19. <view style="padding-top: 6rpx;padding-bottom: 14rpx;" class="flex align-center justify-between">
  20. <view style="width: 114rpx;height: 42rpx;line-height: 42rpx;font-size: 24rpx;color:#F62929;">
  21. ¥{{item.price}}</view>
  22. <image @click.stop="addCart(item)" style="width: 48rpx;height: 48rpx;"
  23. src="../../../static/index/cart.png" mode="aspectFit" class="round"></image>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. name: 'Special',
  34. props: ['storage', 'cheapRecommend', 'options'],
  35. computed: {
  36. showBanner() {
  37. return this.options.banner.show
  38. },
  39. imgUrl() {
  40. const {
  41. imgUrl
  42. } = this.options.banner
  43. if (imgUrl) {
  44. return JSON.parse(imgUrl)[0].url
  45. } else {
  46. return require('../../../static/index/bought.png')
  47. }
  48. },
  49. showStyle() {
  50. return this.options.banner.showStyle
  51. },
  52. imgStyle() {
  53. return this.options.banner.imgStyle
  54. },
  55. scroll() {
  56. return this.options.scroll
  57. }
  58. },
  59. methods: {
  60. naviageToPage(url, title) {
  61. this.$emit('naviage-to-page', url, title)
  62. },
  63. navToDetailPage(id) {
  64. this.$emit('nav-to-detail-page', id)
  65. },
  66. addCart(item) {
  67. this.$emit('add-cart', item)
  68. }
  69. }
  70. }
  71. </script>
  72. <style scoped lang="scss">
  73. </style>