index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="ezy-xuanke-page">
  3. <!-- 返回区域 -->
  4. <view class="icon-title-navBar-box">
  5. <text class="nav-bar-title">选课</text>
  6. </view>
  7. <view class="ezy-page-body">
  8. <!-- 头部区域 -->
  9. <view class="xuanke-tab-box">
  10. <view v-for="item in data.list" :key="item.value" class="tab-item"
  11. :class="{active: item.value == data.chanpinActiveSelect}" @click="handleSelectChanpin(item)">
  12. {{item.name}}</view>
  13. </view>
  14. <!-- 英语列表 -->
  15. <template v-if="data.chanpinActiveSelect == 1">
  16. <view class="ezy-no-sj" v-if="data.list.length">
  17. <icon></icon>
  18. <text>暂无数据</text>
  19. </view>
  20. </template>
  21. <!-- 数学列表 -->
  22. <shuxueListVue v-if="data.chanpinActiveSelect == 2" :list="data.shuxueList"></shuxueListVue>
  23. <!-- 语文列表 -->
  24. <template v-if="data.chanpinActiveSelect == 3">
  25. <view class="ezy-no-sj" v-if="data.list.length">
  26. <icon></icon>
  27. <text>暂无数据</text>
  28. </view>
  29. </template>
  30. </view>
  31. </view>
  32. <custom-tab-bar :show="true" :current-index="currentTabIndex" />
  33. </template>
  34. <script setup>
  35. import {
  36. reactive, ref
  37. } from "vue";
  38. import shuxueListVue from "./components/shuxueList.vue";
  39. import {
  40. onLoad,
  41. onShow
  42. } from "@dcloudio/uni-app"
  43. import * as shuxueHttp from "@/api/chanpinShuxue.js"
  44. import CustomTabBar from "@/components/custom-tabbar/index.vue";
  45. import {useExitApp} from "@/utils/useExitApp.js"
  46. // 初始化退出逻辑
  47. useExitApp();
  48. let currentTabIndex = ref(0)
  49. const data = reactive({
  50. list: [{
  51. name: '英语',
  52. value: 1
  53. },
  54. {
  55. name: '数学',
  56. value: 2
  57. },
  58. {
  59. name: '语文',
  60. value: 3
  61. },
  62. ],
  63. chanpinActiveSelect: 2,
  64. shuxueList: [],
  65. })
  66. function getShuxueList() {
  67. shuxueHttp.getShuxueChanpinList().then(res => {
  68. data.shuxueList = res.data;
  69. })
  70. }
  71. function handleSelectChanpin(item) {
  72. data.chanpinActiveSelect = item.value
  73. }
  74. onShow(() => {
  75. currentTabIndex.value = 0;
  76. })
  77. onLoad(() => {
  78. uni.hideTabBar()
  79. getShuxueList()
  80. })
  81. </script>