index.vue 6.8 KB

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