QYF-GitLab1
2 天以前 9cad6a832c786989be620573b09badccfe7e3b51
src/views/bookStore/detail.vue
@@ -168,10 +168,19 @@
              <el-button v-if="currentRoute == 'teachingServices'" plain @click="addPaperBook"
                >纸质样书</el-button
              >
              <el-button plain @click="applyTextBook" v-if="!bookInfo.alreadyBuy"
              <el-button
                plain
                @click="applyTextBook"
                v-if="!bookInfo.alreadyBuy && currentBook?.state !== 'Normal'"
                >申请试用</el-button
              >
              <el-button plain @click="useCode" v-if="!bookInfo.alreadyBuy">使用购书码</el-button>
              <el-button
                plain
                @click="read"
                v-if="bookInfo.alreadyBuy || currentBook?.state == 'Normal'"
                >开始阅读</el-button
              >
            </div>
          </div>
        </div>
@@ -296,8 +305,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')
@@ -317,6 +325,7 @@
let editableTabsValue = ref('1')
let activateCode = ref('')
let resourceHave = ref(true)
let currentBook = ref(null)
let loading = ref(false)
let buyBookCodeDialog = ref(false)
var chartDom = null
@@ -354,6 +363,7 @@
  digitalTextId.value = route.query.bookId
  getBookDetail(digitalTextId.value)
  getRecommendBookList()
  getTextBookList()
})
watchEffect(() => {
@@ -361,6 +371,34 @@
    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
    }
    currentBook.value = res.datas.find((item) => item.productId == digitalTextId.value)
  }
}
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 +500,23 @@
}
//申请试用
const applyTextBook = () => {
  console.log(userStore.userInfo, 'userInfo')
const applyTextBook = async () => {
  if (currentBook.value?.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))