CourseStart.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="NPC-courseStart">
  3. <h2 :class="[curQue.titleType == 'cn' ? 'hanzi' : '']">
  4. {{ curQue.title }}
  5. </h2>
  6. <div class="item-content">
  7. <template v-if="curQue.detail.wordsList.length == 0">
  8. <p :class="['content-con']" v-if="curQue.detail.sentence">
  9. {{ curQue.detail.sentence }}
  10. </p>
  11. </template>
  12. <template v-else>
  13. <div class="con-box">
  14. <div
  15. :class="['con-item', indexCon === 0 ? 'con-item-0' : '']"
  16. v-for="(itemCon, indexCon) in curQue.detail.resArr"
  17. :key="indexCon"
  18. v-show="itemCon.isShow"
  19. >
  20. <template
  21. v-if="
  22. curQue.detail.wordsList[indexCon + 1] &&
  23. curQue.detail.wordsList[indexCon + 1].chs &&
  24. chsFhList.indexOf(curQue.detail.wordsList[indexCon + 1].chs) >
  25. -1
  26. "
  27. >
  28. <div class="synthesis-box">
  29. <div>
  30. <span
  31. class="pinyin"
  32. :class="[
  33. noFont.indexOf(itemCon.pinyin) > -1 ? 'noFont' : '',
  34. ]"
  35. >{{ itemCon.pinyin }}</span
  36. >
  37. <span class="hanzi content-con">{{ itemCon.chs }}</span>
  38. </div>
  39. <div style="text-align: left">
  40. <span
  41. class="pinyin"
  42. :class="[
  43. noFont.indexOf(
  44. items.detail.wordsList[indexCon + 1].pinyin
  45. ) > -1
  46. ? 'noFont'
  47. : '',
  48. ]"
  49. >{{ curQue.detail.wordsList[indexCon + 1].pinyin }}</span
  50. >
  51. <span class="hanzi content-con">{{
  52. curQue.detail.wordsList[indexCon + 1].chs
  53. }}</span>
  54. </div>
  55. </div>
  56. </template>
  57. <template v-else>
  58. <span
  59. class="pinyin"
  60. :class="[noFont.indexOf(itemCon.pinyin) > -1 ? 'noFont' : '']"
  61. >{{ itemCon.pinyin }}</span
  62. >
  63. <span class="hanzi content-con">{{ itemCon.chs }}</span>
  64. </template>
  65. </div>
  66. </div>
  67. </template>
  68. <b class="content-en" v-if="curQue.en">{{ curQue.en }}</b>
  69. </div>
  70. <div class="item-intro-box">
  71. <div class="item-intro" :style="{textIndent:curQue.textindent?'2em':''}" v-if="curQue.con">
  72. {{ curQue.con }}
  73. </div>
  74. <template v-if="curQue.conDetail&&curQue.conDetail.sentence">
  75. <div class="item-intro">
  76. <OneSentenceTemp
  77. :detail="curQue.conDetail"
  78. :TaskModel="TaskModel"
  79. :Bookanswer="[]"
  80. :correctAnswer="[]"
  81. :isInput="
  82. false
  83. "
  84. :pyPosition="'top'"
  85. :pyColors="'rgba(255, 255, 255, 0.85)'"
  86. :fn_check_list="[]"
  87. :pyNumber="pyNumber"
  88. :record_check="[]"
  89. :maxFontsize="maxFontsize"
  90. :textIndent="curQue.textindent"
  91. />
  92. </div>
  93. </template>
  94. </div>
  95. <a class="start-btn" @click="handleNNPEnext">开始学习</a>
  96. </div>
  97. </template>
  98. <script>
  99. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  100. //例如:import 《组件名称》from ‘《组件路径》';
  101. import OneSentenceTemp from "./components/OneSentenceTemp.vue";
  102. export default {
  103. //import引入的组件需要注入到对象中才能使用
  104. components: {OneSentenceTemp},
  105. props: ["curQue", "handleNNPEnext","TaskModel"],
  106. data() {
  107. //这里存放数据
  108. return {
  109. chsFhList: [",", "。", "“", ":", "》", "?", "!", ";"],
  110. noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")"], // 对应不要拼音字体
  111. pyNumber: 0,
  112. maxFontsize: 16,
  113. titleChsFhList:[",", "”","。",":", "》", "?", "!", ";"],
  114. };
  115. },
  116. //计算属性 类似于data概念
  117. computed: {},
  118. //监控data中数据变化
  119. watch: {},
  120. //方法集合
  121. methods: {
  122. // 处理数据
  123. handleData() {
  124. let _this = this;
  125. let curQue = JSON.parse(JSON.stringify(this.curQue));
  126. let paraArr = [];
  127. curQue.detail.wordsList.forEach((sItem, sIndex) => {
  128. let obj = {
  129. pinyin: sItem.pinyin,
  130. chs: sItem.chs,
  131. isShow: true,
  132. };
  133. paraArr.push(obj);
  134. });
  135. this.$set(_this.curQue.detail, "resArr", paraArr);
  136. if(this.curQue.hasOwnProperty("conDetail")){
  137. let isHasPY = 0;
  138. let maxFontsize = 16;
  139. if (this.curQue.conDetail.wordsList.length > 0) {
  140. this.curQue.conDetail.wordsList.forEach((sItem, sIndex) => {
  141. this.mergeWordSymbol(sItem);
  142. if (sItem.pinyin) {
  143. isHasPY++;
  144. }
  145. sItem.fontColor='rgba(255, 255, 255, 0.85)'
  146. let fontSize = JSON.parse(JSON.stringify(sItem.fontSize));
  147. fontSize = Number(fontSize.replace("px", ""));
  148. maxFontsize = fontSize > maxFontsize ? fontSize : maxFontsize;
  149. });
  150. }
  151. this.maxFontsize = maxFontsize;
  152. this.pyNumber = isHasPY;
  153. }
  154. },
  155. //词和标点合一起
  156. mergeWordSymbol(sItem) {
  157. if (this.titleChsFhList.indexOf(sItem.chs) > -1) {
  158. sItem.isShow = false;
  159. } else {
  160. sItem.isShow = true;
  161. }
  162. },
  163. },
  164. //生命周期 - 创建完成(可以访问当前this实例)
  165. created() {
  166. this.handleData();
  167. },
  168. //生命周期 - 挂载完成(可以访问DOM元素)
  169. mounted() {},
  170. //生命周期-创建之前
  171. beforeCreated() {},
  172. //生命周期-挂载之前
  173. beforeMount() {},
  174. //生命周期-更新之前
  175. beforUpdate() {},
  176. //生命周期-更新之后
  177. updated() {},
  178. //生命周期-销毁之前
  179. beforeDestory() {},
  180. //生命周期-销毁完成
  181. destoryed() {},
  182. //如果页面有keep-alive缓存功能,这个函数会触发
  183. activated() {},
  184. };
  185. </script>
  186. <style lang="scss" scoped>
  187. /* @import url(); 引入css类 */
  188. .NPC-courseStart {
  189. width: 100%;
  190. background: #e35454;
  191. color: rgba(255, 255, 255, 0.85);
  192. padding: 40px;
  193. h2 {
  194. font-size: 24px;
  195. line-height: 32px;
  196. font-weight: normal;
  197. text-align: center;
  198. font-family: "robot";
  199. margin: 0;
  200. &.hanzi {
  201. font-family: "FZJCGFKTK";
  202. }
  203. }
  204. .item-content {
  205. text-align: center;
  206. padding: 24px 0;
  207. }
  208. .content-con {
  209. font-size: 40px;
  210. line-height: 48px;
  211. font-family: "FZJCGFKTK";
  212. margin: 0;
  213. &.content-con-small {
  214. font-size: 16px;
  215. }
  216. }
  217. .content-en {
  218. font-weight: normal;
  219. font-size: 20px;
  220. line-height: 28px;
  221. font-family: "robot";
  222. display: block;
  223. }
  224. .con-box {
  225. display: flex;
  226. flex-flow: wrap;
  227. justify-content: center;
  228. .con-item {
  229. text-align: center;
  230. padding: 0 3px;
  231. }
  232. span {
  233. display: block;
  234. }
  235. .pinyin {
  236. font-family: "GB-PINYINOK-B";
  237. font-size: 24px;
  238. line-height: 32px;
  239. height: 32px;
  240. &.noFont {
  241. font-family: initial;
  242. }
  243. }
  244. .synthesis-box {
  245. display: flex;
  246. }
  247. }
  248. .item-intro-box {
  249. min-height: 272px;
  250. .item-intro {
  251. background: #c43c3c;
  252. border: 1px solid rgba(0, 0, 0, 0.1);
  253. box-sizing: border-box;
  254. border-radius: 8px;
  255. padding: 24px;
  256. font-size: 16px;
  257. line-height: 150%;
  258. white-space: pre-wrap;
  259. word-break: break-word;
  260. text-align: justify;
  261. min-height: 96px;
  262. }
  263. }
  264. .start-btn {
  265. width: 160px;
  266. height: 40px;
  267. box-shadow: 0px 8px 24px rgba(103, 0, 0, 0.25);
  268. border-radius: 8px;
  269. background: #ffffff;
  270. border: 1px solid rgba(0, 0, 0, 0.1);
  271. display: block;
  272. margin: 24px auto;
  273. color: #e35454;
  274. font-size: 20px;
  275. line-height: 28px;
  276. text-align: center;
  277. line-height: 40px;
  278. &:active {
  279. background: rgba(255, 255, 255, 0.85);
  280. }
  281. }
  282. }
  283. .NPC-Big-Book-preview-green {
  284. .NPC-courseStart {
  285. background: #24b99e;
  286. .item-intro {
  287. background: #1fa189;
  288. }
  289. .start-btn {
  290. color: #24b99e;
  291. }
  292. }
  293. }
  294. .NPC-Big-Book-preview-brown {
  295. .NPC-courseStart {
  296. background: #bd8865;
  297. .item-intro {
  298. background: #a37557;
  299. }
  300. .start-btn {
  301. color: #bd8865;
  302. }
  303. }
  304. }
  305. </style>