orchestra-detail.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import OHeader from '@/components/o-header'
  2. import OSticky from '@/components/o-sticky'
  3. import request from '@/helpers/request'
  4. import { Sticky, Tab, Tabs } from 'vant'
  5. import { defineComponent, onMounted, ref } from 'vue'
  6. import { useRoute } from 'vue-router'
  7. import Information from './compontent/information'
  8. import Photo from './compontent/photo'
  9. import Plan from './compontent/plan'
  10. import styles from './orchestra-detail.module.less'
  11. export default defineComponent({
  12. name: 'orchestra-detail',
  13. setup() {
  14. const route = useRoute()
  15. const tabs = sessionStorage.getItem('orchestra-detail-tab')
  16. const tabValue = ref(tabs || route.query.tabs || 'information')
  17. sessionStorage.removeItem('orchestra-detail-tab')
  18. const tabHeight = ref('auto')
  19. const termTimes = ref({
  20. start: '09-01',
  21. end: '03-01'
  22. })
  23. const getDefaultParams = async () => {
  24. // last_term_time 上学期
  25. // next_term_time 下学期
  26. const { data } = await request.get('/api-school/sysParamConfig/queryByParamNameList', {
  27. params: {
  28. paramNames: 'last_term_time,next_term_time'
  29. }
  30. })
  31. ;(data || []).forEach((item: any) => {
  32. if (item.paramName === 'last_term_time') {
  33. termTimes.value.start = item.paramValue
  34. } else if (item.paramName === 'next_term_time') {
  35. termTimes.value.end = item.paramValue
  36. }
  37. })
  38. }
  39. getDefaultParams()
  40. return () => (
  41. <div class={styles.orchestraDetail}>
  42. <OSticky
  43. position="top"
  44. onGetHeight={(height: any) => {
  45. tabHeight.value = height
  46. document.documentElement.style.setProperty('--header-height', height + 'px')
  47. }}
  48. >
  49. <OHeader border={false} />
  50. </OSticky>
  51. <Tabs
  52. sticky
  53. lineWidth={20}
  54. lineHeight={4}
  55. v-model:active={tabValue.value}
  56. animated
  57. offsetTop={tabHeight.value}
  58. swipeable
  59. onChange={(val: string) => {
  60. sessionStorage.setItem('orchestra-detail-tab', val)
  61. }}
  62. >
  63. <Tab title="乐团信息" name="information">
  64. <Information termTimes={termTimes.value} />
  65. </Tab>
  66. <Tab title="训练进度" name="plan">
  67. <Plan height={tabHeight.value} termTimes={termTimes.value} />
  68. </Tab>
  69. {/* <Tab title="训练照片" name="photo"></Tab> */}
  70. {/* <Tab title="乐团资讯" name="info"></Tab> */}
  71. </Tabs>
  72. {/* {tabValue.value === 'information' && <Information termTimes={termTimes.value} />} */}
  73. {/* {tabValue.value === 'plan' && <Plan height={tabHeight.value} termTimes={termTimes.value} />} */}
  74. {/* {tabValue.value === 'photo' && <Photo height={tabHeight.value} />} */}
  75. </div>
  76. )
  77. }
  78. })