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

102 lines
2.2 KiB

  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. @change="onTabChange"
  29. ></uv-tabs>
  30. </view>
  31. <view v-if="list.length" class="content">
  32. <view v-for="item in list" :key="item.id">
  33. <productCard
  34. :data="item"
  35. ></productCard>
  36. </view>
  37. </view>
  38. <template v-else>
  39. <uv-empty mode="list"></uv-empty>
  40. </template>
  41. </view>
  42. </template>
  43. <script>
  44. import productCard from '@/components/home/productCard.vue'
  45. export default {
  46. components: {
  47. productCard,
  48. },
  49. props: {
  50. list: {
  51. type: Array,
  52. default() {
  53. return []
  54. }
  55. },
  56. },
  57. data() {
  58. return {
  59. tabs: [],
  60. current: null,
  61. }
  62. },
  63. created() {
  64. this.fetchCategory()
  65. },
  66. methods: {
  67. fetchCategory() {
  68. // todo: fetch
  69. this.tabs = [
  70. { name: '全部' },
  71. // todo: jump to detail
  72. { id: '001', name: '草原运动会' },
  73. { id: '002', name: '我的韶山行' },
  74. { id: '003', name: '出境游' },
  75. ]
  76. },
  77. onTabChange(e) {
  78. console.log('onTabChange', e.index)
  79. this.current = e.index
  80. // todo: jump to detail
  81. // this.$emit('categoryChange', { classId: this.tabs[this.current].id })
  82. },
  83. },
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .tabs {
  88. width: calc(100% + 22px);
  89. transform: translateX(-11px);
  90. }
  91. .content {
  92. margin-top: 24rpx;
  93. display: grid;
  94. grid-template-columns: repeat(2, 1fr);
  95. gap: 16rpx;
  96. }
  97. </style>