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

128 lines
3.1 KiB

  1. <template>
  2. <view class="category">
  3. <view class="flex flex-column category-item" v-for="item in categoryOptions" :key="item.id" @click="onClick(item)">
  4. <image class="img" :src="item.icon" mode="widthFix"></image>
  5. <view>{{ item.label }}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. categoryOptions: [],
  14. }
  15. },
  16. created() {
  17. this.getData()
  18. },
  19. methods: {
  20. getData() {
  21. // todo: fetch
  22. this.categoryOptions = [
  23. {
  24. id: '001',
  25. icon: '/static/image/temp-1.png',
  26. label: '主题研学',
  27. path: `/pages/index/category?categoryId=1962345709817106434`,
  28. },
  29. {
  30. id: '002',
  31. icon: '/static/image/temp-2.png',
  32. label: '社会实践',
  33. path: `/pages/index/category?categoryId=1962346300198948866`,
  34. },
  35. {
  36. id: '003',
  37. icon: '/static/image/temp-3.png',
  38. label: '研学交流',
  39. path: `/pages/index/category?categoryId=1962346769759670273`,
  40. },
  41. {
  42. id: '004',
  43. icon: '/static/image/temp-4.png',
  44. label: '周末研学',
  45. path: `/pages/index/category?categoryId=1962346834884628481`,
  46. },
  47. {
  48. id: '005',
  49. icon: '/static/image/temp-5.png',
  50. label: '假期专项',
  51. path: `/pages/index/category?categoryId=1962346960097185793`,
  52. },
  53. {
  54. id: '006',
  55. icon: '/static/image/temp-6.png',
  56. label: '研学日记',
  57. },
  58. {
  59. id: '007',
  60. icon: '/static/image/temp-7.png',
  61. label: '研学政策',
  62. path: `/pages_order/article/search?api=queryPolicyList&title=研学政策`,
  63. },
  64. {
  65. id: '008',
  66. icon: '/static/image/temp-8.png',
  67. label: '本地研学',
  68. path: `/pages/index/category?categoryId=1962347024639135745`,
  69. },
  70. {
  71. id: '009',
  72. icon: '/static/image/temp-9.png',
  73. label: '公司动态',
  74. path: `/pages_order/article/search?api=queryNewsList&title=公司动态`,
  75. },
  76. {
  77. id: '010',
  78. icon: '/static/image/temp-10.png',
  79. label: '全部',
  80. path: `/pages/index/category`,
  81. },
  82. ]
  83. },
  84. onClick(target) {
  85. const { path } = target
  86. if (path) {
  87. uni.navigateTo({
  88. url: path
  89. })
  90. }
  91. },
  92. },
  93. }
  94. </script>
  95. <style scoped lang="scss">
  96. .category {
  97. margin-top: 158rpx;
  98. width: 100%;
  99. padding: 24rpx 32rpx;
  100. box-sizing: border-box;
  101. display: grid;
  102. grid-template-columns: repeat(5, 1fr);
  103. column-gap: 16rpx;
  104. row-gap: 4rpx;
  105. background: linear-gradient(#DAF3FF, #FBFEFF 50rpx, #FBFEFF);
  106. border: 2rpx solid #FFFFFF;
  107. border-radius: 32rpx;
  108. &-item {
  109. padding: 16rpx 0;
  110. row-gap: 12rpx;
  111. font-size: 22rpx;
  112. color: #9B9B9B;
  113. .img {
  114. width: 72rpx;
  115. height: auto;
  116. }
  117. }
  118. }
  119. </style>