xinsi_book/src/views/Book.vue

886 lines
21 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-09-12 01:17:30 +00:00
<navigation></navigation>
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"
2025-01-08 11:00:20 +00:00
:navBarHeight=navBarHeight
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"
2025-01-08 11:00:20 +00:00
:trialChapterList ="trialChapterList"
2024-10-12 01:21:27 +00:00
:isAddMark="isAddMark"
2024-06-13 00:50:28 +00:00
: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-09-12 01:17:30 +00:00
:teacherData = "teacherData"
2025-05-14 07:08:53 +00:00
:teacherDate = "teacherData"
2024-09-12 01:17:30 +00:00
:studentData = "studentData"
2025-01-08 11:00:20 +00:00
:robotData = "robotData"
2025-04-01 03:48:29 +00:00
:linkOpenLabel = "true"
2025-01-08 11:00:20 +00:00
:isOperation = "isOperation"
2025-05-14 07:08:53 +00:00
:generalAPI="generalAPI"
2025-01-08 11:00:20 +00:00
robotName = "小新"
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"
2024-09-12 01:17:30 +00:00
@learningStatistics ="learningStatistics"
@changeClass="changeClass"
2025-01-08 11:00:20 +00:00
@clickToRespond = "clickToRespond"
2024-06-13 00:50:28 +00:00
: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"
2025-01-08 11:00:20 +00:00
:isOpenHyperlink = "true"
:isShowAi ="isShowAi"
2024-06-13 00:50:28 +00:00
/>
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-09-12 01:17:30 +00:00
import Navigation from "../components/Navigation"
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-09-12 01:17:30 +00:00
import {eventBus} from '../eventBus'
2025-01-08 11:00:20 +00:00
import Vue from 'vue'
import XML from "../plugin/xml-digital-teaching/lib/index"
Vue.use(XML)
2024-09-12 01:17:30 +00:00
2024-06-13 00:50:28 +00:00
export default {
2024-06-18 03:30:25 +00:00
components:{
2024-09-12 01:17:30 +00:00
NoData,
Navigation,
2024-06-18 03:30:25 +00:00
},
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-10-12 01:21:27 +00:00
isAddMark: true,
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',
2025-05-22 08:20:57 +00:00
isTrial: true,
2024-06-20 02:26:29 +00:00
isTrialIndex: 30,
2025-01-08 11:00:20 +00:00
trialChapterList:[],
2024-06-13 00:50:28 +00:00
userType: 'teacher',
2025-01-08 11:00:20 +00:00
isShowAi: "0",
isOperation:true,
robotData:{
// aiAppId = "44425659-f566-4841-a55c-26ade9813ac7"
// aiToken = "bce-v3/ALTAK-b9aN76J3Uvh578XNMZcnk/d85af61f15629f8ce23cdbd1e242cfa9e58c54c2"
appId:"44425659-f566-4841-a55c-26ade9813ac7",//应用ID
token:"bce-v3/ALTAK-b9aN76J3Uvh578XNMZcnk/d85af61f15629f8ce23cdbd1e242cfa9e58c54c2",//应用token
baseUrl:"/baiduAi/v2/app/conversation",//新建对话接口地址
conversationUrl: "/baiduAi/v2/app/conversation/runs",//大模型对话接口
// baseUrl:"https://qianfan.baidubce.com/v2/app/conversation",//新建对话接口地址
// conversationUrl: "https://qianfan.baidubce.com/v2/app/conversation/runs",//大模型对话接口
},
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: []
}
},
2025-05-14 07:08:53 +00:00
generalAPI:{
isCatalogStudent:true,//是否开启查询章节学期情况
getCatalogStudent: e => this.getCatalogStudent(e),
},
pkid:"",
2024-07-22 10:31:09 +00:00
setting: {},
userInfo:{},
2024-09-12 01:17:30 +00:00
userId:{},
2024-07-22 10:31:09 +00:00
classList:[],
2024-09-13 05:22:40 +00:00
classId:0,
2024-09-12 01:17:30 +00:00
className:'',
teacherData:{},
studentData:{}
2024-06-13 00:50:28 +00:00
}
},
2025-01-08 11:00:20 +00:00
computed:{
navBarHeight(){
if (this.isMobileDevice) {
return 0;
}
return 100;
},
isMobileDevice() {
return window.matchMedia("(max-width: 767px)").matches;
},
},
async created() {
2024-09-12 01:17:30 +00:00
2025-01-08 11:00:20 +00:00
// document.title = '新的页面标题';
2025-05-14 07:08:53 +00:00
2024-06-18 03:30:25 +00:00
this.bookId = this.$route.query.bookId
2024-07-09 10:10:54 +00:00
2025-01-08 11:00:20 +00:00
let title = this.$route.query.title
if (title){
document.title = title
}
2024-09-12 01:17:30 +00:00
this.userId = getStore("userId")
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
2025-01-08 11:00:20 +00:00
2024-06-20 02:26:29 +00:00
2025-01-08 11:00:20 +00:00
if (this.$route.query.showAi=="true") {
this.isShowAi ="0"
}
if (this.$route.query.showAi=="false"){
this.isShowAi ="1"
}
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
2024-09-12 01:17:30 +00:00
2024-06-18 07:53:13 +00:00
if (userType){
this.userType = userType
}
2024-06-20 02:26:29 +00:00
2024-06-18 07:53:13 +00:00
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
2025-01-08 11:00:20 +00:00
this.request()// 请求数据
2024-09-12 01:17:30 +00:00
2024-09-13 05:22:40 +00:00
setTimeout( async() => {
2024-06-18 03:30:25 +00:00
// this.getData()
2024-09-13 05:22:40 +00:00
await this.getMineData()
await this.studySituation()
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
// this.getSetting()
2025-01-08 11:00:20 +00:00
}, 1600)
2024-06-13 00:50:28 +00:00
},
2024-06-18 03:30:25 +00:00
async mounted(){
2024-09-12 01:17:30 +00:00
2025-05-14 07:08:53 +00:00
2024-10-12 01:21:27 +00:00
var apikey = getStore("apikey")
// if(!apikey){
// this.isAddMark = false
// }
2024-09-12 01:17:30 +00:00
this.$store.state.showNaotu = true
var that = this
eventBus.$on('changeMode',(data) =>{
if(data){
that.$refs.xmlDigitalTeaching.READER_MODE("immersive")
}else{
that.$refs.xmlDigitalTeaching.READER_MODE("initial")
}
})
},
2025-01-08 11:00:20 +00:00
2024-09-12 01:17:30 +00:00
methods: {
async request(){
2024-06-20 02:26:29 +00:00
2024-07-05 07:58:15 +00:00
2025-01-08 11:00:20 +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
2024-07-10 08:49:16 +00:00
var res = await bookApi.bookinfo.json({bookId:this.bookId})
2025-06-12 09:07:07 +00:00
2024-07-10 08:49:16 +00:00
// res = JSON.stringify(res)
// res = res.replaceAll("https://smile-ebook.oss-cn-qingdao.aliyuncs.com/", "fileapi/")
// res = JSON.parse(res)
2025-01-08 11:00:20 +00:00
2024-07-10 08:49:16 +00:00
if (res){
var res1 = await fetch(res.LOCAL_VIEW_DETAIL,{
mode: 'cors'
})
this.textBookData = await res1.json()
2025-01-08 11:00:20 +00:00
document.title = this.textBookData.textBooksName //
2024-07-10 08:49:16 +00:00
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'
})
2025-01-08 11:00:20 +00:00
2024-07-10 08:49:16 +00:00
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
2025-01-08 11:00:20 +00:00
this.location = localStorage.getItem(this.textBookData.id)
2024-07-10 08:49:16 +00:00
}
2025-03-13 02:53:59 +00:00
this.show = true
this.fullscreenLoading = false
2025-06-12 09:07:07 +00:00
// var locationData = await bookApi.userAction.getReadLocation({bookId:this.bookId})
// this.location = locationData.location
2025-05-22 08:20:57 +00:00
2025-03-13 02:53:59 +00:00
var abc = await bookApi.bookinfo.request_info({bookId: this.bookId})
2025-05-14 07:08:53 +00:00
2025-03-13 02:53:59 +00:00
// abc.isBuy = 1
2025-03-17 00:47:35 +00:00
if (abc){
2025-05-22 08:20:57 +00:00
2025-03-17 00:47:35 +00:00
if (abc.isBuy == 0) {
this.isTrial = true
}
else {
this.isTrial = false
}
2025-03-13 02:53:59 +00:00
}
2025-05-28 05:42:44 +00:00
// this.isTrial = false
2025-03-13 02:53:59 +00:00
2025-01-08 11:00:20 +00:00
this.trialChapterList = await bookApi.bookinfo.unlock({bookId:this.bookId})
if (this.trialChapterList.length>=0){
2025-05-22 08:20:57 +00:00
this.isTrialIndex = 0
2025-01-08 11:00:20 +00:00
}
2025-03-13 02:53:59 +00:00
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-09-12 01:17:30 +00:00
2024-07-10 08:49:16 +00:00
2024-07-22 10:31:09 +00:00
//
this.userInfo = await bookApi.user.info()
2025-03-13 02:53:59 +00:00
this.digitalTeaching = true
2025-01-08 11:00:20 +00:00
try {
this.classList = await bookApi.user.classList({bookId:this.bookId})
} catch (error) {
console.log(error)
}
2024-09-12 01:17:30 +00:00
if(this.classList.length>0){
2025-04-02 08:42:29 +00:00
this.classId = this.classList[0].pkid
this.className = this.classList[0].className
2024-09-12 01:17:30 +00:00
2025-04-02 08:42:29 +00:00
// this.classId = this.classList.at(-1).pkid
// this.className = this.classList.at(-1).className
2024-09-12 01:17:30 +00:00
}
// this.classId = 12304
//学情
this.getUerData()
this.studySituation()
2025-06-12 09:07:07 +00:00
2024-09-12 01:17:30 +00:00
var params = {
bookId:this.bookId,
userId: this.userId,
classId: this.classId,
lastAt:"0",
learnNum:1
}
// 初始化学情
bookApi.study.update({data:JSON.stringify(params)})
2024-06-13 00:50:28 +00:00
},
2024-06-18 03:30:25 +00:00
2024-09-12 01:17:30 +00:00
// 用户信息
async getUerData(){
var user = {
nickname:this.userInfo.nickname,
className:this.className,
img:this.userInfo.img,
// notNum:this.notes.list.length,
// bookmarkNum:this.bookmark.list.length,//书签数量
// lineationNum:this.highlight.list.length//划线数量
}
if(this.userType == "teacher"){
this.teacherData = user
}
if (this.userType == "student")
{
this.studentData = user
}
},
// 学情
async studySituation(){
var res = await bookApi.study.info({
2025-01-08 11:00:20 +00:00
bookId: this.bookId,
2024-09-12 01:17:30 +00:00
userId: this.userId,
classId: this.classId
})
2025-01-08 11:00:20 +00:00
if (res == undefined){return}
2024-09-12 01:17:30 +00:00
if (this.userType == "teacher") {
if (res.teacherInfo.length>0){
var item = res.teacherInfo[0]
this.teacherData = item
this.teacherData.className = item.nickname
this.teacherData.img = item.headImg
}
// this.teacherData.studentList = res.studentList
this.$nextTick(()=> this.$set(this.teacherData,"studentList", res.studentList))
}
if (this.userType == "student"){
if (res.length>0){
res = res[0]
2025-05-14 07:08:53 +00:00
// this.studentData.learningProgress =res.learningProgress
// this.studentData.learnTime =res.learnTime
// this.studentData.learnNum =res.learnNum
// this.studentData.totalLearnTime = res.totalLearnTime
// this.studentData.imgLearnNum = res.imgLearnNum
// this.studentData.audioLearnNum = res.audioLearnNum
// this.studentData.videoLearnNum = res.videoLearnNum
// this.studentData.videoLearnTime = res.videoLearnTime
// this.studentData.audioLearnTime = res.audioLearnTime
// this.studentData.answersNum = res.answersNum
2024-09-12 01:17:30 +00:00
// noteNum:'',//笔记数量
// bookmarkNum:'',//书签数量
// lineationNum:''//划线数量
2025-05-22 08:20:57 +00:00
console.log(res)
console.log(res,'xueqing')
2025-05-14 07:08:53 +00:00
this.studentData = {...res}
2025-05-22 08:20:57 +00:00
this.studentData.testNum = res.testNum
2024-09-12 01:17:30 +00:00
}
this.studentData.noteNum= this.data.notes.list.length
this.studentData.bookmarkNum = this.data.bookmark.list.length
this.studentData.lineationNum = this.data.highlight.list.length
}
2025-01-08 11:00:20 +00:00
},
2025-05-14 07:08:53 +00:00
/**
* e.chapterId 章节id
*/
getCatalogStudent(e) {
console.log(e)
return new Promise((resolve, reject) => {
// let data = {
// chapterId: '0', //章节id
// studyTime: 0, //本章学习时间,单位秒
// studyProgress: '100', //本章学习进度
// testProgress: '0', //本章试题完成进度
// accuracy: '', //本章试题正确率
// }
bookApi.study.chapterInfo({
userId: this.userId,
bookId: this.bookId,
chapterId:e.id
}).then(res=>{
// resolve(res[0])
2025-05-22 08:20:57 +00:00
//
let resnew ={data:{ ...res[0]}}
// let data = { ...res[0]}
// console.log(resnew, '掌接');
2025-05-14 07:08:53 +00:00
2025-05-22 08:20:57 +00:00
resolve(resnew)
2025-05-14 07:08:53 +00:00
}).catch(error=>{
console.log(error)
})
// 模拟异步操作
// setTimeout(() => {
// resolve({ data })
// }, 1000)
})
},
2025-01-08 11:00:20 +00:00
async clickToRespond(data){
2025-06-12 09:07:07 +00:00
2025-01-08 11:00:20 +00:00
await this.getMineData()
await this.studySituation()
2024-09-12 01:17:30 +00:00
},
2024-06-13 00:50:28 +00:00
// 学生笔记操作 start
2025-01-08 11:00:20 +00:00
async addNote(model) {
this.isOperation = false
await bookApi.note.add({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2025-01-08 11:00:20 +00:00
this.isOperation = true
// await this.getMineData()
2024-06-13 00:50:28 +00:00
this.addData('notes', model)
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
},
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)
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
},
2025-01-08 11:00:20 +00:00
async deleteNote(model,feedback) {
2024-06-18 03:30:25 +00:00
2025-01-08 11:00:20 +00:00
// this.isOperation = false
await bookApi.note.delete({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2025-01-08 11:00:20 +00:00
// this.isOperation = true
// await this.getMineData()
2024-06-13 00:50:28 +00:00
this.deleteData('notes', model)
feedback()
},
// 教师笔记操作 start
2025-01-08 11:00:20 +00:00
async addTeacherNote(model, rollback) {
await bookApi.resource.add({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2025-01-08 11:00:20 +00:00
// await this.getMineData()
2024-06-18 03:30:25 +00:00
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()
},
// 高亮操作
2025-01-08 11:00:20 +00:00
async addHighlight(model, rollback) {
2024-06-18 03:30:25 +00:00
2025-01-08 11:00:20 +00:00
await bookApi.highlight.add({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2025-01-08 11:00:20 +00:00
// await this.getMineData()
2024-06-13 00:50:28 +00:00
this.addData('highlight', model)
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
},
// 高亮删除
2025-01-08 11:00:20 +00:00
async deleteHighlight(model, rollback) {
2024-06-18 03:30:25 +00:00
2025-01-08 11:00:20 +00:00
await bookApi.highlight.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('highlight', model)
console.log(model,"model")
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
},
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)) || {}
},
// 更新笔记
2025-01-08 11:00:20 +00:00
async updateNotes(model) {
2024-06-18 03:30:25 +00:00
2025-01-08 11:00:20 +00:00
await bookApi.note.edit({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(model)
})
2025-01-08 11:00:20 +00:00
this.updateData('notes', model)
this.getuserData()
2024-06-13 00:50:28 +00:00
},
// 添加书签
2025-05-22 08:20:57 +00:00
async addBookmark(e) {
e.classId = this.classId
2025-01-08 11:00:20 +00:00
this.isOperation = false
2025-05-22 08:20:57 +00:00
console.log(e,'adddbookSe')
await bookApi.bookmark.add({
2024-06-18 03:30:25 +00:00
bookId:this.bookId,
data:JSON.stringify(e)
2025-05-22 08:20:57 +00:00
}).then((res)=>{
console.log(res,'addBookmark');
2024-06-18 03:30:25 +00:00
})
2024-06-13 00:50:28 +00:00
this.addData('bookmark', e)
2025-01-08 11:00:20 +00:00
// this.getuserData()
setTimeout(()=>{
this.isOperation = true
},2000)
2024-06-13 00:50:28 +00:00
},
// 删除书签
2025-01-08 11:00:20 +00:00
async deleteBookmark(e) {
this.isOperation = false
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)
2025-01-08 11:00:20 +00:00
this.isOperation = true
2024-06-13 00:50:28 +00:00
},
// 添加数据
2025-01-08 11:00:20 +00:00
async addData(type, item) {
await this.getMineData()
await this.studySituation()
2024-06-13 00:50:28 +00:00
},
2024-06-18 03:30:25 +00:00
async getMineData(){
this.data.notes.list = await bookApi.note.list({
bookId:this.bookId,
})
2025-01-08 11:00:20 +00:00
if(this.data.notes.list){
this.data.notes.list.map( (val)=>{
console.log(val.pkid)
})
}
2024-06-18 03:30:25 +00:00
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
})
2025-01-08 11:00:20 +00:00
console.log('11212j3ijio',this.data);
2024-06-18 03:30:25 +00:00
},
2024-06-13 00:50:28 +00:00
// 查询数据
getData(type, item) {
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
},
getSetting() {
this.setting = JSON.parse(localStorage.getItem('setting_#_' + this.textBookData.id)) || {}
},
// 更新数据
2025-01-08 11:00:20 +00:00
async updateData(type, item) {
2024-06-13 00:50:28 +00:00
console.log(item)
2025-01-08 11:00:20 +00:00
2024-06-13 00:50:28 +00:00
this.getData(type, item)
2025-01-08 11:00:20 +00:00
await this.getMineData()
await this.studySituation()
2024-06-13 00:50:28 +00:00
},
// 删除数据
2025-01-08 11:00:20 +00:00
async deleteData(type, item) {
await this.getMineData()
await this.studySituation()
2024-06-13 00:50:28 +00:00
console.log(item,"deleteData")
2025-01-08 11:00:20 +00:00
// this.getData(type, item)
// await this.getMineData()
// await this.studySituation()
2024-06-13 00:50:28 +00:00
},
// 下载资源文件
2024-06-18 03:30:25 +00:00
downloadFile(e) {
console.log(e)
},
2024-06-13 00:50:28 +00:00
// 更新阅读进度
2025-05-14 07:08:53 +00:00
async updateReadLocation(newLocation) {
2024-09-12 01:17:30 +00:00
2024-06-18 03:30:25 +00:00
console.log('我要更新阅读进度了'+newLocation)
bookApi.userAction.updateReadLocation({
bookId:this.bookId,
2025-01-08 11:00:20 +00:00
data: JSON.stringify(newLocation)
2024-06-18 03:30:25 +00:00
})
2024-06-13 00:50:28 +00:00
localStorage.setItem(this.textBookData.id, newLocation.location)
2024-09-12 01:17:30 +00:00
var params ={
2025-05-14 07:08:53 +00:00
chapterId: newLocation.chapterId,
2024-09-12 01:17:30 +00:00
bookId:this.bookId,
userId: this.userId,
classId: this.classId,
lastAt:Math.floor(Date.now() / 1000),
// learnNum:1,
2025-05-22 08:20:57 +00:00
learningProgress:newLocation.schedule,
...newLocation
2024-09-12 01:17:30 +00:00
}
2025-05-14 07:08:53 +00:00
var res = await bookApi.study.update({data:JSON.stringify(params)})
this.pkid = res.pkid
2024-06-13 00:50:28 +00:00
},
// 添加教师资源
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)
2024-09-12 01:17:30 +00:00
},
2025-01-08 11:00:20 +00:00
async learningStatistics(e){
2025-05-14 07:08:53 +00:00
2024-09-12 01:17:30 +00:00
var params ={
bookId:this.bookId,
userId: this.userId,
classId: this.classId,
2025-05-14 07:08:53 +00:00
xmlCompRef: e.xmlCompRef,
chapterId: e.chapterId,
2024-09-12 01:17:30 +00:00
lastAt:Math.floor(Date.now() / 1000),
// learnNum:1
2024-06-13 00:50:28 +00:00
}
2024-09-12 01:17:30 +00:00
2025-05-22 08:20:57 +00:00
params = {...params,
...e}
2024-09-12 01:17:30 +00:00
if (e.type =="image"){
params.imgLearnNum = 1
}
if (e.type =="audio"){
params.audioLearnTime = 10
params.audioLearnNum = 1
2025-05-22 08:20:57 +00:00
params.time = 10
2024-09-12 01:17:30 +00:00
}
if (e.type =="video"){
params.videoLearnTime = 10
params.videoLearnNum = 1
2025-05-22 08:20:57 +00:00
params.time = 10
2024-09-12 01:17:30 +00:00
}
if (e.type =="question"){
params.answersNum = 1
2025-05-22 08:20:57 +00:00
params = {...params,
...e.e}
2024-09-12 01:17:30 +00:00
}
2025-05-22 08:20:57 +00:00
2025-05-14 07:08:53 +00:00
params.type = e.type
params.pkid = this.pkid
if (e.type == "image" || e.type == "audio" || e.type == "video" || e.type == "question"){
await bookApi.study.resouceUpdate({data:JSON.stringify(params)})
}else{
await bookApi.study.update({data:JSON.stringify(params)})
}
2024-09-12 01:17:30 +00:00
2025-01-08 11:00:20 +00:00
await this.getUerData()
await this.studySituation()
console.log(e)
2024-09-12 01:17:30 +00:00
},
changeClass(e){
this.classId = e.pkid
this.className = e.title
this.studySituation()
console.log(e)
},
2024-06-13 00:50:28 +00:00
}
}
</script>