import ColSticky from '@/components/col-sticky' import { postMessage, promisefiyPostMessage } from '@/helpers/native-message' import request from '@/helpers/request' import { browser } from '@/helpers/utils' import { state } from '@/state' import { Button, Dialog, Toast } from 'vant' import { defineComponent } from 'vue' import styles from './index.module.less' import iconDefault from '@/common/images/icon_teacher.png' export const getAssetsHomeFile = (fileName: string) => { const path = `./images/${fileName}` const modules = import.meta.globEager('./images/*') return modules[path].default } export default defineComponent({ name: 'shareLiveRoom', data() { return { query: { ...this.$route.query // id: 'COOLESHOW-TEMP-416-1663833046284', // userId: 416 }, liveRoom: {} as any, //直播间信息 teacher: {} as any, student: {} as any, // 分享人信息 wxStatus: false } }, async mounted() { await this.getData() this.openApp() }, methods: { // 获取直播信息和分享人信息 async getData() { try { const { data } = await request.get( `/api-student/open/liveRoom/detail/${this.query.id}`, { params: { userId: this.query.userId } } ) this.liveRoom = data this.teacher = data.teacher || {} this.student = data.student || {} } catch {} }, // 分享进入 openApp() { if (browser().weixin) { // 微信浏览器 this.wxStatus = true return } if (!browser().isApp) { // 不是APP this.onWakeApp() return } if (browser().isApp) { if (state.platformType === 'STUDENT') { this.onJoinLiveRoom() } else if (state.platformType === 'TEACHER') { Dialog.alert({ title: '提示', message: '请使用酷乐秀学生端扫码打开', confirmButtonColor: '#2dc7aa' }).then(() => { postMessage({ api: 'back' }) }) } } }, //进入直播间 onJoinLiveRoom() { postMessage({ api: 'joinLiveRoom', content: { roomId: this.liveRoom.roomUid, teacherId: this.liveRoom.speakerId } }) }, // 唤醒APP onWakeApp() { const query = { action: 'app', // app, h5 pageTag: 'liveRoom', // 页面标识 params: JSON.stringify({ liveRoomId: this.query.id }) } const iosStr = encodeURIComponent(JSON.stringify(query)) if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // ColexiuStudent 唤起学生端 // ColexiuTeacher 唤起老师端 window.location.href = `ColexiuStudent://linkUrl=${iosStr}` } else if (/(Android)/i.test(navigator.userAgent)) { window.location.href = `colexiustudent://html:8888/SplashActivity?url=${iosStr}` } else { Toast('请用手机或移动设备打开') } } }, render() { return (