鸿宇研学生前端代码
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.

111 lines
2.4 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view>
  3. <view class="tabs">
  4. <uv-tabs
  5. :list="tabs"
  6. :activeStyle="{
  7. 'font-family': 'PingFang SC',
  8. 'font-weight': 500,
  9. 'font-size': '28rpx',
  10. 'line-height': 1.5,
  11. 'color': '#FFFFFF',
  12. 'background-color': '#191919',
  13. 'border-radius': '34rpx',
  14. 'padding': '12rpx 32rpx',
  15. }"
  16. :inactiveStyle="{
  17. 'font-family': 'PingFang SC',
  18. 'font-weight': 400,
  19. 'font-size': '28rpx',
  20. 'line-height': 1.5,
  21. 'color': '#191919',
  22. 'background-color': '#E4E7EB',
  23. 'border-radius': '34rpx',
  24. 'padding': '12rpx 32rpx',
  25. }"
  26. lineWidth="0"
  27. lineHeight="0"
  28. :current="current"
  29. @click="onClickTab"
  30. ></uv-tabs>
  31. </view>
  32. <view v-if="list.length" class="content">
  33. <view v-for="item in list" :key="item.id">
  34. <productCard
  35. :data="item"
  36. size="small"
  37. @collect="$emit('collect')"
  38. ></productCard>
  39. </view>
  40. </view>
  41. <template v-else>
  42. <uv-empty mode="list"></uv-empty>
  43. </template>
  44. </view>
  45. </template>
  46. <script>
  47. import productCard from '@/components/product/productCard.vue'
  48. export default {
  49. components: {
  50. productCard,
  51. },
  52. props: {
  53. list: {
  54. type: Array,
  55. default() {
  56. return []
  57. }
  58. },
  59. },
  60. data() {
  61. return {
  62. tabs: [],
  63. current: 0,
  64. }
  65. },
  66. created() {
  67. this.fetchRecommend()
  68. },
  69. methods: {
  70. fetchRecommend() {
  71. // todo: fetch
  72. this.tabs = [
  73. { name: '全部' },
  74. // { id: '1962342791093227522', name: '研学活动一', disabled: true, },
  75. ]
  76. },
  77. onClickTab(e) {
  78. this.current = 0
  79. const index = e.index
  80. if (index > 0) {
  81. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${this.tabs[e.index].id}`)
  82. }
  83. this.$nextTick(() => {
  84. this.current = 0
  85. })
  86. setTimeout(() => {
  87. this.current = 0
  88. }, 800)
  89. },
  90. },
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .tabs {
  95. width: calc(100% + 22px);
  96. transform: translateX(-11px);
  97. }
  98. .content {
  99. margin-top: 24rpx;
  100. display: grid;
  101. grid-template-columns: repeat(2, 1fr);
  102. gap: 16rpx;
  103. }
  104. </style>