普兆健康管家前端代码仓库
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.

80 lines
1.7 KiB

  1. <template>
  2. <view>
  3. <swiper
  4. class="swiper"
  5. :current="current"
  6. :autoplay="false"
  7. :display-multiple-items="1.8"
  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: 228px;"
  15. imgStyle="width: 100%; height: 130px;"
  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>
  23. <indicator :current="current" :length="list.length" @click="current = $event"></indicator>
  24. </view>
  25. </template>
  26. <script>
  27. import productCard from '@/pages_order/product/productCard.vue'
  28. import indicator from '@/components/home/indicator.vue'
  29. export default {
  30. components: {
  31. productCard,
  32. indicator,
  33. },
  34. data() {
  35. return {
  36. current: 0,
  37. list: [],
  38. }
  39. },
  40. created() {
  41. this.getData()
  42. },
  43. methods: {
  44. async getData() {
  45. try {
  46. const queryParams = {
  47. pageNo: 1,
  48. // todo: check
  49. pageSize: 6,
  50. type: 0, // 产品类型(0营养剂,1预约,2课程)
  51. homeRecommend: 'Y',
  52. }
  53. this.list = (await this.$fetch('getProductList', queryParams))?.records || []
  54. } catch (err) {
  55. }
  56. },
  57. onChange(e) {
  58. this.current = e.detail.current
  59. }
  60. },
  61. }
  62. </script>
  63. <style scoped lang="scss">
  64. .swiper {
  65. width: 100vw;
  66. height: 230px;
  67. margin-bottom: 24rpx;
  68. &-item {
  69. height: 460rpx;
  70. padding-left: 32rpx;
  71. }
  72. }
  73. </style>