bookView.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div class="container">
  3. <div class="book-content-inner">
  4. <div id="content-tree" :class="[fullTree?'content-tree-full':'content-tree']">
  5. <!-- <TreeView ref="treeView" :book-id="bookId" :change-id="changeId" /> -->
  6. </div>
  7. <div id="data-screen" class="inner">
  8. <!-- 显示答案按钮 -->
  9. <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->
  10. <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->
  11. <div v-if="chapterId" class="title-box">
  12. <img
  13. v-if="!treeFlag"
  14. src="../assets/common/icon-view-back.png"
  15. @click="treeShow"
  16. >
  17. <img
  18. v-if="!treeFlag"
  19. :src="fullTree?require('../assets/common/icon-treelist-gray.png'):require('../assets/common/icon-treelist.png')"
  20. @click="chooseCourseware"
  21. >
  22. <!-- <h2 class="title">{{ chapterName }}</h2> -->
  23. <!-- <el-switch
  24. v-if="!treeFlag"
  25. v-model="switchvalue"
  26. active-color="#FF9900"
  27. active-text
  28. inactive-text="生词模式"
  29. /> -->
  30. </div>
  31. <Preview
  32. v-if="chapterId && context"
  33. ref="previewAnswer"
  34. :context="context"
  35. :bookAnswerContent="bookAnswerContent"
  36. bookclientwidth="900"
  37. :TaskModel="TaskModel"
  38. @handleBookUserAnswer="handleBookUserAnswer"
  39. :isShowTitle="true"
  40. />
  41. </div>
  42. <a
  43. v-if="chapterId && treeFlag"
  44. class="screen-full"
  45. @click="fullScreen()"
  46. />
  47. </div>
  48. <!-- <Preview :context="context" :queIndex="queIndex" /> -->
  49. </div>
  50. </template>
  51. <script>
  52. // import TreeView from '@/components/inputModules/common/TreeView'
  53. import { getContent } from '@/api/ajax'
  54. import Cookies from 'js-cookie'
  55. // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
  56. import Preview from '@/components/Adult/Preview'
  57. export default {
  58. name: 'CourseView',
  59. components: {
  60. // TreeView,
  61. Preview
  62. },
  63. props:['bookId',"bookIsBuy"],
  64. data() {
  65. return {
  66. chapterId: '',
  67. chapterName: '',
  68. fullscreen: false, // 控制全屏
  69. context: null,
  70. question: null, // 选择的模板题型
  71. queIndex: '',
  72. treeFlag: true, // tree是否显示
  73. switchvalue: true, // 生词模式
  74. isAnswerShow: false, // 是否显示答案
  75. bookAnswerContent: '[[6],[],[9]]',
  76. TaskModel: 'PRACTICE',
  77. fullTree:false, // 全屏模式下树是否显示
  78. }
  79. },
  80. mounted() {
  81. // const _this = this
  82. // _this.bookId = this.$route.query.bookId
  83. },
  84. methods: {
  85. changeId(id, name,free) {
  86. if( this.bookIsBuy == 'true' || ( this.bookIsBuy == 'false'&& free == 'true')){
  87. const _this = this
  88. _this.chapterId = id
  89. _this.chapterName = name
  90. _this.isAnswerShow = false
  91. _this.onGetData()
  92. if(!_this.treeFlag){
  93. _this.fullTree = false
  94. document.getElementById('content-tree').style.display = 'none'
  95. }
  96. }else{
  97. this.chapterId = ''
  98. this.chapterName = ''
  99. this.context = null
  100. this.$message(
  101. {
  102. type: "warning",
  103. message: "您还没有购买此教材,请购买后查看!",
  104. },
  105. 2000
  106. );
  107. }
  108. },
  109. // 点击全屏展示 隐藏tree
  110. fullScreen() {
  111. this.treeFlag = false
  112. document.getElementById('content-tree').style.display = 'none'
  113. this.$emit("bookdetailShow", false)
  114. },
  115. treeShow() {
  116. this.treeFlag = true
  117. this.fullTree = false
  118. document.getElementById('content-tree').style.display = 'block'
  119. this.$emit("bookdetailShow", true)
  120. },
  121. // 获取预览数据
  122. onGetData() {
  123. const _this = this
  124. const MethodName = 'book-courseware_manager-GetCoursewareContent_View'
  125. const data = {
  126. id: _this.chapterId
  127. }
  128. getContent(MethodName, data).then(
  129. (res) => {
  130. if (res.content) {
  131. const _this = this
  132. _this.context = {
  133. id: _this.chapterId,
  134. ui_type: JSON.parse(res.content).question ? JSON.parse(res.content).question.ui_type : '',
  135. sort_number: 1,
  136. content: JSON.parse(res.content)
  137. }
  138. } else {
  139. const _this = this
  140. _this.context = null
  141. }
  142. }
  143. )
  144. },
  145. // 显示或隐藏答案
  146. handleAnswerShow() {
  147. this.isAnswerShow = !this.isAnswerShow
  148. this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow)
  149. },
  150. // 得到用户答题答案
  151. handleBookUserAnswer(data){
  152. console.log(data)
  153. },
  154. // 悬浮树隐藏显示
  155. chooseCourseware(){
  156. this.fullTree = !this.fullTree
  157. if(this.fullTree){
  158. document.getElementById('content-tree').style.display = 'block'
  159. }else{
  160. document.getElementById('content-tree').style.display = 'none'
  161. }
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .container {
  168. width: 100%;
  169. height: auto;
  170. // padding: 24px 120px;
  171. // background: #F5F5F5;
  172. .book-content-inner {
  173. background: #fff;
  174. width: 100%;
  175. height: 700px;
  176. overflow: auto;
  177. display: flex;
  178. justify-content: flex-start;
  179. align-items: flex-start;
  180. position: relative;
  181. &-tree {
  182. width: 340px;
  183. height: 100%;
  184. overflow: auto;
  185. padding: 20px 0px;
  186. border-right: 1px solid #d9d9d9;
  187. }
  188. .content-tree{
  189. border-right: 1px solid #D9D9D9;
  190. max-height: 700px;
  191. overflow: auto;
  192. }
  193. .content-tree-full{
  194. position: fixed;
  195. top: 100px;
  196. left: 152px;
  197. max-height: 588px;
  198. overflow: auto;
  199. z-index: 999;
  200. background: #fff;
  201. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
  202. border-radius: 4px;
  203. }
  204. .inner {
  205. width: 1000px;
  206. max-height: 700px;
  207. overflow: auto;
  208. flex: 1;
  209. margin: 0 auto;
  210. box-sizing: border-box;
  211. padding: 20px;
  212. position: relative;
  213. background: #fff;
  214. .title-box {
  215. display: flex;
  216. align-items: center;
  217. margin-bottom: 12px;
  218. padding-right: 160px;
  219. position: relative;
  220. > img {
  221. width: 40px;
  222. margin-right: 16px;
  223. cursor: pointer;
  224. }
  225. }
  226. .title {
  227. font-size: 24px;
  228. margin-bottom: 20px;
  229. line-height: 40px;
  230. margin: 0;
  231. }
  232. .has-module {
  233. display: flex;
  234. justify-content: flex-start;
  235. align-items: flex-start;
  236. &-tree {
  237. width: 340px;
  238. height: 100%;
  239. overflow: auto;
  240. padding: 20px 0px;
  241. border-right: 1px solid #d9d9d9;
  242. }
  243. .inner {
  244. // border-left: 1px solid #d9d9d9;
  245. width: 1000px;
  246. flex: 1;
  247. margin: 0 auto;
  248. box-sizing: border-box;
  249. padding: 20px;
  250. position: relative;
  251. background: #fff;
  252. .title-box {
  253. display: flex;
  254. align-items: center;
  255. margin-bottom: 12px;
  256. padding-right: 160px;
  257. position: relative;
  258. > img {
  259. width: 40px;
  260. margin-right: 16px;
  261. cursor: pointer;
  262. }
  263. }
  264. .title {
  265. font-size: 24px;
  266. margin-bottom: 20px;
  267. line-height: 40px;
  268. margin: 0;
  269. }
  270. .has-module {
  271. display: flex;
  272. justify-content: flex-start;
  273. align-items: flex-start;
  274. }
  275. .edit-btn {
  276. display: inline-block;
  277. font-size: 14px;
  278. background: #ff9900;
  279. float: right;
  280. line-height: 36px;
  281. color: #fff;
  282. width: 60px;
  283. text-align: center;
  284. border-radius: 4px;
  285. }
  286. }
  287. }
  288. }
  289. .nav-list {
  290. width: 200px;
  291. height: 40px;
  292. background: rgba(49, 212, 134, 0.2);
  293. border-radius: 240px;
  294. display: flex;
  295. justify-content: flex-start;
  296. align-items: center;
  297. padding: 0;
  298. margin: 0;
  299. margin-bottom: 10px;
  300. list-style: none;
  301. > li {
  302. height: 40px;
  303. width: 100px;
  304. text-align: center;
  305. font-style: normal;
  306. font-weight: bold;
  307. font-size: 14px;
  308. line-height: 40px;
  309. color: #19b068;
  310. cursor: pointer;
  311. &.active {
  312. background: #19b068;
  313. border-radius: 240px;
  314. color: #ffffff;
  315. }
  316. }
  317. }
  318. }
  319. .screen-full {
  320. position: absolute;
  321. right: 30px;
  322. bottom: 30px;
  323. width: 48px;
  324. height: 48px;
  325. background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")
  326. center no-repeat;
  327. background-size: 32px;
  328. }
  329. .answerShow{
  330. position: absolute;
  331. right: 20px;
  332. top: 20px;
  333. width: 112px;
  334. height: 40px;
  335. background: #FFFFFF url('../assets/common/icon-eye-close.png') 16px center no-repeat;
  336. background-size: 16px;
  337. border: 1px solid rgba(44, 44, 44, 0.15);
  338. box-sizing: border-box;
  339. border-radius: 4px;
  340. font-size: 14px;
  341. line-height: 150%;
  342. color: #000000;
  343. padding:9px 16px 9px 36px;
  344. cursor: pointer;
  345. z-index: 2;
  346. &.answerShowTrue{
  347. background: #F5F5F5 url('../assets/common/icon-eye-open.png') 16px center no-repeat;
  348. background-size: 16px;
  349. }
  350. }
  351. }
  352. </style>
  353. <style lang="scss">
  354. .title-box {
  355. .el-switch {
  356. position: absolute;
  357. top: 0;
  358. right: 0px;
  359. border: 1px solid rgba(44, 44, 44, 0.15);
  360. border-radius: 40px;
  361. height: 40px;
  362. padding: 6px 6px 6px 16px;
  363. }
  364. .el-switch__label.is-active {
  365. color: #000000;
  366. font-size: 16px;
  367. }
  368. }
  369. </style>