普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.0 KiB

  1. <template>
  2. <view style="padding: 0 32rpx;">
  3. <swiper
  4. class="swiper"
  5. :current="current"
  6. :autoplay="false"
  7. :display-multiple-items="2.09"
  8. @change="onChange"
  9. >
  10. <swiper-item v-for="item in list" :key="item.id" style="display: inline-block;">
  11. <view class="swiper-item">
  12. <productCard
  13. :data="item"
  14. cardStyle="width: 100%; height: 192px;"
  15. imgStyle="width: 100%; height: 110px;"
  16. ></productCard>
  17. </view>
  18. </swiper-item>
  19. <swiper-item style="display: inline-block;">
  20. <view class="swiper-item"></view>
  21. </swiper-item>
  22. <swiper-item style="display: inline-block;">
  23. <view class="swiper-item"></view>
  24. </swiper-item>
  25. </swiper>
  26. <indicator :current="current" :length="list.length" @click="current = $event"></indicator>
  27. </view>
  28. </template>
  29. <script>
  30. import productCard from '@/pages_order/product/productCard.vue'
  31. import indicator from '@/components/home/indicator.vue'
  32. export default {
  33. components: {
  34. productCard,
  35. indicator,
  36. },
  37. data() {
  38. return {
  39. current: 0,
  40. list: [],
  41. }
  42. },
  43. created() {
  44. this.getData()
  45. },
  46. methods: {
  47. async getData() {
  48. try {
  49. const queryParams = {
  50. pageNo: 1,
  51. // todo: check
  52. pageSize: 6,
  53. type: 1, // 产品类型(0营养剂,1预约,2课程)
  54. homeRecommend: 'Y',
  55. }
  56. let records = (await this.$fetch('getProductList', queryParams))?.records || []
  57. this.list = records.map(item => {
  58. delete item.sold
  59. return item
  60. })
  61. } catch (err) {
  62. }
  63. },
  64. onChange(e) {
  65. this.current = e.detail.current
  66. }
  67. },
  68. }
  69. </script>
  70. <style scoped lang="scss">
  71. .swiper {
  72. width: 100vw;
  73. height: 194px;
  74. margin-bottom: 24rpx;
  75. &-item {
  76. width: 100%;
  77. height: 460rpx;
  78. padding-right: 32rpx;
  79. box-sizing: border-box;
  80. }
  81. }
  82. </style>