83ac3252f0326f5a49cdf7c26a5a4c78b5c76f9b..18d886c2f23dc5c032ebcf42bbb39c739d908a4f
2024-11-05 litian
Merge branch 'master' of http://182.92.203.7:2001/r/TextbookReader
18d886 对比 | 目录
2024-11-05 litian
yidong
400829 对比 | 目录
2个文件已修改
129 ■■■■ 已修改文件
src/views/readerPages/home.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/readerPages/mobileHome.vue 123 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/readerPages/home.vue
@@ -1,6 +1,6 @@
<template>
  <div class="homePage">
    <webHome v-if="!homeBoxHide" />
    <webHome v-if="homeBoxWebHide" />
    <mobileHome v-if="homeBoxHide" />
  </div>
  <div class="pdfDialog">
@@ -24,11 +24,11 @@
import mobileHome from '@/views//readerPages/mobileHome.vue'
import preView from '../components/pdfview.vue'
// import { da } from 'element-plus/es/locale'
const qiankunActions = inject('qiankunActions')
const screenWidth = ref(
  window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
)
const homeBoxHide = ref(false)
const homeBoxWebHide = ref(false)
const dialogState = reactive({
  dialogVisible: false,
  pdfTitle: '',
@@ -38,7 +38,9 @@
onMounted(() => {
  if (screenWidth.value < 420) {
    homeBoxHide.value = true
    homeBoxWebHide.value = false
  } else {
    homeBoxWebHide.value = true
    homeBoxHide.value = false
  }
  window.qiankunActions.setGlobalState({
src/views/readerPages/mobileHome.vue
@@ -526,21 +526,17 @@
  </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'
@@ -549,13 +545,25 @@
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,
@@ -567,17 +575,20 @@
  window.qiankunActions.onGlobalStateChange((state, prev) => {
    console.log('父层state变化', state)
    window.qiankunState = state
    if (window.qiankunState && window.qiankunState.initTestBook) {
      window.qiankunState.initTestBook(
        localStorage.getItem('bookId') + '',
        localStorage.getItem('tryPageCount')
      )
    if (isBuy.value) {
      if (window.qiankunState && window.qiankunState.initTestBook) {
        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) => {
    //   // 绑定子应用选择监听事件
@@ -628,15 +639,15 @@
    },
    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))
@@ -657,6 +668,83 @@
    }
  })
})
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')
@@ -1479,6 +1567,7 @@
  }
}
let dialogToolList = [] //选中文字操作
//选中文字工具栏
const showToolBox = ref(false)
const toolActive = ref('')