index.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import OHeader from '@/components/o-header'
  2. import OSticky from '@/components/o-sticky'
  3. import request from '@/helpers/request'
  4. import { state } from '@/state'
  5. import { Sticky, Tab, Tabs } from 'vant'
  6. import { defineComponent, onMounted, ref } from 'vue'
  7. import Practice from './component/practice'
  8. import Standard from './component/standard'
  9. import { resestState } from './create'
  10. import styles from './index.module.less'
  11. export default defineComponent({
  12. name: 'train-planning',
  13. setup() {
  14. const trainType = sessionStorage.getItem('trainType')
  15. const tabValue = ref(trainType || 'standard')
  16. const address = ref('')
  17. // sessionStorage.removeItem('trainType')
  18. const getSchoolDetail = async () => {
  19. try {
  20. const { data } = await request.get(`/api-school/school/detail/${state.user.data.school.id}`)
  21. address.value = data.address || ''
  22. } catch {
  23. //
  24. }
  25. }
  26. const heightV = ref(0)
  27. onMounted(() => {
  28. getSchoolDetail()
  29. })
  30. return () => (
  31. <div class={styles.train}>
  32. <OSticky
  33. position="top"
  34. onGetHeight={(height: any) => {
  35. heightV.value = height
  36. document.documentElement.style.setProperty('--header-height', height + 'px')
  37. }}
  38. >
  39. <OHeader />
  40. </OSticky>
  41. <Tabs
  42. sticky
  43. lineWidth={20}
  44. lineHeight={4}
  45. swipeable
  46. animated
  47. offsetTop={heightV.value}
  48. v-model:active={tabValue.value}
  49. onChange={(val: any) => {
  50. // 切换时间重置表单数据
  51. resestState()
  52. sessionStorage.setItem('trainType', val)
  53. }}
  54. >
  55. <Tab title="标准训练" name="standard">
  56. {/* <Standard address={address.value} /> */}
  57. {tabValue.value === 'standard' && <Standard address={address.value} />}
  58. </Tab>
  59. <Tab title="自定义训练" name="practice">
  60. {/* <Practice address={address.value} /> */}
  61. {tabValue.value === 'practice' && <Practice address={address.value} />}
  62. </Tab>
  63. </Tabs>
  64. {/* {tabValue.value === 'standard' && <Standard address={address.value} />}
  65. {tabValue.value === 'practice' && <Practice address={address.value} />} */}
  66. </div>
  67. )
  68. }
  69. })