123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- <template>
- <div class="container">
- <div class="book-content-inner">
- <div
- id="content-tree"
- :class="[fullTree ? 'content-tree-full' : 'content-tree']"
- >
- <h2 class="catelog"><!-- 目录 -->{{ $t("Key612") }}</h2>
- <div style="padding-left: 8px">
- <TreeView
- ref="treeView"
- :book-id="bookId"
- :change-id="changeId"
- :changeTreeData="changeTreeData"
- :currentTreeID="chapterId"
- />
- </div>
- </div>
- <el-image :src="pictureUrl" fit="scale-down" class="img_url" v-if="!chapterId&&pictureUrl">
- <div slot="placeholder" class="image-slot">
- <img src="../assets/common/icon-imgloading.png" />
- </div>
- </el-image>
- <div
- id="data-screen"
- class="inner"
- v-if="chapterFree == 'true' || bookIsBuy == 'true'"
- >
- <!-- 显示答案按钮 -->
- <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->
- <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->
- <div v-if="chapterId" class="title-box">
- <img
- v-if="!treeFlag"
- src="../assets/common/icon-view-back.png"
- @click="treeShow"
- />
- <img
- v-if="!treeFlag"
- :src="
- fullTree
- ? require('../assets/common/icon-treelist-gray.png')
- : require('../assets/common/icon-treelist.png')
- "
- @click="chooseCourseware"
- />
- <!-- <h2 class="title">{{ chapterName }}</h2> -->
- <!-- <el-switch
- v-if="!treeFlag"
- v-model="switchvalue"
- active-color="#FF9900"
- active-text
- inactive-text="生词模式"
- /> -->
- </div>
- <template v-if="category == 'OC' || !category">
- <Preview
- v-if="chapterId && context"
- ref="previewAnswer"
- :context="context"
- :bookAnswerContent="bookAnswerContent"
- bookclientwidth="900"
- :TaskModel="TaskModel"
- @handleBookUserAnswer="handleBookUserAnswer"
- />
- </template>
- <template v-if="category == 'NPC'">
- <Booknpc
- v-if="chapterId && context"
- ref="previewAnswer"
- :context="context"
- :currentTreeID="chapterId"
- :FatherTreeData="FatherTreeData"
- :change-id="changeId"
- :themeColor="themeColor"
- :isShowTitle="true"
- :isAnswerItemShow="isAnswerItemShow"
- />
- </template>
- <template v-if="category == 'NNPE'">
- <Booknnpe
- v-if="chapterId && context"
- ref="previewAnswer"
- :context="context"
- :currentTreeID="chapterId"
- :FatherTreeData="FatherTreeData"
- :change-id="changeId"
- :themeColor="themeColor"
- :isShowTitle="true"
- :isAnswerItemShow="true"
- />
- </template>
- <template v-if="category == 'RLC'">
- <Bookrlc
- v-if="chapterId && context"
- ref="previewAnswer"
- :context="context"
- :currentTreeID="chapterId"
- :FatherTreeData="FatherTreeData"
- :change-id="changeId"
- :themeColor="themeColor"
- :isShowTitle="true"
- :bookFontSize="bookFontSize"
- :isAnswerItemShow="isAnswerItemShow"
- />
- </template>
- <template v-if="category == 'NEW'">
- <BookNew
- v-if="chapterId && context"
- ref="book"
- :context="context"
- :currentTreeID="chapterId"
- />
- </template>
- </div>
- <a
- v-if="chapterId && treeFlag"
- class="screen-full"
- @click="fullScreen()"
- />
- </div>
- <!-- <Preview :context="context" :queIndex="queIndex" /> -->
- </div>
- </template>
- <script>
- import TreeView from "@/components/inputModules/common/TreeView.vue";
- import { getContent } from "@/api/ajax";
- import Cookies from "js-cookie";
- // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
- import Preview from "@/components/Preview";
- import { getToken } from "../utils/auth";
- export default {
- name: "CourseView",
- components: {
- TreeView,
- Preview,
- },
- props: ["bookId", "bookIsBuy","bookFontSize","pictureUrl"],
- data() {
- return {
- chapterId: "",
- chapterName: "",
- fullscreen: false, // 控制全屏
- context: null,
- question: null, // 选择的模板题型
- queIndex: "",
- treeFlag: true, // tree是否显示
- switchvalue: true, // 生词模式
- isAnswerShow: false, // 是否显示答案
- bookAnswerContent: "[]",
- TaskModel: "",
- fullTree: false, // 全屏模式下树是否显示
- category: "",
- FatherTreeData: null,
- themeColor: "",
- chapterFree: "false", // 课件免费观看
- isAnswerItemShow: false,
- };
- },
- mounted() {
- // const _this = this
- // _this.bookId = this.$route.query.bookId
- },
- created(){
- const _this = this
- let userInfor = JSON.parse(getToken());
- if (userInfor && (userInfor.user_type == "TEACHER"||userInfor.user_type == "INNER")) {
- _this.isAnswerItemShow = true;
- } else {
- _this.isAnswerItemShow = false;
- }
- },
- methods: {
- changeTreeData(val) {
- this.FatherTreeData =
- val != undefined ? JSON.parse(JSON.stringify(val)) : null;
- },
- changeId(id, name, free) {
- // if (
- // this.bookIsBuy == "true" ||
- // (this.bookIsBuy == "false" && free == "true")
- // ) {
- const _this = this;
- _this.chapterId = id;
- _this.chapterName = name;
- _this.isAnswerShow = false;
- _this.chapterFree = free;
- _this.onGetData();
- if (!_this.treeFlag) {
- _this.fullTree = false;
- document.getElementById("content-tree").style.display = "none";
- }
- // scrollTo(0,0)
- // } else {
- // this.chapterId = "";
- // this.chapterName = "";
- // this.context = null;
- // this.$message(
- // {
- // type: "warning",
- // message: "您还没有购买此教材,请购买后查看!",
- // },
- // 2000
- // );
- // }
- },
- // 点击全屏展示 隐藏tree
- fullScreen() {
- this.treeFlag = false;
- document.getElementById("content-tree").style.display = "none";
- this.$emit("bookdetailShow", false);
- },
- treeShow() {
- this.treeFlag = true;
- this.fullTree = false;
- document.getElementById("content-tree").style.display = "block";
- this.$emit("bookdetailShow", true);
- },
- // 获取预览数据
- onGetData() {
- const _this = this;
- const MethodName = "book-courseware_manager-GetCoursewareContent_View";
- const data = {
- id: _this.chapterId,
- };
- getContent(MethodName, data).then((res) => {
- console.log(res);
- this.category = res.category;
- this.themeColor = res.book_theme_color;
- if (res.content) {
- const _this = this;
- if (!this.category || this.category == "OC") {
- _this.context = {
- id: _this.chapterId,
- ui_type: JSON.parse(res.content).question
- ? JSON.parse(res.content).question.ui_type
- : "",
- sort_number: 1,
- content: JSON.parse(res.content),
- };
- } else {
- _this.context = JSON.parse(res.content);
- }
- } else {
- const _this = this;
- _this.context = null;
- }
- });
- },
- // 显示或隐藏答案
- handleAnswerShow() {
- this.isAnswerShow = !this.isAnswerShow;
- this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow);
- },
- // 得到用户答题答案
- handleBookUserAnswer(data) {
- console.log(data);
- },
- // 悬浮树隐藏显示
- chooseCourseware() {
- this.fullTree = !this.fullTree;
- if (this.fullTree) {
- document.getElementById("content-tree").style.display = "block";
- } else {
- document.getElementById("content-tree").style.display = "none";
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .container {
- width: 100%;
- height: auto;
- .catelog {
- padding: 24px 40px 16px 40px;
- font-weight: 600;
- font-size: 24px;
- line-height: 150%;
- color: #000000;
- margin: 0;
- }
- .book-content-inner {
- background: #fff;
- width: 100%;
- height: 700px;
- overflow: auto;
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- position: relative;
- &-tree {
- width: 340px;
- height: 100%;
- overflow: auto;
- padding: 20px 0px;
- border-right: 1px solid #d9d9d9;
- }
- .content-tree {
- width: 320px;
- border-right: 1px solid #d9d9d9;
- max-height: 700px;
- overflow: auto;
- }
- .content-tree-full {
- position: fixed;
- top: 100px;
- left: 152px;
- max-height: 588px;
- overflow: auto;
- z-index: 1000;
- background: #fff;
- box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
- border-radius: 4px;
- }
- .inner {
- width: 1000px;
- max-height: 700px;
- overflow: auto;
- flex: 1;
- margin: 0 auto;
- box-sizing: border-box;
- padding: 20px;
- position: relative;
- background: #fff;
- .title-box {
- display: flex;
- align-items: center;
- margin-bottom: 12px;
- padding-right: 160px;
- position: relative;
- > img {
- width: 40px;
- margin-right: 16px;
- cursor: pointer;
- }
- }
- .title {
- font-size: 24px;
- margin-bottom: 20px;
- line-height: 40px;
- margin: 0;
- }
- .has-module {
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- &-tree {
- width: 340px;
- height: 100%;
- overflow: auto;
- padding: 20px 0px;
- border-right: 1px solid #d9d9d9;
- }
- .inner {
- // border-left: 1px solid #d9d9d9;
- width: 1000px;
- flex: 1;
- margin: 0 auto;
- box-sizing: border-box;
- padding: 20px;
- position: relative;
- background: #fff;
- .title-box {
- display: flex;
- align-items: center;
- margin-bottom: 12px;
- padding-right: 160px;
- position: relative;
- > img {
- width: 40px;
- margin-right: 16px;
- cursor: pointer;
- }
- }
- .title {
- font-size: 24px;
- margin-bottom: 20px;
- line-height: 40px;
- margin: 0;
- }
- .has-module {
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- }
- .edit-btn {
- display: inline-block;
- font-size: 14px;
- background: #ff9900;
- float: right;
- line-height: 36px;
- color: #fff;
- width: 60px;
- text-align: center;
- border-radius: 4px;
- }
- }
- }
- }
- .nav-list {
- width: 200px;
- height: 40px;
- background: rgba(49, 212, 134, 0.2);
- border-radius: 240px;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- padding: 0;
- margin: 0;
- margin-bottom: 10px;
- list-style: none;
- > li {
- height: 40px;
- width: 100px;
- text-align: center;
- font-style: normal;
- font-weight: bold;
- font-size: 14px;
- line-height: 40px;
- color: #19b068;
- cursor: pointer;
- &.active {
- background: #19b068;
- border-radius: 240px;
- color: #ffffff;
- }
- }
- }
- }
- .screen-full {
- position: absolute;
- right: 30px;
- bottom: 30px;
- width: 48px;
- height: 48px;
- background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")
- center no-repeat;
- background-size: 32px;
- }
- .answerShow {
- position: absolute;
- right: 20px;
- top: 20px;
- width: 112px;
- height: 40px;
- background: #ffffff url("../assets/common/icon-eye-close.png") 16px center
- no-repeat;
- background-size: 16px;
- border: 1px solid rgba(44, 44, 44, 0.15);
- box-sizing: border-box;
- border-radius: 4px;
- font-size: 14px;
- line-height: 150%;
- color: #000000;
- padding: 9px 16px 9px 36px;
- cursor: pointer;
- z-index: 2;
- &.answerShowTrue {
- background: #f5f5f5 url("../assets/common/icon-eye-open.png") 16px center
- no-repeat;
- background-size: 16px;
- }
- }
- }
- .img_url{
- width: 1000px;
- height: 700px;
- }
- </style>
- <style lang="scss">
- .title-box {
- .el-switch {
- position: absolute;
- top: 0;
- right: 0px;
- border: 1px solid rgba(44, 44, 44, 0.15);
- border-radius: 40px;
- height: 40px;
- padding: 6px 6px 6px 16px;
- }
- .el-switch__label.is-active {
- color: #000000;
- font-size: 16px;
- }
- }
- </style>
|