index.vue 5.5 KB

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