index.vue 1.4 KB

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