Preview.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <!-- -->
  2. <template>
  3. <div class="NNPE-Big-Book-preview">
  4. <div class="NNPE-title">
  5. <h1>{{ fatherName }}</h1>
  6. <div class="NNPE-operate">
  7. <a class="btn-prev" @click="handleNNPEprev"></a>
  8. <a class="btn-next" @click="handleNNPEnext"></a>
  9. </div>
  10. </div>
  11. <div class="NNPE-Book-content-inner" v-if="cur">
  12. <div v-for="(item, index) in cur.cur_fn_data" :key="index">
  13. <h2 v-if="item.Ztitle">{{ item.Ztitle }}</h2>
  14. <h3 v-if="item.Ftitle">{{ item.Ftitle }}</h3>
  15. <div
  16. :class="['NNPE-tableList', item.Isbg ? 'NNPE-tableList-hasBg' : '']"
  17. >
  18. <div
  19. class="NNPE-tableList-tr"
  20. v-for="(items, indexs) in item.table_list"
  21. :key="indexs"
  22. >
  23. <div
  24. :class="[
  25. 'NNPE-tableList-item',
  26. items.length == 1 ? 'NNPE-tableList-item-noMargin' : '',
  27. ]"
  28. v-for="(itemss, indexss) in items"
  29. :key="indexss"
  30. >
  31. <template v-if="itemss.data">
  32. <template v-if="itemss.data.type == 'ligature'">
  33. <Ligature :curQue="itemss.que" />
  34. </template>
  35. <template v-if="itemss.data.type == 'image_chs'">
  36. <Picture :curQue="itemss.data" />
  37. </template>
  38. <template v-if="itemss.data.type == 'record_chs'">
  39. <Record :curQue="itemss.data" />
  40. </template>
  41. <template v-if="itemss.data.type == 'phrase_chs'">
  42. <WordPhrase :curQue="itemss.data" />
  43. </template>
  44. <template v-if="itemss.data.type == 'NewWord_chs'">
  45. <WordPhrase :curQue="itemss.data" />
  46. </template>
  47. <template v-if="itemss.data.type == 'annotation_chs'">
  48. <WordPhrase :curQue="itemss.data" />
  49. </template>
  50. <template v-if="itemss.data.type == 'notes_chs'">
  51. <Notes :curQue="itemss.data" />
  52. </template>
  53. <template v-if="itemss.data.type == 'article_chs'">
  54. <ArticleTemChs
  55. :curQue="itemss.data"
  56. :NNPENewWordList="NNPENewWordList"
  57. :NNPENewPhraseList="NNPENewPhraseList"
  58. :NNPEAnnotationList="NNPEAnnotationList"
  59. />
  60. </template>
  61. </template>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import Picture from "./preview/Picture.vue"; // 图片模板
  71. import Record from "./preview/Record.vue"; // 音频播放
  72. import Soundrecord from "./preview/Soundrecord.vue"; // 录音模板
  73. import ArticleTemChs from "./preview/ArticleViewChs/index.vue"; // 文章模板
  74. import WordPhrase from "./preview/WordPhrase.vue"; // 生词 短语
  75. import Notes from "./preview/Notes.vue"; // 注释
  76. import Ligature from "./preview/Ligature.vue";
  77. export default {
  78. name: "preview",
  79. components: {
  80. Picture,
  81. Record,
  82. Soundrecord,
  83. ArticleTemChs,
  84. WordPhrase,
  85. Notes,
  86. Ligature,
  87. },
  88. props: ["context", "fatherName"],
  89. data() {
  90. return {
  91. contextData: null,
  92. queIndex: -1, // 题目的索引
  93. cur: null, // 当前的题目
  94. watchIndex: -1, // 监听的值
  95. queList: [],
  96. queTotal: 0, // 题目总数
  97. NNPENewWordList: [], // 存放文章的生词
  98. NNPENewPhraseList: [], // 存放文章的短语
  99. NNPEAnnotationList: [], // 存放文章注释
  100. height: "", //总体的高度
  101. };
  102. },
  103. computed: {},
  104. watch: {
  105. context: {
  106. handler: function (val, oldVal) {
  107. const _this = this;
  108. if (val) {
  109. _this.initContextData();
  110. }
  111. },
  112. // 深度观察监听
  113. deep: true,
  114. },
  115. },
  116. //方法集合
  117. methods: {
  118. initContextData() {
  119. const _this = this;
  120. _this.contextData = JSON.parse(JSON.stringify(_this.context));
  121. _this.queIndex = 0;
  122. _this.NNPENewWordList = [];
  123. _this.NNPENewPhraseList = [];
  124. _this.watchIndex = _this.queIndex + new Date().getTime();
  125. if (_this.contextData) {
  126. const list = _this.contextData;
  127. if (list && list.length > 0) {
  128. _this.queList = list;
  129. _this.cur = list[_this.queIndex];
  130. _this.queTotal = list.length;
  131. _this.cur.cur_fn_data.forEach((item) => {
  132. item.table_list.forEach((items) => {
  133. items.forEach((itemss) => {
  134. if (itemss.data && itemss.data.type == "NewWord_chs") {
  135. _this.NNPENewWordList = _this.NNPENewWordList.concat(
  136. itemss.data.option
  137. );
  138. } else if (itemss.data && itemss.data.type == "notes_chs") {
  139. _this.NNPEAnnotationList = _this.NNPEAnnotationList.concat(
  140. itemss.data.option
  141. );
  142. }
  143. });
  144. });
  145. });
  146. }
  147. }
  148. },
  149. // 上一页
  150. handleNNPEprev() {
  151. const _this = this;
  152. if (_this.queIndex == 0) {
  153. // this.$message({
  154. // message: "已经是第一题",
  155. // type: "success",
  156. // });
  157. } else {
  158. _this.queIndex = _this.queIndex - 1;
  159. _this.watchIndex = _this.queIndex + new Date().getTime();
  160. _this.cur = _this.queList[_this.queIndex];
  161. }
  162. },
  163. // 下一页
  164. handleNNPEnext() {
  165. const _this = this;
  166. if (_this.queIndex == _this.queTotal - 1) {
  167. // this.$message({
  168. // message: "已经是最后一题",
  169. // type: "success",
  170. // });
  171. } else {
  172. _this.queIndex = _this.queIndex + 1;
  173. _this.watchIndex = _this.queIndex + new Date().getTime();
  174. _this.cur = _this.queList[_this.queIndex];
  175. }
  176. },
  177. },
  178. //生命周期 - 创建完成(可以访问当前this实例)
  179. created() {},
  180. //生命周期 - 挂载完成(可以访问DOM元素)
  181. mounted() {
  182. const _this = this;
  183. if (_this.context) {
  184. _this.initContextData();
  185. }
  186. },
  187. beforeCreate() {}, //生命周期 - 创建之前
  188. beforeMount() {}, //生命周期 - 挂载之前
  189. beforeUpdate() {}, //生命周期 - 更新之前
  190. updated() {}, //生命周期 - 更新之后
  191. beforeDestroy() {}, //生命周期 - 销毁之前
  192. destroyed() {}, //生命周期 - 销毁完成
  193. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  194. };
  195. </script>
  196. <style lang='scss' scoped>
  197. //@import url(); 引入公共css类
  198. .NNPE-Big-Book-preview {
  199. width: 860px;
  200. margin: 0 auto;
  201. position: relative;
  202. .NNPE-title {
  203. background: #4f92f6;
  204. padding: 20px 24px;
  205. position: relative;
  206. h1 {
  207. color: #ffffff;
  208. font-weight: bold;
  209. font-size: 16px;
  210. line-height: 150%;
  211. margin: 0;
  212. }
  213. .NNPE-operate {
  214. position: absolute;
  215. top: 10px;
  216. right: 20px;
  217. a {
  218. background: #66a3ff url("../../assets/newImage/common/btn-pre.png")
  219. center no-repeat;
  220. border-radius: 4px;
  221. width: 44px;
  222. height: 44px;
  223. display: inline-block;
  224. margin: 0 4px;
  225. &.btn-next {
  226. background: #66a3ff url("../../assets/newImage/common/btn-next.png")
  227. center no-repeat;
  228. }
  229. &:hover {
  230. background-color: #3f75c4;
  231. }
  232. }
  233. }
  234. }
  235. .NNPE-Book-content-inner {
  236. padding: 0 40px;
  237. > div {
  238. padding-top: 24px;
  239. > h2 {
  240. color: #000000;
  241. font-size: 16px;
  242. line-height: 150%;
  243. font-weight: bold;
  244. margin: 0;
  245. }
  246. > h3 {
  247. color: #000000;
  248. font-size: 16px;
  249. line-height: 150%;
  250. font-weight: normal;
  251. margin: 8px 0 16px 0;
  252. }
  253. }
  254. .NNPE-tableList {
  255. background: #fff;
  256. padding: 12px 8px;
  257. border-radius: 8px;
  258. &.NNPE-tableList-hasBg {
  259. background: #f3f3f3;
  260. }
  261. .NNPE-tableList-tr {
  262. display: flex;
  263. justify-content: space-between;
  264. // flex-flow: wrap;
  265. .NNPE-tableList-item {
  266. width: 100%;
  267. margin: 12px 16px;
  268. // padding: 16px;
  269. // background: #FFFFFF;
  270. // border-radius: 4px;
  271. display: flex;
  272. flex-flow: wrap;
  273. justify-content: center;
  274. &.NNPE-tableList-item-noMargin {
  275. margin: 0;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. </style>