index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. <!-- 动画按钮 -->
  11. <ezyActiveVue class="ezy-btn-active tab-item" v-for="item in data.list" :key="item.value"
  12. :class="{active: item.value == data.chanpinActiveSelect}" @aclick="handleSelectChanpin(item)">
  13. {{item.name}}</ezyActiveVue>
  14. </view>
  15. <!-- 英语列表 -->
  16. <template v-if="data.chanpinActiveSelect == 1">
  17. <view class="ezy-no-sj" v-if="data.list.length">
  18. <icon></icon>
  19. <text>暂无数据</text>
  20. </view>
  21. </template>
  22. <!-- 数学列表 -->
  23. <shuxueListVue v-if="data.chanpinActiveSelect == 2" :list="data.shuxueList"></shuxueListVue>
  24. <!-- 语文列表 -->
  25. <template v-if="data.chanpinActiveSelect == 3">
  26. <view class="ezy-no-sj" v-if="data.list.length">
  27. <icon></icon>
  28. <text>暂无数据</text>
  29. </view>
  30. </template>
  31. </view>
  32. </view>
  33. <custom-tab-bar :show="true" :current-index="currentTabIndex" />
  34. </template>
  35. <script setup>
  36. import {
  37. reactive, ref
  38. } from "vue";
  39. import shuxueListVue from "./components/shuxueList.vue";
  40. import {
  41. onLoad,
  42. onShow
  43. } from "@dcloudio/uni-app"
  44. import * as shuxueHttp from "@/api/chanpinShuxue.js"
  45. import CustomTabBar from "@/components/custom-tabbar/index.vue";
  46. import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
  47. let currentTabIndex = ref(0)
  48. const data = reactive({
  49. list: [{
  50. name: '英语',
  51. value: 1
  52. },
  53. {
  54. name: '数学',
  55. value: 2
  56. },
  57. {
  58. name: '语文',
  59. value: 3
  60. },
  61. ],
  62. chanpinActiveSelect: 2,
  63. shuxueList: [],
  64. })
  65. function getShuxueList() {
  66. shuxueHttp.getShuxueChanpinList().then(res => {
  67. data.shuxueList = res.data;
  68. })
  69. }
  70. function handleSelectChanpin(item) {
  71. data.chanpinActiveSelect = item.value
  72. }
  73. onShow(() => {
  74. currentTabIndex.value = 0;
  75. })
  76. onLoad(() => {
  77. uni.hideTabBar()
  78. getShuxueList()
  79. })
  80. </script>