222
杨磊
18 小时以前 f1ee7357faf2bc1c2d62d4784ca02cd2213b8d30
222
1个文件已修改
57 ■■■■■ 已修改文件
src/views/bookStore/detail.vue 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/bookStore/detail.vue
@@ -172,6 +172,7 @@
                >申请试用</el-button
              >
              <el-button plain @click="useCode" v-if="!bookInfo.alreadyBuy">使用购书码</el-button>
              <el-button plain @click="read" v-if="bookInfo.alreadyBuy">开始阅读</el-button>
            </div>
          </div>
        </div>
@@ -296,8 +297,7 @@
import VRIcon from '@/assets/images/digitalTextbooks/VR.png'
import ziliaoIcon from '@/assets/images/digitalTextbooks/ziliao.png'
import teacherCertification from '@/views/personalCenter/teacherCertification.vue'
import { ElMessage } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, onBeforeMount, inject, reactive, onMounted, watchEffect } from 'vue'
const MG = inject('MG')
const config = inject('config')
@@ -361,6 +361,41 @@
    getBookResource()
  }
})
const getTextBookList = async () => {
  const data = {
    start: 0,
    size: 9999,
    topicIdOrRefCode: 'applyDigitalBook',
    appRefCode: config.appRefCode,
    sort: {
      type: 'Desc',
      field: 'CreateDate',
    },
  }
  const res = await MG.ugc.getTopicMessageList(data)
  if (res.datas && res.datas.length > 0) {
    for (let i = 0; i < res.datas.length; i++) {
      const item = res.datas[i]
      item.content = JSON.parse(item.content)[0]
      item.productId = item.content.id
    }
    const currentBook = res.datas.find((item) => item.productId == digitalTextId.value)
    if (currentBook) {
      return currentBook
    } else {
      return null
    }
  } else {
    return null
  }
}
const read = () => {
  let token = localStorage.getItem(config.tokenKey)
  const url = config.textBookResourceUrl + '?bookId=' + bookInfo.value.refCode + '&token=' + token
  window.open(url)
}
const userActiveCodeGet = () => {
  let lock = true
@@ -462,9 +497,25 @@
}
//申请试用
const applyTextBook = () => {
const applyTextBook = async () => {
  console.log(userStore.userInfo, 'userInfo')
  const isApply = await getTextBookList()
  if (isApply?.state == 'WaitAudit') {
    ElMessageBox.confirm('您已申请试用该书,是否前往查看', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(() => {
      router.push({
        path: '/myApply',
      })
    })
  } else {
    toApply()
  }
}
const toApply = () => {
  if (localStorage.getItem(config.tokenKey)) {
    if (userStore.userInfo && userStore.userInfo.role == 'Teacher') {
      localStorage.setItem('applyBookInfo', JSON.stringify(bookInfo.value))