CourseStart.vue 9.3 KB

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