index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. let currentTabIndex = ref(0)
  46. const data = reactive({
  47. list: [{
  48. name: '英语',
  49. value: 1
  50. },
  51. {
  52. name: '数学',
  53. value: 2
  54. },
  55. {
  56. name: '语文',
  57. value: 3
  58. },
  59. ],
  60. chanpinActiveSelect: 2,
  61. shuxueList: [],
  62. })
  63. function getShuxueList() {
  64. shuxueHttp.getShuxueChanpinList().then(res => {
  65. data.shuxueList = res.data;
  66. })
  67. }
  68. function handleSelectChanpin(item) {
  69. data.chanpinActiveSelect = item.value
  70. }
  71. onShow(() => {
  72. currentTabIndex.value = 0;
  73. })
  74. onLoad(() => {
  75. getShuxueList()
  76. })
  77. </script>