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

110 lines
2.3 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. :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. ></productCard>
  38. </view>
  39. </view>
  40. <template v-else>
  41. <uv-empty mode="list"></uv-empty>
  42. </template>
  43. </view>
  44. </template>
  45. <script>
  46. import productCard from '@/components/product/productCard.vue'
  47. export default {
  48. components: {
  49. productCard,
  50. },
  51. props: {
  52. list: {
  53. type: Array,
  54. default() {
  55. return []
  56. }
  57. },
  58. },
  59. data() {
  60. return {
  61. tabs: [],
  62. current: 0,
  63. }
  64. },
  65. created() {
  66. this.fetchRecommend()
  67. },
  68. methods: {
  69. fetchRecommend() {
  70. // todo: fetch
  71. this.tabs = [
  72. { name: '全部' },
  73. { id: '1962342791093227522', name: '研学活动一', disabled: true, },
  74. ]
  75. },
  76. onClickTab(e) {
  77. this.current = 0
  78. const index = e.index
  79. if (index > 0) {
  80. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${this.tabs[e.index].id}`)
  81. }
  82. this.$nextTick(() => {
  83. this.current = 0
  84. })
  85. setTimeout(() => {
  86. this.current = 0
  87. }, 800)
  88. },
  89. },
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .tabs {
  94. width: calc(100% + 22px);
  95. transform: translateX(-11px);
  96. }
  97. .content {
  98. margin-top: 24rpx;
  99. display: grid;
  100. grid-template-columns: repeat(2, 1fr);
  101. gap: 16rpx;
  102. }
  103. </style>