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

109 lines
2.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  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="aspectFit"></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. async getData() {
  21. try {
  22. const categorys = (await this.$fetch('queryCategoryList', { pageSize: 6, isShow: '1' }))?.records?.map(item => {
  23. const { id, icon, title } = item
  24. return {
  25. id,
  26. icon,
  27. label: title,
  28. path: `/pages/index/category?categoryId=${id}`,
  29. }
  30. })
  31. this.categoryOptions = [
  32. ...categorys.slice(0, 5),
  33. {
  34. id: '006',
  35. icon: '/static/image/temp-6.png',
  36. label: '研学日记',
  37. path: `/pages_order/article/search?api=queryJournalList&title=研学日记`,
  38. },
  39. {
  40. id: '007',
  41. icon: '/static/image/temp-7.png',
  42. label: '研学政策',
  43. path: `/pages_order/article/search?api=queryPolicyList&title=研学政策`,
  44. },
  45. categorys[5],
  46. {
  47. id: '009',
  48. icon: '/static/image/temp-9.png',
  49. label: '公司动态',
  50. path: `/pages_order/article/search?api=queryNewsList&title=公司动态`,
  51. },
  52. {
  53. id: '010',
  54. icon: '/static/image/temp-10.png',
  55. label: '全部',
  56. path: `/pages/index/category`,
  57. },
  58. ]
  59. } catch(err) {
  60. }
  61. },
  62. onClick(target) {
  63. const { path } = target
  64. if (path) {
  65. uni.navigateTo({
  66. url: path
  67. })
  68. }
  69. },
  70. },
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. .category {
  75. margin-top: 158rpx;
  76. width: 100%;
  77. padding: 24rpx 32rpx;
  78. box-sizing: border-box;
  79. display: grid;
  80. grid-template-columns: repeat(5, 1fr);
  81. column-gap: 16rpx;
  82. row-gap: 4rpx;
  83. background: linear-gradient(#DAF3FF, #FBFEFF 50rpx, #FBFEFF);
  84. border: 2rpx solid #FFFFFF;
  85. border-radius: 32rpx;
  86. &-item {
  87. padding: 16rpx 0;
  88. row-gap: 12rpx;
  89. font-size: 22rpx;
  90. color: #9B9B9B;
  91. .img {
  92. width: 72rpx;
  93. height: 72rpx;
  94. }
  95. }
  96. }
  97. </style>