xinsi_book/src/views/Book.vue

470 lines
12 KiB
Vue
Raw Normal View History

2024-06-13 00:50:28 +00:00
<template>
2024-07-05 07:58:15 +00:00
<div v-loading="fullscreenLoading"
style="height: 100dvh;"
element-loading-text="书籍加载中,请稍等"
>
2024-06-18 03:30:25 +00:00
<div class="xml-read" v-if="show">
2024-06-13 00:50:28 +00:00
<xml-digital-teaching
v-if="digitalTeaching"
ref="xmlDigitalTeaching"
2024-07-05 07:58:15 +00:00
systemEnvId="855e5965-d6a9-4aa0-9933-177e705399af"
:navBarHeight=60
2024-06-13 00:50:28 +00:00
:textBookData="textBookData"
:catalogList="catalogList"
:looseLeafData="looseLeafData"
2024-07-05 07:58:15 +00:00
:chapterId="chapterId"
2024-06-13 00:50:28 +00:00
:location="location"
:notesList="data.notes.list"
:bookmarkList="data.bookmark.list"
:resourcesList="data.resources.list"
:highlightList="data.highlight.list"
:isTrial="isTrial"
:isTrialIndex="isTrialIndex"
:userType="userType"
:setting="setting"
2024-07-16 10:33:58 +00:00
:joinClass ="joinClass"
:READER_MODE ="READER_MODE"
:gradesName = "gradesName"
2024-07-22 10:31:09 +00:00
:userInfoparms = "userInfo"
:teacherDateclass = "classList"
2024-06-13 00:50:28 +00:00
@updateReadLocation="updateReadLocation"
@addNote="addNote"
@editNote="editNote"
@deleteNote="deleteNote"
@deleteHighlight = "deleteHighlight"
@addTeacherNote="addTeacherNote"
@editTeacherNote="editTeacherNote"
@deleteTeacherNote="deleteTeacherNote"
@addHighlight="addHighlight"
@updateNotes="updateNotes"
@addBookmark="addBookmark"
@deleteBookmark="deleteBookmark"
@downloadFile="downloadFile"
@addResources="addResources"
@deleteResource="deleteResource"
@editResources="editResources"
@settingChange="settingChange"
:action = "action"
:headers = "headers"
2024-06-18 07:53:13 +00:00
:data = "extradata"
2024-06-13 00:50:28 +00:00
:isShowTeacherResource="true"
:continueReading="true"
:basisPath="basisPath"
:pageType="pageType"
/>
2024-06-20 02:26:29 +00:00
<!-- officePreviewPath="https://idocview.xxxxxxx.com/view/url?url=" -->
2024-06-18 03:30:25 +00:00
</div>
<div v-show="showError">
2024-06-18 07:53:13 +00:00
<no-data :msg="errormsg"></no-data>
2024-06-18 03:30:25 +00:00
</div>
2024-06-13 00:50:28 +00:00
</div>
2024-06-18 03:30:25 +00:00
2024-06-13 00:50:28 +00:00
</template>
<script>
import {LOCAL_VIEW_DETAIL,LOCAL_VIEW_CATALOG,LOCAL_VIEW_DATA} from "../seed/mock"
2024-06-18 03:30:25 +00:00
import NoData from "../components/noData.vue"
2024-06-18 07:53:13 +00:00
import {getStore,processReuestData} from '../utils/mUtils'
2024-06-18 03:30:25 +00:00
import {bookApi} from "../service/getData"
2024-06-13 00:50:28 +00:00
export default {
2024-06-18 03:30:25 +00:00
components:{
NoData
},
2024-06-13 00:50:28 +00:00
data() {
return {
action:'http://60.xxxx.137.15:8081/admin-api/teachingMaterial/resource/upload/16550/6940601956829184',
headers:{Authorization:`eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjYyMDFlYjA3LTY4ZWUtNGJhOC1iMjc3LTk4MjU0ZGI0MzUwMSJ9.zvW8Rr8ShOvwH5i7Cvl9bgp4MtznyLusrY86LMLW7MplNOjRp6j8lx6zkAD4_CvNXVF7v7MsYcRhN90DvhTq1g`},
2024-07-09 10:10:54 +00:00
digitalTeaching: false,
2024-06-18 03:30:25 +00:00
// textBookData: LOCAL_VIEW_DETAIL,
// catalogList: LOCAL_VIEW_CATALOG,
// looseLeafData: LOCAL_VIEW_DATA,
textBookData: {},
catalogList: [],
looseLeafData: {},
bookId: '',
2024-07-22 10:31:09 +00:00
chapterId:"",
2024-06-18 03:30:25 +00:00
show:false,
showError:false,
2024-07-05 07:58:15 +00:00
fullscreenLoading:true,
// loadingText:'书籍加载中,请稍等',
2024-06-18 07:53:13 +00:00
errormsg:'无数据',
2024-06-13 00:50:28 +00:00
location: '',
2024-06-18 03:30:25 +00:00
basisPath: 'https://smile-ebook.oss-cn-qingdao.aliyuncs.com/newjc/',
2024-06-13 00:50:28 +00:00
pageType: 'pc',
isTrial: false,
2024-06-20 02:26:29 +00:00
isTrialIndex: 30,
2024-06-13 00:50:28 +00:00
userType: 'teacher',
2024-06-18 07:53:13 +00:00
extradata :{},
2024-07-16 10:33:58 +00:00
READER_MODE:"immersive",
joinClass:"",
gradesName:"班级名称",
2024-06-13 00:50:28 +00:00
data: {
notes: {
list: []
},
bookmark: {
list: []
},
highlight: {
list: []
},
resources: {
list: []
}
},
2024-07-22 10:31:09 +00:00
setting: {},
userInfo:{},
classList:[],
2024-06-13 00:50:28 +00:00
}
},
created() {
2024-07-22 10:31:09 +00:00
document.title = "新思课堂电子书阅读"
2024-06-18 03:30:25 +00:00
this.bookId = this.$route.query.bookId
2024-07-09 10:10:54 +00:00
2024-07-10 08:49:16 +00:00
if (this.$route.query.chapterId){
this.chapterId = this.$route.query.chapterId
}
2024-06-18 07:53:13 +00:00
// this.userType = this.$route.query.userType || 'student'
2024-07-05 07:58:15 +00:00
this.$store.state.redirecturl = this.$route.query.redirecturl
2024-06-18 07:53:13 +00:00
var userType = getStore("userType")
2024-06-20 02:26:29 +00:00
this.isTrial = this.$route.query.isTrial=="true"?true:false
2024-06-18 07:53:13 +00:00
this.extradata = processReuestData({})
// var uploadUrl = "https://local.xinsiketang.com"
var uploadUrl = ""
uploadUrl = uploadUrl+'/api/smile/uploadResources'
this.action = uploadUrl
if (userType){
this.userType = userType
}
2024-06-20 02:26:29 +00:00
2024-06-18 07:53:13 +00:00
2024-06-13 00:50:28 +00:00
if (this.$route.query.type) {
this.pageType = this.$route.query.type
// this.isTrialIndex = Number(this.$route.query.isTrialIndex)
if (this.$route.query.isTrialIndex) {
this.isTrial = true
}
}
this.location = localStorage.getItem(this.textBookData.id)
setTimeout(() => {
2024-06-18 03:30:25 +00:00
// this.getData()
this.getMineData()
2024-06-13 00:50:28 +00:00
// this.getSetting()
}, 800)
},
2024-06-18 03:30:25 +00:00
async mounted(){
2024-06-20 02:26:29 +00:00
2024-07-05 07:58:15 +00:00
2024-06-13 00:50:28 +00:00
this.pageType = /Mobi|Android|iPhone/i.test(navigator.userAgent)?'h5':'pc'
2024-06-18 03:30:25 +00:00
// resourcesList({})
2024-07-10 03:34:11 +00:00
// console.log(this.bookId)
2024-06-18 03:30:25 +00:00
// var locationData = await bookApi.userAction.getReadLocation({bookId:this.bookId})
// this.location = locationData.location
2024-06-20 02:26:29 +00:00
2024-07-09 10:10:54 +00:00
2024-07-10 08:49:16 +00:00
var res = await bookApi.bookinfo.json({bookId:this.bookId})
// res = JSON.stringify(res)
// res = res.replaceAll("https://smile-ebook.oss-cn-qingdao.aliyuncs.com/", "fileapi/")
// res = JSON.parse(res)
if (res){
var res1 = await fetch(res.LOCAL_VIEW_DETAIL,{
mode: 'cors'
})
this.textBookData = await res1.json()
var res2 = await fetch (res.LOCAL_VIEW_CATALOG,{
mode: 'cors'
})
2024-07-17 08:46:32 +00:00
this.$store.state.textBookData = this.textBookData
2024-07-10 08:49:16 +00:00
this.catalogList = await res2.json()
var res3 = await fetch(res.LOCAL_VIEW_DATA,{
mode: 'cors'
})
console.log(this.catalogList)
this.looseLeafData = await res3.json()
2024-07-17 08:46:32 +00:00
2024-07-10 08:49:16 +00:00
this.basisPath = res.basisPath
2024-07-17 08:46:32 +00:00
2024-07-10 08:49:16 +00:00
}
2024-07-17 08:46:32 +00:00
2024-07-10 08:49:16 +00:00
2024-07-17 08:46:32 +00:00
//
2024-07-10 08:49:16 +00:00
// console.log(res)
// return
// try {
// this.textBookData = await bookApi.bookinfo.detail({bookId:this.bookId})
// this.$store.state.textBookData = this.textBookData
// } catch (error) {
// this.fullscreenLoading = false
// this.show= false
// this.showError = true
// this.errormsg = error
// this.$message.error(error);
// }
// this.catalogList = await bookApi.bookinfo.category({bookId:this.bookId})
// this.looseLeafData = await bookApi.bookinfo.data({bookId:this.bookId})
2024-06-20 02:26:29 +00:00
2024-06-19 00:32:38 +00:00
this.data.resources.list = await bookApi.resource.list({bookId:this.bookId})
2024-06-20 02:26:29 +00:00
2024-07-09 10:10:54 +00:00
if (this.$route.query.chapterId){
2024-07-10 03:34:11 +00:00
this.chapterId = this.$route.query.chapterId
2024-07-09 10:10:54 +00:00
}
2024-06-20 02:26:29 +00:00
2024-07-10 08:49:16 +00:00
this.show = true
this.fullscreenLoading = false
this.digitalTeaching = true
2024-07-22 10:31:09 +00:00
//
this.userInfo = await bookApi.user.info()
this.classList = await bookApi.user.classList({bookId:this.bookId})
2024-06-13 00:50:28 +00:00
},
methods: {
2024-06-18 03:30:25 +00:00
2024-06-13 00:50:28 +00:00
// 学生笔记操作 start
addNote(model) {
2024-06-18 03:30:25 +00:00
bookApi.note.add({
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.addData('notes', model)
},
editNote(model) {
2024-06-18 03:30:25 +00:00
bookApi.note.edit({
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.updateData('notes', model)
},
deleteNote(model,feedback) {
2024-06-18 03:30:25 +00:00
bookApi.note.delete({
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.deleteData('notes', model)
feedback()
},
// 教师笔记操作 start
addTeacherNote(model, rollback) {
2024-06-20 02:26:29 +00:00
bookApi.resource.add({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
this.addData('resources', model)
2024-06-13 00:50:28 +00:00
},
editTeacherNote(model) {
2024-06-20 02:26:29 +00:00
bookApi.resource.edit({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.updateData('resources', model)
},
deleteTeacherNote(model, feedback) {
2024-06-20 02:26:29 +00:00
bookApi.resource.delete({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.deleteData('resources', model)
feedback()
},
// 高亮操作
addHighlight(model, rollback) {
2024-06-18 03:30:25 +00:00
bookApi.highlight.add({
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.addData('highlight', model)
},
// 高亮删除
deleteHighlight(model, rollback) {
2024-06-18 03:30:25 +00:00
bookApi.highlight.delete({
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.deleteData('highlight', model)
console.log(model,"model")
},
settingChange(key, value) {
// let newSetting = Object.assign({}, this.setting, { [key]: value })
// localStorage.setItem('setting_#_' + this.textBookData.id, JSON.stringify(newSetting))
// this.setting = JSON.parse(localStorage.getItem('setting_#_' + this.textBookData.id)) || {}
},
// 更新笔记
updateNotes(model) {
2024-06-18 03:30:25 +00:00
bookApi.note.edit({
bookId:this.bookId,
data:JSON.stringify(model)
})
2024-06-13 00:50:28 +00:00
this.updateData('notes', model)
},
// 添加书签
2024-06-18 03:30:25 +00:00
addBookmark(e) {
bookApi.bookmark.add({
bookId:this.bookId,
data:JSON.stringify(e)
})
2024-06-13 00:50:28 +00:00
this.addData('bookmark', e)
},
// 删除书签
deleteBookmark(e) {
2024-06-18 03:30:25 +00:00
bookApi.bookmark.delete({
bookId:this.bookId,
pkid:e.pkid,
data:JSON.stringify(e)
})
2024-06-13 00:50:28 +00:00
this.deleteData('bookmark', e)
},
// 添加数据
addData(type, item) {
this.data[type].list.push(item)
let list = JSON.stringify(this.data)
localStorage.setItem('simulated-data_' + this.textBookData.id, list)
this.getData(type, item)
},
2024-06-18 03:30:25 +00:00
async getMineData(){
this.data.notes.list = await bookApi.note.list({
bookId:this.bookId,
})
this.data.bookmark.list = await bookApi.bookmark.list({
bookId:this.bookId
})
this.data.highlight.list = await bookApi.highlight.list({
bookId:this.bookId
})
this.data.resources.list = await bookApi.resource.list({
bookId:this.bookId
})
},
2024-06-13 00:50:28 +00:00
// 查询数据
getData(type, item) {
setTimeout(() => {
2024-06-18 03:30:25 +00:00
// JSON.parse(localStorage.getItem('simulated-data_' + this.textBookData.id))
this.data =
JSON.parse(localStorage.getItem('simulated-data_' + this.textBookData.id))
|| {
2024-06-13 00:50:28 +00:00
notes: {
list: []
},
bookmark: {
list: []
},
highlight: {
list: []
},
resources: {
list: []
}
}
2024-06-18 03:30:25 +00:00
//
2024-06-13 00:50:28 +00:00
}, 300)
},
getSetting() {
this.setting = JSON.parse(localStorage.getItem('setting_#_' + this.textBookData.id)) || {}
},
// 更新数据
updateData(type, item) {
console.log(item)
let i = this.data[type].list.findIndex((items) => items.id == item.id)
this.data[type].list[i] = item
let list = JSON.stringify(this.data)
localStorage.setItem('simulated-data_' + this.textBookData.id, list)
this.getData(type, item)
},
// 删除数据
deleteData(type, item) {
console.log(item,"deleteData")
let i = this.data[type].list.findIndex((items) => items.id == item.id)
this.data[type].list.splice(i, 1)
let list = JSON.stringify(this.data)
localStorage.setItem('simulated-data_' + this.textBookData.id, list)
this.getData(type, item)
},
// 下载资源文件
2024-06-18 03:30:25 +00:00
downloadFile(e) {
console.log(e)
},
2024-06-13 00:50:28 +00:00
// 更新阅读进度
updateReadLocation(newLocation) {
2024-06-18 03:30:25 +00:00
console.log('我要更新阅读进度了'+newLocation)
bookApi.userAction.updateReadLocation({
bookId:this.bookId,
data: newLocation.location
})
2024-06-13 00:50:28 +00:00
localStorage.setItem(this.textBookData.id, newLocation.location)
},
// 添加教师资源
addResources(e) {
2024-06-18 07:53:13 +00:00
bookApi.resource.add({
bookId:this.bookId,
data:JSON.stringify(e)
})
2024-06-13 00:50:28 +00:00
this.addData('resources', e)
},
// 删除教师资源
deleteResource(e) {
2024-06-18 07:53:13 +00:00
bookApi.resource.delete({
bookId:this.bookId,
data:JSON.stringify(e)
})
2024-06-13 00:50:28 +00:00
this.deleteData('resources', e)
},
// 编辑教师资源
editResources(e) {
2024-06-18 07:53:13 +00:00
bookApi.resource.edit({
bookId:this.bookId,
data:JSON.stringify(e)
})
2024-06-13 00:50:28 +00:00
this.updateData('resources', e)
}
}
}
</script>