index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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)">{{item.name}}</view>
  12. </view>
  13. <!-- 英语列表 -->
  14. <view v-if="data.chanpinActiveSelect == 1">
  15. <view class="no-kc-list" v-if="data.list.length">
  16. <icon></icon>
  17. <text>暂无数据</text>
  18. </view>
  19. </view>
  20. <!-- 数学列表 -->
  21. <shuxueListVue v-if="data.chanpinActiveSelect == 2" :list="data.shuxueList"></shuxueListVue>
  22. <!-- 语文列表 -->
  23. <view v-if="data.chanpinActiveSelect == 3">
  24. <view class="no-kc-list" v-if="data.list.length">
  25. <icon></icon>
  26. <text>暂无数据</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <CustomTabBar :currentTabNumber="0"></CustomTabBar>
  32. </template>
  33. <script setup>
  34. import {reactive} from "vue";
  35. import shuxueListVue from "./components/shuxueList.vue";
  36. import {onLoad} from "@dcloudio/uni-app"
  37. import * as shuxueHttp from "@/api/chanpinShuxue.js"
  38. import CustomTabBar from "@/components/custom-tabbar/custom-tabbar.vue";
  39. const data = reactive({
  40. list: [
  41. {
  42. name: '英语',
  43. value: 1
  44. },
  45. {
  46. name: '数学',
  47. value: 2
  48. },
  49. {
  50. name: '语文',
  51. value: 3
  52. },
  53. ],
  54. chanpinActiveSelect: 2,
  55. shuxueList: [],
  56. })
  57. function getShuxueList() {
  58. shuxueHttp.getShuxueChanpinList().then(res => {
  59. data.shuxueList = res.data;
  60. })
  61. }
  62. function handleSelectChanpin(item) {
  63. data.chanpinActiveSelect = item.value
  64. }
  65. onLoad(() => {
  66. getShuxueList()
  67. })
  68. </script>