index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!-- -->
  2. <template>
  3. <div class="NPC-ArticleView">
  4. <div class="ArticleView-header">
  5. <el-switch
  6. style="display: block"
  7. v-model="showPhrases"
  8. active-color="#DE4444"
  9. inactive-color="rgba(0,0,0,0.1)"
  10. active-text=""
  11. inactive-text="本课生词"
  12. @change="handleSwitchChange('showPractice', 'showWord')"
  13. >
  14. </el-switch>
  15. <el-switch
  16. style="display: block"
  17. v-model="showPractice"
  18. active-color="#DE4444"
  19. inactive-color="rgba(0,0,0,0.1)"
  20. active-text=""
  21. inactive-text="语音练习"
  22. @change="handleSwitchChange('showPhrases', 'showWord')"
  23. >
  24. </el-switch>
  25. <el-switch
  26. style="display: block"
  27. v-model="showWord"
  28. active-color="#DE4444"
  29. inactive-color="rgba(0,0,0,0.1)"
  30. active-text=""
  31. inactive-text="取词"
  32. @change="handleSwitchChange('showPhrases', 'showPractice')"
  33. >
  34. </el-switch>
  35. <!-- <div class="setting-fontsize">
  36. <a @click="handleFontsize('-')"
  37. ><img src="../../../../assets/newImage/common/btn-reduce.png"
  38. /></a>
  39. <img src="../../../../assets/newImage/common/font-size.png" />
  40. <a @click="handleFontsize('+')"
  41. ><img src="../../../../assets/newImage/common/btn-increase.png"
  42. /></a>
  43. </div> -->
  44. </div>
  45. <div class="ArticleView-body" ref="ArticleViewbody">
  46. <NormalModelChs
  47. :curQue="curQue"
  48. :titleFontsize="titleFontsize"
  49. :wordFontsize="wordFontsize"
  50. :bodyLeft="bodyLeft"
  51. :bodyWidth="bodyWidth"
  52. :colorBox="colorBox"
  53. :NotesList="NotesList"
  54. v-if="!showPhrases && !showPractice && !showWord"
  55. />
  56. <PhraseModel
  57. :curQue="curQue"
  58. :titleFontsize="titleFontsize"
  59. :wordFontsize="wordFontsize"
  60. :NNPENewWordList="NNPENewWordList"
  61. :colorBox="colorBox"
  62. v-if="showPhrases"
  63. />
  64. <Practice
  65. :curQue="curQue"
  66. :titleFontsize="titleFontsize"
  67. :wordFontsize="wordFontsize"
  68. :colorBox="colorBox"
  69. v-if="showPractice"
  70. />
  71. <WordModel
  72. :curQue="curQue"
  73. :titleFontsize="titleFontsize"
  74. :wordFontsize="wordFontsize"
  75. :bodyLeft="bodyLeft"
  76. :bodyWidth="bodyWidth"
  77. :NNPENewWordList="NNPENewWordList"
  78. :colorBox="colorBox"
  79. v-if="showWord"
  80. />
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import PhraseModel from "./PhraseModelChs.vue";
  86. import NormalModelChs from "./NormalModelChs.vue";
  87. import Practice from "./Practicechs.vue"; // 语音练习模式
  88. import WordModel from "./WordModelChs.vue"; // 语音练习模式
  89. export default {
  90. name: "ArticleView",
  91. props: ["curQue", "NNPENewWordList", "NotesList", "colorBox"],
  92. components: { NormalModelChs, Practice, WordModel, PhraseModel },
  93. data() {
  94. return {
  95. showPreview: true, // 全文预览
  96. showPhrases: false, // 显示单词和短语
  97. showPractice: false, // 语音练习
  98. showWord: false, // 取词
  99. titleFontsize: 20, // 标题字号初始值
  100. wordFontsize: 16, // 文章内容字号初始值
  101. bodyLeft: 0,
  102. bodyWidth: 0,
  103. resColorArr: [],
  104. };
  105. },
  106. computed: {},
  107. watch: {},
  108. //方法集合
  109. methods: {
  110. // 处理字体大小
  111. handleFontsize(symbol) {
  112. if (symbol == "+") {
  113. if (this.wordFontsize < 24) {
  114. this.titleFontsize = this.titleFontsize + 2;
  115. this.wordFontsize = this.wordFontsize + 2;
  116. }
  117. } else if (symbol == "-") {
  118. if (this.wordFontsize > 12) {
  119. this.titleFontsize = this.titleFontsize - 2;
  120. this.wordFontsize = this.wordFontsize - 2;
  121. }
  122. }
  123. },
  124. // 切换开关
  125. handleSwitchChange(obj1, obj2) {
  126. this[obj1] = false;
  127. this[obj2] = false;
  128. this.showPreview = false;
  129. },
  130. },
  131. //生命周期 - 创建完成(可以访问当前this实例)
  132. created() {},
  133. //生命周期 - 挂载完成(可以访问DOM元素)
  134. mounted() {
  135. console.log("我是文章预览");
  136. console.log(this.curQue);
  137. this.$nextTick(() => {
  138. this.bodyLeft = this.$refs.ArticleViewbody.getBoundingClientRect().left;
  139. });
  140. console.log(this.NNPENewWordList);
  141. },
  142. beforeCreate() {}, //生命周期 - 创建之前
  143. beforeMount() {}, //生命周期 - 挂载之前
  144. beforeUpdate() {}, //生命周期 - 更新之前
  145. updated() {}, //生命周期 - 更新之后
  146. beforeDestroy() {}, //生命周期 - 销毁之前
  147. destroyed() {}, //生命周期 - 销毁完成
  148. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  149. };
  150. </script>
  151. <style lang='scss' scoped>
  152. //@import url(); 引入公共css类
  153. .NPC-ArticleView {
  154. width: 100%;
  155. .ArticleView-header {
  156. display: flex;
  157. justify-content: flex-end;
  158. align-items: center;
  159. margin-bottom: 16px;
  160. .setting-fontsize {
  161. display: flex;
  162. margin-left: 24px;
  163. a {
  164. border: 1px solid rgba(0, 0, 0, 0.1);
  165. box-sizing: border-box;
  166. border-radius: 4px;
  167. display: block;
  168. height: 24px;
  169. width: 24px;
  170. }
  171. img {
  172. width: 100%;
  173. }
  174. > img {
  175. margin: 0 8px;
  176. width: 24px;
  177. }
  178. }
  179. }
  180. .ArticleView-body {
  181. border: 1px solid rgba(0, 0, 0, 0.1);
  182. box-sizing: border-box;
  183. border-radius: 8px;
  184. overflow: hidden;
  185. background: #fff;
  186. box-sizing: border-box;
  187. .aduioLine-box {
  188. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  189. width: 100%;
  190. }
  191. }
  192. }
  193. </style>
  194. <style lang="scss">
  195. .NPC-ArticleView {
  196. .notice {
  197. font-weight: normal;
  198. font-size: 14px;
  199. line-height: 150%;
  200. margin-bottom: 16px;
  201. color: #000000;
  202. padding: 0 24px;
  203. margin-bottom: 8px;
  204. }
  205. .ArticleView-header {
  206. .el-switch {
  207. margin-left: 24px;
  208. }
  209. .el-switch__core {
  210. width: 44px !important;
  211. height: 24px;
  212. border-radius: 20px;
  213. }
  214. .el-switch__core:after {
  215. top: 3px;
  216. left: 3px;
  217. }
  218. .el-switch.is-checked .el-switch__core::after {
  219. left: 100%;
  220. margin-left: -19px;
  221. }
  222. .el-switch__label {
  223. color: #000000;
  224. }
  225. .el-switch__label.is-active {
  226. color: rgba($color: #000000, $alpha: 0.3);
  227. }
  228. .el-switch__label--left {
  229. margin-right: 8px;
  230. }
  231. }
  232. }
  233. </style>