index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <!-- 返回区域 -->
  3. <view class="icon-title-navBar-box">
  4. <!-- <view @click="handleBack" class="nav-bar-icon"></view> -->
  5. <text class="nav-bar-title">选课</text>
  6. </view>
  7. <view style="position: relative;background-color: #fff;z-index: 1;">
  8. <!-- 头部区域 -->
  9. <view >
  10. <view v-for="item in data.list" :key="item.value" :class="{active: item.value == data.chanpinActiveSelect}" @click="handleSelectChanpin">{{item.name}}</view>
  11. </view>
  12. <!-- 英语列表 -->
  13. <view class="list yingyu" v-if="data.chanpinActiveSelect == 1">
  14. </view>
  15. <!-- 数学列表 -->
  16. <shuxueListVue class="list shuxue" v-if="data.chanpinActiveSelect == 2" :list="data.shuxueList"></shuxueListVue>
  17. <!-- 语文列表 -->
  18. <view class="list yuwen" v-if="data.chanpinActiveSelect == 3">
  19. </view>
  20. </view>
  21. <CustomTabBar :currentTabNumber="0"></CustomTabBar>
  22. </template>
  23. <script setup>
  24. import {reactive} from "vue";
  25. import shuxueListVue from "./components/shuxueList.vue";
  26. import {onLoad} from "@dcloudio/uni-app"
  27. import * as shuxueHttp from "@/api/chanpinShuxue.js"
  28. import CustomTabBar from "@/components/custom-tabbar/custom-tabbar.vue";
  29. const data = reactive({
  30. list: [
  31. {
  32. name: '英语',
  33. value: 1
  34. },
  35. {
  36. name: '数学',
  37. value: 2
  38. },
  39. {
  40. name: '语文',
  41. value: 3
  42. },
  43. ],
  44. chanpinActiveSelect: 2,
  45. shuxueList: [],
  46. })
  47. function handleBack() {}
  48. function getShuxueList() {
  49. shuxueHttp.getShuxueChanpinList().then(res => {
  50. data.shuxueList = res.data;
  51. })
  52. }
  53. function handleSelectChanpin(item) {
  54. data.chanpinActiveSelect = item.value
  55. }
  56. onLoad(() => {
  57. getShuxueList()
  58. })
  59. </script>
  60. <style scoped lang="scss">
  61. .active {
  62. color: red
  63. }
  64. </style>