shop-recommend.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="shop-recommend" :class="type">
  3. <view class="flex row-between" style="padding: 26rpx 20rpx" v-if="title">
  4. <view class="bold xl">{{ title }}</view>
  5. <router-link :to="url" v-if="url">
  6. <view class="sm">
  7. 更多
  8. <u-icon name="arrow-right" size="22"></u-icon>
  9. </view>
  10. </router-link>
  11. </view>
  12. <view>
  13. <!-- <swiper :style="'height:' + swiperH + 'rpx;'" @change="swiperChange">
  14. <swiper-item v-for="(items, index) in shopList" :key="index"> -->
  15. <view v-for="(items, index) in shopList" :key="index">
  16. <view class="shop-list flex flex-wrap">
  17. <router-link class="item-link" :to="{ path: '/pages/store_index/store_index', query: { id: item.id } }" v-for="(item, index2) in items" :key="index2">
  18. <view class="flex-col col-center m-l-24">
  19. <view class="shop-item bg-white">
  20. <u-image width="100%" height="140rpx" mode="aspectFill" :src="item.background"></u-image>
  21. <view class="flex-col col-center" style="margin-top: -34rpx">
  22. <u-image width="68rpx" height="68rpx" border-radius="50%" :src="item.logo"></u-image>
  23. <view class="text flex-col col-center">
  24. <view class="line-1 name">{{ item.name }}</view>
  25. <!-- <view class="br60 muted sale xxs m-t-10 line-1">共{{ item.on_sales_count }}件商品</view> -->
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </router-link>
  31. </view>
  32. </view>
  33. <!-- </swiper-item>
  34. </swiper> -->
  35. <view class="dots flex row-center m-t-20" v-if="shopList.length > 1">
  36. <view v-for="(item, index) in shopList" :key="index" :class="'dot ' + (index == currentSwiper ? 'active' : '')"></view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import { arraySlice } from '@/utils/tools';
  43. export default {
  44. name: 'shop-recommend',
  45. props: {
  46. type: {
  47. type: String,
  48. default: ''
  49. },
  50. title: {
  51. type: String,
  52. default: ''
  53. },
  54. url: {
  55. type: String,
  56. default: ''
  57. },
  58. list: {
  59. type: Array,
  60. default: () => []
  61. }
  62. },
  63. data() {
  64. return {
  65. swiperH: 0,
  66. currentSwiper: 0,
  67. shopList: []
  68. };
  69. },
  70. methods: {
  71. swiperChange(e) {
  72. this.currentSwiper = e.detail.current;
  73. }
  74. },
  75. watch: {
  76. list: {
  77. handler(val) {
  78. if (val.length <= 3) {
  79. this.swiperH = 320;
  80. } else {
  81. this.swiperH = 606;
  82. }
  83. this.shopList = arraySlice(val, [], 1000);
  84. console.log(this.shopList);
  85. },
  86. immediate: true
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="scss">
  92. .nearby-shops {
  93. background-image: url(../../static/images/index_community_bg.png);
  94. }
  95. .shop-recommends {
  96. background: url(../../static/images/index_shop_bg.png) no-repeat;
  97. }
  98. .shop-recommend {
  99. background-size: cover;
  100. background-repeat: no-repeat;
  101. .shop-list {
  102. .item-link {
  103. width: 33.3%;
  104. }
  105. .shop-item {
  106. width: 220rpx;
  107. border-radius: 16rpx;
  108. margin-bottom: 16rpx;
  109. overflow: hidden;
  110. // &:not(:nth-of-type(3n)) {
  111. // margin-right: 15rpx;
  112. // }
  113. .text {
  114. padding: 8rpx 8rpx 19rpx;
  115. text-align: center;
  116. .name {
  117. width: 200rpx;
  118. padding: 0 0rpx 16rpx;
  119. }
  120. .sale {
  121. background-color: #f4f4f4;
  122. padding: 4rpx 16rpx;
  123. display: inline-block;
  124. }
  125. }
  126. }
  127. }
  128. .dots {
  129. .dot {
  130. width: 12rpx;
  131. height: 12rpx;
  132. border-radius: 50%;
  133. margin-right: 10rpx;
  134. background-color: #e5e5e5;
  135. &.active {
  136. width: 12rpx;
  137. background-color: $-color-primary;
  138. }
  139. }
  140. }
  141. }
  142. </style>