index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="ezy-ziliao-page">
  3. <view class="icon-title-navBar-box">
  4. <text class="nav-bar-title">资料</text>
  5. </view>
  6. <view class="ezy-page-body">
  7. <!-- 科目标签切换 -->
  8. <view class="ezy-xueke-tab-box">
  9. <ezyActiveVue class="tab-item ezy-btn-active" v-for="item in data.list" :key="item.value"
  10. :class="{active: item.key == data.chanpinActiveSelect}" @aclick="handleSelectChanpin(item)">
  11. {{item.label}}</ezyActiveVue>
  12. </view>
  13. <!-- 资源卡片列表 -->
  14. <!-- 数学 -->
  15. <!--<ShuXueList v-if="data.chanpinActiveSelect === 'shuxue'" :list="data.shuxueList" />-->
  16. <!-- 英语 -->
  17. <!--<YingYuList v-if="data.chanpinActiveSelect === 'yingyu'" :list="data.yingyuList" />-->
  18. <!-- 语文 -->
  19. <!--<YuWenList v-if="data.chanpinActiveSelect === 'yuwen'" :list="data.yuwenList" />-->
  20. </view>
  21. </view>
  22. <custom-tab-bar :show="true" :current-index="currentTabIndex" />
  23. </template>
  24. <script setup>
  25. import {reactive, ref} from "vue";
  26. import {onLoad,onShow} from "@dcloudio/uni-app"
  27. import {ziliaoIndex} from '@/api/ziliao.js'
  28. import CustomTabBar from "@/components/custom-tabbar/index.vue";
  29. import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
  30. import ShuXueList from "./shuxue/sxList.vue"
  31. import YingYuList from "./yingyu/yyList.vue"
  32. import YuWenList from "./yuwen/ywList.vue"
  33. let currentTabIndex = ref(2);
  34. const data = reactive({
  35. list:[
  36. { key: 'shuxue', label: '数学' },
  37. { key: 'yingyu', label: '英语' },
  38. { key: 'yuwen', label: '语文' }
  39. ],
  40. chanpinActiveSelect: 'shuxue',
  41. shuxueList: {},
  42. yingyuList: {},
  43. yuwenList: {}
  44. })
  45. // tab click
  46. function handleSelectChanpin(item) {
  47. data.chanpinActiveSelect = item.key
  48. }
  49. // ziliao list
  50. function getZiliaoList() {
  51. ziliaoIndex({}).then(res => {
  52. const result = getFormatData(res.data);
  53. data.shuxueList = result.shuxue;
  54. data.yingyuList = result.yingyu;
  55. data.yuwenList = result.yuwen;
  56. })
  57. }
  58. // Format
  59. function getFormatData(data) {
  60. const shuxue = data.shuxue || {};
  61. const yingyu = data.yingyu || {};
  62. const yuwen = data.yuwen || {};
  63. return {
  64. shuxue: Object.entries(shuxue).map(([chanpin, content]) => {
  65. return { chanpin, content };
  66. }),
  67. yingyu:Object.entries(yingyu).map(([chanpin, content]) => {
  68. return { chanpin, content };
  69. }),
  70. yuwen:Object.entries(yuwen).map(([chanpin, content]) => {
  71. return { chanpin, content };
  72. }),
  73. }
  74. }
  75. onShow(() => {
  76. currentTabIndex.value = 2;
  77. data.chanpinActiveSelect = 'shuxue'
  78. // 缺少功能 每日刷新
  79. /* if (getFullTimer() !== `2026-01-28`) {
  80. //每日刷新
  81. getZiliaoList();
  82. } */
  83. })
  84. onLoad(() => {
  85. // 隐藏默认系统导航栏显示自定义导航栏
  86. uni.hideTabBar()
  87. getZiliaoList()
  88. })
  89. </script>
  90. <style>
  91. </style>