| | |
| | | </div> |
| | | </template> |
| | | <script setup lang="ts"> |
| | | import { ref, reactive, watch, onMounted, onBeforeMount, inject } from 'vue' |
| | | import { ref, reactive, watch, onMounted, onBeforeUnmount,inject } from 'vue' |
| | | import axios from 'axios' |
| | | import { useRouter, useRoute } from 'vue-router' |
| | | import { ElMessage, ElMessageBox, valueEquals } from 'element-plus' |
| | | import useClipboard from 'vue-clipboard3' |
| | | const { toClipboard } = useClipboard() |
| | | const MG: any = inject('MG') |
| | | const toolClass = inject('toolClass') |
| | | const qiankunActions = inject('qiankunActions') |
| | | import { loadMicroApp } from 'qiankun' |
| | | import { microApps } from '@/child.ts' |
| | | //获取路由器 |
| | | let router = useRouter() |
| | | |
| | | //获取当前路由的信息 |
| | | let route = useRoute() |
| | | import moment from 'moment' |
| | | |
| | | import bianji from '@/assets/images/operation/bianji.png' |
| | |
| | | import search from '@/assets/images/operation/search.png' |
| | | import search1 from '@/assets/images/operation/search1.png' |
| | | import xuanzhong from '@/assets/images/operation/xuanzhong.png' |
| | | |
| | | let token = localStorage.getItem('token') |
| | | const bookInfo = ref() |
| | | const isBuy = ref(false) |
| | | const tryPageCount = ref(0) |
| | | let microApp = null // 微应用实例 |
| | | const bookConfig = ref({}) |
| | | let userInfo = ref({}) |
| | | //当前显示章节 |
| | | const activeCatalog = ref() |
| | | const currentChapter = ref(1) |
| | | onMounted(() => { |
| | | if (token) { |
| | | getUserInfo() |
| | | } |
| | | if (localStorage.getItem('bookId')) { |
| | | getBookInfo() |
| | | } |
| | | // 加载微应用 |
| | | |
| | | microApp = loadMicroApp(microApps[localStorage.getItem('bookId')], { |
| | | sandbox: { |
| | | strictStyleIsolation: true, |
| | |
| | | window.qiankunActions.onGlobalStateChange((state, prev) => { |
| | | console.log('父层state变化', state) |
| | | window.qiankunState = state |
| | | |
| | | if (isBuy.value) { |
| | | if (window.qiankunState && window.qiankunState.initTestBook) { |
| | | window.qiankunState.initTestBook( |
| | | localStorage.getItem('bookId') + '', |
| | | localStorage.getItem('tryPageCount') |
| | | ) |
| | | window.qiankunState.initTestBook(localStorage.getItem('bookId') + '') |
| | | } |
| | | } else { |
| | | if (window.qiankunState && window.qiankunState.initTestBook) { |
| | | window.qiankunState.initTestBook(localStorage.getItem('bookId') + '', tryPageCount.value) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | // 定义父层方法 |
| | | window.qiankunActions.setGlobalState({ |
| | | state: 1, |
| | | disableSign: false, |
| | | // windowSelection: (data) => { |
| | | // // 绑定子应用选择监听事件 |
| | |
| | | }, |
| | | catalogChange: (data) => { |
| | | activeCatalog.value = data.showCatalogList |
| | | if (window.qiankunState.disableSign) { |
| | | // getSignData() |
| | | } |
| | | // if (window.qiankunState.disableSign) { |
| | | // // getSignData() |
| | | // } |
| | | // getSignData() |
| | | console.log(data, '章节切换:目前显示的三个章节') |
| | | }, |
| | | pageChange: (data) => { |
| | | headerData.process = Number(data.page) |
| | | // currentChapter.value = data.catalog |
| | | currentChapter.value = data.catalog |
| | | // console.log(data, '页面切换:目前显示页面和对应的章节信息') |
| | | // if (catalogTree.value) { |
| | | // catalogTree.value.setCurrentKey(Number(data.page)) |
| | |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | onBeforeUnmount(() => { |
| | | if (microApp) { |
| | | microApp.unmount() // 卸载微应用 |
| | | } |
| | | }) |
| | | |
| | | const getUserInfo = () => { |
| | | MG.identity.getCurrentAppUser().then((res) => { |
| | | if (res) { |
| | | let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher') |
| | | let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo') |
| | | let wechatInfo = res.infoList.find((item) => item.type == 'WeChat') |
| | | let studentInfo = res.infoList.find((item) => item.type == 'Default') |
| | | let phoneInfo = res.secretList.find((item) => item.type == 'MobilePhone') |
| | | let nameAndPassword = res.secretList.find((item) => item.type == 'LoginNameAndPassword') |
| | | |
| | | if (teacherRole && teacherInfos) { |
| | | userInfo.value = { |
| | | ...teacherInfos, |
| | | name: teacherInfos.name, |
| | | role: 'Teacher', |
| | | roleId: teacherRole.role.id |
| | | } |
| | | localStorage.setItem('userInfo', JSON.stringify(userInfo.value)) |
| | | } else if (wechatInfo) { |
| | | userInfo.value = { |
| | | ...wechatInfo, |
| | | phoneNumber: phoneInfo?.credential, |
| | | Email: emailInfo?.credential, |
| | | role: 'Student' |
| | | } |
| | | } else if (phoneInfo) { |
| | | userInfo.value = { |
| | | name: phoneInfo.credential |
| | | } |
| | | localStorage.setItem('userInfo', JSON.stringify(userInfo.value)) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | //根据refcode获取图书信息 |
| | | |
| | | const getBookInfo = () => { |
| | | const obj = { |
| | | storeInfo: 'jsek_digitalTextbooks', |
| | | path: '*', |
| | | queryType: '*', |
| | | coverSize: { |
| | | width: 150 |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | | size: 6 |
| | | }, |
| | | filterList: [ |
| | | { |
| | | value: 'Normal', |
| | | field: 'state' |
| | | } |
| | | ], |
| | | fields: { |
| | | author: [], |
| | | RefCodes: [localStorage.getItem('bookId')], |
| | | probationPage: [] |
| | | } |
| | | } |
| | | MG.store.getProductList(obj).then((res) => { |
| | | bookInfo.value = res.datas[0] |
| | | if (res.datas[0].purchasedSaleMethodIdList.includes(res.datas[0].defaultSaleMethodId)) { |
| | | isBuy.value = true |
| | | } else { |
| | | isBuy.value = false |
| | | } |
| | | tryPageCount.value = Number(res.datas[0].probationPage) |
| | | }) |
| | | } |
| | | |
| | | //菜单 |
| | | const activeIndex = ref('0') |
| | |
| | | } |
| | | } |
| | | |
| | | let dialogToolList = [] //选中文字操作 |
| | | //选中文字工具栏 |
| | | const showToolBox = ref(false) |
| | | const toolActive = ref('') |
| | |
| | | text-align: right; |
| | | } |
| | | .pageBox-content { |
| | | height: 100%; |
| | | height: calc(100vh - 130px); |
| | | #container { |
| | | background: #fbf9f4; |
| | |
| | | #__qiankun_microapp_wrapper_for_app_content_1__ { |
| | | height: 100%; |
| | | } |
| | | #__qiankun_microapp_wrapper_for_app_content__{ |
| | | height: 100%; |
| | | } |
| | | } |
| | | } |
| | | } |