index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <!-- -->
  2. <template>
  3. <div
  4. class="NPC-ArticleView NPC-ArticleView-container"
  5. id="articleBoby"
  6. v-if="curQue && curQue.Bookanswer"
  7. >
  8. <div class="ArticleView-header">
  9. <!-- <a :class="['ArticleView-full']" v-if="showPractice" @click="goFullscreen"
  10. >全屏模式</a
  11. > -->
  12. <div>
  13. <div
  14. class="left"
  15. @click="submit"
  16. :style="{ marginLeft: showPractice ? '97px' : '' }"
  17. v-if="tokenData.popedom_code_list.indexOf(2000001) != -1&&1==2"
  18. >
  19. <img src="../../../../assets/NPC/wbfx-icon.png" alt="" />
  20. 文本分析
  21. </div>
  22. </div>
  23. <div class="right">
  24. <template v-if="curQue.checkList.indexOf(1) > -1">
  25. <el-switch
  26. style="display: block"
  27. v-model="showPhrases"
  28. :active-color="activeColor"
  29. inactive-color="rgba(0,0,0,0.1)"
  30. active-text=""
  31. inactive-text="本课生词"
  32. @change="handleSwitchChange('showPractice', 'showWord')"
  33. >
  34. </el-switch>
  35. </template>
  36. <template v-if="curQue.checkList.indexOf(2) > -1">
  37. <el-switch
  38. style="display: block"
  39. v-model="showPractice"
  40. :active-color="activeColor"
  41. inactive-color="rgba(0,0,0,0.1)"
  42. active-text=""
  43. inactive-text="语音练习"
  44. @change="handleSwitchChange('showPhrases', 'showWord')"
  45. >
  46. </el-switch>
  47. </template>
  48. <template v-if="curQue.checkList.indexOf(3) > -1">
  49. <el-switch
  50. style="display: block"
  51. v-model="showWord"
  52. :active-color="activeColor"
  53. inactive-color="rgba(0,0,0,0.1)"
  54. active-text=""
  55. inactive-text="取词"
  56. @change="handleSwitchChange('showPhrases', 'showPractice')"
  57. >
  58. </el-switch>
  59. </template>
  60. </div>
  61. <!-- <div class="setting-fontsize">
  62. <a @click="handleFontsize('-')"
  63. ><img src="../../../../assets/newImage/common/btn-reduce.png"
  64. /></a>
  65. <img src="../../../../assets/newImage/common/font-size.png" />
  66. <a @click="handleFontsize('+')"
  67. ><img src="../../../../assets/newImage/common/btn-increase.png"
  68. /></a>
  69. </div> -->
  70. </div>
  71. <div class="ArticleView-body" ref="ArticleViewbody">
  72. <NormalModelChs
  73. :curQue="curQue"
  74. :titleFontsize="titleFontsize"
  75. :wordFontsize="wordFontsize"
  76. :bodyLeft="bodyLeft"
  77. :bodyWidth="bodyWidth"
  78. :colorBox="colorBox"
  79. :NNPEAnnotationList="NNPEAnnotationList"
  80. :themeColor="themeColor"
  81. :noFont="noFont"
  82. :config="config"
  83. :TaskModel="TaskModel"
  84. @changeConfig="changeConfig"
  85. v-if="!showPhrases && !showPractice && !showWord"
  86. />
  87. <PhraseModel
  88. :curQue="curQue"
  89. :titleFontsize="titleFontsize"
  90. :wordFontsize="wordFontsize"
  91. :NNPENewWordList="NNPENewWordList"
  92. :NNPEAnnotationList="NNPEAnnotationList"
  93. :colorBox="colorBox"
  94. :themeColor="themeColor"
  95. :noFont="noFont"
  96. :currentTreeID="currentTreeID"
  97. :bodyLeft="bodyLeft"
  98. :config="config"
  99. :TaskModel="TaskModel"
  100. @changeConfig="changeConfig"
  101. v-if="showPhrases"
  102. />
  103. <Practice
  104. :curQue="curQue"
  105. :titleFontsize="titleFontsize"
  106. :wordFontsize="wordFontsize"
  107. :colorBox="colorBox"
  108. :themeColor="themeColor"
  109. :noFont="noFont"
  110. :currentTreeID="currentTreeID"
  111. :NNPENewWordList="NNPENewWordList"
  112. :config="config"
  113. :TaskModel="TaskModel"
  114. @changeConfig="changeConfig"
  115. v-if="showPractice"
  116. />
  117. <WordModel
  118. :curQue="curQue"
  119. :titleFontsize="titleFontsize"
  120. :wordFontsize="wordFontsize"
  121. :bodyLeft="bodyLeft"
  122. :bodyWidth="bodyWidth"
  123. :NNPENewWordList="NNPENewWordList"
  124. :colorBox="colorBox"
  125. :themeColor="themeColor"
  126. :noFont="noFont"
  127. :currentTreeID="currentTreeID"
  128. :config="config"
  129. :TaskModel="TaskModel"
  130. @changeConfig="changeConfig"
  131. v-if="showWord"
  132. />
  133. </div>
  134. </div>
  135. </template>
  136. <script>
  137. import PhraseModel from "./PhraseModelChs.vue";
  138. import NormalModelChs from "./NormalModelChs.vue";
  139. import Practice from "./Practicechs.vue"; // 语音练习模式
  140. import WordModel from "./WordModelChs.vue"; // 语音练习模式
  141. import { analysSubmit } from "@/api/ajax";
  142. import { getToken } from "@/utils/auth";
  143. export default {
  144. name: "DialogueArticleViewChs",
  145. props: [
  146. "curQue",
  147. "NNPENewWordList",
  148. "NNPEAnnotationList",
  149. "colorBox",
  150. "themeColor",
  151. "currentTreeID",
  152. "TaskModel"
  153. ],
  154. components: { NormalModelChs, Practice, WordModel, PhraseModel },
  155. data() {
  156. return {
  157. showPreview: true, // 全文预览
  158. showPhrases: false, // 显示单词和短语
  159. showPractice: false, // 语音练习
  160. showWord: false, // 取词
  161. titleFontsize: 20, // 标题字号初始值
  162. wordFontsize: 16, // 文章内容字号初始值
  163. bodyLeft: 0,
  164. bodyWidth: 0,
  165. resColorArr: [],
  166. noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "/"],
  167. config: {
  168. isShowEN: false,
  169. isHasEN: false,
  170. isShowPY: false,
  171. isHasPY: false
  172. },
  173. userAnswer: {
  174. normalModel: {
  175. recordList: []
  176. },
  177. writeModel: {}, //生词/取词模式
  178. practiceModel: {}, //练习模式
  179. wordModel: {
  180. recordList: []
  181. }
  182. },
  183. tokenData: null
  184. };
  185. },
  186. computed: {
  187. activeColor: function() {
  188. let color = "";
  189. if (this.themeColor == "red") {
  190. color = "#DE4444";
  191. } else if (this.themeColor == "green") {
  192. color = "#24B99E";
  193. } else if (this.themeColor == "brown") {
  194. color = "#BD8865";
  195. }
  196. return color;
  197. }
  198. },
  199. watch: {},
  200. //方法集合
  201. methods: {
  202. submit() {
  203. let loading = this.$loading({
  204. lock: true,
  205. text: "Loading",
  206. spinner: "el-icon-loading",
  207. background: "rgba(0, 0, 0, 0.7)"
  208. });
  209. console.log(this.curQue);
  210. analysSubmit({
  211. tenantId: "",
  212. text: this.curQue.article
  213. })
  214. .then(res => {
  215. window.open(
  216. process.env.VUE_APP_BASE_API +
  217. `/GCLS-TC/#/textanalysis/Result?partitionKey=${res.data.result.partitionKey}&subjectWords=${res.data.result.subjectWords}&wordTextCount=${res.data.result.textCount}&wordCount=${res.data.result.wordCount}&vocabularyTextCount=${res.data.result.vocabularyTextCount}&vocabularyCount=${res.data.result.vocabularyCount}&pinyinCount=${res.data.result.pinyinCount}&pinyinTextCount=${res.data.result.pinyinTextCount}&pinyinDifficulty=${res.data.result.pinyinDifficulty}&wordDifficulty=${res.data.result.wordDifficulty}&vocabularyDifficulty=${res.data.result.vocabularyDifficulty}&type=文本分析`
  218. );
  219. loading.close();
  220. })
  221. .catch(res => {
  222. loading.close();
  223. });
  224. },
  225. goFullscreen() {
  226. var element = document.getElementById("articleBoby");
  227. if (element.mozRequestFullScreen) {
  228. element.mozRequestFullScreen();
  229. } else if (element.webkitRequestFullScreen) {
  230. element.webkitRequestFullScreen();
  231. }
  232. },
  233. changeConfig(obj) {
  234. this.config[obj] = !this.config[obj];
  235. },
  236. // 英文的显示和隐藏
  237. changeEN() {
  238. this.isShowEN = !this.isShowEN;
  239. },
  240. changePY() {
  241. this.isShowPY = !this.isShowPY;
  242. },
  243. // 处理字体大小
  244. handleFontsize(symbol) {
  245. if (symbol == "+") {
  246. if (this.wordFontsize < 24) {
  247. this.titleFontsize = this.titleFontsize + 2;
  248. this.wordFontsize = this.wordFontsize + 2;
  249. }
  250. } else if (symbol == "-") {
  251. if (this.wordFontsize > 12) {
  252. this.titleFontsize = this.titleFontsize - 2;
  253. this.wordFontsize = this.wordFontsize - 2;
  254. }
  255. }
  256. },
  257. // 切换开关
  258. handleSwitchChange(obj1, obj2) {
  259. this[obj1] = false;
  260. this[obj2] = false;
  261. this.showPreview = false;
  262. },
  263. articleFullScreen() {},
  264. handleObj(list) {
  265. let pinyin = "";
  266. list.forEach(item => {
  267. pinyin += item.pinyin;
  268. });
  269. return pinyin;
  270. }
  271. },
  272. //生命周期 - 创建完成(可以访问当前this实例)
  273. created() {
  274. let data = JSON.parse(getToken());
  275. this.tokenData = data;
  276. },
  277. //生命周期 - 挂载完成(可以访问DOM元素)
  278. mounted() {
  279. let _this = this;
  280. if (!_this.curQue.Bookanswer) {
  281. let userAnswer = JSON.parse(JSON.stringify(_this.userAnswer));
  282. _this.$set(this.curQue, "Bookanswer", userAnswer);
  283. }
  284. if (_this.curQue) {
  285. _this.$nextTick(() => {
  286. _this.bodyLeft = _this.$refs.ArticleViewbody.getBoundingClientRect().left;
  287. });
  288. for (let i = 0; i < _this.curQue.detail.length; i++) {
  289. let enStr = this.curQue.detail[i].sentencesEn.join("");
  290. if (enStr) {
  291. this.config.isShowEN = true;
  292. this.config.isHasEN = true;
  293. }
  294. let pinyin = this.handleObj(this.curQue.detail[i].wordsList);
  295. if (pinyin) {
  296. this.config.isShowPY = true;
  297. this.config.isHasPY = true;
  298. }
  299. if (enStr && pinyin) {
  300. break;
  301. }
  302. }
  303. }
  304. },
  305. beforeCreate() {}, //生命周期 - 创建之前
  306. beforeMount() {}, //生命周期 - 挂载之前
  307. beforeUpdate() {}, //生命周期 - 更新之前
  308. updated() {}, //生命周期 - 更新之后
  309. beforeDestroy() {}, //生命周期 - 销毁之前
  310. destroyed() {}, //生命周期 - 销毁完成
  311. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  312. };
  313. </script>
  314. <style lang="scss" scoped>
  315. //@import url(); 引入公共css类
  316. .NPC-ArticleView {
  317. width: 100%;
  318. &:-webkit-full-screen {
  319. width: 100%;
  320. height: 100%;
  321. }
  322. &:-moz-full-screen {
  323. width: 100%;
  324. height: 100%;
  325. }
  326. .ArticleView-header {
  327. display: flex;
  328. justify-content: space-between;
  329. align-items: center;
  330. margin-bottom: 16px;
  331. position: relative;
  332. .left {
  333. display: flex;
  334. align-items: center;
  335. justify-content: center;
  336. width: 104px;
  337. height: 32px;
  338. background: #ffffff;
  339. border: 1px solid rgba(0, 0, 0, 0.25);
  340. box-shadow: 0px 2px 0px rgba(0, 0, 0, 0.02);
  341. border-radius: 4px;
  342. cursor: pointer;
  343. img {
  344. width: 24px;
  345. height: 24px;
  346. margin-right: 4px;
  347. }
  348. }
  349. .right {
  350. display: flex;
  351. }
  352. .setting-fontsize {
  353. display: flex;
  354. margin-left: 24px;
  355. a {
  356. border: 1px solid rgba(0, 0, 0, 0.1);
  357. box-sizing: border-box;
  358. border-radius: 4px;
  359. display: block;
  360. height: 24px;
  361. width: 24px;
  362. }
  363. img {
  364. width: 100%;
  365. }
  366. > img {
  367. margin: 0 8px;
  368. width: 24px;
  369. }
  370. }
  371. }
  372. .ArticleView-body {
  373. border: 1px solid rgba(0, 0, 0, 0.1);
  374. box-sizing: border-box;
  375. border-radius: 8px;
  376. background: #fff;
  377. box-sizing: border-box;
  378. .aduioLine-box {
  379. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  380. width: 100%;
  381. }
  382. }
  383. }
  384. </style>
  385. <style lang="scss">
  386. .NNPE-tableList-item-noMargin {
  387. .NPC-ArticleView {
  388. background: #fff;
  389. }
  390. }
  391. .NPC-ArticleView {
  392. &.NPC-ArticleView-container {
  393. margin-bottom: 24px;
  394. }
  395. .notice {
  396. font-weight: normal;
  397. font-size: 14px;
  398. line-height: 150%;
  399. margin-bottom: 24px;
  400. color: #000000;
  401. padding: 0 24px 8px;
  402. margin: 0;
  403. &.hasRemark {
  404. width: 553px;
  405. box-sizing: border-box;
  406. border-right: 1px rgba(0, 0, 0, 0.1) solid;
  407. }
  408. }
  409. .ArticleView-header {
  410. .el-switch {
  411. margin-left: 24px;
  412. }
  413. .el-switch__core {
  414. width: 44px !important;
  415. height: 24px;
  416. border-radius: 20px;
  417. }
  418. .el-switch__core:after {
  419. top: 3px;
  420. left: 3px;
  421. }
  422. .el-switch.is-checked .el-switch__core::after {
  423. left: 100%;
  424. margin-left: -19px;
  425. }
  426. .el-switch__label {
  427. color: #000000;
  428. }
  429. .el-switch__label.is-active {
  430. color: rgba($color: #000000, $alpha: 0.3);
  431. }
  432. .el-switch__label--left {
  433. margin-right: 8px;
  434. }
  435. }
  436. }
  437. </style>