lex 2 years ago
parent
commit
0a80d1653f

+ 4 - 4
src/school/orchestra/create-orchestra/select-teacher.tsx

@@ -71,14 +71,14 @@ export default defineComponent({
 
     const onConfirm = () => {
       resestState()
-      router.back()
-      // router.replace('/train-planning')
+      // router.back()
+      router.replace('/train-planning')
     }
     // 取消
     const onCancel = () => {
       resestState()
-      router.back()
-      // router.replace('/my-orchestra')
+      // router.back()
+      router.replace('/my-orchestra')
     }
 
     return () => (

+ 13 - 1
src/school/orchestra/index.tsx

@@ -2,7 +2,7 @@ import OHeader from '@/components/o-header'
 import OSticky from '@/components/o-sticky'
 import request from '@/helpers/request'
 import { ActionSheet, Cell, Icon, List, Popover, Tag } from 'vant'
-import { defineComponent, onMounted, reactive } from 'vue'
+import { defineComponent, onMounted, onUnmounted, reactive } from 'vue'
 import { useRouter } from 'vue-router'
 import styles from './index.module.less'
 import { state } from '@/state'
@@ -114,7 +114,19 @@ export default defineComponent({
 
     onMounted(() => {
       getList()
+      // 处理返回上一页的问题
+      window.history.pushState(null, '', document.URL)
+      window.addEventListener('popstate', onBack, false)
     })
+
+    const onBack = () => {
+      postMessage({ api: 'back' })
+    }
+
+    onUnmounted(() => {
+      window.removeEventListener('popstate', onBack)
+    })
+
     return () => (
       <div class={!form.listState.dataShow && 'emptyRootContainer'}>
         <OSticky