index.vue 7.1 KB

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