orchestra-information.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import OHeader from '@/components/o-header'
  2. import OSticky from '@/components/o-sticky'
  3. import request from '@/helpers/request'
  4. import { Button, Tab, Tabs } from 'vant'
  5. import { defineComponent, onMounted, reactive } from 'vue'
  6. import { useRoute, useRouter } from 'vue-router'
  7. import styles from './orchestra-information.module.less'
  8. import OrchestraInformationList from './orchestra-information-list'
  9. export default defineComponent({
  10. name: 'orchestra-information',
  11. setup() {
  12. const tabName = sessionStorage.getItem('orchestra-information-tab')
  13. const state = reactive({
  14. activeName: tabName || 'publish',
  15. listState: {
  16. height: 0 // 页面头部高度,为了处理下拉刷新用的
  17. },
  18. offlineCount: 0,
  19. publishedCount: 0
  20. })
  21. const getStat = async () => {
  22. try {
  23. const { data } = await request.get('/api-school/sysNewsInformation/stat')
  24. state.publishedCount = data.publishedCount || 0
  25. state.offlineCount = data.offlineCount || 0
  26. } catch {
  27. //
  28. }
  29. }
  30. onMounted(async () => {
  31. // getStat()
  32. })
  33. return () => (
  34. <div class={[styles.information]}>
  35. <OSticky
  36. position="top"
  37. onGetHeight={(height: any) => {
  38. state.listState.height = height
  39. document.documentElement.style.setProperty('--header-height', height + 'px')
  40. }}
  41. >
  42. <OHeader border={false} />
  43. </OSticky>
  44. <Tabs
  45. sticky
  46. lineWidth={20}
  47. lineHeight={4}
  48. animated
  49. v-model:active={state.activeName}
  50. offsetTop={state.listState.height}
  51. swipeable
  52. onChange={(val: string) => {
  53. sessionStorage.setItem('orchestra-information-tab', val)
  54. }}
  55. >
  56. <Tab title={`已发布(${state.publishedCount})`} name="publish">
  57. <OrchestraInformationList
  58. headHeight={state.listState.height}
  59. type="1"
  60. onChangeList={getStat}
  61. />
  62. </Tab>
  63. <Tab title={`已下架(${state.offlineCount})`} name="offline">
  64. <OrchestraInformationList
  65. headHeight={state.listState.height}
  66. type="0"
  67. onChangeList={getStat}
  68. />
  69. </Tab>
  70. </Tabs>
  71. </div>
  72. )
  73. }
  74. })