index.vue 6.4 KB

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