bookView.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <div class="container">
  3. <div class="book-content-inner">
  4. <div
  5. id="content-tree"
  6. :class="[fullTree ? 'content-tree-full' : 'content-tree']"
  7. >
  8. <h2 class="catelog"><!-- 目录 -->{{ $t("Key612") }}</h2>
  9. <div style="padding-left: 8px">
  10. <TreeView
  11. ref="treeView"
  12. :book-id="bookId"
  13. :change-id="changeId"
  14. :changeTreeData="changeTreeData"
  15. :currentTreeID="chapterId"
  16. />
  17. </div>
  18. </div>
  19. <el-image :src="pictureUrl" fit="scale-down" class="img_url" v-if="!chapterId&&pictureUrl">
  20. <div slot="placeholder" class="image-slot">
  21. <img src="../assets/common/icon-imgloading.png" />
  22. </div>
  23. </el-image>
  24. <div
  25. id="data-screen"
  26. class="inner"
  27. v-if="chapterFree == 'true' || bookIsBuy == 'true'"
  28. >
  29. <!-- 显示答案按钮 -->
  30. <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->
  31. <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->
  32. <div v-if="chapterId" class="title-box">
  33. <img
  34. v-if="!treeFlag"
  35. src="../assets/common/icon-view-back.png"
  36. @click="treeShow"
  37. />
  38. <img
  39. v-if="!treeFlag"
  40. :src="
  41. fullTree
  42. ? require('../assets/common/icon-treelist-gray.png')
  43. : require('../assets/common/icon-treelist.png')
  44. "
  45. @click="chooseCourseware"
  46. />
  47. <!-- <h2 class="title">{{ chapterName }}</h2> -->
  48. <!-- <el-switch
  49. v-if="!treeFlag"
  50. v-model="switchvalue"
  51. active-color="#FF9900"
  52. active-text
  53. inactive-text="生词模式"
  54. /> -->
  55. </div>
  56. <template v-if="category == 'OC' || !category">
  57. <Preview
  58. v-if="chapterId && context"
  59. ref="previewAnswer"
  60. :context="context"
  61. :bookAnswerContent="bookAnswerContent"
  62. bookclientwidth="900"
  63. :TaskModel="TaskModel"
  64. @handleBookUserAnswer="handleBookUserAnswer"
  65. />
  66. </template>
  67. <template v-if="category == 'NPC'">
  68. <Booknpc
  69. v-if="chapterId && context"
  70. ref="previewAnswer"
  71. :context="context"
  72. :currentTreeID="chapterId"
  73. :FatherTreeData="FatherTreeData"
  74. :change-id="changeId"
  75. :themeColor="themeColor"
  76. :isShowTitle="true"
  77. :isAnswerItemShow="isAnswerItemShow"
  78. />
  79. </template>
  80. <template v-if="category == 'NNPE'">
  81. <Booknnpe
  82. v-if="chapterId && context"
  83. ref="previewAnswer"
  84. :context="context"
  85. :currentTreeID="chapterId"
  86. :FatherTreeData="FatherTreeData"
  87. :change-id="changeId"
  88. :themeColor="themeColor"
  89. :isShowTitle="true"
  90. :isAnswerItemShow="true"
  91. />
  92. </template>
  93. <template v-if="category == 'RLC'">
  94. <Bookrlc
  95. v-if="chapterId && context"
  96. ref="previewAnswer"
  97. :context="context"
  98. :currentTreeID="chapterId"
  99. :FatherTreeData="FatherTreeData"
  100. :change-id="changeId"
  101. :themeColor="themeColor"
  102. :isShowTitle="true"
  103. :bookFontSize="bookFontSize"
  104. :isAnswerItemShow="isAnswerItemShow"
  105. />
  106. </template>
  107. <template v-if="category == 'NEW'">
  108. <BookNew
  109. v-if="chapterId && context"
  110. ref="book"
  111. :context="context"
  112. :currentTreeID="chapterId"
  113. />
  114. </template>
  115. </div>
  116. <a
  117. v-if="chapterId && treeFlag"
  118. class="screen-full"
  119. @click="fullScreen()"
  120. />
  121. </div>
  122. <!-- <Preview :context="context" :queIndex="queIndex" /> -->
  123. </div>
  124. </template>
  125. <script>
  126. import TreeView from "@/components/inputModules/common/TreeView.vue";
  127. import { getContent } from "@/api/ajax";
  128. import Cookies from "js-cookie";
  129. // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
  130. import Preview from "@/components/Preview";
  131. import { getToken } from "../utils/auth";
  132. export default {
  133. name: "CourseView",
  134. components: {
  135. TreeView,
  136. Preview,
  137. },
  138. props: ["bookId", "bookIsBuy","bookFontSize","pictureUrl"],
  139. data() {
  140. return {
  141. chapterId: "",
  142. chapterName: "",
  143. fullscreen: false, // 控制全屏
  144. context: null,
  145. question: null, // 选择的模板题型
  146. queIndex: "",
  147. treeFlag: true, // tree是否显示
  148. switchvalue: true, // 生词模式
  149. isAnswerShow: false, // 是否显示答案
  150. bookAnswerContent: "[]",
  151. TaskModel: "",
  152. fullTree: false, // 全屏模式下树是否显示
  153. category: "",
  154. FatherTreeData: null,
  155. themeColor: "",
  156. chapterFree: "false", // 课件免费观看
  157. isAnswerItemShow: false,
  158. };
  159. },
  160. mounted() {
  161. // const _this = this
  162. // _this.bookId = this.$route.query.bookId
  163. },
  164. created(){
  165. const _this = this
  166. let userInfor = JSON.parse(getToken());
  167. if (userInfor && (userInfor.user_type == "TEACHER"||userInfor.user_type == "INNER")) {
  168. _this.isAnswerItemShow = true;
  169. } else {
  170. _this.isAnswerItemShow = false;
  171. }
  172. },
  173. methods: {
  174. changeTreeData(val) {
  175. this.FatherTreeData =
  176. val != undefined ? JSON.parse(JSON.stringify(val)) : null;
  177. },
  178. changeId(id, name, free) {
  179. // if (
  180. // this.bookIsBuy == "true" ||
  181. // (this.bookIsBuy == "false" && free == "true")
  182. // ) {
  183. const _this = this;
  184. _this.chapterId = id;
  185. _this.chapterName = name;
  186. _this.isAnswerShow = false;
  187. _this.chapterFree = free;
  188. _this.onGetData();
  189. if (!_this.treeFlag) {
  190. _this.fullTree = false;
  191. document.getElementById("content-tree").style.display = "none";
  192. }
  193. // scrollTo(0,0)
  194. // } else {
  195. // this.chapterId = "";
  196. // this.chapterName = "";
  197. // this.context = null;
  198. // this.$message(
  199. // {
  200. // type: "warning",
  201. // message: "您还没有购买此教材,请购买后查看!",
  202. // },
  203. // 2000
  204. // );
  205. // }
  206. },
  207. // 点击全屏展示 隐藏tree
  208. fullScreen() {
  209. this.treeFlag = false;
  210. document.getElementById("content-tree").style.display = "none";
  211. this.$emit("bookdetailShow", false);
  212. },
  213. treeShow() {
  214. this.treeFlag = true;
  215. this.fullTree = false;
  216. document.getElementById("content-tree").style.display = "block";
  217. this.$emit("bookdetailShow", true);
  218. },
  219. // 获取预览数据
  220. onGetData() {
  221. const _this = this;
  222. const MethodName = "book-courseware_manager-GetCoursewareContent_View";
  223. const data = {
  224. id: _this.chapterId,
  225. };
  226. getContent(MethodName, data).then((res) => {
  227. console.log(res);
  228. this.category = res.category;
  229. this.themeColor = res.book_theme_color;
  230. if (res.content) {
  231. const _this = this;
  232. if (!this.category || this.category == "OC") {
  233. _this.context = {
  234. id: _this.chapterId,
  235. ui_type: JSON.parse(res.content).question
  236. ? JSON.parse(res.content).question.ui_type
  237. : "",
  238. sort_number: 1,
  239. content: JSON.parse(res.content),
  240. };
  241. } else {
  242. _this.context = JSON.parse(res.content);
  243. }
  244. } else {
  245. const _this = this;
  246. _this.context = null;
  247. }
  248. });
  249. },
  250. // 显示或隐藏答案
  251. handleAnswerShow() {
  252. this.isAnswerShow = !this.isAnswerShow;
  253. this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow);
  254. },
  255. // 得到用户答题答案
  256. handleBookUserAnswer(data) {
  257. console.log(data);
  258. },
  259. // 悬浮树隐藏显示
  260. chooseCourseware() {
  261. this.fullTree = !this.fullTree;
  262. if (this.fullTree) {
  263. document.getElementById("content-tree").style.display = "block";
  264. } else {
  265. document.getElementById("content-tree").style.display = "none";
  266. }
  267. },
  268. },
  269. };
  270. </script>
  271. <style lang="scss" scoped>
  272. .container {
  273. width: 100%;
  274. height: auto;
  275. .catelog {
  276. padding: 24px 40px 16px 40px;
  277. font-weight: 600;
  278. font-size: 24px;
  279. line-height: 150%;
  280. color: #000000;
  281. margin: 0;
  282. }
  283. .book-content-inner {
  284. background: #fff;
  285. width: 100%;
  286. height: 700px;
  287. overflow: auto;
  288. display: flex;
  289. justify-content: flex-start;
  290. align-items: flex-start;
  291. position: relative;
  292. &-tree {
  293. width: 340px;
  294. height: 100%;
  295. overflow: auto;
  296. padding: 20px 0px;
  297. border-right: 1px solid #d9d9d9;
  298. }
  299. .content-tree {
  300. width: 320px;
  301. border-right: 1px solid #d9d9d9;
  302. max-height: 700px;
  303. overflow: auto;
  304. }
  305. .content-tree-full {
  306. position: fixed;
  307. top: 100px;
  308. left: 152px;
  309. max-height: 588px;
  310. overflow: auto;
  311. z-index: 1000;
  312. background: #fff;
  313. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
  314. border-radius: 4px;
  315. }
  316. .inner {
  317. width: 1000px;
  318. max-height: 700px;
  319. overflow: auto;
  320. flex: 1;
  321. margin: 0 auto;
  322. box-sizing: border-box;
  323. padding: 20px;
  324. position: relative;
  325. background: #fff;
  326. .title-box {
  327. display: flex;
  328. align-items: center;
  329. margin-bottom: 12px;
  330. padding-right: 160px;
  331. position: relative;
  332. > img {
  333. width: 40px;
  334. margin-right: 16px;
  335. cursor: pointer;
  336. }
  337. }
  338. .title {
  339. font-size: 24px;
  340. margin-bottom: 20px;
  341. line-height: 40px;
  342. margin: 0;
  343. }
  344. .has-module {
  345. display: flex;
  346. justify-content: flex-start;
  347. align-items: flex-start;
  348. &-tree {
  349. width: 340px;
  350. height: 100%;
  351. overflow: auto;
  352. padding: 20px 0px;
  353. border-right: 1px solid #d9d9d9;
  354. }
  355. .inner {
  356. // border-left: 1px solid #d9d9d9;
  357. width: 1000px;
  358. flex: 1;
  359. margin: 0 auto;
  360. box-sizing: border-box;
  361. padding: 20px;
  362. position: relative;
  363. background: #fff;
  364. .title-box {
  365. display: flex;
  366. align-items: center;
  367. margin-bottom: 12px;
  368. padding-right: 160px;
  369. position: relative;
  370. > img {
  371. width: 40px;
  372. margin-right: 16px;
  373. cursor: pointer;
  374. }
  375. }
  376. .title {
  377. font-size: 24px;
  378. margin-bottom: 20px;
  379. line-height: 40px;
  380. margin: 0;
  381. }
  382. .has-module {
  383. display: flex;
  384. justify-content: flex-start;
  385. align-items: flex-start;
  386. }
  387. .edit-btn {
  388. display: inline-block;
  389. font-size: 14px;
  390. background: #ff9900;
  391. float: right;
  392. line-height: 36px;
  393. color: #fff;
  394. width: 60px;
  395. text-align: center;
  396. border-radius: 4px;
  397. }
  398. }
  399. }
  400. }
  401. .nav-list {
  402. width: 200px;
  403. height: 40px;
  404. background: rgba(49, 212, 134, 0.2);
  405. border-radius: 240px;
  406. display: flex;
  407. justify-content: flex-start;
  408. align-items: center;
  409. padding: 0;
  410. margin: 0;
  411. margin-bottom: 10px;
  412. list-style: none;
  413. > li {
  414. height: 40px;
  415. width: 100px;
  416. text-align: center;
  417. font-style: normal;
  418. font-weight: bold;
  419. font-size: 14px;
  420. line-height: 40px;
  421. color: #19b068;
  422. cursor: pointer;
  423. &.active {
  424. background: #19b068;
  425. border-radius: 240px;
  426. color: #ffffff;
  427. }
  428. }
  429. }
  430. }
  431. .screen-full {
  432. position: absolute;
  433. right: 30px;
  434. bottom: 30px;
  435. width: 48px;
  436. height: 48px;
  437. background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")
  438. center no-repeat;
  439. background-size: 32px;
  440. }
  441. .answerShow {
  442. position: absolute;
  443. right: 20px;
  444. top: 20px;
  445. width: 112px;
  446. height: 40px;
  447. background: #ffffff url("../assets/common/icon-eye-close.png") 16px center
  448. no-repeat;
  449. background-size: 16px;
  450. border: 1px solid rgba(44, 44, 44, 0.15);
  451. box-sizing: border-box;
  452. border-radius: 4px;
  453. font-size: 14px;
  454. line-height: 150%;
  455. color: #000000;
  456. padding: 9px 16px 9px 36px;
  457. cursor: pointer;
  458. z-index: 2;
  459. &.answerShowTrue {
  460. background: #f5f5f5 url("../assets/common/icon-eye-open.png") 16px center
  461. no-repeat;
  462. background-size: 16px;
  463. }
  464. }
  465. }
  466. .img_url{
  467. width: 1000px;
  468. height: 700px;
  469. }
  470. </style>
  471. <style lang="scss">
  472. .title-box {
  473. .el-switch {
  474. position: absolute;
  475. top: 0;
  476. right: 0px;
  477. border: 1px solid rgba(44, 44, 44, 0.15);
  478. border-radius: 40px;
  479. height: 40px;
  480. padding: 6px 6px 6px 16px;
  481. }
  482. .el-switch__label.is-active {
  483. color: #000000;
  484. font-size: 16px;
  485. }
  486. }
  487. </style>