lex 2 éve
szülő
commit
9c7492c8b2
2 módosított fájl, 37 hozzáadás és 11 törlés
  1. 37 2
      src/student/home/index.tsx
  2. 0 9
      src/student/main.ts

+ 37 - 2
src/student/home/index.tsx

@@ -14,7 +14,12 @@ import VideoClass from './components/video-class'
 import styles from './index.module.less'
 import Download from './model/download'
 import popupClose from './images/popup-close.png'
-import { postMessage } from '@/helpers/native-message'
+import {
+  listenerMessage,
+  postMessage,
+  promisefiyPostMessage,
+  removeListenerMessage
+} from '@/helpers/native-message'
 import { browser } from '@/helpers/utils'
 import { state } from '@/state'
 import event from './event'
@@ -51,9 +56,39 @@ export default defineComponent({
     this.headerHeight = (this as any).$refs.header?.getHeadeHeight()
     this.init()
 
-    event.on('downloadApp', () => {
+    event.on('downloadApp', async () => {
+      // 管乐团里面,获取是否已安装酷乐秀
+      const type = browser().orchestraAndroid
+        ? 'com.cooleshow.student'
+        : 'ColexiuStudent://'
+      await promisefiyPostMessage({
+        api: 'isInstall',
+        content: { type: type }
+      }).then((res: any) => {
+        const content = res.content
+        state.orchestraInfo.installStatus = content.installStatus
+      })
       this.downloadStatus = true
     })
+
+    listenerMessage('webViewOnResume', () => {
+      promisefiyPostMessage({ api: 'getUserAccount' }).then((res: any) => {
+        const content = res.content
+        // state.orchestraInfo.token = content.token
+        // state.orchestraInfo.phone = content.phone
+        // state.orchestraInfo.nickname = content.nickname
+        // state.orchestraInfo.avatar = content.avatar
+        // state.orchestraInfo.unionId = content.unionId || 0
+        if (content.phone !== state.orchestraInfo.phone) {
+          window.location.reload()
+        }
+      })
+    })
+  },
+  unmounted() {
+    removeListenerMessage('webViewOnResume', () => {
+      //
+    })
   },
   methods: {
     async init() {

+ 0 - 9
src/student/main.ts

@@ -45,15 +45,6 @@ if (browser().isOrchestraStudent) {
     state.orchestraInfo.unionId = content.unionId || 0
   })
 
-  // 管乐团里面,获取是否已安装酷乐秀
-  const type = browser().orchestraAndroid
-    ? 'com.cooleshow.student'
-    : 'ColexiuStudent://'
-  promisefiyPostMessage({ api: 'isInstall', content: { type: type } }).then((res: any) => {
-    const content = res.content
-    state.orchestraInfo.installStatus = content.installStatus
-  })
-
   // 从缓存里面获取token
   promisefiyPostMessage({ api: 'getCache', content: { key: 'h5-colexiu-token' } }).then((res: any) => {
     const content = res.content