index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view class="page_body">
  3. <!-- 课程中心 -->
  4. <course-center v-if="state.tabBarValue=='courseCenter'"></course-center>
  5. <!-- 我的学习 -->
  6. <my-learning v-if="state.tabBarValue=='myLearning'"></my-learning>
  7. <!-- 学习监控 -->
  8. <learning-monitor v-if="state.tabBarValue=='learningMonitor'"></learning-monitor>
  9. <!-- 底部tabbar -->
  10. <pageTabbar :tabBarValue="state.tabBarValue" :tabBarList="state.tabBarList" @ChangeTabBarValue="ChangeTabBarValue"></pageTabbar>
  11. </view>
  12. </template>
  13. <script setup>
  14. import pageTabbar from '@/components/pageTabbar.vue';//头部
  15. import courseCenter from './courseCenter/index.vue';//课程中心
  16. import myLearning from './myLearning/index.vue';//我的学习
  17. import learningMonitor from './learningMonitor/index.vue';//学习监控
  18. import { reactive, ref,onMounted } from 'vue';
  19. import { useStore } from 'vuex';
  20. const store = useStore();
  21. const state = reactive({
  22. tabBarValue:'courseCenter',
  23. tabBarList:[{
  24. "pathName":"courseCenter",
  25. "iconPath": "/static/image/tabbar/courseCenter.png",
  26. "selectedIconPath": "/static/image/tabbar/courseCenter_cur.png",
  27. "text": "课程中心"
  28. },{
  29. "pathName":"myLearning",
  30. "iconPath": "/static/image/tabbar/myLearning.png",
  31. "selectedIconPath": "/static/image/tabbar/myLearning_cur.png",
  32. "text": "我的学习"
  33. }]
  34. })
  35. //切换tabBar
  36. const ChangeTabBarValue = (name) => {
  37. state.tabBarValue = name;
  38. }
  39. onMounted(()=>{
  40. const roleCodes = store.state?.userStore?.userInfo?.roleCodes || [];
  41. if(roleCodes.includes('SCHOOL_MANAGER')){//管理员
  42. state.tabBarList.push({
  43. "pathName":"learningMonitor",
  44. "iconPath": "/static/image/tabbar/learningMonitor.png",
  45. "selectedIconPath": "/static/image/tabbar/learningMonitor_cur.png",
  46. "text": "学习监控"
  47. })
  48. }
  49. })
  50. </script>
  51. <style lang="scss" scoped>
  52. .page_body{
  53. height: 100%;
  54. min-height: auto;
  55. }
  56. </style>